I dont understand what I'm doing wrong in the following situation. If I put this:
case(whens={exclude_table.c.minutes_limit != None: exclude_table.c.minutes_limit}, else_=5000).label (name='minutes_limit') in the select clause of my query, I can't say: having=(func.sum(cdr_table.c.duration) / 60) >= 'minutes_limit', later on as I get the following error: sqlalchemy.exc.DatabaseError: (DatabaseError) ORA-01722: invalid number I got around the problem by doing this: stupid = case(whens={exclude_table.c.minutes_limit != None: exclude_table.c.minutes_limit}, else_=5000).label (name='minutes_limit') and referring to "stupid" in the select clause and the having clause. What is the right way of referring to the labeled CASE clause? The complete query: query = select( [cdr_table.c.nodeid_ingress, node_table.c.deviceid, customer_table.c.name, stupid, (func.sum(cdr_table.c.duration) / 60).label (name='duration_minutes'), location_table.c.datestarted, location_table.c.dateended ], and_(node_table.c.nodeid != None, customer_table.c.customerid != None, cloud_table.c.networkid == 1, between(cdr_table.c.callconnected, location_table.c.datestarted, case(whens={location_table.c.dateended != None: location_table.c.dateended}, else_=func.sysdate())) ), from_obj = cdr_table.outerjoin( node_table, node_table.c.nodeid == cdr_table.c.nodeid_ingress ).outerjoin(cloud_table, cloud_table.c.cloudid == node_table.c.cloudid ).outerjoin(node_contract_table, node_contract_table.c.nodeid==node_table.c.nodeid ).outerjoin(location_table, location_table.c.trunkid==node_contract_table.c.trunkid ).outerjoin(customer_table, customer_table.c.customerid==location_table.c.customerid ).outerjoin(exclude_table, exclude_table.c.customer_name == customer_table.c.name), group_by=[cdr_table.c.nodeid_ingress, node_table.c.deviceid, customer_table.c.name, 'minutes_limit', location_table.c.datestarted, location_table.c.dateended], having=(func.sum(cdr_table.c.duration) / 60) >= stupid, order_by=[cdr_table.c.nodeid_ingress, node_table.c.deviceid, customer_table.c.name, 'minutes_limit', location_table.c.datestarted, location_table.c.dateended] ) --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---