length()

length() takes a character string argument and returns an integer, which represents the number of bytes in its argument, ignoring any blank spaces after the character string.

length() displays a dialog box with a field, into which you can type a string.  The string length is then measured and a message window confirms the string and tells you, by returning an integer value, how many characters it contains.

In this example, the length() results are displayed in the form message string.

 

These are some of the uses that the LENGTH( ) function can be used for:

length() is also useful as a check on user input. In the following example, an IF statement is used to determine whether the user has responded to a displayed message:

IF LENGTH (l_contact.cont_name) = 0 THEN

      NEXT FIELD cont_name

      ERROR "You must enter a value for this field" ELSE ...

If its argument is a null string, LENGTH( ) returns zero.

Using length() in SQL expressions

length() is one of the 4GL built-in functions that can also be used in SQL statements.  It can also be called from a C function. 

In a SELECT or UPDATE statement, the argument of length() is the identifier of a character column. In this context, length() returns the number of bytes in the CLIPPED data value (for CHAR and VARCHAR columns) or the full number of bytes (for TEXT and BYTE data types).

length() can also take the name of a database column as its argument but only within an SQL statement.

 

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.