Subject | Re: [ib-support] Stored procedure and Select |
---|---|
Author | Lucas Franzen |
Post date | 2002-07-09T14:05:14Z |
Matteo Giacomazzi schrieb:
FOR SELECT
<FIELDLIST>
FROM TABLE
INTO <FIELD_RETURNING_LIST>
DO BEGIN
SUSPEND;
EXIT; /* If you want to select just the first row */
END
Hth
Luc.
>If you have a SP that's returning "rows" the correct syntax is:
> Hi all,
>
> there's a thing I cannot understand with SP.
> Let's say I have a SP that should return some results on the basis
> of a SELECT query.
> This SELECT may return more than one result but I'm interested only
> in the first one for my computation.
> Well, if the SELECT returns more than one row, my SP won't return
> anything!
> If I change my SP so that the SELECT query will return only one
> result, then my SP returns the expected result.
>
> EXAMPLE:
> ===================================================================
> TABLE_1
> ID FIELD_1 FIELD_2
> 1 'Test' 134
> 2 'Another Test' 12
> 3 'Last test' 4
>
> CREATE PROCEDURE TEST
> RETURNS (ID SMALLINT, FIELD_1 VARCHAR(20), FIELD_2 INTEGER)
> AS
> BEGIN
> SELECT *
> FROM TABLE_1
> INTO :ID, :FIELD_1, :FIELD_2;
> SUSPEND;
> END
FOR SELECT
<FIELDLIST>
FROM TABLE
INTO <FIELD_RETURNING_LIST>
DO BEGIN
SUSPEND;
EXIT; /* If you want to select just the first row */
END
Hth
Luc.