Solved

user parameter within sql statement

  • 10 November 2022
  • 5 replies
  • 67 views

Badge

Hi,

i read a postgis table with the feature reader. As a WHERE clause i want to filter on a certain criteria, say:

 

name_community IN ('Comm1','Comm2','Comm3')

 

I would like to allow multiple selection. Therfore I have choosen the type of parameter "choice" and a list with multiple selection. The name of the parameter is "_community".

 

Now , I thought:

 

name_community IN (%(_community))

 

However, this does not work. Any support would be appreciated.

icon

Best answer by femo 11 November 2022, 12:24

View original

5 replies

Userlevel 4

It seems you're missing a dollar-sign to indicate the reference the parameter. Try something like

name_community IN ($(_community))

 

Userlevel 6
Badge +31

I did not test this but does it work when you create the where statement in an attribute with an attributecreator upstream of the featurereader and then refer to the attribute in the featurereader?

Userlevel 4

I did not test this but does it work when you create the where statement in an attribute with an attributecreator upstream of the featurereader and then refer to the attribute in the featurereader?

Agreed. Definitely what I'd do myself in this situation. So much easier to debug and control for edge cases.

Userlevel 1
Badge +22

The query needs to have the correct syntax, so you need to generate a variable (_community_list) with a content of 'Comm1','Comm2','Comm3', and then use name_community in (@Value(_community_list)) in your query.

This can be done with an AttributeCreator and an Aggregator between two FeatureReader's.

Cheers

Badge

Hi everybody,

 

thanks realy a lot for the imediate and valuable replies! They helped me a lot.

I finally managed it, maybe not in the smartest way, but it works:

imageBest wishes, Uwe

 

Reply