The New Command Rule Form
Published 19 March 2018
The Data Masker Create/Edit Command Rule Form
This form is used to create and edit Data Masker Command rules which are designed to run user written T-SQL statements. The title text and button labels on the form will change as is appropriate to the create or edit mode. In the example screen shot above, the form is editing an existing Command rule.
Any valid T-SQL statement which performs data manipulation actions (INSERT, UPDATE, DELETE) or DDL commands (CREATE INDEX, DROP TABLE, etc.) are valid within a Data Masker Command rule. As with all Data Masker rules - Command rules execute in the order specified by their Rule Block and Dependency state.
It is possible to implement an unlimited number of SQL statements in a Command rule. See the discussion in the Command rule help file for more information.
The Ignore listed errors panel permits the execution of the rule (and hence the masking set) to continue if the specified error occurs. The ignore errors panel can contain the error number or all or part of the error message. Note that if multiple SQL statements are placed in the same Command rule the SQL Server error exception handler applies at the block level. See the discussion below for more detailed information.
If multiple commands are present in a Command Rule, those commands can be presented to the SQL Server in two ways. The first method assumes each statement is terminated with a semi-colon character. Each statement will be presented individually to the SQL Server database. If an error occurs, it is possible to proceed to subsequent statements if the error is listed as permitted. In the second mode, the T-SQL statements are delimited with a GO command. All statements in each GO block are presented together to the SQL Server database. If an error occurs in any statement in a GO block then the subsequent statements within the same block may not execute - even if the error is permitted. GO blocks are primarily used when creating procedures.
Command rules can contain multiple statements or blocks of statements. The Exit script after first ignored error option will cause the rule to terminate without continuing to process statements within the rule if an error occurs. In other words when an error occurs, even if it is trapped and ignored, any remaining lines (or blocks) in the script will not be executed. If the Exit script after first ignored error option is not active and a trapped error occurs, subsequent statements (or blocks) within the rule will be processed. If further errors occur the error trapping mechanism will also apply to those statements.
Command rules can have other rules dependent on them. When the If error is ignored, skip all dependent rule option is active no dependent rules will be processed if a error is trapped and ignored.
Creating or editing a Command rule is a straightforward process. Simply enter the T-SQL statements you wish to execute in the SQL Command window and press the Create/Update Command Rule button. It can be useful to enter a summary of the rules purpose in the Description area.
Existing Command rules can be edited by double clicking on them with the mouse. Command rules are created by launching the New Command rule form using the New Rule button located on the bottom of the Rules in Set tab.
How to Create a New Command Rule