List:MySQL and Perl« Previous MessageNext Message »
From:Daniel Kern Date:July 19 2012 12:34pm
Subject:question about stored procedures with Select statements and
critical errors.
View as plain text  
Can someone please help with the following.  I am using mysql dbd 4.017 and mysql 5.5.17.

When I call a stored procedure that has Select statements in it, and the stored procedure
has a critical error, I am not getting back any indication there was an error.

The SP looks like this:
SELECT CONCAT("Populating summary tables from: ",@v_from_date, " , to: ",@v_to_date) AS
<Critical Error here>

Here is the code, where $sql is call <sp name> (\'2012-06-16\', \'2012-06-16\')
              $sth = $dbh->prepare($sql);
              if (!$sth) {
             my $ex_result = $sth->execute();

And when I run in the debugger, I get this result on the statement handle:
x DBI::dump_results($sth):
'Populating summary tables from...'
1 rows

0         1

And x $sth->errstr returns:

RaiseError is off.  If I set it to On, I then need to run the execute in an eval
statement.  But this is not necessary if there is no Select statement in the SP - in that
case I get this when I dump the results of $sth:
Returns:  'PROCEDURE <db name>.<sp name> does not exist'

which is exactly the error expected.

How can I capture the error when I have at least one select statement in the stored

Thanks very much.

Daniel Kern

question about stored procedures with Select statements andcritical errors.Daniel Kern19 Jul