Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Copy row and alter a column
JC,
Try this:
INSERT INTO tab (Col1,Col2,..,STATE) SELECT Col1,Col2,..,2 FROM tab WHERE
EID = 41;
or if business rules are more comlex, try to write a small PL/SQL procedure
to do it.
Thomas
<jeanch_at_my-deja.com> wrote in message news:864mfu$8rn$1_at_nnrp1.deja.com...
> Folks,
>
> Does anybody know how to achieve this ?
>
> I am trying to copy a row in a table,
> alter that row and insert the altered row
> in the same table. Ideally I would like
> to achieve this in one single transaction:
>
> INSERT INTO tab SELECT * FROM tab WHERE EID = 41
>
> "AND"
> UPDATE tab set state = 2 where eid = 41 and rownum = 1;
> state is a column of tab table;
>
> The reason I need to do that in one transaction is the table
> have a unique constraint which does not allow me to enter identical
> twice.
>
> Your help is much appreaciated
>
> Cheers
> JC
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Wed Jan 19 2000 - 10:29:42 CST
![]() |
![]() |