(copied to comp.databases.ibm-db2)
Greetings,
Settings:
DBD::DB2 v0.76
DBI v1.38
Perl v5.8.0
IBM DB2 ESE v8.1 sp 4
RedHat Linux 9
Problem:
I am doing DB2 access via perl DBI but have trouble with fetching negative REAL value:
i.e. SELECT X FROM TABLE FETCH FIRST ROWS ONLY;
In this case, X is "-1" and the query should return "-1". But instead I have this error message and no data retrieved:
[error] DBD::DB2::st fetchrow_array failed: [IBM][CLI Driver] CLI0111E Numeric value out of range. SQLSTATE=22003
The same SQL works fine in command line mode. As you may know, REAL is 4 byte single-precision float-point in DB2. The value can be:
zero, or
-3.402E+38 to -1.175E-37, or
1.175E-37 to -3.402E+38.
In DBD::DB2, it should map to SQL_REAL ($sth->{TYPE} returns data type 7). But instead, I haven't found anything in the module. It seems all the postive values of REAL work fine and so does any converted DOUBLE and CHAR. To prove this, I have tested these SQL statements:
SELECT abs(X) FROM TABLE FETCH FIRST ROWS ONLY;
SELECT double(X) FROM TABLE FETCH FIRST ROWS ONLY;
SELECT char(X) FROM TABLE FETCH FIRST ROWS ONLY;
All of them work properly with DBD::DB2. Thus I believe this is a BUG. Could anyone please advice?
Many thanks in advance,
Bing