Skip to content

Support delimiter expressions in LISTAGG() and GROUP_CONCAT() #16563

@raoua-eng

Description

@raoua-eng

Use case

When attempting to use the listagg function with chr(10) as a delimiter in jOOQ, the parser encounters an error and fails to parse the SQL query. This prevents the successful parsing of SQL queries that utilize listagg with newline characters as delimiters.

Reproducer:

public class ListaggReproducer {
    public static void main(String[] args) {
        // JDBC connection parameters
        String url = "jdbc:postgresql://url/username";
        String username = "XXX";
        String password = "XXX";

        // SQL query with listagg and chr(10) delimiter
        String sql = "SELECT listagg(emp_name, chr(10)) WITHIN GROUP (ORDER BY column_name) AS result FROM employe";

        try (Connection conn = DriverManager.getConnection(url, username, password);
             PreparedStatement pstmt = conn.prepareStatement(sql);
             ResultSet rs = pstmt.executeQuery()) {

            // Fetch and print the result
            while (rs.next()) {
                String result = rs.getString("result");
                System.out.println(result);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

Possible solution

No response

Possible workarounds

No response

jOOQ Version

3.19.6

Database product and version

PostgreSQL 14.5

Java Version

Java 11

JDBC / R2DBC driver name and version (include name if unofficial driver)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions