Btrim
Definition
The btrim method allows you to add the BTRIM function to the query. The BTRIM function removes the longest string containing only characters specified by the argument (whitespace by default) from the start and end of a string.
There are 2 ways to call this method:
1. Calling from a KColumn or a KTableColumn
The methods available to use this functionality calling from a KColumn or a KTableColumn are:
btrim(): It does not receive any parameters. TheKColumnorKTableColumnthat invokes the method will be the one supplied to theBTRIMfunction.btrim(String characters): Receives a String which will be supplied to theBTRIMfunction. TheKColumnorKTableColumnthat invokes the method will be the one supplied to theBTRIMfunction.
Example: ()
Java code:
k
.select(
APP_USER.EMAIL.btrim()
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
BTRIM(au.email)
FROM app_user au
Parameters:
- None
Example: (String)
Java code:
k
.select(
APP_USER.EMAIL.btrim("xyz")
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
BTRIM(au.email, ?1)
FROM app_user au
Parameters:
- ?1: "xyz"
2. Calling from the KFunction class
The methods available to use this functionality calling from the KFunction class are:
btrim(KColumn kColumn): Receives aKColumnor aKTableColumnwhich will be supplied to theBTRIMfunction.btrim(KValTextField kValTextField): Receives aKValTextFieldwhich will be supplied to theBTRIMfunction.btrim(KColumn kColumn, String characters): Receives aKColumnor aKTableColumnand a String which will be supplied to theBTRIMfunction.btrim(KValTextField kValTextField, String characters): Receives aKValTextFieldand a String which will be supplied to theBTRIMfunction.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example: (KColumn)
Java code:
k
.select(
btrim(APP_USER.EMAIL)
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
BTRIM(au.email)
FROM app_user au
Parameters:
- None
Example: (KValTextField)
Java code:
k
.select(
btrim(val("A short text "))
)
.single();
SQL generated:
SELECT BTRIM(?1)
Parameters:
- ?1: "A short text "
Example: (KColumn, String)
Java code:
k
.select(
btrim(APP_USER.EMAIL, "xyz")
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
BTRIM(au.email, ?1)
FROM app_user au
Parameters:
- ?1: "xyz"
Example: (KValTextField, String)
Java code:
k
.select(
btrim(val("A short text"), "xt")
)
.single();
SQL generated:
SELECT BTRIM(?1, ?2)
Parameters:
- ?1: "A short text"
- ?2: "xt"