Home » RDBMS Server » Server Administration » urgent ---can we put sql text in unix shellscript
urgent ---can we put sql text in unix shellscript [message #62422] Wed, 21 July 2004 05:19 Go to next message
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 #62424 is a reply to message #62422] Wed, 21 July 2004 05:33 Go to previous messageGo to next message
shoblock
Messages: 325
Registered: April 2004
Senior Member
put the exit as the last line og nonmov.txt

then run_script.txt:
sqlplus nonmov/nonmov @/home/oracle/nonmov.txt
Re: urgent ---can we put sql text in unix shellscript [message #62435 is a reply to message #62424] Wed, 21 July 2004 21:06 Go to previous messageGo to next message
BhavinShah
Messages: 105
Registered: February 2004
Senior Member
hi
friends
thax,
bhavin
Re: urgent ---can we put sql text in unix shellscript [message #62442 is a reply to message #62424] Thu, 22 July 2004 02:52 Go to previous messageGo to next message
BhavinShah
Messages: 105
Registered: February 2004
Senior Member
hi ..
by this my nonmov.txt is executing but i m unable to exit from sqlplus help me how can i exit from sqlplus .

sqlplus nonmov/nonmov @/home/oracle/nonmov.txt exit;

i have tried upper shell script but it cannot exit from sqlplus.
Re: urgent ---can we put sql text in unix shellscript [message #62447 is a reply to message #62442] Thu, 22 July 2004 04:07 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 Go to previous message
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
Previous Topic: avoiding chaining & migration
Next Topic: too:urgent recovery problem in live database
Goto Forum:
  


Current Time: Thu Jan 23 15:49:57 CST 2025