简体   繁体   中英

Oracle equivalent of PostgreSQL's sub-select to array?

Is there an equivalent in Oracle to get an array from a subselect so if there is more than one row in the subselect's results there will still only be one row in the final results?

eg:

select c.name, array(select order_id from ORDER o where o.customer_id = c.id)
from CUSTOMER c;

Will only return one row per CUSTOMER, where the second value in each returned row is an array of order_id's.

You can use a CURSOR :

select c.name, cursor(select order_id from ORDER o where o.customer_id = c.id)
from CUSTOMER c;

Then your database interface will have some way of getting the results out of a cursor result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM