Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 27th, 2005, 05:15 AM
kirilzlatkov kirilzlatkov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 kirilzlatkov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 2 sec
Reputation Power: 0
Automating Import From CSV

Hello,
I receive data files in CSV format. This happens fairly frequently and I am looking for an automated way to transfer the data to Oracle 9 tables. My first idea was to write a PL/SQL script to do this. Is this the best approach? Does anyone have CSV parsing functions for PL/SQL? Any other suggestions from your personal experience would be very helpful. Thanks.

Reply With Quote
  #2  
Old June 27th, 2005, 05:21 AM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 996 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 12 m 14 sec
Reputation Power: 66
You can either use external tables or use SQL*Loader to put them into the database.

SQL*Loader:
http://download-west.oracle.com/doc...art2.htm#436160

External tables example:
http://download-west.oracle.com/doc...73a.htm#2093662

Reply With Quote
  #3  
Old June 27th, 2005, 05:27 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,826 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 11 h 35 m 33 sec
Reputation Power: 278
I've used exernal tables.

Reply With Quote
  #4  
Old June 30th, 2005, 05:24 AM
kirilzlatkov kirilzlatkov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 kirilzlatkov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 2 sec
Reputation Power: 0
Thanks for your suggestions. I decided to use external tables. But I am facing a problem. How do I store the Create Table statement in a stored procedure. I get the following error when I have placed it in the begin section:

PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:begin case declare exit for goto if loop mod null pragma...

Can anyone share with me some code. Thanks

Reply With Quote
  #5  
Old June 30th, 2005, 05:43 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,826 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 11 h 35 m 33 sec
Reputation Power: 278
Why create the external table in a stored proc?

Reply With Quote
  #6  
Old June 30th, 2005, 06:42 AM
kirilzlatkov kirilzlatkov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 kirilzlatkov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 2 sec
Reputation Power: 0
I receive the CSV file every month. So I want to call the stored procedure to add the new csv file as an external table and then with a
insert into tablename select * from external table
to transfer the data in the table where i hold them. If there's a better way to do it can you show me? Thanks.

Reply With Quote
  #7  
Old June 30th, 2005, 07:51 AM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 996 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 12 m 14 sec
Reputation Power: 66
Quote:
Originally Posted by kirilzlatkov
I receive the CSV file every month. So I want to call the stored procedure to add the new csv file as an external table and then with a
insert into tablename select * from external table
to transfer the data in the table where i hold them.

You don't need to re-create the table each time. Create it once, point it to the location of the CVS file, and then in you stored procedure you only need to do the INSERT. The SELECT will return the data from the current file.

Reply With Quote
  #8  
Old June 30th, 2005, 09:19 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,826 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 11 h 35 m 33 sec
Reputation Power: 278
Or do you receive a file with the date in the name, like extraction062005.csv?

Reply With Quote
  #9  
Old June 30th, 2005, 11:30 AM
kirilzlatkov kirilzlatkov is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 13 kirilzlatkov User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 2 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
Or do you receive a file with the date in the name, like extraction062005.csv?


Yes the name of the file is different.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Automating Import From CSV


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway