Re: execute vs do in DBI
Michael Peppler <[email protected]> Sat, 21 Feb 2009 08:15:20 +0100
| Newsgroups | gmane.comp.lang.perl.modules.dbi.sybase |
|---|---|
| Message-ID | <[email protected]> |
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_Multi= ple_Result_Sets Michael On Fri, Feb 20, 2009 at 8:49 PM, Vitaly Komarovsky <[email protected]> wrote: > I never subnitted questions to the group and I am sorry if I directed i= t to > the wrong address. Please=A0correct me=A0if I made this mistake. > The issue is as follows. I have a very simple Perl script which execute= s 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=A0when called=A0from isql, but when called from t= he > following script - does not complete all its steps. > It completes just about half of the steps=A0and then... gently stops.=A0= There is > no early exit logic in the procedure, and it does not fail=A0(I know, i= t > sounds unbelievable) > Here is the script: > my $srcSTH; > my $DBH2 =3D > DBI->connect("dbi:Sybase:server=3D$DBSERVER;database=3D$DBNAME",$DBUSER= ,$DBPASS,{PrintError > =3D> 1}); > &die("Can't connect to server $DBI::errstr\n") unless $DBH2; > > my $sqlQuery =3D "execute stage..loadTmpStrategyTEST"; > > $srcSTH =3D $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,=A0and the results match=A0the=A0resul= ts > from=A0isql call. > > my $srcSTH; > > my $DBH2 =3D > DBI->connect("dbi:Sybase:server=3D$DBSERVER;database=3D$DBNAME",$DBUSER= ,$DBPASS,{PrintError > =3D> 1}); > &die("Can't connect to server $DBI::errstr\n") unless $DBH2; > > my $sqlQuery =3D "execute stage..loadTmpStrategyTEST"; > > $srcSTH =3D $DBH2->do($sqlQuery) || > die("Can't execute SQL statement: \"$sqlQuery\":" . $srcSTH->errstr() . > "\n"); > > What could be the issue? > > Thank you, > Vitaly Komarovsky > >