Running multiple sql files in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running multiple sql files in unix
# 1  
Old 10-15-2009
Running multiple sql files in unix

In c:/zaheer/123-456/sql/ folder i have below 7 sql files.

cv_abc_a.sql
cv_abc_b.sql
cv_abc_c.sql
vtemp_d.sql
vtemp_e.sql
cv_abc_f.sql
Exviews.sql

In Exviews.sql file i have mentioned all cv and vtemp files to run like

start ${SQLDIR}/cv_abc_a.sql
start ${SQLDIR}/cv_abc_b.sql
start ${SQLDIR}/cv_abc_c.sql
start ${SQLDIR}/vtemp_d.sql
start ${SQLDIR}/vtemp_e.sql
start ${SQLDIR}/cv_abc_f.sql

My aim is to run all sql files in order which present in Exview.sql file
even if error occured print that error and continue with next file.

Please suggest.
Thanks in advance
# 2  
Old 10-15-2009
Quote:
Originally Posted by Zaheer.mic
...
In Exviews.sql file i have mentioned all cv and vtemp files to run like

start ${SQLDIR}/cv_abc_a.sql
start ${SQLDIR}/cv_abc_b.sql
start ${SQLDIR}/cv_abc_c.sql
start ${SQLDIR}/vtemp_d.sql
start ${SQLDIR}/vtemp_e.sql
start ${SQLDIR}/cv_abc_f.sql

My aim is to run all sql files in order which present in Exview.sql file
...
So just execute the script "Exview.sql".
You have put down the order already. So all you need is to execute it.
(Unless I am missing something.)

Quote:
...
even if error occured print that error and continue with next file.
...
If we are talking about Oracle, then I think this really depends on the way exceptions are handled in those individual sql files.

- If you have no EXCEPTION block in any sql file, then the error message will be escalated to the client program (which I assume is sqlplus in this case.)
- If you have handled exceptions in those sql files, then the error will be printed only if you programmed it so.
- If you have those ghastly "when others then null;" or "when <XYZ> then null;" exception handlers then your script essentially gobbles up the exception.

In all cases, sqlplus will continue with the next file, unless you have run the command "whenever [sqlerror|oserror] then exit ..." somewhere in the sqlplus session.

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies

2. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

3. UNIX for Dummies Questions & Answers

Running a SQL Query from UNIX

Hi, Could you please help me on this. I have bulk of queries written in text file. I want to use those queries and want to execute from UNIX. I don't want to run this file as a sql file as this file will change every week. I want to run it in my environment as bulk sql statement from text... (1 Reply)
Discussion started by: abhii
1 Replies

4. Shell Programming and Scripting

Help to merge multiple .sql files

Hello all, I have a shell script that uses multiple .sql files. These .sql files mainly contain Oracle SQL queries to pull fields from the database. I want to place all the contents of these .sql files in one .sql file and have some parameter sent based on which the respective block or query... (6 Replies)
Discussion started by: snvniranjanrao
6 Replies

5. Shell Programming and Scripting

sql loader for inserting the data from multiple fields from unix

Hi , I have my log file something like this (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011 (07/29/2009 00:02:26.236) 367524 (07/29/2009 00:02:28.207) 949395117 (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864 I am trying to insert the data... (3 Replies)
Discussion started by: rdhanek
3 Replies

6. 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

7. Shell Programming and Scripting

put value of multiple sql statements into unix variables

i want to use multple sql count statements and store these count values in unix variable but in one connection only i.e. in only 1 time database should be hit ,which is the main requirement. (1 Reply)
Discussion started by: sw@pnil
1 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Running PL/SQL procedure via unix

All, I have a 10g PL/SQL procedure that needs to be run via a unix script. How could such a script be developed. Thanks Aditya. (1 Reply)
Discussion started by: kingofprussia
1 Replies

10. UNIX for Advanced & Expert Users

Bus error(coredump) while running SQL*Loader in HP Unix 11

Hi All, I am getting coredump error, when I try to execute Oracle SQL*Loader from Shell script in Unix environment. But SQL*Loader from local machine runs fine with same database. SQL*Loader: Release 9.2.0.6.0 - Production on Mon Apr 23 05:23:47 2007 Copyright (c) 1982, 2002, Oracle... (3 Replies)
Discussion started by: srinivas_paluku
3 Replies
Login or Register to Ask a Question