Domanda

I'm having this error while trying to compile the following trigger :

CREATE OR REPLACE TRIGGER INCREMENTER_ID_CONSISTANCE 

BEFORE INSERT ON BD.CONSISTANCE 
for each row
BEGIN
:new.code := ID_CONSISTANCE.nextval;
END;  


**ERROR** : Table,View Or Sequence reference 'ID_CONSISTANCE.nextval' not allowed in
this context  

What is the problem here ? and how can I fix this ?

È stato utile?

Soluzione

This syntax is only allowed in Oracle 11 or later.

The (unsupported and outdated) 9i version did not support direct assignment of a sequence value.

You need to use a select into instead:

select ID_CONSISTANCE.nextval
  into :new.code 
FROM dual;

And you should really plan an upgrade to a current version of Oracle (11.x or 12.x)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top