Calling a Related Procedure in a Trigger Template

Some target databases do not accept code within a trigger statement. For these databases, a trigger template can call a related procedure as a parameter, which is defined in a procedure template. In these cases, procedure templates are listed in the list of trigger templates.

Example

Informix does not accept code in trigger templates. The template InsertTrigger calls the procedure in the form of the variable %PROC%, as follows:

-- Insert trigger "[%QUALIFIER%]%TRIGGER%" for table "[%QUALIFIER%]%TABLE%"
create trigger [%QUALIFIER%]%TRIGGER% insert on [%QUALIFIER%]%TABLE%
referencing new as new_ins
 for each row (execute procedure %PROC%(.FKCOLN("new_ins.%COLUMN%", "", ",", "));")
/

The template InsertProc defines the procedure, as follows:

--  Insert procedure "%PROC%" for table "[%QUALIFIER%]%TABLE%"
create procedure %PROC%(.FKCOLN("new_%.14L:COLUMN% %COLTYPE%", "", ",", ")")
  .DeclInsertChildParentExist
  .DeclInsertTooManyChildren
  define  errno   integer;
  define  errmsg  char(255);
  define  numrows   integer;

  .InsertChildParentExist
  .InsertTooManyChildren

end procedure;
/