Subject | RE: [firebird-support] Cast as Numeric without parenthesis |
---|---|
Author | Svein Erling Tysvær |
Post date | 2015-03-26T12:35:29Z |
>then why here is an error?Logically speaking I don't understand why
>
>SELECT CAST('123456789.23' as numeric) FROM RDB$DATABASE
SELECT CAST('123456789.23' as numeric(9,0)) FROM RDB$DATABASE
is failing when
SELECT CAST('1.23' as numeric(1,0)) FROM RDB$DATABASE
succeeds.
Practically, I guess it means that Firebird first converts from a (var)char to an intermediate integer field before trying to round to nearest whole number, but I don't know why.
Normally, I don't store numbers in strings, and
SELECT CAST(123456789.23 as integer) FROM RDB$DATABASE
succeeds.
Here, I find that
SELECT CAST(123456789.12345678 as decimal) FROM RDB$DATABASE
succeeds, whereas
SELECT CAST(123456789.123456789 as decimal) FROM RDB$DATABASE
fails. I don't know why.
Sorry for not being able to shed any more light,
Set