很多人在实际的工作和学习中
都遇到了无法通过sqlplus向shell传递变量
下面我们来介绍一个实例脚本来进行折中处理
[oracle@jumper oracle]$ cat ashsqlplus S / as sysdba << !set heading offcol today noprintcolumn today new_val datselect to_char( sysdate yyyymmdd) today from dual;host echo today is &datexit;exit;![oracle@jumper oracle]$ /ashtoday is [oracle@jumper oracle]$
下面我们再来介绍另一个实例方法
[oracle@jumper oracle]$ more ash#!/bin/kshVALUE=`sqlplus silent / as sysdba < < ENDset pagesize feedback off verify off heading off echo offselect max(sequence#) from v\\\$log_history;exit;END`if [ z $VALUE ]; thenecho No rows returned from databaseexit elseecho Max Sequence Number: $VALUEfi[oracle@jumper oracle]$ /ashMax Sequence Number: