ALLBASE/SQL Reference Manual (36216-90216)

Chapter 4 157
Constraints, Procedures, and Rules
Using Rules
ROLLBACK statement upon completion of work and before termination; or it should be
entirely contained within a transaction, that is, it should not contain any COMMIT or
ROLLBACK statements.
If the procedure executes any COMMIT or ROLLBACK statements, it should be treated as
a transaction. This means that the last statement accessing the DBEnvironment within
the procedure should be a COMMIT WORK or a ROLLBACK WORK statement.
If the procedure uses any cursors, they should be closed before termination. If the
procedure opens any cursors with the KEEP option, and subsequently executes any
COMMIT statements, the cursors should be closed and committed before termination.
A procedure should not change the application's environment without restoring it upon
termination. The application's environment includes settings for isolation level,
constraint checking, timeout values, and rule firing.
Documentation of the procedure should clearly state the following:
Whether or not a transaction should already exist at the time of procedure execution.
Whether any COMMIT or ROLLBACK statements will be executed by the procedure.
Whether the procedure modifies any environment settings.
What types of errors are handled by the procedure and how they are handled.
Meanings of all possible return status values.
Meaning of any errors returned by RAISE ERROR statements.
Using Rules
Rules allow you to tie procedures to data manipulation statements. Rules are more flexible
than simple integrity constraints, enabling you to incorporate complex business rules into
the structure of a DBEnvironment with minimal application programming. The following
sections describe the use of rules:
Understanding Rules
Creating Rules
Techniques for Using Procedures with Rules
Error Handling in Procedures Invoked by Rules
Using RAISE ERROR in Procedures Invoked by Rules
Enabling and Disabling Rules
Special Considerations for Procedures Invoked by Rules
Differences between Rules and Integrity Constraints