Defining the Script of a Custom Check

This section also applies for defining the script of a custom method, a calculated collection, an event handler, or a transformation.

You type the script of a custom check in the Check Script tab of the custom check properties. By default, the Check Script tab displays the following script items:

  • %Check% is the function name, it is passed on parameter obj. It is displayed as a variable, which is a concatenation of the name of the resource file, the name of the current metaclass, the name of the stereotype or criterion, and the name of the check itself defined in the General tab. If any of these names contains an empty space, it is replaced by an underscore

  • A comment explaining the expected script behavior

  • The return value line that indicates if the check succeeded (true) or not (false)

In Sybase AS IQ, you need to create additional checks on indexes in order to verify their columns. The custom check you are going to create verifies if indexes of type HG, HNG, CMP, or LF are linked with columns which data type VARCHAR length is higher than 255.

  1. Right-click a metaclass, stereotype or a criterion under Profile, and select New > Custom Check.
  2. Click the Check Script tab in the custom check properties to display the script editor.

    By default, the function is declared at the beginning of the script. You should not modify this line.

  3. Type a comment after the function declaration in order to document the custom check, and then declare the different variables used in the script.
    Dim c 'temporary  index column
    Dim col 'temporary column
    Dim position
    Dim DT_col
  4. Enter the function body.
    %Check%= True
    
    if obj.type = "LF" or obj.type = "HG" or obj.type = "CMP" or obj.type ="HNG" then
     for each c in obj.indexcolumns
      set col = c.column
      
       position = InStr(col.datatype,"(") 
       if position <> 0 then
        DT_col = left(col.datatype, position -1) 
       else 
        DT_col = col.datatype
       end if
    if ucase(DT_col) = "VARCHAR" and col.length > 255 then
         output "Table " & col.parent.name & " Column " & col.name & " : Data type is not compatible with Index " & obj.name & " type " & obj.type
         %Check% = False
      end if


  5. Click Apply to save your changes.