turbodbc: MSSQL column name alias: Invalid column name
I am using turbodbc on a Linux environment using FreeTDS as a Driver.
I find myself with a table with a DATE and a TIME column, combining these two columns into a new one of the DATETIME type and giving it an alias, when I use this column in a WHERE always getting the following error:
ODBC error
state: 42S22
native error code: 207
message: [FreeTDS][SQL Server]Invalid column name 'pippo'.
This is my query:
SELECT dbo.View_Log.ID, dbo.View_Log.Postazione,
dbo.View_Log.Data, dbo.View_Log.ora, CAST(Data as DATETIME) + CAST(ora as DATETIME) AS pippo
FROM dbo.View_Log
WHERE pippo >= ?
AND pippo < ?;
The query works correctly using another client
Can someone help me?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (4 by maintainers)
At this point @pietromingo , I’m assuming turbodbc does not support TIME datatypes. Hence, you won’t be able to retrieve the “ora” column directly. Having said that, in the scenario you describe, I don’t think you need to retrieve it separately at all. You are retrieving it indirectly in the “pippo” column, and you can retrieve the time portion of “pippo” in your Python code. If you really need to retrieve “pippo” separately though, you can always convert it to a DATETIME first. Not ideal I know, but it should get you going.
Someone would need to write a test, I’m not using any TIME type, so it could be that this isn’t working.
@xhochy Does turbodbc support TIME datatypes? Issue #85 implies is doesn’t, but the docs state it does.