Subject | Re: [IBO] Returning value from SP |
---|---|
Author | Geoff Worboys |
Post date | 2004-03-29T05:33:47Z |
>>Create procedure SingleLineHelen, this is not true - in FB 1.5.0 at least.
>>Returns (a integer)
>>as
>>begin
>>a = 1;
>>Suspend;
>>a = 2;
>>end
> Currently (with the bug) it would return 1. You can only get
> multi-row output from a cursor. There is no cursor here, so
> there is nothing to wait for. Suspend just drops control
> down to the final END statement: the second assignment is
> never executed.
CREATE PROCEDURE TEST_SUSPEND
RETURNS ( A INTEGER )
AS
BEGIN
A = 1;
SUSPEND;
A = 2;
INSERT INTO TABLE1 (PK) VALUES(:A);
END
SELECT * FROM TEST_SUSPEND
produces 1 row (as expected from the single suspend)
the insert does create a row with PK=2 (is executed)
This is as described in the IB6 doco. SUSPEND suspends
operation until the next fetch, then execution proceeds
from the next statement.
I would not expect it to return 2 unless I placed another
SUSPEND command at the end. EXIT/END is not the same as
SUSPEND. To do so would be likely to break existing code,
since it would imply that every procedure using SUSPEND
would always return an additional entry.
At this point I cannot see anything out of place from
what I expect of SUSPEND.
--
Geoff Worboys
Telesis Computing