2012-03-21 97 views
0

我遇到了此過程的問題。我不斷收到的錯誤是:程序警告:執行完成併發出警告

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'); 

在堆棧溢出好對象,但是這不是我的實際代碼。我禁用了約束,然後在沒有警告的情況下進行編譯,然後再次啓用約束,並可以根據需要多次執行它。有點奇怪。希望這可以幫助某人。

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'); 
+0

SO上的語法突出顯示了您的問題。你在'Jan'附近丟失了''''。沒有必要「提交」一個包。 – Ben 2012-03-21 01:10:00

+0

如果在啓用約束的情況下重新編譯,會發生錯誤? – 2012-03-21 12:42:01

+0

您使用什麼客戶端來編譯過程? – 2012-03-21 15:48:41

回答

0

不是你的問題的答案,但太長的評論。

請更換光標,光標for循環和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; 

by子句包含ORDER只有當你有一個很好的理由,比如將數據與相同的值在同一個街區:

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;