Hi All,

I want to write a query in SA which uses ORACLE 'connect' along with
joins on other table.
The query will be:-
SELECT grouprelation.grouprelationid AS grouprelation_grouprelationid,
grouprelation.parentgroupid AS grouprelation_parentgroupid,
grouprelation.childgroupid AS grouprelation_childgroupid FROM
grouprelation, grouptable CONNECT BY childgroupid = PRIOR
parentgroupid START WITH childgroupid = 91 AND
grouprelation.parentgroupid = grouptable.groupid AND
grouptable.wfstatus != 'I'

I tried writing it in SA as following:-

connectstring = "connect by childgroupid = prior parentgroupid start
with childgroupid = 91"

query =
session.query(GroupRelation).filter(sql.and_(GroupRelation.c.parentgroupid
== GroupTable.c.groupid, GroupTable.c.wfstatus != 'I', connectstring))

compiles to

SELECT grouprelation.grouprelationid AS grouprelation_grouprelationid,
grouprelation.parentgroupid AS grouprelation_parentgroupid,
grouprelation.childgroupid AS grouprelation_childgroupid FROM
grouprelation, grouptable WHERE grouprelation.parentgroupid =
grouptable.groupid AND grouptable.wfstatus != 'I' AND connect by
childgroupid = prior parentgroupid start with childgroupid = 91

which is erroneous because when I write a filter, it compiles to a
WHERE clause, which does not go with CONNECT and gives ORA-00936:
missing expression error.

The only way as of now will be to write the whole query in the
from_statement which will be my last resort.

Does anyone know how to write it using SA ?

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