Subject | Re: [firebird-support] Re: Returning values from stored procedure |
---|---|
Author | Helen Borrie |
Post date | 2003-07-12T13:09:42Z |
At 01:22 PM 12/07/2003 +0100, you wrote:
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)
AS
/* __OR__ declare local variables to execute STUF on the server */
declare variable var1 sometype;
declare variable var2 othertype;
...etc.....
begin
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
begin
<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 */
end
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.
heLen
>Anyway, just of curiosity, can we write DECLARE CURSOR syntax in ourYou can create an old-style cursor for processing in PSQL by an old,
>stored procedures like in Oracle & MS SQL Server?
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)
AS
/* __OR__ declare local variables to execute STUF on the server */
declare variable var1 sometype;
declare variable var2 othertype;
...etc.....
begin
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
begin
<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 */
end
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.
heLen