我正在創建DDL腳本以基於現有數據庫創建數據庫模型。基本上拋光我從expdp得到。必須聲明標識符'UTILS.IDENTITY_VALUE'
由於數據庫是Oracle 11gR2,它尚不支持12c標識列(https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1)。 因此,導出的語句使用像https://community.oracle.com/thread/3677631?start=0&tstart=0中提到的序列觸發器 - 所以也許它最初是從MS SQL Server轉換而來的,我很確定。
觸發器同樣期待
create or replace TRIGGER "TABLEX_TRG" BEFORE INSERT ON TABLEX
FOR EACH ROW
DECLARE
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
IF INSERTING AND :new.TABLEXId IS NULL THEN
SELECT TABLEX_TABLEXId_SEQ.NEXTVAL INTO v_newVal FROM DUAL;
-- If this is the first time this table have been inserted into (sequence == 1)
IF v_newVal = 1 THEN
--get the max indentity value from the table
SELECT NVL(max(TABLEXId),0) INTO v_newVal FROM TABLEX;
v_newVal := v_newVal + 1;
--set the sequence to that value
LOOP
EXIT WHEN v_incval>=v_newVal;
SELECT TABLEX_TABLEXId_SEQ.nextval INTO v_incval FROM dual;
END LOOP;
END IF;
-- save this to emulate @@identity
utils.identity_value := v_newVal;
-- assign the value from the sequence to emulate the identity column
:new.TABLEXId := v_newVal;
END IF;
END;
的問題是,SQL Developer和抱怨 「錯誤(21,3):PLS-00201:標識符 'UTILS.IDENTITY_VALUE' 必須聲明爲」
奇怪的是,當我連接到原始數據庫並檢查觸發器時,它是相同的,沒有聲明或任何'UTILS.IDENTITY_VALUE'。綠色很好。
任何解釋/建議歡迎!
我們展示包'UTILS' –