Wednesday 26 September 2018

Passing list to viewparams variables in GeoServer SQL views?



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


viewparams=list:(1,2,3)

does not work.


I already tried other things like


viewparams=list:"1,2,3"

but nothing works.


Does anyone know how to do this?



Answer




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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...