When sending variables from linux command to a plsql block, i am calling the program as sqlplus user/pass@db @file param1 and within the file i can use the param1 as &1. Now what happens on the other way around? If you want to have a file which will execute sth. sqlplus user/pass@db and inside this file you have select number from table and this results to a single number out. When this executes, how can i send this number back to linux so that to use it within my sell script? i.e. export NUMBER=the number i got from sql

有帮助吗?

解决方案

You can do this using here document:

v1=`$ORACLE_HOME/bin/sqlplus -S /nolog > ${logfile} 2>&1 << EOF
connect test/passwd@sid
SET FEED OFF;
SET TERMOUT ON;
SET VERIFY OFF;
SET ECHO OFF;
SET HEAD OFF;
SELECT sysdate from dual FROM DUAL;
EXIT
EOF`

echo $v1
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top