Reputation:
I'm having a hard time understanding this error:
Error at line 3: PLS-00103: Encountered the symbol "&" when expecting one of the following:
) , * & - + / at mod remainder rem and or as || multiset
The code is:
CREATE OR REPLACE TRIGGER class_trigger
BEFORE INSERT ON Class FOR EACH ROW
BEGIN
IF (type = 'vl' && mass < 15000) THEN
mass := 15000;
END IF;
END;
What is wrong with my code? I'm using Oracle's APEX. Thanks.
Upvotes: 2
Views: 110
Reputation: 50077
You have two problems:
PL/SQL uses AND
as the logical operator for the boolean AND operation, not &&
.
When accessing fields which are passed to the trigger, you must qualify them with the :OLD
or :NEW
pseudo-row names.
Thus, you'd need to rewrite your trigger as:
CREATE OR REPLACE TRIGGER class_trigger
BEFORE INSERT ON Class
FOR EACH ROW
BEGIN
IF :NEW.TYPE = 'vl' AND
:NEW.mass < 15000
THEN
:NEW.MASS := 15000;
END IF;
END class_trigger;
Upvotes: 6