Equivalent to PostgreSQL array() / array_to_string() functions in Oracle 9i

后端 未结 2 873
我寻月下人不归
我寻月下人不归 2020-12-10 15:03

I\'m hoping to return a single row with a comma separated list of values from a query that returns multiple rows in Oracle, essentially flattening the returned rows into a s

2条回答
  •  伪装坚强ぢ
    2020-12-10 15:16

    Tim Hall has the definitive collection of string aggregation techniques in Oracle.

    If you're stuck on 9i, my personal preference would be to define a custom aggregate (there is an implementation of string_agg on that page) such that you would have

    SELECT string_agg( name )
      FROM people
    

    But you have to define a new STRING_AGG function. If you need to avoid creating new objects, there are other approaches but in 9i they're going to be messier than the PostgreSQL syntax.

提交回复
热议问题