程序警告:执行完成并发出警告

时间:2012-03-21 00:48:35

标签: sql oracle stored-procedures oracle10g

我遇到了这个程序的问题。我一直收到的错误是:

dbms_warning.set_warning_setting_string 'ENABLE:ALL', succeeded.
PROCEDURE promo_ship_sp compiled
Warning: execution completed with warning

我已尝试设置错误报告,因此我会获得更多信息,但没有其他信息显示出来。 SELECT * FROM BB_PROMOLIST;显示获取0行的结果,因此它不能是插入ID问题吗?我提交了它,但仍然无法成功编译。

set serveroutput on;
CALL DBMS_WARNING.set_warning_setting_string ('ENABLE:ALL', 'SESSION');
create or replace procedure promo_ship_sp  
  (
    tmp_id in date
  )
IS
v_dt date := tmp_id;
v_Promo_flag bb_promolist.promo_flag%type;
cursor cur_select is
    select idshopper, dtcreated
    from bb_basket 
  where dtcreated < v_dt
  order by idshopper;

BEGIN
 for rec_something in cur_select loop   
     insert into bb_promolist (idshopper, month, year, promo_flag, used) values
     (rec_something.idshopper, 'JAN', '2010', 1, 'N');
     dbms_output.put_line(rec_something.idshopper  || ' ' ||rec_something.dtcreated);
 end loop;
END;
/ 
show errors;
execute promo_ship_sp('15-FEB-07');

GOOD Catch堆栈溢出,但这不是我的实际代码。我禁用了约束,然后在没有警告的情况下进行编译,然后再次启用约束,并且可以根据需要多次执行它。有点奇怪的bug。希望这有助于某人。

set serveroutput on;
CALL DBMS_WARNING.set_warning_setting_string ('ENABLE:ALL', 'SESSION');
create or replace procedure promo_ship_sp  
  (
    tmp_id in date
  )
IS
v_dt date := tmp_id;
v_Promo_flag bb_promolist.promo_flag%type;
cursor cur_select is
    select idshopper, dtcreated
    from bb_basket 
  where dtcreated < v_dt
  order by idshopper;

BEGIN
 delete from bb_promolist;
 for rec_something in cur_select loop   
     insert into bb_promolist (idshopper, month, year, promo_flag, used) values
     (rec_something.idshopper, to_char(rec_something.dtcreated, 'MON'),  to_char(rec_something.dtcreated, 'YYYY'), 1, 'N');
 end loop;
END;
/ 
show errors;
execute promo_ship_sp('15-FEB-07');

1 个答案:

答案 0 :(得分:0)

不是你问题的答案,但是评论的时间太长了。

请将光标替换为光标,将光标替换为insert ... values

  insert into bb_promolist (idshopper, month, year, promo_flag, used)
  select idshopper, to_char(dtcreated, 'MON'),  to_char(dtcreated, 'YYYY'), 1, 'N'
    from bb_basket 
  where dtcreated < v_dt;

只有在有充分理由的情况下才包含order by子句,例如在同一块上放置具有相同值的数据:

  insert into bb_promolist (idshopper, month, year, promo_flag, used)
  select idshopper, to_char(dtcreated, 'MON'),  to_char(dtcreated, 'YYYY'), 1, 'N'
    from bb_basket 
  where dtcreated < v_dt
  order by idshopper;