trigger para proibir atendimento por convênio e TP atendimento (pode-se incrementar especialidade :new.cd_especialid))
Citação de andre.pegorin em 25/11/2022, 13:05PROMPT CREATE OR REPLACE TRIGGER trg_hsman_bloq_atend
CREATE OR REPLACE TRIGGER trg_hsman_bloq_atendBEFORE INSERT OR UPDATE ON atendime
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
IF :new.cd_convenio = 1 AND :new.tp_atendimento = 'A' THEN
raise_application_error( -20001, 'CONVENIO NAO PERMITIDO');
END IF;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, SQLERRM);END;
/
PROMPT CREATE OR REPLACE TRIGGER trg_hsman_bloq_atend
CREATE OR REPLACE TRIGGER trg_hsman_bloq_atend
BEFORE INSERT OR UPDATE ON atendime
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
IF :new.cd_convenio = 1 AND :new.tp_atendimento = 'A' THEN
raise_application_error( -20001, 'CONVENIO NAO PERMITIDO');
END IF;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, SQLERRM);
END;
/