It is not clear from the post if you want to cast a type at the database level or the database level. If you want to do it at the web2py level your choice is looping or map
map(lambda row: row.update(field=int(row.field)), rows) If you want to cast at the database level, tells us the SQL query and we can tell you how to translate it in DAL-ese. On Thursday, 22 October 2015 00:01:04 UTC-5, Benson Myrtil wrote: > > Hey guys, > > I have a quick question. Does the DAL support type casting on the fly? I > am working with a legacy mssql 2008 database that I cannot alter. Within > this database it has a field of integers but the field type is string. When > I try to run the sum() function on that field I get <class > 'gluon.contrib.pypyodbc.ProgrammingError'>((u'42000', u'[42000] > [FreeTDS][SQL Server]Operand data type char is invalid for sum operator.')) > > Short of having to loop over the fields and int() them so I can add them, > I was wondering if there was anyway to do this within web2py/DAL framework? > > I tried to change the field type before running the sum() function hoping > I could trick it but that still did not work. > -- 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. For more options, visit https://groups.google.com/d/optout.