Hello All,

I am facing a problem using the IN queries in sqlalchemy. I am using
sqlalchemy-0.4.5-py2.4.egg for the following.

The documentation at sqlalchemy.org states the following example for
showing IN queries
session.query(Address).filter(Address.email_address.in_(['[EMAIL PROTECTED]',
'[EMAIL PROTECTED]']))

When I write the following code, it returns me proper results
session.query(Student).filter(Student.c.studentid.in_([1,2,3,4]))

But I want to run the query based on the arguments provided to the
function, where in the list [1,2,3,4] will be passed in as an argument
as studentidlist = [1,2,3,4]. Hence when I write the following query ,
it throws me a SQLError: (DatabaseError) ORA-01484: arrays can only be
bound to PL/SQL statements
session.query(Student).filter(Student.c.studentid.in_(studentidlist))

Currently I am using a workaround to first generate a string criteria
looping over each element in the list, then use this criteria to
execute query
studentidlist = [1,2,3,4]
str_criteria = "studentid in (1,2,3,4)"
session.query(Student).filter(str_criteria).all()

But I would like to use the inbuild in_ criterion, rather than the
workaround.

Any ideas ?

Thanks
sbhatt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to