CREATE OR REPLACE TRIGGER CT_MRDS.TRG_BIU_CHCK_TEMPLATE_TABLE_NAME
BEFORE INSERT OR UPDATE ON "CT_MRDS"."A_COLUMN_DATE_FORMAT" 
FOR EACH ROW
DECLARE
    vCount NUMBER;
BEGIN
  SELECT COUNT(*) 
    INTO vCount 
    FROM CT_MRDS.A_SOURCE_FILE_CONFIG 
   WHERE TEMPLATE_TABLE_NAME = :NEW.TEMPLATE_TABLE_NAME;
 
    IF vCount = 0 THEN
        RAISE_APPLICATION_ERROR(-20001, 'TEMPLATE_TABLE_NAME = '''||:NEW.TEMPLATE_TABLE_NAME||''' not exists in A_SOURCE_FILE_CONFIG.TEMPLATE_TABLE_NAME ');
    END IF;
END;
/