Subject Re: [ib-support] Update in SP
Author Ann W. Harrison
>At 11:17 AM 09-05-01 +0300, Dorin wrote:
> >Hi everyone !
> >How can I update a table in a SP using a FOR SELECT ... clause ?
> >
> >FOR SELECT <some columns> from <table> into <vars> DO BEGIN
> > ... Here is the updating part ...
> >END

At 10:07 PM 5/9/2001 +1000, Helen Borrie wrote:


>In a FOR SELECT loop on one table you can use the selected data to update
>another table but not to update the one which is the subject of the loop, e.g.

Helen must have been having an off day.

Something like this will work:

for select <primary key> from <table> where <condition>
into <variable>
do begin
update <table> set <assignments> where <primary key> = <variable>
end;

There are a couple of variants that might be slightly faster (using
the undocumented cursor mechanism or db_keys) but as all the structures
you're using will be in cache, the difference is unlikely to be
measurable.

Regards,

Ann
www.ibphoenix.com
we have answers