Chapter 4 Managing Profiles


Using the global script

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

The Global Script tab is used to store functions and static attributes that may be reused among different functions. This tab displays a library of available sub-functions.

Example

In the Sybase AS IQ example, you could have a function called DataTypeBase that retrieves the data type of an item in order to further analyze it.

This function is defined as follows:

Function DataTypeBase(datatype)
   Dim position
   position = InStr(datatype, "(") 
   If position <> 0 Then
      DataTypeBase = Ucase(Left(datatype, position -1))
   Else 
      DataTypeBase = Ucase(datatype)
   End If
End Function

In this case, this function only needs to be referenced in the check and autofix scripts:

Function %Check%(obj)
Dim c   'temporary  index column
   Dim col 'temporary column
   Dim position
   %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
         If (DataTypeBase(col.datatype) = "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
      Next
   End If
End Function

Global variables

You can also declare global variables in the Global Script. These variables are reinitialized each time you run the custom check.

 


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