Solved

update Oracle table with data from Excel spreadsheet

Posted on 2014-04-16
7
2,833 Views
Last Modified: 2014-04-18
I have an Oracle table that I need to update one column in the table for several thousand rows.  I have the data to do that update in an excel spreadsheet.  How can I update that Oracle table with the data in the excel spreadsheet.  I have the unique identifier in the excel spreadsheet for each table row that needs to be updated.  Thanks for any help that you can give.
0
Comment
Question by:newtoperlpgm
  • 4
  • 2
7 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40005500
You 'could' write a lot of VBA code but here is what I would do.

Save the Excel spreadsheet as a CSV.
Either use SQL Loader to load the data into a temp table in Oracle or create an External table against the CSV.

Then perform the update from the temp or external table.

There are tons of sql loader and external table examples out there on the web.

Hopefully the update is straight forward.

If you need any help with any of this, please post back with sample data and expected results and what pieces you need help with.
0
 
LVL 22

Expert Comment

by:Steve Wales
ID: 40005505
I have always done something similar in same kind of circumstance.  I have a Delphi piece of template code that opens a spreadsheet and loops through the data and I generate a text file with the insert or update statement then run that through sqlplus.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40005513
>>and I generate a text file with the insert or update statement then run that through sqlplus.

Didn't think about brute force.

Alternatives without the delphi piece:

global search and replace from a txt/csv file in notepad.
or
I have seen people insert new columns in Excel with the DML then save to txt and replace the tabs.

For example:
insert columnA and add: update some_table set some_column='
columnB has the value
insert columnC: ' where comeothercolumn='
columnD has the value
Insert columnE ';

then save, repace the tabs for the column breaks and run in sqlplus.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 22

Expert Comment

by:Steve Wales
ID: 40005552
Sometimes the brute force approach is the simplest way to get the job done.

A little effort the first time, then super easy each successive time you need to complete a similar task.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40005555
Could not agree more
0
 

Author Comment

by:newtoperlpgm
ID: 40007039
I was able to easily create an Oracle staging table, feed the data into the data from the spreadsheet and update my original table with a simple update statement.  Thanks so much for making it easy for me.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40007074
No problem.  Glad to help!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to take different types of Oracle backups using RMAN.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now