Subject | Re: [ib-support] Update in SP |
---|---|
Author | Ann W. Harrison |
Post date | 2001-05-09T13:53:18Z |
>At 11:17 AM 09-05-01 +0300, Dorin wrote:At 10:07 PM 5/9/2001 +1000, Helen Borrie 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
>In a FOR SELECT loop on one table you can use the selected data to updateHelen must have been having an off day.
>another table but not to update the one which is the subject of the loop, e.g.
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