[Zope] can't use a cast operator in a sql query

Graham Chiu anon_emouse@hotmail.com
Tue, 28 Mar 2000 23:28:50 +1300


I couldn't see this covered in the Zsql user's guide.

select myfield from foo

works as expected.

As the current ODBC driver I am using has a bug which truncates varchar
fields, it was suggested I cast it to char while retrieving the field.

But

select cast(my_varchar_field as char(140)) from foo

gives an error with the following traceback...

Zope Error
Zope has encountered an error while publishing this resource. 

ValueError

Sorry, a Zope error occurred.

Traceback (innermost last):
  File D:\zope2\lib\python\ZPublisher\Publish.py, line 214, in
publish_module
  File D:\zope2\lib\python\ZPublisher\Publish.py, line 179, in publish
  File D:\zope2\lib\python\Zope\__init__.py, line 202, in
zpublisher_exception_hook
    (Object: sqlTest)
  File D:\zope2\lib\python\ZPublisher\Publish.py, line 165, in publish
  File D:\zope2\lib\python\ZPublisher\mapply.py, line 160, in mapply
    (Object: manage_test)
  File D:\zope2\lib\python\ZPublisher\Publish.py, line 102, in
call_object
    (Object: manage_test)
  File d:\zope2\lib\python\Shared\DC\ZRDB\DA.py, line 319, in
manage_test
    (Object: sqlTest)
  File d:\zope2\lib\python\Shared\DC\ZRDB\DA.py, line 300, in
manage_test
    (Object: sqlTest)
  File d:\zope2\lib\python\Shared\DC\ZRDB\DA.py, line 415, in __call__
    (Object: sqlTest)
  File D:\zope2\lib\python\Shared\DC\ZRDB\RDB.py, line 151, in __init__
ValueError: Empty column name, 


Using 2.1.6 with the ODBC DA.

-------
Regards,        Graham Chiu
gchiu<at>compkarori.co.nz
http://www.compkarori.com/dynamo - The Homebuilt Dynamo
http://www.compkarori.com/dbase - The dBase bulletin