Character Length
Definition
The characterLength method allows you to add the CHARACTER_LENGTH function to the query. The CHARACTER_LENGTH function is used to count the number of characters in a specified string. The CHAR_LENGTH function is similar to CHARACTER_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:
characterLength(): It does not receive any parameters. TheKColumnorKTableColumnthat invokes the method will be the one supplied to theCHARACTER_LENGTHfunction.
Example
Java code:
k
.select(
APP_USER.EMAIL.characterLength()
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
CHARACTER_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:
characterLength(KColumn kColumn): Receives aKColumnor aKTableColumnwhich will be supplied to theCHARACTER_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(
characterLength(APP_USER.EMAIL)
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
CHARACTER_LENGTH(au.email)
FROM app_user au
Parameters:
- None