Database data events

Reference topic for the database data code events set.

Table 1. Database data events
Event Use when ... Function
Set Default Values

Use this event if you need to change a default value, or if you want to set a default value for a field that does not have a default value defined in the database schema.

This event is called to initialize form fields with default values from the database schema before a row is inserted.

SetDefaultValues
Check Table Constraints
The BAM generates code to check constraints defined in the database table:
  • A value is required (NOT NULL constraints)
  • A value must be unique (PRIMARY KEY constraint, UNIQUE constraint)
  • A value must pass referential integrity (FOREIGN KEY constraint)

Use this event if you are using a database for which constraints are missing, and where you cannot update the database schema. To preserve data integrity, you can implement constraints and referential integrity checks as if the schema was designed with them.

For example, use this event to ensure that a field does not have a NULL value.

This event is called to check table constraints before inserting or updating rows.

CheckTableConstraints
Before Insert Row By Key

Use this event if you are using a database for which constraints are missing, and where you cannot update the database schema. To preserve data integrity, you can implement constraints and referential integrity checks as if the schema was designed with them.

For example, you can check to ensure that the field value entered as a foreign key does exist in the related table.

BeforeInsertRowByKey
After Insert Row By Key

Use this event for administration tasks that might otherwise be performed in SQL triggers.

For example, when a record for a new employee is created, the salaries table might be updated.

It is recommended to avoid duplicating a SQL trigger in the database. If a database trigger exists, there is no need to create the event.

AfterInsertRowByKey
Before Update Row By Key

Use this event if you are using a database for which constraints are missing, and where you cannot update the database schema. To preserve data integrity, you can implement constraints and referential integrity checks as if the schema was designed with them.

For example, you can check to ensure that the field value entered as a foreign key does exist in the related table.

BeforeUpdatetRowByKey
After Update Row By Key

Use this event for administration tasks that might otherwise be performed in SQL triggers.

For example, when a record is updated in the orders table, the stock inventory table is also updated.

It is recommended to avoid duplicating a SQL trigger in the database. If a database trigger exists, there is no need to create the event.

AfterUpdateRowByKey
Before Delete Row By Key

Use this event to execute code prior to deleting a row.

For example, you can use this event to write the row of data to a backup table before the row is deleted.

BeforeDeleteRowByKey
After Delete Row By Key

Use this event for administration tasks that might otherwise be performed in SQL triggers.

For example, you can code to record the executed action in a log table, or record in another table the information being deleted in the row.

It is recommended to avoid duplicating a SQL trigger in the database. If a database trigger exists, there is no need to create the event.

AfterDeleteRowByKey