Customized Rule Examples

The following examples suggest more uses of business rules. The goal of every custom rule group is DBA Rules Concluded. Alternate goal variables may be used as long as they are tested in subsequent rules and DBA Rules Concluded is ultimately satisfied. See BRL Example on page 298.


Top of page

Example: Checking for Table Names Used

This example illustrates how to check for one or more table names used in the original SQL or TABLE request. For example, this rule file might have been built for TABLE2, and you know you never want TABLE1 used with TABLE2.

! Assuming this rule file is for TABLE2, do not allow joins to TABLE1
RULE Check table name
IF TableName IS TABLE1
THEN DBA Rules Concluded
AND Run := "F"
AND Reason := "TABLE"
AND Rule Number := 9999

Top of page

Example: Making Sure a Request Runs If an Equality Condition Exists

This rule example assures that if an equality condition exists on an indexed column in a WHERE clause, the request runs.

RULE Check Relation
ACTIVATE %RELOPCOL
DATA Relational
IF Relational IS TABLE1.COLUMN1.EQ.LITERAL
THEN DBA Rules Concluded
AND Run := "T"
AND Reason := "INDEX"

Top of page

Example: Canceling Requests That Use SELECT * and Have No WHERE Clauses

This rule example cancels all requests that use a SELECT * and lack WHERE clauses. It also sets the Rule Number and Reason, which are saved in the SMGOVEND RG repository table and available for reporting. The Rule Number and Reason also display to the user in a cancel message. Message1 through Message5 may contain message information that is display with an advise or cancel message to the user and the edaprint.log file.

RULE Check for Asterisk
IF Select asterisk
AND Number of Relations = 0
THEN DBA Rules Concluded
AND Run := "F"
AND Reason := "SELECT*"
AND Rule Number := 9998
AND Message1 := "Please add a WHERE clause to your SELECT statement."
AND Message2 := "You selected every row in the table."
AND Message3 :=:"5 Message variables are available."

Top of page

Example: Making Sure No Requests are Canceled

The following rule example ensures no requests are canceled.

RULE Do not cancel any queries
THEN DBA Rules Concluded
AND Run := "T"

Top of page

Example: No Temporary Computes or Defines Allowed on Relational Data

This rule checks for any temporary columns. They are defined or computed at runtime, not in the master file definition. This also illustrates how to check for a relational data source.

RULE check temporary fields 
IF Temporary field 
AND Relational source 
THEN DBA Rules Concluded
AND Rule Number := 1
AND Run := "F" AND
Reason := "temp"
AND Message1 := "used a temporary field"

Top of page

Example: Using a Wild Card for Column Names

These rules will catch any use of HEIGHT, WEIGHT, COUNTRY or CAR from the CAR file and allow the request to run. If they are not used, the process will drop down to the second rule and cancel.

RULE Check for column group
ACTIVATE %COLUMNS
DATA Column name IS WHAT
IF Column name IS $IGHT
OR Column name IS C$ 
THEN DBA Rules Concluded
AND Run := "T"
RULE fall through
THEN DBA Rules Concluded
AND Run := "F"

Top of page

Example: Exclude Adhoc Requests

This rule checks for the procedure name being blank, which indicates an adhoc request.

RULE no adhoc
IF Procedure = " "
THEN DBA Rules Concluded
AND Run := "F"

WebFOCUS