shell 中执行Oracle查询和执行存储过程

[oracle@master2 test]$ more b.sh
#!/bin/sh

#数据库地址
ip=192.168.1.250
port=1521
sid=orcl
username=c##scott
password=tiger
oracle_name="${username}/${password}@${ip}:${port}/${sid}"
#查询一个值
QUERYRETS=`sqlplus -s /nolog <<EOF 
 set echo off feedback off heading off underline off; 
 conn ${username}/${password}; 
 select sales from TEST where revenue=2500;
exit 
EOF`
echo ${QUERYRETS} 

FILE_DATE=`date +"%Y%m%d"`
#执行存储过程 QUERYRETS
=`sqlplus 'c##scott/tiger@192.168.1.250:1521/orcl' <<EOF set echo off feedback off heading off underline off; var o_result number; call SP_UPDATE_T1($FILE_DATE,:o_result); select :o_result from dual; commit; exit EOF` if [ $o_result=0 ];then echo "0" else echo "1" fi echo "脚本执行完成 !" exit 0

简单,注意格式就行。

posted @ 2019-03-18 19:35  醉城、  阅读(7207)  评论(0编辑  收藏  举报