Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stored proc result set with perl dbi

Status
Not open for further replies.

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
 
------------------ 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::DB2::Constants;

$user_id=111;

$database='dbi:DB2: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();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top