Discussion:
execute vs do in DBI
Michael Peppler
2009-02-21 07:15:20 UTC
Permalink
Hi

Please see the DBD::Sybase documentation on handling multiple result sets.

The execute() call only processes the first result set - so you need
to add a loop to process each of the result sets that are returned
from the proc (and each insert, update, etc. statement is considered a
result set in this context).

See http://search.cpan.org/~mewp/DBD-Sybase-1.09/Sybase.pm#Handling_Multiple_Result_Sets

Michael


On Fri, Feb 20, 2009 at 8:49 PM, Vitaly Komarovsky
I never subnitted questions to the group and I am sorry if I directed it to
the wrong address. Please correct me if I made this mistake.
The issue is as follows. I have a very simple Perl script which executes a
stored procedure in ASE 12.5.3.
This stored procedure does updates and inserts into the database tables and
also logs it progress by inserts into the log table.
It executes perfectly when called from isql, but when called from the
following script - does not complete all its steps.
It completes just about half of the steps and then... gently stops. There is
no early exit logic in the procedure, and it does not fail (I know, it
sounds unbelievable)
my $srcSTH;
my $DBH2 =
DBI->connect("dbi:Sybase:server=$DBSERVER;database=$DBNAME",$DBUSER,$DBPASS,{PrintError
=> 1});
&die("Can't connect to server $DBI::errstr\n") unless $DBH2;
my $sqlQuery = "execute stage..loadTmpStrategyTEST";
$srcSTH = $DBH2->prepare($sqlQuery) ||
die("Can't prepare SQL statement: \"$sqlQuery\":" . $DBH2->errstr() . "\n");
$srcSTH->execute ||
die("Can't execute SQL statement: \"$sqlQuery\":" . $srcSTH->errstr() .
"\n");
But, when I replace the "prepare-execute" method with "do" (see below), the
stored procedure works perfectly, and the results match the results
from isql call.
my $srcSTH;
my $DBH2 =
DBI->connect("dbi:Sybase:server=$DBSERVER;database=$DBNAME",$DBUSER,$DBPASS,{PrintError
=> 1});
&die("Can't connect to server $DBI::errstr\n") unless $DBH2;
my $sqlQuery = "execute stage..loadTmpStrategyTEST";
$srcSTH = $DBH2->do($sqlQuery) ||
die("Can't execute SQL statement: \"$sqlQuery\":" . $srcSTH->errstr() .
"\n");
What could be the issue?
Thank you,
Vitaly Komarovsky
Loading...