Chapter 4 Managing 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 in the Profile category and select New→Custom Check.

    or

    Right-click a stereotype or a criterion in a metaclass and select New→Custom Check.

    A new custom check is created under the selected category.
  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.
  4. Declare the different variables used in the script.

    Dim c 'temporary  index column
    Dim col 'temporary column
    Dim position
    Dim DT_col
  5. Declare 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
  6. Declare the end of the function.
  7. Click Apply.

 


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