Certain DBMS require that a cursor and variables are declared for each template item before the template item name is used in the script. This can be a statement that calls a corresponding procedure
.Decltemplate item name
-- Before insert trigger "[%QUALIFIER%]%TRIGGER%" for table "[%QUALIFIER%]%TABLE%" create trigger [%QUALIFIER%]%TRIGGER% before insert on [%QUALIFIER%]%TABLE% for each row declare integrity_error exception; errno integer; errmsg char(200); dummy integer; found boolean; .DeclInsertChildParentExist begin .InsertChildParentExist -- Errors handling exception when integrity_error then raise_application_error(errno, errmsg); end; /
.FOREACH_PARENT() -- Declaration of InsertChildParentExist constraint for the parent "[%PQUALIFIER%]%PARENT%" .DEFINE "CURSOR" "cpk%REFNO%_%.25L:TABLE%" cursor %CURSOR%(.JOIN("var_%.L26:FK% %.L:COLTYPE%", "", ",", ") is") select 1 from [%PQUALIFIER%]%PARENT% where .JOIN("%PK% = var_%.L26:FK%", "and ") and .JOIN("var_%.L26:FK% is not null", "and ", "", ";") .ENDFOR