- 论坛徽章:
- 0
|
我的问题是:shell调用oracle的存储过程,成功了,为什么不更新数据呢?
--在调用存在过程之前字段a1都是空的。我在shell里面调用,然后在日志文件里面返回的是:
PL/SQL procedure successfully completed.
然后再去查一下表ta_test ,发现a1还是空的(a2肯定是小于当前时间了),即没有更新数据。
我在PLSQL Developer 里单独执行存储过程,是更新了数据了的。为什么shell里面调用的话,没有更新呢?
我试过在shell里面添加commit也是不行的。。。。
大家帮我看一下,哪里出错了呢?
-------------------存储过程-----------------------------------------
create or replace procedure pr_test
is
sqlstr varchar2(4000);
begin
sqlstr:='update ta_test
set a1=to_date('''||to_char(sysdate,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'')
where a2<=to_date('''||to_char(sysdate,'YYYY-MM-DD HH24:MI:SS')||''',''YYYY-MM-DD HH24:MI:SS'')
and a1 is null';
dbms_output.put_line(sqlstr);
execute immediate sqlstr;
commit;
exception
when others then
begin
dbms_output.put_line('错误代码 = ' || to_char(sqlcode));
dbms_output.put_line('错误信息:' || SQLERRM);
rollback;
end;
end pr_test;
----------------shell脚本--------------------------------------------
#!/bin/sh
constr="username/password@myDB"
sqlstr=` sqlplus -s ${constr}<<eof
exec pr_test;
exit;
eof`
echo $(date +'%Y-%m-%d %H:%M:%S')$sqlstr>>a.log
|
|