Subject | Re: [firebird-support] How to Update when the val is a result set from a select |
---|---|
Author | Milan Babuskov |
Post date | 2009-07-22T18:05:27Z |
Car Toper wrote:
execute block
as
declare variable id bigint;
declare variable newval integer;
begin
newval = 1000;
for select id from atable order by sort_order into :id
do
begin
update atable set sort_order = :newval where id = :id;
newval = newval + 1000;
end
end
This is a simple example with EXECUTE BLOCK, but without UPDATE WHERE
CURRENT OF. I leave that one for exercise.
HTH
--
Milan Babuskov
==================================
The easiest way to import XML, CSV
and textual files into Firebird:
http://www.guacosoft.com/xmlwizard
==================================
> 2009/7/22 Dimitry Sibiryakov <sd@...>:Assuming your primary key field is named ID:
>>> What am I doing wrong here?
>> RTFM EXECUTE BLOCK, FOR SELECT, UPDATE WHERE CURRENT OF.
>
> Yea, I am RTFM and I am too dumb to get it. Guess I will do it the
> hard way since there doesn't seem to be any enlightenment here :(
execute block
as
declare variable id bigint;
declare variable newval integer;
begin
newval = 1000;
for select id from atable order by sort_order into :id
do
begin
update atable set sort_order = :newval where id = :id;
newval = newval + 1000;
end
end
This is a simple example with EXECUTE BLOCK, but without UPDATE WHERE
CURRENT OF. I leave that one for exercise.
HTH
--
Milan Babuskov
==================================
The easiest way to import XML, CSV
and textual files into Firebird:
http://www.guacosoft.com/xmlwizard
==================================