[Solved] Sql If statement error


I think you need:

CREATE OR REPLACE TRIGGER CREAT_SERVIÇO 
BEFORE INSERT ON SERVIÇO FOR EACH ROW
BEGIN

  if(:new.MORADA_RUA is NULL and :NEW.LOCAIS_ID_LOCAL is NULL) THEN
      RAISE_APPLICATION_ERROR(-20000, 'YOU HAVE TO HAVE AN ADRESS OR AN LOCAL');
END IF;
END;

If your trigger is going do disallow inserting when both address and local are null. But to do that is better to use constrain that checks if ADDRESS || LOCAL is null.

3

solved Sql If statement error