Clarity

 View Only
  • 1.  Remove single quote in GEL

    Broadcom Employee
    Posted Sep 01, 2016 12:36 PM

    Hi All.

    I need to load resources from a CSV file. Some names contain a quote (i.e.: ANGILE' FABRIZIO), and I have the same into PPM resources (I mean, I have the quote too).

    I have a query with the following WHERE condition:

     

    WHERE full_name='${userRead}'

     

    When the full name contain the single quote, I get an error, since the statement is transalted into

     

     WHERE full_name='ANGILE' FABRIZIO'

     

    I'm not able to find a way to remove the quote using replace function in gel (userRead.replace(....)).

    Any suggestion would be greately appreciated.

    Thanks

    Fabio



  • 2.  Re: Remove single quote in GEL
    Best Answer

    Posted Sep 01, 2016 04:10 PM

    Fabio,

     

    You use the following code to replace the single quote with its equivalent code. 

    For the single quote, you are sending the equivalent of "''", double-quote single-quote single-quote double-quote .

     

    <core:set value="${userRead.replaceAll ('\x27', &quot;&apos;&apos;&quot;)}" var="userRead"/> <!-- ' Characters -->

     

     

    Or you can use this code to replace all XOG unfriendly characters with their equivalent codes.

     

     

    <!-- Clean up Data in userRead -->
    <core:set value="${userRead}"  var="TMP_String"/>
    <core:set value="${TMP_String.replaceAll ('[^\p{ASCII}]', '?')}"  var="TMP_String"/> <!-- Extended Characters -->
    <core:set value="${TMP_String.replaceAll ('\x26', '&amp;')}"   var="TMP_String"/> <!-- & Characters -->
    <core:set value="${TMP_String.replaceAll ('\x22', '&quot;')}"   var="TMP_String"/> <!-- " Characters -->
    <core:set value="${TMP_String.replaceAll ('\x3e', '&gt;')}"   var="TMP_String"/> <!-- greater than Characters -->
    <core:set value="${TMP_String.replaceAll ('\x3c', '&lt;')}"   var="TMP_String"/> <!-- less than Characters -->
    <core:set value="${TMP_String.replaceAll ('\x2f', '&#47;')}"   var="TMP_String"/> <!-- / Characters -->
    <core:set value="${TMP_String.replaceAll ('\x27', &quot;&apos;&apos;&quot;)}" var="TMP_String"/> <!-- ' Characters -->
    <core:set value="${TMP_String}"   var="userRead"/>



  • 3.  Re: Remove single quote in GEL

    Broadcom Employee
    Posted Sep 02, 2016 05:25 AM

    Thanks, it works perfectly!!!

    Fabio