The Contract Block
In addition to a Compile keyword, stored procedures may include a contract block. The contract block improves the reliability and maintainability of your code by defining conditions that must be met before processing will begin, and before data is returned. Although not a requirement, using the contract block is often a good idea, especially when sharing code between multiple developers.
The contract block contains the following statements:
Begin Condition Pre: Post: End Condition
Rules for contract blocks are as follows:
- The contract block must precede executable statements in the stored procedure.
- The contract block may be placed before a $INSERT statement, a Declare, Equate, Common statement, or comments.
- Conditional logic is not allowed.
- Each of the keywords must appear on a separate line. Put the actual conditions on the lines below the Pre: and Post: keywords.
- Only single-line comments are allowed. Put single-line comments on a line by themselves. If comments exist, they must precede the associated condition.
- Valid contract block clauses must be BASIC+ expressions, system variables, or common variables.
- You can use multiple expressions within the Pre: condition and within the Post: condition blocks. The expressions are evaluated in the order they appear.
Note
If no conditions within the block are defined, your application is responsible for dealing with error conditions.