I am creating DDL scripts to create a DB model based on an existing DB. Basically polishing what I got from expdp.
As the DB is Oracle 11gR2, it does not support the 12c Identity Columns yet (https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1). Therefore the exported statements use sequences-triggers like mentioned in https://community.oracle.com/thread/3677631?start=0&tstart=0 -- so maybe it was originally converted from MS SQL Server, I'm note sure.
The triggers look similarly to
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;
The problem is that SQL Developer complains with "Error(21,3): PLS-00201: identifier 'UTILS.IDENTITY_VALUE' must be declared"
Strangely when I connect to the original DB and check the trigger, it is the same, no declaration or whatever of 'UTILS.IDENTITY_VALUE'. And is nicely green.
Any explanation/advice welcome!