.FOREACH_CHILD Macro

Repeats a statement for each parent-to-child reference in the current table fulfilling a condition.

Syntax

.FOREACH_CHILD ("condition")
"statement"
.ENDFOR

Argument

Description

condition

Reference condition (see below)

statement

Statement to repeat

Condition

Selects

UPDATE RESTRICT

Restrict on update

UPDATE CASCADE

Cascade on update

UPDATE SETNULL

Set null on update

UPDATE SETDEFAULT

Set default on update

DELETE RESTRICT

Restrict on delete

DELETE CASCADE

Cascade on delete

DELETE SETNULL

Set null on delete

DELETE SETDEFAULT

Set default on delete

Example

In a trigger for the table TITLE, the following macro:

.FOREACH_CHILD("DELETE RESTRICT")
--  Cannot delete parent "%PARENT%" if children still exist in "%CHILD%"
.ENDFOR

generates the following trigger script:

--  Cannot delete parent "TITLE" if children still exist in "ROYSCHED"
--  Cannot delete parent "TITLE" if children still exist in "SALE"
--  Cannot delete parent "TITLE" if children still exist in "TITLEAUTHOR"