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!

Xmltable - xmltype - Replacement

ramarunJan 23 2014 — edited Jan 24 2014

Hi All,

We have a query like below

Select Columns

from T1,t2,t3

where t1.c = t2.c2

and t1.c = t3.c3

and t1.Col in

SELECT :Col

  FROM xmltable('r/c' passing

                xmltype('<r><c>' ||

                        replace(REPLACE(:Col1 || ', ' ||

                                        DECODE(:Col_2_Decode,

                                               '1',

                                               :Col_1,

                                               '2',

                                               :Col_1,

                                               '') || ',' ||

                                        DECODE(:Col_2_Decode, '2', :Col2, ''),

                                        ''''),

                                ',',

                                '</c><c>') || '</c></r>') columns new_str

                varchar2(50) path '.') d

How else we can rewrite this, this seems to be a bit clumsy and also performance wise not ok. I am not in a position to share the exact query with sample data, sorry for the same.  Hence I would like to hear from the Pro's on how better or best to have this rewritten by some other way or function built-ins available in 11g. Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 21 2014
Added on Jan 23 2014
11 comments
885 views