The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
unix script for loading a data from a file into database grajesh_955 Shell Programming and Scripting 5 3 Weeks Ago 08:49 PM
Howto capture data from rs232port andpull data into oracle database-9i automatically boss UNIX for Dummies Questions & Answers 1 09-22-2007 11:35 PM
Need Shell Script to upload data from Text file to Oracle database chandrashekharj Shell Programming and Scripting 6 03-26-2007 12:21 AM
How to export data file from Unix whatisthis UNIX for Dummies Questions & Answers 20 03-03-2005 11:16 AM
export table from oracle database inquirer Shell Programming and Scripting 1 06-24-2003 06:48 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-18-2005
Registered User
 

Join Date: Jul 2005
Posts: 2
unix script to export data from csv file to oracle database

Hello people,

Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these files then need to be exported to an oracle database.

I wonder if anyone has done anything similar to this. Does anyone have a shell script that I can borrow? Any help will be appreciated. Thanks.

Vina
Reply With Quote
Forum Sponsor
  #2  
Old 07-18-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,022
I guess you want to import data into Oracle [not to 'export data to Oracle].
If that's the case you might want to look into Oracle's sqlldr - that's the data loader.
Here's a sample usage:
Code:
$ORACLE_HOME/bin/sqlldr userid=userName/userPasswd control=/path/to/controlFile log=/path/to/logFile data=/path/to/dataFile
Reply With Quote
  #3  
Old 07-19-2005
Registered User
 

Join Date: Jul 2005
Location: Uk
Posts: 1
I use sqlldr on a monthly basis as follows:

1. Create a control file - filename.ctl
2. Create an executable script - load_file (or whatever you want to call it)
3. Make sure the file you want to load does not change name or type, mine is just called start.csv and in comma seperated format. Write some error checking code for this.

##filename.ctl##
load data
infile start.csv
into table contact append
fields terminated by ',' optionally enclosed by '"'
(
URN,
TITLE,
FIRST_NAME,
OTHER_NAME,
LAST_NAME
)

##load_file##
sqlldr scott/tiger control=filename.ctl

##start.csv - first record example##

"0061031","Mr","B","A","Williams"

load_file will look at the control file and import the values from start.csv as required. If you sure the file is being placed in a directory it is worth while checking whether it exists before trying to import it into oracle else abort.

sqlldr does create a filename.log in the directory where you specified unless you specify a path as shown with the example by vgersh99.

Pretty basic but with a cron job should be able to get it working easily.

Hope this helps.
Reply With Quote
  #4  
Old 07-20-2005
Registered User
 

Join Date: Jul 2005
Posts: 2
Thanks to you both DirkLottering and vgersh99. I'll try it. If i want to make it as recurring process, can I do it by control file ?

I'm new to unix so bear with me if its silly question.

thanks again.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0