create or replace procedure pr_klfx(dw in varchar, y in int, m in int) is
  i   number;
  j   number;
  mny number;
BEGIN
DELETE IA_KLFX IA WHERE IA.PK_CORP=dw and ia.caccountyear=y and ia.caccountmonth=m;在执行存储过程时,始终不执行delete语句,请求各路大神帮忙。在线等存储delete

解决方案 »

  1.   

    create or replace procedure pr_klfx(dw in varchar, y in int, m in int) is
      i   number;
      j   number;
      mny number;
    BEGIN
      select count(1)
        into i
        from IA_KLFX IA
       WHERE IA.PK_CORP = dw
         and ia.caccountyear = y
         and ia.caccountmonth = m;
      dbms_output.put_line(i);
    end;运行下,看什么结果
      

  2.   

    在PL DEV单步调试一下
    另外看看有没有发生锁等等
      

  3.   

    看不出结果,因为直接执行的存储过程。你说的delete用的正确的吗?我已经commit了
      

  4.   

    给你个例子自己看
    declare 
     cout number;
    begin 
      select count(1) into cout from t_system_usermodel s where s.modelid=(select m.id from t_districtmodule m where m.modulename='学生基本情况统计(省资助)' and m.supmodule=(select id from t_districtmodule where modulename='中小学资助统计' and supmodule=(select id from t_districtmodule where modulename='查询统计' and supmodule is null))) and s.columnid=1 and s.type=1;
      if cout>0 then
         execute immediate 'delete from t_system_usermodel s where s.modelid=(select m.id from t_districtmodule m where m.modulename=''学生基本情况统计(省资助)'' and m.supmodule=(select id from t_districtmodule where modulename=''中小学资助统计'' and supmodule=(select id from t_districtmodule where modulename=''查询统计'' and supmodule is null))) and s.columnid=1 and s.type=1';
         commit;
      end if;
    end;
    /
    删除语句要放在execute immediate '';里面执行,试试吧
      

  5.   


    你是怎么执行存储过程的,,pl/SQL,toad??delete语句看起来没啥问题,你的没执行 是啥意思,报错还是没删掉数据?要是没删掉数据,你先看表里面有没有符合条件的数据啊。
      

  6.   

    手工删除执行delete是可以的,很简单的语句,就是不知道要不要commit?还是把commit 放在其他地方?
      

  7.   

    delete from ...;
    i := sql%rowcount;
    dbms_output.put_line(i);
    commit;
    看看i是什么值
      

  8.   

    存储过程中执行DML需要使用自治事务。PL/SQL“ ORA-14551: 无法在查询中执行 DML 操作”解决