|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Starting sql scripts from shell script
Hi
I am not a DBA and I have to help someone at work so: 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 of each sql script in a CSV file. 4. Highlight how much time it took the queries to execute. Anyone want to help me with this? Thanks! |
|
#2
|
|||
|
|||
|
1. Fires off all the .sql scripts. - create another sql files which contains the folowing :
@/xxxx/xxxx/xxxx/sqlscript.sql .... 2. Passes them the value of the wire center which is used to query the DB. in order to pass a parameter your sql script will need to accept it (aaaa is the parameter value): @/xxxx/xxxx/xxxx/sqlscript.sql 'aaaa' and the sqlscript will be something like: select '&1' from dual; 3. Capture the results of each sql script in a CSV file. - in order to create a file from an sql script you must create a spool: spool /xxxx/xxxx/xxx/sqlscript.csv @/xxxx/xxxx/xxxx/sqlscript.sql spool off 4. Highlight how much time it took the queries to execute. - set timing on will highlight how mach time a command/sql script took: set timing on spool ... @ .... Good luck, Galit. |
|
#3
|
|||
|
|||
|
Code:
#!/bin/ksh
# $1 = username
# $2 = password
UIPW=$1"/"$2
PrntCode=$(echo "$UIPW
set pages 0
@/home/myself/mysqlscript.sql |
$ORACLE_HOME/bin/sqlplus -s )
|
|
#4
|
|||
|
|||
|
Hi Galith and Jim,
Thanks for the reply. This is what I did: Quote:
What do you think? Thanks! |
|
#5
|
|||
|
|||
|
Hi,
I think that will do the work. Galit. |
|
#6
|
|||
|
|||
|
Quote:
Thank you. If I have any other question on this, I'll ask. ![]() Btw: I need to do the exact same thing in Sybase: do you have experience with Sybase? |
|
#7
|
|||
|
|||
|
Hi,
don't know sybase (only oracle,db2 and sql server). Galit. |
|
#8
|
||||
|
||||
|
Quote:
No problem. I have another question about using sqlldr in my script. I have this line: Quote:
Everything else works but when I run the script, the log file says "SP2-0734: unknown command beginning "SQLLDR USE..." - rest of line ignored." Do you see anything wrong with the way I am calling sqlldr? This is k-shell btw. Thank you! ![]() |
|
#9
|
|||
|
|||
|
I got the problem.
The problem was that i was calling sqlldr from within the sqlplus section of the shell script. Doing some googling told me that sqlldr is a separate application and has to be run directly from the prompt. So I placed the sqlldr section outside of the STOP block. Thanks! ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Starting sql scripts from shell script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|