Index

  1. Home
  2. Docs
  3. Index
  4. Query Builder
  5. Database triggers

Database triggers

The Query Builder allows you to write your own database triggers. Here is a simple example of a database trigger which prevents updates on table dept.

CREATE TRIGGER prevent_updates_on_dept BEFORE UPDATE ON dept
   FOR EACH ROW
   BEGIN
	SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Update failed...';
   END;
/

When the user tries to update a row in table dept with this trigger enabled, the trigger prevents the update and returns error “Update failed…”. You can change this error message to anything you like.

When a users performs this action within a Data Project, WP Data Access adds the custom message to its standard error message:

On your development server with debug enabled it looks a little different:

Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published.

six + 3 =