Subject Re: [firebird-support] Re: Returning values from stored procedure
Author Helen Borrie
At 01:22 PM 12/07/2003 +0100, you wrote:

>Anyway, just of curiosity, can we write DECLARE CURSOR syntax in our
>stored procedures like in Oracle & MS SQL Server?

You can create an old-style cursor for processing in PSQL by an old,
undocumented method, but Firebird's FOR SELECT ...DO syntax is a much more
logical and easy-to-debug way to process a cursor.

create procedure dosomething (<input-list)
/* __EITHER__ make a returns-list if you want to output a set */
returns (var1 sometype, var2 othertype, var3 anothertype, var5 sometype)


/* __OR__ declare local variables to execute STUF on the server */
declare variable var1 sometype;
declare variable var2 othertype;

for select a.col1, a.col2, a.col3, b.col5 from atable a
join btable b on <whatever>
where <whatever>
order by <whatever>
into :var1, :var2, :var3, :var5 DO
<do STUF with vars>;
suspend; /*only if you want to SELECT as an output set */
end /* loop will repeat for every row in the cursor set until done */

Did you know that documentation is available? You can pick up the IB6 beta
docs from the interbase downloads page of the ibphoenix site. Stored
procedure language stuff is the Language Reference.