存储过程老是出错?该怎么处理

存储过程老是出错?C# codedeclarecidnumber(20) beginselect a.id into cidfrom b_table a where a.mac

存储过程老是出错?

C# code
declare     cid   number(20); begin   select a.id into cid   from b_table a where a.mac='911:34:34:34:GG:GG';   if cid >0     then        update 语句;   else      insert 语句;     end if; commit; exceptionwhen others thenrollback;end;

有一个问题,当where条件为真的时候,正确;但是当where条件为假,else就不会走,这是什么情况啊?

[解决办法]
当where条件找不到值的时候,就发生了NO_DATA_FOUND异常.直接rollback了.
解法:select 语句需要改成count计数方式
SQL code
declare     cid   number(20); begin   select count(a.id) into cid   from b_table a where a.mac='911:34:34:34:GG:GG';   if cid >0     then        select a.id into cid   from b_table a where a.mac='911:34:34:34:GG:GG';        update 语句;   else      insert 语句;     end if; commit; exceptionwhen others thenrollback;end;
[解决办法]
把declare去掉。