Subject Re: [ib-support] declare cursor
Author Helen Borrie
At 03:24 PM 19-04-01 +0200, Jordi wrote:
>Hi!
>
>how can I create a cursor? the documentation talks about something like:
>
>DECLARE cursor CURSOR FOR <select> [FOR UPDATE OF <col> [, <col>.]];
>
>available in SQL, but this doesn't works, it gives me an invalid token error
>just in the cursor name

Perhaps you have the cursor name in the wrong position; and "cursor" is a reserved token.

DECLARE Mycursor CURSOR FOR...ETC. ought to work.

Tip: unless you have some especial reason to use a cursor (e.g. you are writing embedded SQL), don't. In a stored procedure that has to iterate through a set, a FOR SELECT...INTO...DO construction is recommended.

If your purpose is to get an output set from a SP using a cursor to populate a temporary table or disk file for client use, STOP THERE. This is not MSSQL Server. :) In IB, you can use the FOR..SELECT...INTO...DO...SUSPEND construct to build a dataset, which your client application then gets with a SELECT statement.

Cheers,
Helen


Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________