TRUNC(DOUBLE) dont returns an INTEGER
-------------------------------------
Key: CORE-3425
URL: http://tracker.firebirdsql.org/browse/CORE-3425
Project: Firebird Core
Issue Type: Bug
Components: Engine
Affects Versions: 2.1.4
Environment: Windows 7 x64, Firebird 2.1.4 "Stable" 32 bits
Reporter: Pierre Yager
Priority: Minor
The result of the TRUNC() built-in function is not coherent, and is very
complex to use.
I want to obtain a random string of 4 numeric characters from 1000 to 9999
So I type :
select cast(TRUNC(RAND() * 8999) + 1000) as varchar(4)) from rdb$database
And I get this error :
Arithmetic overflow or division by zero has occurred.arithmetic exception,
numeric overflow, or string truncation.
Because the result of RAND() is a double, the result of TRUNC(RAND()) is a
double too.
I have to cast the result into an integer in order to have this code working as
expected :
select cast(cast(trunc(rand() * 8999) + 1000 as integer) as varchar(4)) from
rdb$database
I expect that when TRUNC() is used without the second argument, the result is
ALWAYS an INTEGER or a BIGINT
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself;
WebMatrix provides all the features you need to develop and
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel