Oracle User Defined Aggregate Function Script

The WM_CONCAT function and LISTAGG function if not supported then  you can create your own user defined aggregate function as below:
 
-----------------------
CREATE OR REPLACE TYPE xxtex_string_agg AS OBJECT
(
  g_string  VARCHAR2(32767),

  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  xxtex_string_agg)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  xxtex_string_agg,
                                       value  IN      VARCHAR2 )
     RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   xxtex_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  xxtex_string_agg,
                                     ctx2  IN      xxtex_string_agg)
    RETURN NUMBER
);



------------------------------
CREATE OR REPLACE TYPE BODY xxtex_string_agg IS
  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  xxtex_string_agg)
    RETURN NUMBER IS
  BEGIN
    sctx := xxtex_string_agg(NULL);
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  xxtex_string_agg,
                                       value  IN      VARCHAR2 )
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := self.g_string || ',' || value;
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   xxtex_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER IS
  BEGIN
    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  xxtex_string_agg,
                                     ctx2  IN      xxtex_string_agg)
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
    RETURN ODCIConst.Success;
  END;
END;


---------------------------------------
CREATE OR REPLACE FUNCTION xxtex_string_agg_f (p_input VARCHAR2)
   RETURN VARCHAR2 PARALLEL_ENABLE AGGREGATE
   USING xxtex_string_agg;


------------------------------using in select statement -----------------
SELECT  xxtex_string_agg_f(distinct pa.name) AS project_name
FROM po_distributions_all po_dist,pa_projects_all pa
     WHERE po_dist.po_header_id= :po_header_id
           AND po_dist.project_id=pa.project_id;

Return 91234,92345,93456,94567,95678