There is a build-in package : DBMS_UTILITY
This should be able to solve your problem
This procedure converts a PL/SQL table of names into a comma-separated list of names. This takes a PL/SQL table, 1..n,
terminated with n+1 null.
tab IN UNCL_ARRAY,
tablen OUT BINARY_INTEGER,
list OUT VARCHAR2);