fork download
  1. CREATE OR REPLACE TRIGGER s_trigger
  2. BEFORE UPDATE OR INSERT OR DELETE ON employee
  3. FOR EACH ROW
  4. BEGIN
  5. IF inserting OR updating('salary') THEN
  6. IF :NEW.salary < 0 THEN
  7. DBMS_OUTPUT.PUT_LINE('THE SALARY CANNOT BE NEGATIVE');
  8. ELSIF :NEW.salary > 6000 THEN
  9. DBMS_OUTPUT.PUT_LINE('THE SALARY CANNOT EXCEED 6000');
  10. END IF;
  11. END IF;
  12. END;
  13. /
Success #stdin #stdout #stderr 0.01s 10076KB
stdin
CREATE OR REPLACE TRIGGER s_trigger
BEFORE UPDATE OR INSERT OR DELETE ON employee
FOR EACH ROW
BEGIN
  IF inserting OR updating('salary') THEN
    IF :NEW.salary < 0 THEN
      DBMS_OUTPUT.PUT_LINE('THE SALARY CANNOT BE NEGATIVE');
    ELSIF :NEW.salary > 6000 THEN
      DBMS_OUTPUT.PUT_LINE('THE SALARY CANNOT EXCEED 6000');
    END IF;
  END IF;
END;
/
stdout
Object: nil error: did not understand #OR
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #OR (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:1)
Object: 'salary' error: did not understand #THEN
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
String(Object)>>doesNotUnderstand: #THEN (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:5)
stderr
./prog:6: expected expression