You enter the script of the custom check in the Check Script tab using VBScript. In this example, we will write a script to verify that SAP® Sybase® IQ indexes of type HG, HNG, CMP, or LF are not linked with columns with a data type of VARCHAR with a length higher than 255.
Function %Check%(obj)At run-time the variable %Check% is replaced by concatenating the names of the resource file, metaclass, any stereotypes or criteria, and the name of the check itself from the General tab, with any spaces replaced by an underscore. The parameter obj contains the object being checked.
Dim c 'temporary index column Dim col 'temporary column Dim position Dim DT_col
%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
For more information about using VBScript in PowerDesigner, see Scripting PowerDesigner.