Monday, July 21, 2008

Embedding sqlplus commands directly in a script

The standard way to do this is to wrap the sqlplus login using the << EOF script method; all lines are fed into sqlpus up till the final EOF marker.
sqlplus -s /nolog << EOF
connect sys/change_on_install as sysdba
desc dual
select * from dual;
exit;
EOF
Passing a parameter from the shell to sqlplus

fred="hello"
sqlplus -s /nolog << EOF
connect / as sysdba
select '$fred' from dual;
quit
EOF

Running a shell script / operating system command from sqlplus
in SQLPLUS, you just type, for example, host(ls -al) to get the command to run. You do NOT type: host('ls -al') this will NOT work.

No comments:

search engine

Custom Search