PREV
INDEX
NEXT
SLUUG HOME
SQL in KSH
Running SQL Scripts in Kornshell
Tidbits
# Put SQL output into shell variable
nextday=`sqlplus -s <<! # backquotes better
define dt = $somedate
define fmt = yyyy-mm-dd
select
to_char(to_date('&dt','&fmt')+1,'&fmt')
from dual;
!
`
# myshellscript mysqlscript.sql $var1 $var2
sqlplus -s <<! # do whatever script I say...
@$*
!
# echo 'select * from mytable;'|myshellscript
sqlplus -s <<! # do whatever I say ...
$(cat -)
!
# Send SQL output through shell pipe
sqlplus -s <<! |
-- whatever sql here
!
while read line; do whatever with $line; done
2002 April 10
Tom Chapin -- 314-721-3581 -- tjc@mvp.net