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!

Decode over an xmlelement

DevguyFeb 27 2020 — edited Feb 28 2020

Hi All,

I have a situation where I am trying to do a decode over an xmlelement but it doesn't seem to work. The requirement is for me to include either Debit(or) Credit xmltag and the corresponding amount based on the invoice type, is there any other way other than using decode that xmlelement would accept?

SELECT XMLCONCAT (

           XMLELEMENT ("TrxNumber", 12345),

           XMLELEMENT (DECODE ( :p_class,  'INV', "Debit",  'CM', "Credit"),

                       DECODE ( :p_class,  'INV', 123,  'CM', -123)

                       )

                  )

           abc

  FROM dual

We are on Oracle DB version 12.1.0.2.0

Appreciate any inputs

Thanks in advance!

This post has been answered by mNem on Feb 27 2020
Jump to Answer
Comments
Post Details
Added on Feb 27 2020
4 comments
496 views