LINUX下执行SQL语句

[oracle@hngdcrm xxx]$ vi xtest.sh

#!/bin/sh
sqlplus /nolog <<EOF
conn crm_owner_user/bss_crm_xxp1 as sysdba;
 select city_code from bb_service_relation_t  t  where t.service_id=8073102026973775  and t.if_valid=1;
exit;
EOF;

--赋予权限,要不crontab不能执行,报Permission denied

[oracle@hngdcrm log]$ chmod 777 xtest.sh

[oracle@hngdcrm log]$ crontab -e

 

*/2 * * * * /home/oracle/xxx/xtest.sh >>/home/oracle/xxx/log/mylog.log 2>&1

[oracle@hngdcrm log]$ cat mylog.log

/home/oracle/xxx/xtest.sh: line 2: sqlplus: command not found   //没有引入变量

[oracle@hngdcrm xxx]$ vi xtest.sh

#环境变量的引入
if [ -f /usr/local/tdneusoft/ORACLE_crm.profile ];then
#    . /usr/local/tdneusoft/ORACLE_crm.profile
#source /home/oracle/.bash_profile
export ORACLE_BASE=/home/oracle/app;#export ORACLE_BASE
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0;
export ORACLE_SID=hngdcrm
export PATH=$ORACLE_HOME/bin:$PATH
fi

#引入系统环境变量
if [ -f /usr/local/tdneusoft/Runtime_64bit.profile ];then
    . /usr/local/tdneusoft/Runtime_64bit.profile
fi


sqlplus /nolog <<EOF
conn crm_owner_user/bss_crm_xxp1 as sysdba;
 update bb_service_relation_t t set t.city_code=t.city_code+1 where t.service_id=8073102026973775  and t.if_valid=1;
 commit;
exit;
EOF;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值