-- created by Oraschemadoc Fri Jun 13 14:06:09 2008
-- visit http://www.yarpen.cz/oraschemadoc/ for more info

  CREATE OR REPLACE TRIGGER "RHNSAT"."RHN_CMETH_VAL_TRIG" 
before insert or update on rhn_contact_methods
referencing new as new old as old
for each row
declare
    msg  varchar2(200);
    missing_data exception;
begin
    msg :='missing or invalid data for contact_methods table';
    if :new.method_type_id = 1
    then
        if (
            :new.pager_email   is null     or
            :new.pager_split_long_messages  is null )
        then
            raise missing_data;
        end if;
    end if;
    if :new.method_type_id = 2
    then
        if :new.email_address is null
        then
            raise missing_data;
        end if;
    end if;
    if :new.method_type_id = 5
    then
        if (:new.snmp_host is null   or
           :new.snmp_port is null)
        then
            raise missing_data;
        end if;
    end if;
    exception
    when missing_data then
    raise_application_error (-20012,msg);
    when others then
    raise;
end;
ALTER TRIGGER "RHNSAT"."RHN_CMETH_VAL_TRIG" ENABLE
 
/
