Implicit Type-Casting of Date/Time Literals - Firebird

Whenever date literals—whether regular or pre-defined—are used in SQL in the context of corresponding date/time type columns or variables, the SQL parser can interpret them correctly without casting. However, in a small number of cases, where there is no typed value to which the parser can map the date literal, it treats any date literal as a string.

For example, it is perfectly valid to ask a SELECT query to return a constant that is unrelated to any database column. A common “hack” in Firebird is to use the system table RDB$DATABASE for just such a query—since this table has one and only one row and thus can always be relied upon to return a scalar set—to pick up a single context value from the server. The next two examples illustrate a typical use of this hack:

Because the query returns a constant, not a column value, its data type is interpreted as a CHAR(3), 'NOW'. This example:

To have the parser correctly interpret a date literal in conditions where the parser cannot determine the data type, use the CAST(..) function.

For dialect 3:

For dialect 1:

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Firebird Topics