GetFieldMaxLength
Description
Returns the maximum length of the field as specified when you create the field using HCL Compass Designer. This value corresponds to the number of bytes allowed in the column. The actual number of characters allowed depends on the database encoding (that is, the character set and character set encoding) and the characters in the field string.
This method is relevant only for fields whose type is SHORT_STRING.
Syntax
VBScript
entity.GetFieldMaxLength
field_name
Perl
$entity->GetFieldMaxLength
(field_name);
- Identifier
- Description
- entity
- An Entity object representing a user data record. Inside a hook, if you omit this part of the syntax, the Entity object corresponding to the current data record is assumed (VBScript only).
- field_name
- A String that identifies a valid field name of the entity. The field must contain a fixed-length string.
- Return value
- A Long indicating the maximum length of the field.
The value is the number of bytes as represented in the database that
the field can store. Note: The number of bytes is not the same as the number of characters. The exact number of bytes needed to represent a string is determined by the database vendor code page, and the particular characters that are stored in the field. Different characters may consume different numbers of bytes, and the number of bytes required to store a particular character is dependent on the database vendor code page.
Examples
VBScript
' Check the maximum length of a string field.
fieldType = GetFieldType("field1")
If fieldType = AD_SHORT_STRING Then
maxLength = GetFieldMaxLength("field1")
End If
Perl
# Check the maximum length of a string field.
$fieldtype = $entity->GetFieldType("field1");
if ($fieldtype eq $CQPerlExt::CQ_SHORT_STRING)
{
$maxlength = $entity->GetFieldMaxLength("field1");
}