18.01.2018 02:36, Adriano dos Santos Fernandes wrote:
I don't known a reason, but I feel that very few people uses date/time (and timestamp) literals. In Firebird generally people use casts to transform a string to these types. In Oracle, they use TO_DATE.
Many people use string literals without explicit casts.
It's much better to use DATE '2018-01-01', TIME '10:00:00' and TIMESTAMP '2018-01-01 10:00:00'.
Agreed.
However, I found a very weird situation with some literals. We may use things as DATE 'TODAY', TIME 'NOW' and TIMESTAMP 'NOW'. And different than these strings used in CAST, these are literals (evaluated at compile time). So if you create a procedure/function with them, they value are refreshed every time you recompile (from SQL) the routine, but never refreshed when you run it. Also imagine a compiled statement cache (implementation detail), a "select timestamp 'now' from rdb$database" will give stalled results. For me this is more a bug than a feature.
Also agreed.
I think these expressions should better generate the equivalent of CAST(string as type).
By design, these hardcoded strings are expressions, but date/time/timestamp prefixes imply literals (by standard). I'd rather suggest to validate the string at compile time and throw a misuse error.
Dmitry ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel