Rule

The Rule category is located in the Root > Script > Objects category, and can contain the following items that define how rules are modeled for your DBMS.

Item

Description

[Common items]

The following common object items may be defined for rules:

  • AfterCreate, AfterDrop, AfterModify

  • BeforeCreate, BeforeDrop, BeforeModify

  • Create, Drop

  • Enable

  • Maxlen

  • ModifiableAttributes

  • ReversedQueries, ReversedStatements

  • SqlAttrQuery, SqlListQuery

For a description of each of these common items, see Common object items.

ColnDefault Name

Specifies the name of a default for a column. This item is used with DBMSs that do not support check parameters on columns. When a column has a specific default value defined in its check parameters, a name is created for this default value.

The corresponding variable is %DEFAULTNAME%.

Example (ASE 15):

D_%.19:COLUMN%_%.8:TABLE%

The EMPFUNC column of the EMPLOYEE table has a default value of Technical Engineer. The D_EMPFUNC_EMPLOYEE column default name is created:

create default D_EMPFUNC_EMPLOYEE
as 'Technical Engineer'
go
execute sp_bindefault D_EMPFUNC_EMPLOYEE, "EMPLOYEE.EMPFUNC"
go

ColnRuleName

Specifies the name of a rule for a column. This item is used with DBMSs that do not support check parameters on columns. When a column has a specific rule defined in its check parameters, a name is created for this rule.

The corresponding variable is %RULE%.

Example (ASE 15):

R_%.19:COLUMN%_%.8:TABLE%

The TEASPE column of the Team table has a list of values - Industry, Military, Nuclear, Bank, Marketing - defined in its check parameters:

The R_TEASPE_TEAM rule name is created and associated with the TEASPE column:

create rule R_TEASPE_TEAM
as @TEASPE in ('Industry','Military','Nuclear','Bank','Marketing')
go
execute sp_bindrule R_TEASPE_TEAM, "TEAM.TEASPE"
go

MaxDefaultLen

Specifies the maximum length that the DBMS supports for the name of the column Default name

RuleComment

Specifies a statement for adding a rule comment.

UddtDefault Name

Specifies the name of a default for a user-defined data type. This item is used with DBMSs that do not support check parameters on user-defined data types. When a user-defined data type has a specific default value defined in its check parameters, a name is created for this default value.

The corresponding variable is %DEFAULTNAME%.

Example (ASE 15):

D_%.28:DOMAIN%

The FunctionList domain has a default value defined in its check parameters: Technical Engineer. The following SQL script will generate a default name for that default value:

create default D_FunctionList
as 'Technical Engineer'
go

UddtRuleName

Specifies the name of a rule for a user-defined data type. This item is used with DBMSs that do not support check parameters on user-defined data types. When a user-defined data type has a specific rule defined in its check parameters, a name is created for this rule.

The corresponding variable is %RULE%.

Example (ASE 15):

R_%.28:DOMAIN%

The Domain_speciality domain has to belong to a set of values. This domain check has been defined in a validation rule. The SQL script will generate the rule name following the template defined in the item UddtRuleName:

create rule R_Domain_speciality
as (@Domain_speciality in ('Industry','Military','Nuclear','Bank','Marketing'))
go
execute sp_bindrule R_Domain_speciality, T_Domain_speciality
go