【问题标题】:How to represent concatenation operator (||) in jOOQ?如何在 jOOQ 中表示连接运算符 (||)?
【发布时间】:2021-09-09 22:38:28
【问题描述】:

我正在尝试将此查询转换为 jOOQ 但卡在“||”上我用来将值连接到数组。

with recursive nodes(node_key, parent_ids, parent_path) as (
    select node_key, array[node_key] as parent_ids, array[name::text] as parent_path
    from node
    where parent_node_key is null
    
    union all
    select c.node_key, parent_ids || c.node_key, parent_path || c.name::text
    from node c
    join nodes n on n.node_key = c.parent_node_key
)
select * from nodes order by parent_path;

到目前为止我做过的jOOQ代码:

dsl.withRecursive( name( "nodes" )
                       .fields( "node_key",
                                "parent_ids",
                                "parent_path" ).as(
        select(
            NODE.NODE_KEY,
            array( NODE.NODE_KEY).as( "parent_ids" ),
            array( NODE.NAME).as( "parent_path" )
        )
            .from( NODE)
            .where( NODE.PARENT_NODE_KEY.isNull() )
            .unionAll(
                select( NODE.NODE_KEY,
                        field( "parent_ids" ))
            ) )
) );

如何将值连接到数组?

【问题讨论】:

    标签: java postgresql jooq


    【解决方案1】:
    猜你喜欢
    • 2016-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 2019-09-02
    • 1970-01-01
    • 2021-06-25
    相关资源
    最近更新 更多