Char Length
Definition
The charLength method allows you to add the CHAR_LENGTH function to the query. The CHAR_LENGTH function is used to count the number of characters in a specified string. The CHARACTER_LENGTH function is similar to CHAR_LENGTH function.
There are 2 ways to call this method:
1. Calling from a KColumn or a KTableColumn
The only one method available to use this functionality calling from a KColumn or a KTableColumn is:
charLength(): It does not receive any parameters. TheKColumnorKTableColumnthat invokes the method will be the one supplied to theCHAR_LENGTHfunction.
Example
Java code:
k
.select(
APP_USER.EMAIL.charLength()
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
CHAR_LENGTH(au.email)
FROM app_user au
Parameters:
- None
2. Calling from the KFunction class
The only one method available to use this functionality calling from the KFunction class is:
charLength(KColumn kColumn): Receives aKColumnor aKTableColumnwhich will be supplied to theCHAR_LENGTHfunction.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example
Java code:
k
.select(
charLength(APP_USER.EMAIL)
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
CHAR_LENGTH(au.email)
FROM app_user au
Parameters:
- None