Search code examples
sqlfirebirdfirebird2.5

Using reserved word TimeStamp as a field name


I am extending the data layer of an existing application to work with Firebird 2.5, in addition to SQL Server and SQLite, but I have hit a stumbling block.

I have a field called TimeStamp which stores the data/time as type TimeStamp. This works fine under SQL Server and SQLite where the type is datetime, but fails on Firebird. The following SQL:

SELECT SysTrnId,'TimeStamp' from "TRANSACTIONS"

seemingly works, but the TimeStamp field is returned as fieldname "CONSTANT" and the contents are the text "timestamp"

Is it possible to do this under Firebird, or am I going to have to rename the field and change the code in the other data layers.


Solution

  • The Firebird escape character is the double quote ". Note that in Firebird if you have a field that you have to escape with double quotes, it also becomes case-sensitive. So, if you've declared your field as TimeStamp, then select "TIMESTAMP" ... will fail with a field not found error.