Help shell script to loop through files update ctl file to be sql loaded


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help shell script to loop through files update ctl file to be sql loaded
# 1  
Old 04-15-2008
Help shell script to loop through files update ctl file to be sql loaded

I am currently trying to find a way to loop through files in a given directory and for each file modify a ctl file and sql load it. I have been using the sed command to change the infile, badfile parameters of the control file. I have not yet tried to sql load it.
Requirement: files are ftp to directory. Shell loops through the files and then using a master control file change the infile, badfile parameters with the file name. SQL load file.

I currently have been trying the following.
<<filename>> is what I am using to change in the ctl file.

export MY_DIR=/volume/files

for a in $MY_DIR/*ctl
do
sed -e "s/<<filename>>/$a/g" $a $a.ctl
done

I am wondering if their is a way to reference the infile, badfile directly in the ctl file instead. I also have an insert into a table where the filename that I am loading needs to be inserted. My method leaves me with a badfile with "name.ctl.bad" instead of just "name.bad". I am new to shell scripting so please be nice.

Thanks in advance.
# 2  
Old 04-15-2008
Quote:
Originally Posted by dba_nh

My method leaves me with a badfile with "name.ctl.bad" instead of just "name.bad".

I'm not sure whether this is what you are looking for:

Code:
badfile=${a%.ctl}.bad

[QUOTE]
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute 10 sql files from a folder through sqlplus in shell script?

I am new to shell scripting and i want to know how to execute the *.sql files from a folder through sqlplus in shell script and files should be execute in sequentially one by one while execution if any ORA error it has to exit from sqlplus session 1) scripts from external folder 2) logs has... (1 Reply)
Discussion started by: sreekanth Reddy
1 Replies

2. Shell Programming and Scripting

Oop to copy and rename files through SQL Statement in shell Script

#!/bin/sh sqlplus -s "/ as sysdba" << EOF SET HEADING OFF SET FEEDBACK OFF Select pt.user_concurrent_program_name , OUTFILE_NAME FROm apps.fnd_concurrent_programs_tl pt, apps.fnd_concurrent_requests f where pt.concurrent_program_id = f.concurrent_program_id and pt.application_id =... (1 Reply)
Discussion started by: usman_oracle
1 Replies

3. Shell Programming and Scripting

Shell script to perform appending of .sql files

Hi, We are having multiple .sql files generated programatically which is not containing.. create or replace -- at the start and / -- at the end We need to append those .sql files with the above 2 statements at their respective positions. We will be really thankful to get responses... (6 Replies)
Discussion started by: Rami Reddy
6 Replies

4. Shell Programming and Scripting

how to pass a variable to an update sql statement inside a loop

hi all, i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code. sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE whenever sqlerror exit set serveroutput on size 1000000 declare l_rc ... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

5. Shell Programming and Scripting

How to retrieve all the linked script files/ctl files/sql files?

Hi I am going to migrate our datawarehouse system from HP Tru 64 Unix to the Red Hat Linux. Inside the box, it is running around 40 cron jobs; inside each cron job, it is calling other shell script files, and the shell script files may again call other shell script files or ctl files(for... (1 Reply)
Discussion started by: franksubramania
1 Replies

6. Shell Programming and Scripting

shell script to run .sql files

hi Friends, Please help me in writing shell script to run list of sql files. database is Oracle 9i, unix os is solaris Requirement is 1. sql file must take two inputs a)feed id and b)business date 2.shell script must out put .xls or .csvfile as out put without trimming any column name and... (1 Reply)
Discussion started by: balireddy_77
1 Replies

7. Shell Programming and Scripting

how to call shell script from pl/sql loop

Hello, I am doing a shell script which contain a pl/sql loop to search for 3 values, i would like to call another shell script inside this sql loop each time it find the values. so how can i call shell script from pl/sql using its variables, any idea? Here is idea about the code: my... (1 Reply)
Discussion started by: rosalinda
1 Replies

8. Linux

perl update while script is loaded

Hi All, What will happen to the perl script loaded on the memory if I do perl update? Thanks. (1 Reply)
Discussion started by: itik
1 Replies

9. Shell Programming and Scripting

Executing Multiple .SQL Files from Single Shell Script file

Hi, Please help me out. I have around 700 sql files to execute in a defined order, how can i do it from shell script (3 Replies)
Discussion started by: anushilrai
3 Replies

10. Shell Programming and Scripting

Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are 1. The Control file name(.ctl file) 2. The Data file name(.csv file) Does anybody have an idea about it? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies
Login or Register to Ask a Question