Xmlagg
Definition
The xmlAgg
method allows you to add the XML_AGG
function to the query. The XML_AGG
is a function that concatenates a list of xmls.
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:
xmlAgg()
: It does not receive any parameters. TheKColumn
orKTableColumn
that invokes the method will be the one supplied to theXML_AGG
function.
Example
Java code:
k
.select(
APP_USER.EMAIL.xmlAgg(),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
XML_AGG(au.email),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- None
2. Calling from the KFunction
class
The only one method available to use this functionality calling from the KFunction
class is:
xmlAgg(KColumn kColumn)
: Receives aKColumn
or aKTableColumn
which will be supplied to theXML_AGG
function.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example
Java code:
k
.select(
xmlAgg(APP_USER.EMAIL),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
XML_AGG(au.email),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- None