Chapter 4 Extending your Models with Profiles


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:

Example

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.

Steps To define the script of a custom check:

  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.

 


Copyright (C) 2008. Sybase Inc. All rights reserved.