Skip to main content

To Hex

Definition

The toHex method allows you to add the TO_HEX function to the query. The TO_HEX function is used to convert a number to its equivalent hexadecimal representation.

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:

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

Example

Java code:

k
.select(
APP_USER.ID.toHex()
)
.from(APP_USER)
.multiple();

SQL generated:

SELECT
TO_HEX(au.id)
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:

  • toHex(KColumn kColumn): Receives a KColumn or a KTableColumn which will be supplied to the TO_HEX function.
  • toHex(KValNumberField kValNumberField): Receives a KValNumberField which will be supplied to the TO_HEX 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(
toHex(APP_USER.ID)
)
.from(APP_USER)
.multiple();

SQL generated:

SELECT
TO_HEX(au.id)
FROM app_user au

Parameters:

  • None

Example: (KValNumberField)

Java code:

k
.select(
toHex(val(12))
)
.from(APP_USER)
.multiple();

SQL generated:

SELECT
TO_HEX(?1)
FROM app_user au

Parameters:

  • ?1: 12