views:

52

answers:

1

Hi.

I am trying to construct a Groovy statement to find values that don't exist in a pre-populated list.

I'm using SQL and think I want to do something like :

myList = [a, b, c, d, e ... lots more data]

sql.findAll("SELECT * FROM table WHERE code not in " + <myList>)

I have a feeling this is very simple .. I'm just not sure how to construct the closure.

Also open for any other suggestions on how to do it ..

Thanks for any insight ..

A: 

The value of myList in the sql statement should be a comma separated list of values. You eventually want your query to look like

SELECT * FROM table WHERE code not in ('a','b','c','d','e',...lots more)

Have you tried something like this?

sql.findAll("SELECT * FROM table WHERE code not in ('" + myList.join("','") + "')")
r-dub
That did exactly what I needed. Thank you !
sidd.darko