Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Location
    cottbus
    Posts
    2

    Unanswered: result set from stored procedure in perl

    hello

    is it possible to handle a result set from a sql-stored-procedure in perl ?

    thanx bernd

  2. #2
    Join Date
    Apr 2002
    Location
    cottbus
    Posts
    2
    ------------------ 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();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •