oracle - SYS_CONNECT_BY_PATH and START WITH/CONNECT BY PostgreSQL Equivalent -


i have query part of larger query written in oracle need convert postgresql.

/*rn , cnt defined earlier*/ select wtn, ltrim(sys_connect_by_path(resp_tcsi, ','),',') tcsi_codes data rn = cnt start rn = 1 connect prior rn = rn-1 , prior wtn = wtn 

from i'm able tell, there's not equivalent sys_connect_by_path() in postgres. know postgres has connectby() function in tablefunc, don't think either start , connect bits do. i'm aware of postgres equivalent ltrim() is, if have use connectby() or similar, i'm not sure if trimming string important.

reading , searching around noticed there way recursive select, i'm unsure how that, , beyond that, don't understand code doing. assumption has hierarchical tree, based on oracle equivalents, i'm not sure. how equivalent or similar in postgres?

thanks.

use recursive common table expression:

with recursive tree (   select wtn,           resp_tcsi tcsi_codes    data    rn = 1 -- "start with" part     union     select ch.wtn,            p.tcsi_codes||','||ch.resp_tcsi     data ch     join tree p        on ch.rn -1 = p.rn -- "connect by" part      , ch.wtn = p.wtn ) select * tree; 

Comments