Defining a schema rule
Schema rules define the acceptance criteria for SQL DDL schema by the validation process. You can also specify when the validation process applies the schema rules to the schema. The following figure shows a sample schema rule.
(BMC.DB2.SPE2201) BMC AMI Command Center cannot resolve user-defined variables that you use in rule definitions. The program identifies them as unresolvable host variables. After you verify that the user-defined variable is the only error, you can save the rule by using the Accept the rule with errors option. When you run the process, the Schema Standards process resolves the user-defined variables based on the definition in the XML file.
This topic contains the following sections:
To define a schema rule
This procedure assumes that you have already opened the rule editor. For more information, see Managing-schema-rule-sets .
On the Definition tab, enter the following information:
Field or section
Description
Rule name
Identifier for the rule. This field is read-only when editing a rule.
Explanation
Short description that explains the rule. The explanation is included in the validation logs to help developers correct violations.
Object type
Object type to which the rule applies. This field is read-only when editing a rule. Select one of the following object types:
- Database
- Index
- Index partition
- Storage group
- Table
- Table column
- Table space
- Table space partition
- Volume
The selected object type determines which attributes are available for defining the rule expression and the when condition.
Rule
Expression that defines how an object type attribute should be specified in a schema. For more information, see Rule expression.
When
Expression that determines under what circumstances the rule applies to the object type. If you do not enter an expression, the rule applies to all objects of the specified type. For more information, see When condition.
On the Options tab, enter the following information:
Field
Description
Log mode
Select one of the following values to determine the severity of violations of the schema rule:
Value
Description
Log a warning for violations
The validation process logs violations as warnings, and the operation can end successfully.
Log a failure for violations
(Default) The validation process logs violations as errors, and the operation fails.
The log mode is overridden if either of the following log modes is set to warn:- The log mode of the rule set to which this rule belongs
- The log mode of an ancestor rule set
Comment
Enter a description of the purpose of the rule.
- Click OK.
If BMC AMI Command Center detects an error, it displays the Verify Rule Failed dialog box. Otherwise, the rule editor closes. In the Verify Rule Failed dialog box, choose one of the following options:
Option
Description
Return to the rule editor
BMC AMI Command Center displays the Error tab that lists the errors found.
(BMC.DB2.SPE2201) If you entered a user-defined variable, BMC AMI Command Center displays the following error message:
Encountered a host variable userVariable that could not be resolved
Use this option to verify whether the user-defined variable is the only error.
Disable the rule
BMC AMI Command Center disables the rule and saves it.
Accept the rule with errors
BMC AMI Command Center saves the rule with the error.
(BMC.DB2.SPE2201) If you entered a user-defined variable, verify whether the variable is the only error and use this option to save the rule.
Rule expression
This section describes the fields used to define the rule expression.
Number | Description |
---|---|
1 | Enter the target of the rule that identifies the attribute that you want to verify. You can enter any valid SQL that is available for use in an SQL WHERE clause. |
2 | Opens the Select Attribute dialog box in which you can choose an attribute for the field to the left (1). |
3 | Select an operator that identifies the relationship between the target (1) and value (4). |
4 | Enter the value against which the target (1) should be verified. You can enter any valid SQL that is available for use in an SQL WHERE clause. (BMC.DB2.SPE2201) You can also use user-defined variables defined in an XML document. Enter a user-defined variable preceded by a single quotation mark and colon, then followed by another single quotation mark. For example, you would enter the user-defined variable DBNM as ‘:DBNM’. For more information, see Using Schema Standards rules with user-defined variables. |
5 | If you selected IN or NOT IN as the operator, this option opens the Enter List Values dialog box. Otherwise, it opens the Select Attribute dialog box in which you can choose an attribute for the field to the left (4). |
6 | Opens the free-form rule editor. This icon is disabled after you select a target (1). For more information, see Free-form editor. |
When condition
This section describes the fields used to define the when condition. If the When condition evaluates to true, the rule expression is applied to the object.
Number | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | You can enter one or more left parenthesis to control the logical evaluation of the conditions. | ||||||||||||
2 | Enter the target attribute of the condition that determines to which objects the rule applies. You can enter any valid SQL that is available for use in an SQL WHERE clause. | ||||||||||||
3 | Opens the Select Attribute dialog box in which you can choose an attribute for the field to the left (2). | ||||||||||||
4 | Select an operator that identifies the relationship between the target (2) and value (5). | ||||||||||||
5 | Enter a value to compare to the target that determines to which objects the rule applies. You can enter any valid SQL that is available for use in an SQL WHERE clause. (BMC.DB2.SPE2201) You can also use user-defined variables defined in an XML document. Enter the user-defined variable preceded by a single quotation mark and colon, then followed by another single quotation mark. For example, you would enter the user-defined variable DBNM as ‘:DBNM’. For more information, see Using Schema Standards rules with user-defined variables. | ||||||||||||
6 | If you selected IN or NOT IN as the operator, this option opens the Enter List Values dialog box. Otherwise, it opens the Select Attribute dialog box in which you can choose an attribute for the field to the left (5). | ||||||||||||
7 | You can enter one or more right parentheses to control the logical evaluation of the conditions. | ||||||||||||
8 | Select a logical operator to connect the conditions. Logical operators are enabled when you add more than one condition. | ||||||||||||
9 | The following table describes the available actions:
| ||||||||||||
10 | Click |
Free-form editor
You can use the free-form editor to define rule expressions and when conditions as shown in the following figure. The free-form editor accepts any valid SQL that is available for use in an SQL WHERE clause.
Number | Description |
---|---|
1 | Opens the Insert Attribute dialog box. The selected attribute is inserted at the cursor location. |
2 | Opens the Insert Operator dialog box. The selected operator is inserted at the cursor location. |
Rule attribute clarifications
The Select Attribute dialog box displays a description of the selected attribute, as shown in the following image:
The following table displays additional information about the attributes:
Attribute | Object types | Host variable | Description |
---|---|---|---|
BMCSTATE | Storage group (SG) Volume (VL) | SGBMCSTATE | References the state of the object referenced in the schema source input The valid values are CREATE, MODIFIED, and EXISTS. The BMCSTATE attribute is available for all parent objects. The child object (sub-object) can access the parent objects BMCSTATE attribute. |
Database (DB) | DBBMCSTATE | ||
Table space (TS) Table space partition (TP) | TSBMCSTATE | ||
Table (TB) Table column (CO) Table space partition (TP) | TBBMCSTATE | ||
Index (IX) Index space partition (IP) | IXBMCSTATE | ||
CREATORTYPE | Storage group (SG) | SGCREATORTYPE | Available when BMCSTATE equals EXISTS or MODIFIED |
Database (DB) | DBCREATORTYPE | ||
Table space (TS) | TSCREATORTYPE | ||
IMPLICIT | Database (DB) | DBIMPLICIT | Available when BMCSTATE equals EXISTS or MODIFIED |
Table space (TS) | TSIMPLICIT | ||
OWNERTYPE | Table (TB) | TBOWNERTYPE | Available when BMCSTATE equals EXISTS or MODIFIED |
Index (IX) | IXOWNERTYPE |