Rtrim
Definition
The rtrim
method allows you to add the RTRIM
function to the query. The RTRIM
function removes the longest string containing only characters specified by the argument (whitespace by default) from the 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:
rtrim()
: It does not receive any parameters. TheKColumn
orKTableColumn
that invokes the method will be the one supplied to theRTRIM
function.rtrim(String characters)
: Receives a String which will be supplied to theRTRIM
function. TheKColumn
orKTableColumn
that invokes the method will be the one supplied to theRTRIM
function.
Example: ()
Java code:
k
.select(
APP_USER.EMAIL.rtrim()
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
RTRIM(au.email)
FROM app_user au
Parameters:
- None
Example: (String)
Java code:
k
.select(
APP_USER.EMAIL.rtrim("xyz")
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
RTRIM(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:
rtrim(KColumn kColumn)
: Receives aKColumn
or aKTableColumn
which will be supplied to theRTRIM
function.rtrim(KValTextField kValTextField)
: Receives aKValTextField
which will be supplied to theRTRIM
function.rtrim(KColumn kColumn, String characters)
: Receives aKColumn
or aKTableColumn
and a String which will be supplied to theRTRIM
function.rtrim(KValTextField kValTextField, String characters)
: Receives aKValTextField
and a String which will be supplied to theRTRIM
function.
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(
rtrim(APP_USER.EMAIL)
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
RTRIM(au.email)
FROM app_user au
Parameters:
- None
Example: (KValTextField)
Java code:
k
.select(
rtrim(val("A short text "))
)
.single();
SQL generated:
SELECT RTRIM(?1)
Parameters:
- ?1: "A short text "
Example: (KColumn, String)
Java code:
k
.select(
rtrim(APP_USER.EMAIL, "xyz")
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
RTRIM(au.email, ?1)
FROM app_user au
Parameters:
- ?1: "xyz"
Example: (KValTextField, String)
Java code:
k
.select(
rtrim(val("A short text"), "xt")
)
.single();
SQL generated:
SELECT RTRIM(?1, ?2)
Parameters:
- ?1: "A short text"
- ?2: "xt"