Subject | Re: [ib-support] CURSOR or WHERE CURRENT OF in a stored procedure |
---|---|
Author | Martijn Tonies |
Post date | 2003-06-05T08:26:48Z |
Helen,
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 :-/
:-)
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com
> >Right - I've found the syntax after all ...Disagreed. This is valid and taken from a test-database:
> >
> > > 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
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 rowscode
> 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
> on each one.Ugh - that's mean!
> If you *really* have a fatal urge to use WHERE CURRENT OF in a stored
> procedure, you could use MSSQL Server...<ducks>
:-)
With regards,
Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com