This question already has an answer here:

I have a sql view which take only one parameter, but this parameter is a list, and a need to know how can i pass this parameter in the url

Here is my sql view

SELECT * FROM shop WHERE id IN %list%

When I put the default value for %list% as (1, 2 ,3) as example, the layer preview works and show the shopa with the default ids, but when I try this in the url


does not work.

I already tried other things like


but nothing works.

Does anyone know how to do this?

marked as duplicate by Ian Turton Nov 2 '16 at 8:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • turn up the logging level and look to see what is inserted in the SQL query sent to the DB. you may need to escape the , – Ian Turton Dec 31 '14 at 14:15
  • did this, but in log viewparams=null – Caio Belfort Dec 31 '14 at 14:36
  • that will be the problem then! – Ian Turton Dec 31 '14 at 14:46
  • maybe i need create a function in javascript to make the query to only one id per loop and join together in an overlay... – Caio Belfort Jan 2 '15 at 19:53
  • More likely to be a quoting issue – Ian Turton Jan 2 '15 at 19:57

Found a solution, i made the query like this SELECT * FROM shop WHERE id IN (%list%)

in Validation regular expression field i put this ^[\d,]+$

and now i can use viewparams=i:1\,2\,3

If you are still getting 400 errors, try using the escaped character for backslash "%5C": viewparams=i:1%5C,2%5C,3


Caio if you use ^[\d,]+$ , it will allow certain parameters you dont want such as 1\,\,2\,3. Use instead the following:

  • excuse the delay of almost a year to comment. Come back to gis dev recently (same class but in master degree). Will try this now. Thanks! – Caio Belfort Nov 12 '15 at 4:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.