4 Replies Latest reply: Aug 23, 2013 1:44 PM by 993517 RSS

    how to concatenate hexadecimal value to string in XQuery

    753684
      hi,

      I have a requirement in my project where I have to concatenate the text value to hexadecimal \x01.
      I am using this hexadecimal \x01 as delimiter in MFL transform where the transform awaits \x01 at the end of the string.
      The query is like : fn:concat("abcd",'\x01')
      When I am exceuting the above query,the value \x01 gets concatenated to the text "abcd" and behaves as string and the MFL is not able to identify it as a hexadecimal (\x01) value.
      The O/P is : abcd\x01

      However.I want the value \x01 to be represented as hexadecimal 1 as I am using hexadecimal 1 (i.e. \x01) as delimiter in MFL transformation.

      With the staement fn:concat("abcd",'\x01'),I get XQuery exception while parsing the data.


      Can anyone please help me with the hexadecimal notation in XQuery and with the correct syntax of above XQuery to concatenate hexadecimal value to a string.

      Thanks in advance,
        • 1. Re: how to concatenate hexadecimal value to string in XQuery
          MichaelS
          What is your db version?

          in 11gr2 you can do:
          SQL> select x, dump (x) dump_x from xmltable (('concat("abc", "'||chr(1)|| '")') columns x varchar2(5) path '.')
          /
          X     DUMP_X                   
          ----- -------------------------
          abc   Typ=1 Len=4: 97,98,99,1  
          • 2. Re: how to concatenate hexadecimal value to string in XQuery
            753684
            Thanks Michael.

            Would like to give more information on the requirement I have:

            I receive text data from an I/P source that contains fields delimited with hexadecimal 01 value(i.e.\x01).This hexadecimal delimiter looks like a square bracket ()in the incoming text file but is actually a hexadecimal 01.The last field in the file is not followed by a delimiter.
            I have written a MFL that uses hexadecimal 01(i.e. \x01) as the delimiter value.The Proxy Service reads the incoming text file .In the message flow,I parse the file content using the MFL I have created.
            Since the last field in the file is not followed by hex-01 delimiter,I am trying to explicitly concatenate hex-01 to the last field before using MFL transform otherwise my XQuery will fail.
            I don't know how to concatenate hexadecimal to the last field.I tried several ways but the data gets concatenated as text and not as hex delimiter.

            Can you please help me with the statement that will concatenate hex-01 delimiter value to the text data so that my Query does not fail.
            • 3. Re: how to concatenate hexadecimal value to string in XQuery
              Jason_(A_Non)
              What micheals was showing you is that chr(1) = hex 01.

              Here is what dump displays, where the default appears to be hexadecimal info.
              • 4. Re: how to concatenate hexadecimal value to string in XQuery
                993517

                I know this is an old post but for others who are searching for the answer this worked for me:
                fn:concat( 'abcd', '' )