Subject | Re: [firebird-support] Re: Help with Queries |
---|---|
Author | Helen Borrie |
Post date | 2004-06-26T13:11:41Z |
At 12:29 PM 26/06/2004 +0000, you wrote:
subquery, e.g.
update table1 t1
set t1.name = (select t2.name from table1 t2
where t2.PK = 99)
where t1.PK = 144
The problem is, it'll be a long job if you have a lot of columns to update,
since you need a separate subquery and table alias for each column you want
to update. It really would be more efficient to create entirely new
records. If you wanted to restore the original PKs, you could just add a
column to store it, and use the value to update the PKs on the new records
once you'd deleted the old ones.
/heLen
>Thanks for the reply HelenIf you only want to do "spot updates" like the latter, use a re-entrant
>
> >Assuming in both cases you are using generator + trigger to populate
>the
>PK:
>
> >insert into table1 (col2, col3, col4, .....)
> >select col2, col3,col4, ... from table1
> >where blah...
>
>I can't use Insert since the row already exists, I just want to
>overwrite
>all the columns in a row , prior to doing other modifications on an
>individual column, e.g. changing the name in the NAME column.
subquery, e.g.
update table1 t1
set t1.name = (select t2.name from table1 t2
where t2.PK = 99)
where t1.PK = 144
The problem is, it'll be a long job if you have a lot of columns to update,
since you need a separate subquery and table alias for each column you want
to update. It really would be more efficient to create entirely new
records. If you wanted to restore the original PKs, you could just add a
column to store it, and use the value to update the PKs on the new records
once you'd deleted the old ones.
/heLen