in reply to Find the status of the execution for stored procedure/SQL query using Perl

When executing a command, iiuc, the driver implicitly creates an anonymous block for the execution. If the command itself is bad, the block will not compile and call itself will fail putting an error in the driver's error variable.

If the code CALLs a stored PROCEDURE, and the error happens within it, as long as you are not trapping errors in the SP itself, the SP will fail and will pass the EXCEPTION to the anonymous block where it is (trapped by the driver and) put into the driver's error variable.

If you trap EXCEPTIONs in the SP, your own code will do what you told it to, so unless you re-RAISE the EXCEPTION (making the trapping of it pretty useless to begin with) you won't get it.

A simple statement like TRUNCATE is best implemented with host variables. It is more secure (no chance of SQL injection), and once put right, can not have syntactical errors.

  • Comment on Re: Find the status of the execution for stored procedure/SQL query using Perl