DBI Stored Procedures and Cursors
- From: KJ <karen.jackson@xxxxxxxxx>
- Date: 8 May 2007 09:01:04 -0700
I have a stored procedure that belongs within a package in Oracle.
This is my first exposure to DBI, so I'm sure i'm doing something
wrong. The stored procedure takes a cursor as one of the parameters.
The stored procedure is supposed to initialize the cursor and all I
need to do is print the contents of the cursor.
I can execute without any problems, but I cannot perform a
fetchrow_array.
Thanks in advance for any help.
#==========================================
use strict ;
use DBI ;
# Note inclusion of DBD::Oracle data types. Without it, we cannot
# work with REF Cursor variables.
use DBD::Oracle qw(:ora_types);
print "connecting..." ;
my $dbh = DBI->connect( 'dbi:Oracle:----','----','-----')
|| die "failed to connect to db" ;
print "connected!\n" ;
my $iDate ;
my $cursor ;
my $sql = qq{ begin
MYDB.MYPKG.myPROC(to_date('2007/05/07', 'yyyy/mm/dd'), :cursor) ;
end ; } ;
my $sth = $dbh->prepare( $sql ) ;
$sth->bind_param_inout( ":cursor", \$cursor, 0, { ora_type =>
ORA_RSET} ) ;
print "Executing ..." ;
$sth->execute() || die "$sql\n statement didn't work! " ;
print "Executed!\n" ;
while( my @row = $cursor->fetchrow_array ) {
# Never gets here.
print "@row\n" ;
}
$sth->finish() ;
$dbh->disconnect() ;
.
- Prev by Date: YAPC Europe 2007 Reminder - CFP and CFH Deadlines Approaching
- Next by Date: Bar Code
- Previous by thread: YAPC Europe 2007 Reminder - CFP and CFH Deadlines Approaching
- Next by thread: Bar Code
- Index(es):
Relevant Pages
|