Single quotes Escape from parameter values

Defined one parameter called "display_name" in sql editor and passing dynamic values in to it and capture in the where ( org_name in ('x','y','I'am there') ) clause as per below .however few values are already have single quotes in it (ex : I'am there) and throwing an error . any help? how to escape single quotes ?

select distinct ltrim(rtrim(a.email)) as email from table_name a
-where
and ltrim(rtrim(b.display_name)) in ({{display_name}})

 

{% form %}

    
email:
    type: multiselect
    default: all
    options:
        labels: email
        values: email

{% endform %}

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi hari babu ,

    Sorry for the delayed response time. Parameters are defined using Liquid, and I think Liquid's replace function will be helpful here. You can use it to replace single quotes in your liquid variable's value with double quotes:

    where owner = '{{ owner | replace: "'", "''" }}'

    Let me know if you have any questions on that!

    Reply Like
Like Follow
  • Status Answered
  • 4 wk agoLast active
  • 1Replies
  • 53Views
  • 2 Following