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: Copy row and alter a column

Re: Copy row and alter a column

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 19 Jan 2000 14:05:32 -0800
Message-ID: <3886352c@news.victoria.tc.ca>


minor correction

Malcolm Dew-Jones (yf110_at_vtn1.victoria.tc.ca) wrote:
: jeanch_at_my-deja.com wrote:
: : 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;

: how about

: insert into tab
: select col1, col2, ... , 2 , ... , coln-1, coln

		from tab

: where eid = 41;

: the literal "2" is placed in the correct position for the "state" column,
: and the other columns are specified as themselves.

: : 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 - 16:05:32 CST

Original text of this message

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