Skip to main content

Reverse

Definition

The reverse method allows you to add the REVERSE function to the query. The REVERSE function is used to reverse a string.

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:

  • reverse(): It does not receive any parameters. The KColumn or KTableColumn that invokes the method will be the one supplied to the REVERSE function.

Example

Java code:

k
.select(
APP_USER.EMAIL.reverse()
)
.from(APP_USER)
.multiple();

SQL generated:

SELECT
REVERSE(au.email)
FROM app_user au

Parameters:

  • None

2. Calling from the KFunction class

The methods available to use this functionality calling from the KFunction class are:

  • reverse(KColumn kColumn): Receives a KColumn or a KTableColumn which will be supplied to the REVERSE function.
  • reverse(KValTextField kValTextField): Receives a KValTextField which will be supplied to the REVERSE 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(
reverse(APP_USER.EMAIL)
)
.from(APP_USER)
.multiple();

SQL generated:

SELECT
REVERSE(au.email)
FROM app_user au

Parameters:

  • None

Example: (KValTextField)

Java code:

k
.select(
reverse(val("A short text"))
)
.single();

SQL generated:

SELECT REVERSE(?1)

Parameters:

  • ?1: "A short text"