I'm trying to use collect
and cast
for string aggregation, similar to listagg
in Oracle Database 11 (also, unfortunately, wm_concat
is not enabled on the database I'm querying). I also have read-only access to this database.
My current query is as follows
SELECT plan.EMPLID,
plan.STRM TERM,
CAST(COLLECT(plan.ACAD_PLAN) AS sys.dbms_debug_vc2coll) agg_plans
FROM SYSADM.PS_OSR_PLAN_TRM plan
WHERE plan.EMPLID = '999999999'
GROUP BY plan.EMPLID, plan.STRM
This gives me this result:
EMPLID TERM AGG_PLANS
999999999 1152 SYS.DBMS_DEBUG_VC2COLL(VARCHAR(ECON-MN, TXTLCLO-MN))
999999999 1154 SYS.DBMS_DEBUG_VC2COLL(VARCHAR(ACCTING-BS, ECON-MN))
I believe my logic is correct, but I'm having with trouble with the cast
statement. I know that sys.dbms_debug_vc2coll
is of type table of varchar2(1000)
. I would like to remove SYS.DBMS_DEBUG_VC2COLL(VARCHAR(
from each row and simply list the results.
Is there a way to join together the resulting collection into a string? This stack overflow post has something similar to what I'm looking for... however, again, I have readonly access to this database. I'd also like to try to keep it one select statement.
Thanks for any help.
EDIT: I am not opposed to a solution that uses xmlagg
.