Hi Ben,

2013/8/5 Ben Hood <[email protected]>

> Hi Lukas,
>
> Using this 3rd party package (http://groupconcat.codeplex.com/) to
> provide GROUP_CONCAT on SQL Server seems to provide more flexibility
> that using the builtin FOR XML PATH (as referred to by
> https://github.com/jOOQ/jOOQ/issues/1277).
>

Yes, this LISTAGG() emulation idea using SQL Server's STUFF is a bit funky.

I was wondering if there is a way to get the LISTAGG generator to be
> dialect aware and generate the necessary syntax for SQL Server, i.e.
> dbo.GROUP_CONCAT(COLUMN_NAME). Or is this something that is not likely
> to be very portable (looking beyond the issue of having to assume that
> this 3rd package is actually installed)?
>

I prefer not to rely on such a third-party extension that might be
installed in SQL Server (or not). Think about the various other "useful"
functions that are present in 1-2 databases but missing in the remaining
12, supported by jOOQ.

Of course, you can create your own function, using plain SQL:

public static Field<String> groupConcat(Field<String> column) {
    return DSL.field("dbo.GROUP_CONCAT({0})",
        String.class, column);
}

public static Field<String> groupConcat(Field<String> column, String
delimiter) {
    return DSL.field("dbo.GROUP_CONCAT({0}, {1})",
        String.class, column, val(delimiter));
}

Note, jOOQ should probably support code generation for custom aggregate
functions. This is currently only supported in Oracle. I have added a
feature request for this:
https://github.com/jOOQ/jOOQ/issues/2677

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to