If the custom check you have defined supports an automatic correction, you enter its script on the Autofix Script tab using VBScript. In this example, we will write a script to fix a Sybase IQ index linked with columns with an invalid data type.
Function %Fix%(obj, outmsg)At run-time the variable %Fix% is replaced by the name of the fix. The parameter obj contains the object being checked and outmsg, the message to be output.
Dim c 'temporary index column Dim col 'temporary column Dim position Dim DT_col
%Fix% = False
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
outmsg = "Automatic correction has removed column " & col.Name & " from index."
c.Delete
%Fix% = True
End If
Next
End If