I want to have answer which contain *id* or *None*, but now in my query I 
have answer as empty list or list with tuple.
It's my query (version 1):
row = db_xml.executesql("SELECT FIRST 1 CASE WHEN V_CODE={0} THEN ID ELSE 
NULL END AS ID FROM ABIT_VALIDATION_CODES WHERE A_EMAIL='{1}' AND 
SESSION_DATE>DATEADD(-2 MINUTE TO CURRENT_TIMESTAMP) ORDER BY SESSION_DATE 
DESC".format(db._adapter.dialect.quote(request.vars.code),db._adapter.
dialect.quote(request.vars.email.strip())))
It's my query (version 2):
cutoff_time = datetime.datetime.now() - datetime.timedelta(minutes=2)
condition = db_xml.abit_validation_codes.V_CODE==request.vars.code
typeOfAnswer = condition.case(db_xml.abit_validation_codes.id,None)
row = 
db_xml((db_xml.abit_validation_codes.A_EMAIL==request.vars.email.strip()) & 
(db_xml.abit_validation_codes.SESSION_DATE>cutoff_time)).select(typeOfAnswer,orderby=~db_xml.abit_validation_codes.SESSION_DATE).first()
Both of them do not work correct.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a10f776a-d446-4679-8ff2-27146092962b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to