Skip to main content

I have a list which has two elements {make, model}. I can receive multiple make, model in in this list. So, I can get values like:

{make = Toyota, model =camry},{make = Toyota, model =Prius} and so on.

I need to use these values create a sql in the format -

select * from cars where (make=toyota and model = camry) or (make = toyota and model - Prius);

 

How do I achieve this in FME? I dont know the no. of values that I will get in the list. Please advise, I am very new to FME

Theres a few ways you could do this, i'm not very knowledgeable with SQL - someone with more SQL knowledge will probably be able to give a better solution.

 

The approach i'd take would be to build the WHERE clause in FME and then pass it to the SQL Executer (assuming that what you're using). To do this, you need to explode the list. You'll end up with one feature for each element in the list, each will have the make and model attributes.

 

Then, using a StringConcatenator you can build part of your where clause, so you'll have on feature with "(make=toyota and model=camry)" and another with "(make=toyota and model=Prius)" and so on. You can now build another list with this attribute. Then use a ListConcatenator with the value "OR" and you'll end up with "(make=toyota and model=camry) OR (make=toyota and model=Prius) OR..."

 

Now you can place this into you SQL Executer - "select * from cars where @Value(where_statement)"


Reply