shell获取sqlplus变量_(转)shell 调用sqlplus各种情况示例

一、最简单的shell里调用sqlplus.$ vi test1.sh#!/bin/bashsqlplus -S /nolog > result.log < set heading off feedback off pagesize 0 verify off echo offconn u_test/iamwangncselect * from tab;exitEOF$ chmod +x...
摘要由CSDN通过智能技术生成

一、最简单的shell里调用sqlplus.

$ vi test1.sh

#!/bin/bash

sqlplus -S /nolog > result.log < set heading off feedback off pagesize 0 verify off echo off

conn u_test/iamwangnc

select * from tab;

exit

EOF

$ chmod +x test1.sh

$ ./test1.sh

二、把sqlplus执行结果传递给shell方法一

注意sqlplus段使用老板键`了, 赋变量的等号两侧不能有空格.

$ vi test2.sh

#!/bin/bash

VALUE=`sqlplus -S /nolog < set heading off feedback off pagesize 0 verify off echo off numwidth 4

conn u_test/iamwangnc

select count(*) from tab;

exit

EOF`

if [ "$VALUE" -gt 0 ]; then

echo "The number of rows is $VALUE."

exit 0

else

echo "There is no row in the table."

fi

$ chmod +x test2.sh

$ ./test2.sh

三、把sqlplus执行结果传递给shell方法二

注意sqlplus段使用

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值