![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| difference in calling shell scripts | arpit_narula | SUN Solaris | 6 | 09-07-2008 03:46 PM |
| Calling shell functions from another shell script | jisha | Shell Programming and Scripting | 6 | 04-05-2008 04:29 PM |
| Calling Shell Script | onlyroshni | Shell Programming and Scripting | 1 | 10-22-2007 07:29 PM |
| script calling other scripts hangs | rein | Shell Programming and Scripting | 1 | 09-07-2007 05:26 AM |
| Calling SQL scripts through Shell Script | madhunk | Shell Programming and Scripting | 18 | 06-14-2006 12:35 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Calling SQL LDR and SQL plus scripts in a shell script
Hi-
I am trying to achieve the following in a script so I can schedule it on a cron job. I am fairly new to the unix environment... I have written a shell script that reads a flat file and loads the data into an Oracle table (Table1) via SQLLDR. This Works fine. Then, I run a nested insert statement to parse through the records in Table1 and load the necessary results into a Table. (Table2). This works fine too. Here is how my script looks like... # Always truncate table 1 before loading data. print "truncate table table1;" | sqlplus -s userid/password@db>$now.log sqlldr userid/password@db control=dbload.ctl>>$now.log # Always truncate table 2 before loading data. print "truncate table table2;" | sqlplus -s userid/password@db>>$now.log # Parse through Table1 and load only necessary records to Table2. print "insert into table2 select id, min(STARTDATE) as startdate from table1 group by id, to_char(STARTDATE,'mm/dd/yyyy');" | sqlplus -s userid/password@db>>$now.log I call this script myscript.sh, which will be run via crontab every 15 mins. Here are my questions: 1) Note how I establish a database connection to execute every sql I need to run? I am thinking there should be an easy way to this. I looked into the "here documents" but not sure how I can use them above. Do I really need to use the "here document" or is my script good the way as it is now? Would it open and close the db connections for each sql correctly? If I do use the "here document", do I need to have one for the sqlldr and the other for all the sqlplus part? Please advise best way to go ahead. Thanks RG |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|