3 Replies Latest reply on Nov 16, 2015 2:25 AM by glorifindal

    Escaping an underscore in an executesql variable

    glorifindal

      Greetings from Thailand,

       

      I want to prohibit the underscore in the variable from being treated as a wildcard - I want it treated as literal text.

       

      I have tried the following in trying to get this to work:

      [code]

      Let( [

      _esc = " ESCAPE '\'" ;

      _val = "PROJ_1" ;

      _val.var = If( PatternCount( _val ; "_" ) > 0 ; Substitute ( _val  ; "_" ; "\_" ) ) & _esc ;

      _qry = "SELECT id FROM SQLPROJ WHERE LOWER(\"Project Name\") = ?" ;

      result = ExecuteSQL( _qry ; "" ; "" ; _val.var )

      ] ;

      result

      )

      [/code]

       

      This returns nothing -

       

      Any ideas what I have done wrong ?

       

      kindest regards

       

      G