Article View: borland.public.interbase.sql
Article #685Re: DECLARE CURSOR...
From: Martijn Tonies
Date: Fri, 02 Nov 2007 15:56
Date: Fri, 02 Nov 2007 15:56
43 lines
2201 bytes
2201 bytes
> IIRC there's an undocumented WHERE CURSOR OF feature in the stored
> procedure and trigger language, but it isn't actually useful for
> anything.
Actually, it's quite useful and fairly easy to use.
Here's an example:
CREATE PROCEDURE LOOP_NAMED_FOR
AS
declare variable v_value integer;
begin
for select v
from dummy_rows_10
into :v_value
as cursor mycursor
do begin
update dummy_rows_10
set v = :v_value
where current of mycursor;
end
end
As you can see, it allows for easier updating of values in the
table that's being used in the "named for loop". This way, you
can even update tables without a primary key or without selecting
the primary key value.
This was a small example in my "Stored Procedures and Triggers in Depth"
presentation which covered Firebird PSQL, but this is also available
in InterBase.
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Technical Details
Message-ID:
<472b489a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<472af011$1@newsgroups.borland.com> <472b2daa$1@newsgroups.borland.com> <472b2fc3$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,e4e23385873d5c38 X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Martijn Tonies" <m.tonies@upscene.removethis.com> Newsgroups: borland.public.interbase.sql References: <472af011$1@newsgroups.borland.com> <472b2daa$1@newsgroups.borland.com> <472b2fc3$1@newsgroups.borland.com> Subject: Re: DECLARE CURSOR... Date: Fri, 2 Nov 2007 16:56:28 +0100 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 NNTP-Posting-Host: 212.238.159.172 Message-ID: <472b489a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1194018970 212.238.159.172 (2 Nov 2007 08:56:10 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail