Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PLS-00103: Encountered the symbol "USER" when expecting one of the following:

I am trying to make a trigger, it compiles but with 2 errors (same error different location). This is the trigger, I have the table and sequence created

create or replace TRIGGER BIU_APPLICATION
BEFORE INSERT OR UPDATE ON APPLICATION
REFERENCING FOR EACH ROW
BEGIN
IF inserting THEN IF :new.APPLICATION_ID IS NULL THEN
SELECT APPLICATION_ID_SEQ.nextval
INTO :new.APPLICATION_ID
FROM dual;
END IF;
:new.created_by := NVL(apex_application.g_user USER);
:new.created_dt := SYSDATE;
END IF;
IF inserting OR updating THEN
:new.created_by := NVL(apex_application.g_user USER);
:new.created_dt := SYSDATE;
END IF;
END;

The error I get is

PLS-00103: Encountered the symbol "USER" when expecting one of the following: . ( ) , * @ % & = – + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or default like like2 like4 likec as between from using || multiset member submultiset The symbol "." was substituted for "USER" to continue.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You forgot about "," in NVL:

 NVL(apex_application.g_user, USER);

note: you don’t need select sequence.nextval by SQL. You can do this like:

:new.APPLICATION_ID :=  APPLICATION_ID_SEQ.nextval
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading