Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL: Copy rows, changing one column

Re: SQL: Copy rows, changing one column

From: Jay <jra_at_inforonics.com>
Date: Fri, 4 Jun 1999 18:22:48 GMT
Message-ID: <37581978.3A2FE6F1@inforonics.com>


Use an insert with a sub-query:

insert into my_table

(col1,
 col2,
 col3,

 col4)
select decode(col1,'v1','w1',
                           'v2','w2',
                           'v3','w3',
                           'v4','w4'),
         col2,
         col3,
         col4

from my_table
where col1 like 'v%'; < or whatever where clause :-) >

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US