[racket] db: SQL in clause

From: George Neuner (gneuner2 at comcast.net)
Date: Sun Nov 30 08:20:45 EST 2014

Hi all,

I'm using Postgresql 9.3.5 and I keep getting a syntax error trying to 
pass a list of identifiers to an "in" clause of a select.

     (set! sql-cmd "select * from contacts where id in $1" )
     (set! result (query db sql-cmd (list 42 101)))

I've tried :
     where id in $1
     where id in ($1)
     where id in (values $1)
     where id in (values [$1])

and also tried converting the list to a pg-array for the values clause.


I have worked around it using "= any" and a pg-array, e.g.,

     (set! sql-cmd "select * from contacts where id = any ($1)" )
     (set! result (query db sql-cmd (list->pg-array (list 42 101))))

but is there any way to actually use an "in" clause?
Thanks,
George


Posted on the users mailing list.