我最近遇到一个问题, C#调用oracle的存储过程, 存储过程中有out型的cursor参数, 其中的update和delete操作虽然可以执行成功但是会出现下面的异常

Concurrency violation: the DeleteCommand affected 0 of the expected 1 records.

查了好久没有找到解决方案, 不过发现做完操作后RecordAffects为0,其实应该是1,所以会出现这个异常。

存储过程例子如下:

create or replace
procedure test1
(
    v_mode in VARCHAR2,
    v_id in NUMBER,
    v_name in VARCHAR2,
    v_age in float,
    v_rc OUT SYS_REFCURSOR
)
as
begin
   OPEN v_rc FOR SELECT * FROM t1;
   if v_mode = 'G' THEN
      OPEN v_rc FOR SELECT t_id,t_name,age FROM t1;
   end if;
   if v_mode = 'U' THEN
      update t1 set t_name = v_name
             where t_id = v_id;
   end if;
   if v_mode = 'D' THEN
      DELETE t1 where t_id = v_id;
   end if;
end;

希望遇到类似问题的多多帮忙!

相关文章:

  • 2022-01-30
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案