我第一次使用Oracle,更習慣於sql server及其身份。但現在我正在嘗試使用序列和觸發器。但不斷收到我無法修復的錯誤。序列和觸發器,PL/SQL
identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
任何人都可以幫助解決它,這裏是我的代碼。
EXECUTE IMMEDIATE' CREATE SEQUENCE stagechardata_stagecharid
START WITH 1
INCREMENT BY 1;';
EXECUTE IMMEDIATE' CREATE OR REPLACE TRIGGER stagechardata_stagecharid_TRG
BEFORE INSERT
ON stage_char_data
FOR EACH ROW
BEGIN
IF NEW.stage_char_id IS NULL THEN
SELECT stagechardata_stagecharid.NEXTVAL INTO NEW.stage_char_id
FROM DUAL;
END IF;
END;';
你爲什麼使用'execute immediate'?你是否有理由需要從PL/SQL而不是普通的SQL動態創建這些動態? (事實上,在第一個動態語句結束時,你不應該有分號,並且你的'new'引用缺少冒號,但是那些不會導致那個錯誤)。你可以顯示其餘的PL/SQL塊或腳本嗎? –
在'create sequence'語句的末尾刪除';'。當使用'execute immediate'時,僅在創建PL/SQL過程時才需要使用常規SQL語句。 –