Equivalent to PostgreSQL array() / array_to_string() functions in Oracle 9i -
i'm hoping return single row comma separated list of values query returns multiple rows in oracle, flattening returned rows single row.
in postgresql can achieved using array , array_to_string functions this:
given table "people":
id | name --------- 1 | bob 2 | alice 3 | jon
the sql:
select array_to_string(array(select name people), ',') names;
will return:
names ------------- bob,alice,jon
how achieve same result in oracle 9i?
thanks,
matt
tim hall has definitive collection of string aggregation techniques in oracle.
if you're stuck on 9i, personal preference define custom aggregate (there implementation of string_agg on page) such have
select string_agg( name ) people
but have define new string_agg function. if need avoid creating new objects, there other approaches in 9i they're going messier postgresql syntax.
Comments
Post a Comment