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

Shell script to fire sql scripts...

Reply to Message Icon

Original Message
Name: dvskid
Date: June 25, 2004 at 18:17:04 Pacific
Subject: Shell script to fire sql scripts...
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!


Report Offensive Message For Removal

Response Number 1
Name: Dlonra
Date: June 26, 2004 at 08:57:12 Pacific
Subject: Shell script to fire sql scripts...
Reply: (edit)

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?


Report Offensive Follow Up For Removal

Response Number 2
Name: dvskid
Date: June 28, 2004 at 10:49:32 Pacific
Subject: Shell script to fire sql scripts...
Reply: (edit)

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?


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Shell script to fire sql scripts...

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software