2017-08-05 35 views
-2

當我使用PowerDesigner中生成的SQL和Oracle中運行它,它會引發錯誤Oracle觸發器的創建與編譯錯誤,ORA-02289:序列不存在

警告:觸發創作與編譯錯誤

create trigger "tib_material_classify" before insert 
on "material_classify" for each row 
declare 
    integrity_error exception; 
    errno   integer; 
    errmsg   char(200); 
    dummy   integer; 
    found   boolean; 

begin 
    -- column ""id"" uses sequence material_classify_seq; 
    select material_classify_seq.nextval into :new."id" from dual; 

-- errors handling 
exception 
    when integrity_error then 
     raise_application_error(errno, errmsg); 
end; 

當我發出的甲骨文show errors,它說以下內容:

10/5 PL/SQL:忽略SQL語句 10/12 PL/SQL:ORA-02289:序列不存在

我在做什麼錯?

+1

「序列不存在」扳機指的序列不存在。也就是說,您的模式沒有名爲'material_classify_seq'的序列。要麼你沒有創建這樣的序列,要麼它的名稱與觸發器代碼中引用的名稱不同。 – APC

回答

0

之前創建您需要創建sequnce Create sequence material_classify_seq start with 1;創建後觸發

1

錯誤消息表明序列material_classify_seq缺失。你可以用下面的SQL語句創建丟失的序列:

Create Sequence material_classify_seq; 
+0

非常感謝,它的工作原理! – fengnan

+0

我很高興命令幫助。由於您的問題已解決,請將此標記爲已接受的答案。 – Kirby