dbTalk Databases Forums  

Copying data from 1 record to another within same table

comp.database.oracle comp.database.oracle


Discuss Copying data from 1 record to another within same table in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andy
 
Posts: n/a

Default Copying data from 1 record to another within same table - 12-11-2003 , 01:01 PM






Hi-

I come from a SQL Server background and am just starting to use
Oracle. We are changing the names of data within a table and want to
copy data from the old record over to the new record. In SQL Server I
can use this

update a
set a.cpty_addr1 = b.cpty_addr1
from cpty a, cpty b
where a.cpty_cpty = 'ENGYAUTH' and b.cpty_addr1 = 'ENGYAUTH_S';

In Oracle this does not work. Could somebody please help me out?

Thanks

Reply With Quote
  #2  
Old   
David Sanchez
 
Posts: n/a

Default Re: Copying data from 1 record to another within same table - 12-25-2003 , 05:51 PM






Try

update cpty
set cpty_addr1 = (select cpty_addr1 from cpty where cpty_addr1 =
'ENGYAUTH_S')
where cpty_cpty = 'ENGYAUTH';

However, it looks like if you made a mistake in you where clause. Should it
not be:

where a.cpty_cpty = 'ENGYAUTH' and b.cpty_cpty = 'ENGYAUTH_S'

If that is the case, then the update should be;

update cpty
set cpty_addr1 = (select cpty_addr1 from cpty where cpty_cpty =
'ENGYAUTH_S')
where cpty_cpty = 'ENGYAUTH';

Note: The select must return only one row.

David

"Andy" <drewb6911 (AT) yahoo (DOT) com> wrote

Quote:
Hi-

I come from a SQL Server background and am just starting to use
Oracle. We are changing the names of data within a table and want to
copy data from the old record over to the new record. In SQL Server I
can use this

update a
set a.cpty_addr1 = b.cpty_addr1
from cpty a, cpty b
where a.cpty_cpty = 'ENGYAUTH' and b.cpty_addr1 = 'ENGYAUTH_S';

In Oracle this does not work. Could somebody please help me out?

Thanks



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.