urgent ---can we put sql text in unix shellscript [message #62422] |
Wed, 21 July 2004 05:19 |
BhavinShah
Messages: 105 Registered: February 2004
|
Senior Member |
|
|
hi friends,
i have prepare simple shell script to run a script.
filename run_script.txt
sqlplus nonmov/nonmov;
@/home/oracle/nonmov.txt;
exit;
but my @script is not running in sql prompt .so any body can help me to execute my nonmov.txt script from unix shell scripting.. it's seems to be urgent
thax,
Bhavin
|
|
|
|
|
|
Re: urgent ---can we put sql text in unix shellscript [message #62447 is a reply to message #62442] |
Thu, 22 July 2004 04:07 |
shoblock
Messages: 325 Registered: April 2004
|
Senior Member |
|
|
I said "put exit as the last line of nonmov.txt".
Let's make this simple and use the proper file extensions for the corresponding functionality. You will have two files: nonmov.sql and run_script.sh (don
't give everything a .txt extension - it serves no purpose).
nomov.sql:
-- sql script to do stuff
break ...
compute ...
select ...
-- now add this line
exit
run_script.sh:
sqlplus nonmov/nonmov @/home/oracle/nonmov.txt
see how the shell script only contains one line, and no semicolons (try to follow along, cause I'm not explaining again), and see how the sql script ends with the exit command. Do it this way!
|
|
|
Thax friend [message #62466 is a reply to message #62447] |
Fri, 23 July 2004 01:16 |
BhavinShah
Messages: 105 Registered: February 2004
|
Senior Member |
|
|
Thax friend .
Thax for step by step guidence...
your help really helped me in critical time.
But is it apply for pl/sql block also..
e.g
my nonmov.txt is
Begin
Select matcode from master where rownum<2;
End;
exit
bye..
|
|
|
Re: urgent ---can we put sql text in unix shellscript [message #62622 is a reply to message #62422] |
Tue, 03 August 2004 21:36 |
clio
Messages: 2 Registered: August 2004
|
Junior Member |
|
|
You have two ways of doing this:
1. Embbed the SQL script into the shell script:
# get the names of the both archived logs having the oldest archived log sequence
LAST_ARCH_LIST=`sqlplus -s /nolog<<!
connect / as sysdba
set head off
set pages 999
set feedb off
select name from v\$archived_log where sequence# = ${LAST_ARCH_SEQ};
exit
!`
2. Save the SQL script and run it as *.sql file:
# take out the Oracle tablespaces from hot backup mode
${ORACLE_HOME}/bin/sqlplus /nolog @/home/oracle/scripts/backup/bkend.sql
Hope that helps,
clio_usa - OCP 8/8i/9i DBA
Oracle DBA Resources
Oracle DBA Forums
USENET Oracle Newsgroups
|
|
|