Subject Re: [ib-support] Returning SQLCODE
Author Ivan Prenosil
> How can I have a stored procedure returning SQLCODE
> in case of an exception (ANY) inside its code back to
> Delphi, using a TIBStoredProc?
>
> Is something like the following possible?
>
> CREATE PROCEDURE MyTableInsert ( AName VARCHAR(40) )
> RETURNS ( RESULT INTEGER )
> AS
> BEGIN
> INSERT INTO MyTable(F_NAME) VALUES ('Delphi');
> RESULT = 0; /* no error */
> WHEN ANY DO
> BEGIN
> RESULT = SQLCODE;
> END
> END ^

If you do not need to handle exceptions inside SP (like in your example)
just do not trap them (i.e. do not use WHEN ANY DO).

Possible errors/exceptions will be reported back to client software
through status vector
(iirc in Delphi components there should be OnError event with SQLCODE parameter).

Ivan
prenosil@...
http://www.volny.cz/iprenosil/interbase