Computing.Net > Forums > Database > Oracle Column Data Convertion

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Oracle Column Data Convertion

Reply to Message Icon

Name: delory
Date: January 9, 2008 at 04:21:48 Pacific
OS: Oracle 9i
CPU/Ram: 1400 256
Product: Compaq
Comment:

Hi everyone,

I have to run a conversion on multiple tables to change the data in one column on each table. I am happy to run this separately for each table, but I would like to know the best way to do this.

e.g. for table 1 with 50 colums and 1000 rows, I wish to change all the data in column 3 to new values based on a lookup spreadsheet I have, containing a list of old values and new values:

value1;value2;
value3;value4;
etc.

so I want to read the first row in the table, see the data in col3, and if it matches value1, change it value2, etc.

I want some kind of a scrip to do this so that I can then change the relevant details for the next table, and change the lookup table with the values for that table.

Does anyone have any suggestions on the most efficient way to do this please?

Many thanks.




Sponsored Link
Ads by Google

Response Number 1
Name: gohome88
Date: January 23, 2008 at 15:27:18 Pacific
Reply:

By doing that,
1. create a lookup table with 2 columuns new and old
2. load the spreadsheet into the lookup table by using SQLloader
3. write PL/SQL
3.1 create cursor for the lookup table
3.2 wirte the cursor for loop to update the table with the new value

This piece of code can be reused for the rest of your tables.


gohome88


0

Response Number 2
Name: User123456789
Date: February 3, 2008 at 06:29:30 Pacific
Reply:

Add the new column in the table, update the value accordingly (cant be that hard), change the PK or UK (if it involves any old column), remove the NOT NULL property from these old columns (if still present), empty the old values, try to remove the columns (wont work on 9i I guess, but have a try).

If the old columns bother you, you can go on to step 2, trying to recreate the table without those columns (create table as select ...), and/or "rename table ...".

Hi there.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Oracle Column Data Convertion

Using sqlldr to insert blob? www.computing.net/answers/dbase/using-sqlldr-to-insert-blob/179.html

converting excel worksheets to access tables www.computing.net/answers/dbase/converting-excel-worksheets-to-access-tables/651.html

RAW data filing system www.computing.net/answers/dbase/raw-data-filing-system/149.html