Subject RE: [firebird-support] FOR SELECT... CURSOR?
Author Rick Debay
Never mind, stupid question. Obviously you can't update a procedure,
and you can only update updateable views.

-----Original Message-----
From: Rick Debay
Sent: Monday, March 06, 2006 10:44 AM
To: 'firebird-support@yahoogroups.com'
Subject: RE: [firebird-support] FOR SELECT... CURSOR?

"On a large table, the cursor update will fly, since it uses the
rdb$db_key"

How about

SELECT COL FROM A_STORED_PROC() INTO :COL AS CURSOR

Or

SELECT COL FROM A_VIEW() INTO :COL AS CURSOR

Will this "fly" on a large result set?

-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Helen Borrie
Sent: Friday, March 03, 2006 4:35 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] FOR SELECT... CURSOR?

At 02:16 AM 4/03/2006, you wrote:
>Hi,
>
> > I have just a little question...
> > Is there a considerable difference between these two ways to update
> > a
>table
> > in a stored proc?
> >
> > 1)
> > FOR
> > SELECT APrimaryKeyField
> > FROM ATable
> > WHERE SomeCondition
> > INTO :AVariable
> > DO
> > BEGIN
> > /* Some Stuff... */
> > UPDATE ATable
> > SET SomeField = SomeValue
> > WHERE APrimaryKeyField = :AVariable;
> > END
> >
> > 2)
> > FOR
> > SELECT Whatever
> > FROM ATable
> > WHERE SomeCondition
> > INTO :SomeDummyVar
> > AS CURSOR SomeCursor
> > DO
> > BEGIN
> > /* Some Stuff... */
> > UPDATE ATable
> > SET SomeField = SomeValue
> > WHERE CURRENT OF SomeCursor
> > END
> >
> > At first glance I'd have thought the second way is the best, but I
> > wonder what the group's opinion is...
>
>The second one will be slightly faster.

Or a lot faster. For a handful of updates on a small table, the
difference won't be noticeable. On a large table, the cursor update
will fly, since it uses the rdb$db_key to locate the database rows.


>IMO, choose what you will be able to maintain and read.

IMO, test both with the same sample data and use the one that is faster.

./heLen