Folks,

I am not sure if this has been answered before or not but on searching the 
list archives I haven't been able to get an answer. I am connecting to DB2 
using DBD::ODBC and am also able to run select statements. Now I have to 
run a stored procedure through the connection and was wondering if this is 
possible through the ODBC driver or do I have to install the native DB2 
driver.

The second thing is if I can run the stored procedure through ODBC then 
can anyone please forward me sample code that shows how to do this as I 
have written snippets of code which are able to connect to DB2 but do not 
run the stored procedure. They are attached with this email.

Any help in this matter would be greatly welcome!!

Thanks in advance,

Samarth


#!j:\perl\bin\perl

use DBI;
use CGI qw( :standard );
use CGI::Carp qw( warningsToBrowser fatalsToBrowser );

my $subsystem = "DQ0G";
my $collectionID = "AVGI00";
my $username = "";
my $password = "";

print( "Content-type: text/html\n\n" ); 
print( "<html>\n" );
print( "\t<head>\n" );
print( "\t\t<title>DBI Connection Test</title>\n" );
print( "\t</head>\n" );
print( "<body>\n" );

my $dbh = DBI -> connect( "DBI:ODBC:$subsystem", "$username", "$password" 
);

if( !$dbh ) {
    print( "Unable to connect to database!!" . DBI -> errstr );
   exit;
}
else {
    print( "Connected to DB2!!\n" );
}
my $rv = $dbh -> prepare( 'call 
dq0gwcat.eposp522(\'AVGI00\',\'CIA\',\'WECIACAT\',\'IIOW\',\'2004-08-05-12.10.23.798322\',\'N\',0,0,0,\'
 
\',\' \',\'Y\',\' \',115436746,364285835)' );

if( !rv ) {
   print( "Unable to prepare select statement: " . $dbh -> errstr );
   $dbh -> disconnect;
   exit;
}

$rv -> execute();

print( "Executed stored procedure" );

$rv -> finish;
$dbh -> disconnect;

print( "</body>" );
print( "</html>\n" );

Reply via email to