Read database triggers

A read database trigger responds to a record that’s successfully read. A record read database trigger runs in response to the following table operations:

[spacer]

Value of table_operation

Description

TRIGGER_ON_DB_READ

Responds to a record that’s successfully read but not locked.

TRIGGER_ON_DB_READ_LOCK

Responds to a record that’s successfully read and passively or actively locked.


You can specify either of these table operations in the table_operations parameter of the Trigger_RegisterDatabase() function. If successful, the record’s buffer is passed to your processing procedure as an inout parameter.

Example 6: Record read database trigger

This database trigger runs when the user displays a new record in the Customer_Maintenance window, using either a lookup or browse buttons. The IG_Update_Contact_History procedure runs in response to this trigger.

{Name: Startup}
local integer l_result;

l_result = Trigger_RegisterDatabase(anonymous(table  RM_Customer_MSTR), form RM_Customer_Maintenance,  TRIGGER_ON_DB_READ_LOCK, script IG_Update_Contact_History);
if l_result <> SY_NOERR then
	warning "Database trigger registration failed.";
end if;

This processing procedure updates the Contact History window with the same key value as the one displayed in the RM_Customer_Maintenance form. It then attempts to retrieve an existing record using the script for the Customer Number field.

{Name: IG_Update_Contact_History}
inout table RM_Customer_MSTR;

if isopen(form IG_Contact_History) then
	clear form IG_Contact_History;
	'Customer Number' of window IG_Contact_History of form IG_Contact_History = 'Customer Number' of table RM_Customer_MSTR;
	'Customer Name' of window IG_Contact_History of form IG_Contact_History = 'Customer Name' of table RM_Customer_MSTR;
	run script 'Customer Number' of window IG_Contact_History of form IG_Contact_History;
end if;


Documentation Feedback