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.

Tip: The <strong>UniBasic</strong> STATUS function returns the status of the preceding command.<br />

You can place it within the trigger subroutine to learn about the status of individual<br />

commands executed within the trigger. If you place it immediately after the statement<br />

that calls the trigger, it returns the status of the <strong>UniBasic</strong> command as determined by<br />

the trigger. The trigger subroutine also returns a value indicating its status in the<br />

parameter execstat. These values returned in execstat are listed in the Parameters<br />

section.<br />

Return<br />

Value Description<br />

0 No error.<br />

Examples<br />

The following example begins with an UPDATE trigger subroutine called TRIG1.<br />

Because the return status is always 0, no record in the file can be updated.<br />

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

1 System error, such as a damaged file.<br />

2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine returns a<br />

value of 0 in the parameter execstat, indicating that the update or delete is not<br />

allowed.<br />

3 Trigger execution error or unexpected return from trigger routine (for<br />

example, the trigger subroutine is not cataloged).<br />

STATUS Function Return Values<br />

SUBROUTINE<br />

TRIG1(exec.stat,dict.flag,trig.name,rec.id.expr,rec.val)<br />

exec.stat=0<br />

RETURN<br />

Next, we create the trigger, associate it with the ORDERS file, and list the triggers<br />

associated with the ORDERS file:<br />

:CREATE.TRIGGER ORDERS TRIG1 UPDATE<br />

:LIST.TRIGGER ORDERS<br />

BEFORE UPDATE TRIGGER: TRIG1<br />

BEFORE DELETE TRIGGER: not defined

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

Saved successfully!

Ooh no, something went wrong!