Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL: Copy rows, changing one column
Use an insert with a sub-query:
insert into my_table
(col1, col2, col3,
select decode(col1,'v1','w1', 'v2','w2', 'v3','w3', 'v4','w4'), col2, col3, col4
hope this is what you wanted to know !
-jay
perry_at_hem.passagen.se wrote:
> Hi
>
> I want to copy a few rows meeting a certain demand
> in a table to the same table, changing the demanded value.
> Like this:
>
> col1 col2 col3 col4
> ----------------------
> v1 a b c
> v1 d e f
> v2 g h i
>
> I want to copy these rows to the same table to:
>
> col1 col2 col3 col4
> ----------------------
> w1 a b c
> w1 d e f
> w2 g h i
>
> Can this be done in a single SQL insert-query or must i loop through the
> recordset and copy each row one at a time, changing the appropriate
> column?
> Any suggestions?
>
> best regards, Per.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Fri Jun 04 1999 - 13:22:48 CDT