Home » SQL & PL/SQL » SQL & PL/SQL » Update question
Update question [message #7418] Thu, 12 June 2003 08:50 Go to next message
Munish
Messages: 21
Registered: November 2001
Junior Member
I have a table called Table A (col1, col2,col3,username).
There are 2 username is the table. (andy,test).

I want to know, how can I write a update statement that will update test username with the same records that of andy. I basically want to clone test user.

I know I can do this by writing a cursor but is there a better way to do this?

PS. There are multiple records in table A for andy username.

thanks
Munish
Re: Update question [message #7419 is a reply to message #7418] Thu, 12 June 2003 10:34 Go to previous message
Mike T
Messages: 32
Registered: August 2002
Member
I would do this:

delete from TableA
where username = 'test';
commit;

insert into TableA
(select col1, col2, col3, 'test' from TableA);
commit;

Otherwise, you need to let us know what the Key field(s) is before using an Update...but since you are simply "cloning" the andy username, I would go this route.
Previous Topic: Heriarcy Level finding using connect by prior or pl/sql
Next Topic: Help writing simple stored procedure!
Goto Forum:
  


Current Time: Thu Apr 25 18:13:30 CDT 2024