Position
Definition
The position method allows you to add the POSITION function to the query. The POSITION function returns the starting index of a specified substring within a specified string.
Available methods
position(KColumn kColumn, String valueToLocate): Receives aKColumnorKTableColumnand a String which will be supplied to thePOSITIONfunction.position(KValTextField kValTextField, String valueToLocate): Receives aKValTextFieldand an String which will be supplied to thePOSITIONfunction.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example: (KColumn, String)
Java code:
k
.select(
position(APP_USER.EMAIL, "om")
)
.from(APP_USER)
.multiple();
SQL generated:
SELECT
POSITION(?1 in au.email)
FROM app_user au
Parameters:
- ?1: "om"
Example: (KValTextField, String)
Java code:
k
.select(
position(val("A previous example"), "ex")
)
.single()
SQL generated:
SELECT POSITION(?1 in ?2)
Parameters:
- ?1: "ex"
- ?2: "A previous example"