views:

66

answers:

2

Hi,

I have this:

SectionHistory.find(:all, :conditions => ["id=? and (name!=? or code!=?)", sec.id, sec.name, sec.code])

And I get the error "The character "!" following "and (name!=? or code" is not valid"

if my condition string is just "id=? and (name!=?)" it's OK

We're using DB2.

Any suggestions on this?

Thanks

+3  A: 

It's SQL; try:

"id=? and not (name=? and code=?)"
MarkusQ
This worked - thanks (although the != approach worked in our DB2 client)
Paul
+1  A: 

I'm not entirely sure how rails handles the conditions but if they are passed straight to the database engine then is != valid syntax for DB2.

You could try <> and see if that works

Steve Weet