If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Import/Export script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-03, 00:52
kondaoracle kondaoracle is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
Import/Export script

Hi

My Req is "data will be taken into a flat file from one database. I need to read the data from this flat file and to put into another database."

I would like to write a procedure (pl/sql) for this.
Any ideas of how it cud b done.
Reply With Quote
  #2 (permalink)  
Old 12-29-03, 21:01
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Well yeah U Bet!!!!

Use UTL_FILE Package to load data into a flat file and then use the same UTL_FILE to read that data from the Flat File to the DB of your choice....

Good Luck!!
Reply With Quote
  #3 (permalink)  
Old 12-29-03, 23:24
kondaoracle kondaoracle is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
Re: Well yeah U Bet!!!!

Thats good idea..

Any sample script available for that...coz some care to be taken when handling null values.

1. The file to be imported may be comma separated
2. The file to be imported may be tab separated.
3. The file to be imported may be some spaces separated.

Is there any other way except reading the entries line by line ?
Reply With Quote
  #4 (permalink)  
Old 12-30-03, 00:45
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Re: Well yeah U Bet!!!!

You have to specify what specify what separated the file is. You have to create a dynamic PL/SQL to handle that, there is no easy way out.
For the second part of your question about reading file in totality rather than line by line... I GUESS NOT.
I CAN give you sample file for reading any "separated" file but I guess you use your sweat a bit to find out that, isn't life full of thorns ? If you can't get to it please let me know I'll create a Proc for you. Best Of luck...

Quote:
Originally posted by kondaoracle
Thats good idea..

Any sample script available for that...coz some care to be taken when handling null values.

1. The file to be imported may be comma separated
2. The file to be imported may be tab separated.
3. The file to be imported may be some spaces separated.

Is there any other way except reading the entries line by line ?
Reply With Quote
  #5 (permalink)  
Old 12-30-03, 01:03
kondaoracle kondaoracle is offline
Registered User
 
Join Date: Sep 2003
Posts: 33
thanx arin for ur support

cud u send me the sample file for reading any "separated" file .

If it serves my purpose i use it or i will make changes accordingly............and definitely get back to you....with modified script..
Reply With Quote
  #6 (permalink)  
Old 12-30-03, 19:42
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Hey

Konda,
Its nearing New Year... will be back after New Year to give you the code. Am sorry to dissapoint you. But you cud spare me sometime for myself and my family...
Cheers!!!!!!

Quote:
Originally posted by kondaoracle
thanx arin for ur support

cud u send me the sample file for reading any "separated" file .

If it serves my purpose i use it or i will make changes accordingly............and definitely get back to you....with modified script..
Reply With Quote
  #7 (permalink)  
Old 01-02-04, 17:20
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Here you goooo!!!

This is a function. Now this function will accept table Name and when u give that it's determine what the columns are and will accordingly make the dynamic insert . This is as dynamic as you can get... You aslo have to specify your directory where the data will be along with the file name. BUT BE SURE TO CHANGE UTL_FILE_DIR VALUE IN ur SP FILE AND BOUNCE THE DATABASE.

Cheers!!!!!!!!
Attached Files
File Type: sql genloaddata.sql (3.0 KB, 70 views)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On