Custom SQL Rules

From CaseTalk Wiki
Revision as of 15:46, 23 January 2018 by Marcow (talk | contribs) (Created page with "= Custom SQL Rules = This feature enables the custom sql scripts to be defined by users to execute arbitrary sql when validating the model for well-formednes is started. Once...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Custom SQL Rules

This feature enables the custom sql scripts to be defined by users to execute arbitrary sql when validating the model for well-formednes is started. Once this feature is activated and the user has created a sql script for it, the result will be shown in the model validation panel / window.

Create Rules

CaseTalk already contains a lot of rules to check the validity of the information model. However since opening up the custom attributes, the use may have the need for more validation rules.

For instance a custom attribute may be defined to help users in the administrative tasks of maintaining a large model. Fact Types need approval, etc. A status attribute might provide for such administration.

Secondly a need may arise to validate the model for approvals. For these kind of examples, a custom rule could be defined in custom SQL.

In the main menu Repository \ Custom Rules.. can be selected to create rules. The default example contains:

INSERT INTO $SCHEMA$.CustomRules 
 SELECT 
 'Starts with A' as name, 
 '"' || otftname || '" starts with A' as message, 
 'OTFT' as repositoryType, 
 otftname as repositoryID, 
 0 as status 
 FROM $SCHEMA$.OTFT 
 WHERE otftname like 'A%'
UNION 
 SELECT 
 'Starts with Y' as name,
 '"' || otftname || '" starts with Y' as message,
 'OTFT' as repositoryType, 
 otftname as repositoryID, 
 1 as status 
 FROM $SCHEMA$.OTFT 
 WHERE otftname like 'Y%';

CaseTalk, when validating, will create a temporary table where this script can insert records. After execution CaseTalk will present the result in the validation panel / window.