Computing.Net > Forums > Unix > Shell script to fire sql scripts...

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell script to fire sql scripts...

Reply to Message Icon

Name: dvskid
Date: June 25, 2004 at 18:17:04 Pacific
OS: Solaris
CPU/Ram: Unknown
Comment:

I got saddled with someone's work and I have very little idea on what to do.

Basically, there are X number of .sql files that have to be run with a specific value for the wirecenter. Then, once the sql script is run, the output has to be captured to a csv file. The platform is oracle 8 on a solaris box (don't have version).

So I am supposed to write a script that:

1. Fires off all the .sql scripts.
2. Passes them the value of the wire center which is used to query the DB.
3. Capture the results in a CSV file.
4. Highlight how much time it took the queries to execute.

Anyone want to help me with this?

Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: Dlonra
Date: June 26, 2004 at 08:57:12 Pacific
Reply:

a sample of the .sql script showing how thhe wire center variable is handled would help.

"A CSV file" - All results are contained in a single file?


0

Response Number 2
Name: dvskid
Date: June 28, 2004 at 10:49:32 Pacific
Reply:

Well, those scripts have to be modified by someone.

But here is what I did:

#! /bin/sh

sqlplus -s scott/tiger@DatabaseName << ENDSQL

WHENEVER SQLERROR EXIT 5
WHENEVER OSERROR EXIT 10

SPOOL ${SCI_PORT_OLD.csv}
@create table SCI_PORT_OLD.sql
SPOOL OFF

SPOOL ${CREATE_CLINK.csv}
@Create clink.sql
SPOOL OFF

SPOOL ${FMS_Before_Picture.csv}
@FMS Before Picture.sql "Value_for_Wirecenter"
SPOOL OFF

SPOOL ${Update_FMS_PORT.csv}
@update FMS.SCI_PORT.sql
SPOOL OFF

SPOOL ${FMS_After_Picture.csv}
@FMS After Picture.sql "Value_For_Wirecenter"
SPOOL OFF

SPOOL ${REPORT_FMS_Fallout.csv}
@REPORT_FMS_Fallout.sql "Value_For_Wirecenter"
SPOOL OFF

SPOOL ${REPORT_FMS_NON_CONVERSION.csv}
@REPORT_FMS_Non_Conversion.sql "Value_For_Wirecenter"
SPOOL OFF

SPOOL ${DROP_VANC_CLINK.csv}
@DROP VANCOUVER_CLINK.sql
SPOOL OFF

EXIT;
ENDSQL


What do you think?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell script to fire sql scripts...

Exit from sqlplus in a shell script www.computing.net/answers/unix/exit-from-sqlplus-in-a-shell-script/8244.html

SQL in shell script www.computing.net/answers/unix/sql-in-shell-script/5703.html

ftp sql results in shell script www.computing.net/answers/unix/ftp-sql-results-in-shell-script/6338.html