oracle储存过程中,if条件为某变量不等于1,怎么写

if v_storeid520 <>1 then
v_sql := 'update ' || v_userinfo.aorgalias ||
'.tab520 t set t.nbyj=''' || v_nbyj ||
''' Where t.StoreID = '||v_storeid520||' ';
execute immediate v_sql;
end if;

这是我的语句,意思是想如果这个v_storeid520变量,等于1的话,不执行update。而如果不等于1,则执行update。
但无论我是上面写v_storeid520 <>1还是v_storeid520 !=1,似乎都不起作用,还是执行了update。求各位接惑啊

oracle存储过程中的if条件判断的写法:
比如:
temp varchar2(10) := '10000';
if temp <> '10000' then
insert into ...
else
update .......

end if;
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-08
用plsql developer调试下,看看v_storeid520的值是多少,有没有执行update;
或者在 if then end if; 中加上dbms_output打印下,例如:
if v_storeid520 <>1 then
v_sql := 'update ' || v_userinfo.aorgalias ||
'.tab520 t set t.nbyj=''' || v_nbyj ||
''' Where t.StoreID = '||v_storeid520||' ';
execute immediate v_sql;
dbms_output.putline('执行update语句,语句SQL:||v_sql||chr(10)||变量v_storeid520的值为'||v_storeid520);
end if;本回答被提问者采纳
第2个回答  2015-06-02
应该是这样写 的啊,哪你调试一下,看到底v_storeid520等于几。就知道是怎么回事了