Subject | RE: [firebird-php] how to capture last exception (from stored procedure) in PHP ? |
---|---|
Author | Helen Borrie |
Post date | 2004-11-08T14:04:07Z |
Alan,
At 12:15 AM 9/11/2004 +1100, you wrote:
multiple row sets, i.e. a selectable stored procedure, and *only* for this
purpose; use EXIT when you want to pass flow of control directly to the
last END statement and *only* for this purpose. To break out of a looping
block, use the LEAVE statement.
When writing an executable procedure that returns values, the returned
values can be one or many: there is nothing that restricts them to a
single value. The values in the structure returned occur in the order they
are declared in the RETURNS clause.
Unhandled exceptions always cause execution to jump outward through the
nests of BEGIN --- END blocks looking for an exception handler following an
END statement. If no appropriate handler is found, execution stops,
control passes to the final END statement and the SQLCODE, GDSCODE and
error text are passed back in the error status vector. You do not get any
output in this case (nor if your SP handles an exception by re-raising it).
cycle in your execution logic, SUSPEND behaves exactly like EXIT and passes
execution directly to the last END statement.
immediately jumps to here:.
BEGIN
BLAH;
BLAH;
if (ncount > 0 ) then /* remove the colon from :ncount !!)
EXCEPTION ERROR_SP_GENERIC 'You cant delete existing tickets
dependencies';
BLAH...;
BLAH....;
result_value = your_good_result;
END
Helen
At 12:15 AM 9/11/2004 +1100, you wrote:
>Just as an aside - you either use SUSPEND or EXIT but not both.That is incorrect. Use SUSPEND when the procedure is for returning
>Use SUSPEND when you wish to return more than one value, EXIT when there is
>only one value to return.
multiple row sets, i.e. a selectable stored procedure, and *only* for this
purpose; use EXIT when you want to pass flow of control directly to the
last END statement and *only* for this purpose. To break out of a looping
block, use the LEAVE statement.
When writing an executable procedure that returns values, the returned
values can be one or many: there is nothing that restricts them to a
single value. The values in the structure returned occur in the order they
are declared in the RETURNS clause.
Unhandled exceptions always cause execution to jump outward through the
nests of BEGIN --- END blocks looking for an exception handler following an
END statement. If no appropriate handler is found, execution stops,
control passes to the final END statement and the SQLCODE, GDSCODE and
error text are passed back in the error status vector. You do not get any
output in this case (nor if your SP handles an exception by re-raising it).
>> But I put only an example, my problem is that ibase_errmsg() allwaysYour problem here is the misuse of SUSPEND. Because there is no loop-wait
> returning empty string and I need to capture the last exception error.
>
> I can correct a prior example, try :
> if (:ncount > 0 ) then
> begin
> result_value=0;
> suspend;
cycle in your execution logic, SUSPEND behaves exactly like EXIT and passes
execution directly to the last END statement.
> EXCEPTION ERROR_SP_GENERIC 'You cant delete existing ticketsThe EXCEPTION and EXIT statements never get executed, because execution
> dependences';
> EXIT;
immediately jumps to here:.
> endHere's what you need to do:
BEGIN
BLAH;
BLAH;
if (ncount > 0 ) then /* remove the colon from :ncount !!)
EXCEPTION ERROR_SP_GENERIC 'You cant delete existing tickets
dependencies';
BLAH...;
BLAH....;
result_value = your_good_result;
END
Helen