Saturday, October 08, 2011

SQLPLUS Script in UNIX Shell Produce Output on Same Line

A Simple Select statement is executed from CURRENT a shell. The value returned by the select query is transferred back to the shell.

For example:

RESULT=`sqlplus -s apps/WELCOME123@DEVPR12 < <(printf "set pages 0 \n select SYSDATE from dual; \n")`
echo "RESULT=${RESULT}"

Another Way to Execute sqlplus from unix shell

sqlplus -s /nolog << EOF
connect apps/Welcome123
select sysdate from dual;
exit;
EOF

2 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.