Reputation: 31
I'm trying to convert this query to jOOQ but got stuck on the "||" that I use to concatenate the value to the array.
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 code that I have done so far:
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" ))
) )
) );
How do I concatenate the value to the array?
Upvotes: 2
Views: 372