Change Large Number of Record Keys using Map Table

Posted by Coyote on Stack Overflow See other posts from Stack Overflow or by Coyote
Published on 2009-11-02T16:46:15Z Indexed on 2010/03/25 15:13 UTC
Read the original article Hit count: 323

Filed under:
|
|

I have a set of records indexed by id numbers, I need to convert these record's indexes to a new id number. I have a two column table mapping the old numbers to the new numbers.

For example given these two tables, what would the update statement look like?

Given:

   OLD_TO_NEW
oldid   |   newid
-----------------
1234        0987
7698        5645
...         ...

and

id      |   data
----------------
1234        'yo'
7698        'hey'
...         ...

Need:

id      |   data
----------------
0987        'yo'
5645        'hey'
...         ...

This oracle so I have access to PL/SQL, I'm just trying to avoid it.

© Stack Overflow or respective owner

Related posts about sql

Related posts about Oracle