Update database triggers

A database trigger responds to an existing record that’s updated if you specify TRIGGER_ON_DB_UPDATE in the table_operations parameter of the Trigger_RegisterDatabase() function. If successful, the database operation passes the updated record’s buffer to your processing procedure as an inout parameter.

Example 3: Updating records

This database trigger updates a contact history record when the user saves an existing customer record in the RM_Customer_MSTR table.

{Name: Startup}
local integer l_result;

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

This trigger processing procedure saves the third-party contact history record with any new information the user may have added to the corresponding customer record.

{Name: IG_Save_Contact_History}
inout table RM_Customer_MSTR;

'Customer Number' of table IG_Contact_History_MSTR = 'Customer Number' of table RM_Customer_MSTR;
change table IG_Contact_History_MSTR by number 1;
if err() = OKAY then
	'Customer Name' of table IG_Contact_History_MSTR = 'Customer Name' of table RM_Customer_MSTR;
	save table IG_Contact_History_MSTR;
end if;


Documentation Feedback