Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Function using XMLAGG

ponicpoolDec 26 2018 — edited Dec 26 2018

I have a question regarding the creation of a function which would return CLOB data type. This function will be used using a DB Link from a 10g database to a legacy 8i database.

The reason for using DBlink is because XMLAGG would not be possible to use in a legacy 8i database. I am combining multiple rows using XMLAGG to a single row which exceeds 32000 characters.

I tried creating a function using the below, however, resulted in error PLS-00103: Encountered the symbol "ORDER".

CREATE or replace FUNCTION get_clob_data (my_clob CLOB, prod_line NUMBER)

   RETURN CLOB

AS

BEGIN

   RETURN RTRIM (

             XMLAGG (XMLELEMENT (

                        e,

                        REPLACE (

                           REGEXP_REPLACE (REPLACE (my_clob, CHR (10), '~~~'),

                                           '[[:cntrl:]]'),

                           '~~~',

                           CHR (10)),

                        CHR (10)) ORDER BY prod_line).EXTRACT ('//text()').getclobval (),

             CHR (10)) ;

END;

Not sure, whether a function is possible to create which would return CLOB with the above code and secondly I am able to access the function using a DB LInk if able to create a function.

Another question is does 8i have any solution to combine multiple rows as one row.

Appreciate any insight or help.

Comments
Post Details
Added on Dec 26 2018
9 comments
1,801 views