Subject Re: [ib-support] CURSOR or WHERE CURRENT OF in a stored procedure
Author Martijn Tonies
Helen,


> >Right - I've found the syntax after all ...
> >
> > > I've been searching high and low, but cannot find it ...
> >
> >But - how does it work? Do you need to at least
> >select the primary key columns in the FOR SELECT
> >clause in order to update such a table? Is there a
> >usuable example out there?
>
> It's only available in embedded SQL....and FOR SELECT is only available in

Disagreed. This is valid and taken from a test-database:

CREATE PROCEDURE CURSOR_TEST
AS
declare variable myvar integer;
BEGIN
for select MyCol from MyTable
into :myvar as cursor mycursor
do begin
suspend;
end
END

Next, you can do things like:

DELETE FROM MyTable ... WHERE CURRENT OF MyCursor;

But I don't understand it's functionality :-/

> PSQL. In ESQL, the declared cursor's WHERE clause determines which rows
> the cursor will step on and WHERE CURRENT OF specifies that the operation
> visits those rows. It's equivalent to (in PSQL) specifying the cursor set
> with FOR SELECT and looping through each row, performing your block of
code
> on each one.

> If you *really* have a fatal urge to use WHERE CURRENT OF in a stored
> procedure, you could use MSSQL Server...<ducks>

Ugh - that's mean!

:-)

With regards,

Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com