GetFieldMaxLength
Description
Returns the maximum length of the field as specified when you create the field using DevOps Plan 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
Perl
$entity->GetFieldMaxLength(field_name);
- Identifier
- Description
- entity
- An Entity object representing a user data record.
- 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.
Example
Perl
# Check the maximum length of a string field.
$fieldtype = $entity->GetFieldType("field1");
if ($fieldtype eq $CQPerlExt::CQ_SHORT_STRING)
{
$maxlength = $entity->GetFieldMaxLength("field1");
}