11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SUBROUTINE (Update Trigger)<br />

Syntax<br />

SUBROUTINE trigname(execstat, dictflag, filename, record.ID.expr, recordval)<br />

FUNCTION trigname(dictflag, filename, record.ID.expr, recordval)<br />

Description<br />

Triggers enforce user-defined constraints that must be met before data can be<br />

updated. The trigger is associated with the data file, so it verifies any access to the<br />

data. A <strong>UniBasic</strong> trigger subroutine or function serves as an UPDATE trigger. The<br />

SUBROUTINE or FUNCTION definition must be the first line in the <strong>UniBasic</strong><br />

trigger.<br />

You must include a RETURN statement in the function:<br />

RETURN [execstat]<br />

Points to Remember<br />

1-880 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

When you attempt to update a record, UniData calls the trigger, passing the<br />

file name, DICT if dictionary file, record ID, and the input value before<br />

updating the record. The subroutine returns the execution status and the new<br />

record value.<br />

If the update request fails, the subroutine must return an execstat value of 0.<br />

If the request passes, the return value must be 1.<br />

Tip: You can call a C routine from the <strong>UniBasic</strong> subroutine or function that is called<br />

from a trigger.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!