Executing Multiple .SQL Files from Single Shell Script file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing Multiple .SQL Files from Single Shell Script file
# 1  
Old 03-07-2006
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
# 2  
Old 03-07-2006
can you give examples of the file names and how they are to be ordered


Gaurav
# 3  
Old 03-07-2006
I am trying to create database objects through the files.

The file names are simillar to the names of the objects they are creating.i want that if the object has been created successfully i get a success in my log file, and if any error then the error in the log file along with the file names

for views i have file with extension .VW, for Procedure .PRC and so on
i want files to be executed in the order
1. .VW
2. .FNC
3. .PRC
4. .SQL
5. .SQH
6. .SQB

Please help
# 4  
Old 04-07-2008
script example

This is how I executed multiple sql files in a folder that had 100 sql files in it:
for filename in *.sql
do
echo "Executing file $filename..."
sqlplus -s ods/passwd@dODS <<EOF
@$filename;
quit;
EOF
done

enjoySmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

2. UNIX for Beginners Questions & Answers

Help with Executing sql in Shell Script

Hello~ I have a requirement to write a shell script which will connect to the oracle database and run a select count(*) query on a table. The script should succeed only when the count returns a number greater than zero. If the count returns zero, the script should fail. Can someone please... (3 Replies)
Discussion started by: Naren.N
3 Replies

3. UNIX for Dummies Questions & Answers

Regarding executing sql query in shell script

Hi, I have one SQL file prepared in UNIX and one script that is executing that. In SQL i have Update and create queries. I want to introduce conditions in SQL file (in UNIX) that if either of the create or update query failes whole transaction should be rollback. I just have 1 create... (2 Replies)
Discussion started by: abhii
2 Replies

4. Shell Programming and Scripting

Executing a shell script from a PL / SQL Block

Hi, I need to call a shell script present on solaris server from within a PL / SQL block. Kindly suggest.. Thanks Sudhir (1 Reply)
Discussion started by: sudhird
1 Replies

5. Programming

Single sql query to spool to multiple files

Is there anyway to spool my select statement into spool files of max 10000 records each? eg I have a select statement that will return 45000 records. A normal spool command will output the 45000 into just one spool file. How can I make sqlplus do this? 00001 - 10000 records --- spool... (3 Replies)
Discussion started by: Leion
3 Replies

6. UNIX for Dummies Questions & Answers

split a single sql file into multiple files

Hi,I have a single sql file containing many create table ddl's.Example: CREATE TABLE sec_afs ( rpt_per_typ_c char(1) NOT NULL, rpt_per_typ_t varchar(20) NULL, LOCK ALLPAGES go EXEC sp_primarykey 'sec_afs', rpt_per_typ_c go GRANT SELECT ON sec_afs TO developer_read_only... (5 Replies)
Discussion started by: smarter_aries
5 Replies

7. Shell Programming and Scripting

executing a SQL query in shell script

Hi ALL, I need an help in connecting to oracle database, executing a select query and printing it on the screen. Can any one please write a simple code or psuedo code and let me know. select query returns multiple values( say select name from emp) Thanks in advance LM (1 Reply)
Discussion started by: lijju.mathew
1 Replies

8. Shell Programming and Scripting

Executing Sql Query Using Shell Script

HI ALL i have a requirement like this. i have to write a shell script to run a sql query. DB is oracle. once the query is run, the results of the query has to be published in a data file. can you please advice me how to go about it. i am absolutely new to shell scripts and this is a part of my job. (14 Replies)
Discussion started by: ragha81
14 Replies

9. UNIX for Dummies Questions & Answers

Sh Shell Script executing remote SQL queries

Hi there folks, I am trying to execute remote sql queries on an Oracle server. I would like to save the result of the executed sql queries on a text file, and send that text file as an attachment to an email address. Could anyone give me an idea on how the above could be achieved? Any help... (2 Replies)
Discussion started by: Javed
2 Replies

10. UNIX for Dummies Questions & Answers

Executing a SQL query from a shell script

I cannot figure out how to run a SQL script, or just a sqlplus query, from a shell script (bash or ksh). Basically, I need to su - oracle from root and run a query, then test the exit status. (3 Replies)
Discussion started by: 98_1LE
3 Replies
Login or Register to Ask a Question