PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: ndronen at technolalia dot com
Subject: syb_more_results is 0 when I expect it to be 1
Date: Jun 2 2004 4:01PM

Hi, all:

I'm pretty sure I'm just doing something dumb here.  I'm expecting
multiple result sets back from a stored procedure but $sth->{syb_more_results}
is 0 when I'd expect it to be 1.

$ perl -V:version; isql -v
version='5.8.2';
Sybase CTISQL Utility/11.1.1/P-EBF10173/DRV.HP10.11.1.1.1/hp800/HP-UX 10.01/BUILD1111-024/OPT/Mon Apr 15 01:42:20 2002

#############################################################
#!/usr/local/bin/perl

$|++;
use warnings;
use strict;
use DBI;
use Data::Dumper;

my $datasource = 'dbi:Sybase:database=agiprospect;server=callisto_dev';
my $username = 'username';
my $password = 'password';
my $dbh = DBI->connect($datasource, $username, $password)
	or die $DBI::errstr;
my $sth = $dbh->prepare('load_ers_data1_p')
	or die $dbh->errstr();

$sth->execute();

do {
	my $row = $sth->fetchrow_arrayref();
	print Dumper $row;
} while ($sth->{syb_more_results});
#############################################################

For testing purposes, the stored procedure load_ers_data1_p essentially
does this:

	SELECT 'some text: %1', @var1
	SELECT 'some text: %1!', @var2
	SELECT 'some text: %1!', @var3
	SELECT 'some text: %1!', @var4
	SELECT 'some text: %1!', @var5

(That code's slightly broken.  The SELECTs used to be PRINTs.  I had them
changed so as not to use a message handler in the script.)

The output of the script is:

	$ ./sqltest.pl
	$VAR1 = [
		'some text: %1!',
		0
	];


Here's the DBI trace output at level 3:

syb_st_execute() -> ct_command() OK
syb_st_execute() -> ct_send() OK
st_next_result() -> ct_results(4040) == 1
ct_res_info() returns 2 columns
ct_describe(0): type = 0, maxlen = 32
describe() -> col 0, type 0, realtype 0
ct_describe(1): type = 8, maxlen = 4
describe() -> col 1, type 8, realtype 8
describe() retcode = 1
st_next_result() -> lasterr = 0, lastsev = 0
<- execute= -1 at sqltest.pl line 12
-> fetchrow_arrayref for DBD::Sybase::st (DBI::st=HASH(0x401c6240)~0x4000fa2c)
dbih_setup_fbav for 2 fields => 0x401c60d8
<- fetchrow_arrayref= [ 'some text: %1!' 0 ] row1 at sqltest.pl line 15
-> FETCH for DBD::Sybase::st (DBI::st=HASH(0x4000fa2c)~INNER 'syb_more_results')
<- FETCH= 0 at sqltest.pl line 14

Am I missing something obvious?

Regards,

Nicholas