LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2006, 07:10 AM   #1
ancys
LQ Newbie
 
Registered: Jul 2006
Posts: 28

Rep: Reputation: Disabled
Regarding sqlldr


hi
I wrote a shell script(bash) for reading the text file and store into database
sample.sh
#!bin/sh
var="test.txt"
sqlldr uname/pwd@dbname control=crl.ctl

crl.ct
Load data infile '/sai/test.txt' into table employee fields terminated by "#" trailing nullcols(Col1,col2,col3)

here in control file i am hardcoding the filename i.e test.txt and pathname but i dont want to hard code it.

I need to transfer the filename and path stored in variable in shell program(sample.sh) to control file

I created the control.template as mentioned below but it replace only filename

how to replace both
the solution is given for replacing file name how to replace the path






Help me

Last edited by ancys; 08-07-2006 at 04:28 AM.
 
Old 08-05-2006, 01:15 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
You could have a file crl.template like so
Code:
Load data infile '/sai/REPLACE_ME' into table employee fields terminated by "#" trailingn ullcols(Col1,col2,col3)
And in the script do
Code:
#!bin/sh
var="test.txt"
sed "s/REPLACE_ME/$var/" crl.template > crl.ctl
sqlldr uname/pwd@dbname control=crl.ctl


Cheers,
Tink
 
Old 08-05-2006, 04:11 AM   #3
ancys
LQ Newbie
 
Registered: Jul 2006
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thanks For the solution
 
Old 08-07-2006, 02:55 AM   #4
ancys
LQ Newbie
 
Registered: Jul 2006
Posts: 28

Original Poster
Rep: Reputation: Disabled
but how can include the path name stored in a variable
 
Old 08-07-2006, 04:39 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Almost exactly like that. You just use something that's not in a file- or
pathname as the separator, e.g. @

Code:
#!bin/sh
var="/path/to/test.txt"
sed "s@REPLACE_ME@$var@" crl.template > crl.ctl
sqlldr uname/pwd@dbname control=crl.ctl

Cheers,
Tink
 
Old 08-07-2006, 05:44 AM   #6
ancys
LQ Newbie
 
Registered: Jul 2006
Posts: 28

Original Poster
Rep: Reputation: Disabled
Ihanks the script works successfully
 
Old 08-10-2006, 08:02 AM   #7
ancys
LQ Newbie
 
Registered: Jul 2006
Posts: 28

Original Poster
Rep: Reputation: Disabled
Hi,
Even the delimiter is stored i an variable called delimter='#'

how to place in control.template
 
  


Reply



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



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration