Tuesday, January 23, 2007

HowTo: How to run sqlplus queries on the fly?

Generally in shell script we use to invoke sqlplus passing some sql script like as follows:-
---------Sample.sql--------------------
select sysdate from dual;
---------------------------------------
---------Script1.sh--------------------
echo "Starting the script"
sqlplus scott/tiger@orcl @sample.sql
echo "Finishing the script"
---------------------------------------
Now you can run that query on the fly like as follows:-

$pwd
/mnt/hasim/home
$print "select sysdate from dual;"|sqlplus scott/tiger@orcl

Or
---------Script2.sh--------------------
echo "Starting the script"
sqlplus scott/tiger@orcl"<<"EOF # Remove both quotes,put due to error while posting
select sysdate from dual; -- Write n no of sql scripts
EOF
echo "Finishing the script"
---------------------------------------

Can check more in this page
How do I interact with Oracle via the UNIX Korn shell?


---: I am not responsible for any damages happened from the suggestion of my blog :---
Reach me at : m.a.hasim@inbox.com

Labels:

0 Comments:

Post a Comment

<< Home