Apr 19, 2002 #1 111999111 Programmer Feb 13, 2002 8 DE Is ist possible to handle a result set from a db2 stored procedure in perl ?? we can not ! thanx bernd
Is ist possible to handle a result set from a db2 stored procedure in perl ?? we can not ! thanx bernd
Apr 23, 2002 Thread starter #2 111999111 Programmer Feb 13, 2002 8 DE ------------------ SQL ------------------ ------------------------------------------ -- RecordSet from journal for user_id -- -- call: dmt_selectContentBillingSet -- ------------------------------------------ create procedure dmt_selectContentBillingSet (in spUser_id integer) language sql begin declare sqlstate char(5) default '00000'; declare resultSet cursor with return to client for select contentID,datum,value from journal where user_id=spUser_id; open resultSet; end @ ------------------ PERL ------------------ #!/usr/local/bin/perl use DBI; use DBD:B2::Constants; $user_id=111; $database='dbiB2:damit1'; $user='damit'; $password='timad'; $dbh = DBI->connect($database, $user, $password) or die "Can't connect to $database: $DBI::errstr"; if (!defined($dbh)) { exit; } $stmt = "call dmt_selectContentBillingSet(?)"; $sth = $dbh->prepare($stmt); $sth->bind_param_inout(1,\$user_id,10); $sth->execute(); do { while( @row = $sth->fetchrow_array ) { print $row[0]." ",$row[1]." ",$row[2]."\n"; } } while ($sth->{db2_more_results} ); # close selection criteria cursor $sth->finish(); $dbh->disconnect(); Upvote 0 Downvote
------------------ SQL ------------------ ------------------------------------------ -- RecordSet from journal for user_id -- -- call: dmt_selectContentBillingSet -- ------------------------------------------ create procedure dmt_selectContentBillingSet (in spUser_id integer) language sql begin declare sqlstate char(5) default '00000'; declare resultSet cursor with return to client for select contentID,datum,value from journal where user_id=spUser_id; open resultSet; end @ ------------------ PERL ------------------ #!/usr/local/bin/perl use DBI; use DBD:B2::Constants; $user_id=111; $database='dbiB2:damit1'; $user='damit'; $password='timad'; $dbh = DBI->connect($database, $user, $password) or die "Can't connect to $database: $DBI::errstr"; if (!defined($dbh)) { exit; } $stmt = "call dmt_selectContentBillingSet(?)"; $sth = $dbh->prepare($stmt); $sth->bind_param_inout(1,\$user_id,10); $sth->execute(); do { while( @row = $sth->fetchrow_array ) { print $row[0]." ",$row[1]." ",$row[2]."\n"; } } while ($sth->{db2_more_results} ); # close selection criteria cursor $sth->finish(); $dbh->disconnect();