|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57049 Overflow when fetching data from Double field in DB2/UDB/Cloudscape
Submitted: 2006-05-30 04:22 UTC Modified: 2006-10-10 23:11 UTC
From: royb at ubiquity dot com dot au Assigned: wez (profile)
Status: Closed Package: PDO_ODBC (PECL)
PHP Version: 5.1.2 OS: XP IIS 5.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: royb at ubiquity dot com dot au
New email:
PHP Version: OS:


 [2006-05-30 04:22 UTC] royb at ubiquity dot com dot au
Installed Windows 5.1.4 on discovering error but made no difference.

hence using 

php_pdo_odbc.dll version

Tried against the following databases
UDB2 version 8.1
DB2(zOS) Version 8
Cloudscape version 10.1

All failed

Unless the DOUBLE field contains a NULL then OK.

Note replacing PDO with db2_connect does not generate the error.

Reproduce code:
Create table tableA

  fldA DOUBLE,
  PRIMARY KEY(name) );

Insert a row:

insert into APP.tableA
(NAME,fldA ,fldB ) Values('Baz',3,2000); 

Execute a select statement like
   'Select fldA, fldB from APP.tableA'

Where field fldA is created as a DOUBLE and fldB is an INTEGER.


Cast any valid field to a DOUBLE seems to generate the error.

'Select CAST(fldB as DOUBLE) as testfld from tableA'

example code:

try {
     $dbh = new PDO($constrng, $user, $pass);
     echo 'Connected';

    } catch (PDOexception $exp) {
    echo 'Exception: ' . $exp->getMessage();
   $sql = "Select fldA, fldB from APP.tableA;";	
   $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR,PDO::CURSOR_FWDONLY));
   print "results for $sql \n\n";
   $rows = $sth->fetchAll();

Actual result:
Returns the following error message.

SQLSTATE[22003]: Numeric value out of range: -99999 [IBM][CLI Driver] CLI0111E Numeric value out of range. SQLSTATE=22003 (SQLFetchScroll[-99999] at ext\pdo_odbc\odbc_stmt.c:372)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-28 11:42 UTC] simonslaws at googlemail dot com
I am getting this also in 5.1.4 on windows XP. It is the root cause of SDO error 7880 ( 

I think the problem is down in the odbc_stmt.c::odbc_stmt_describe() function. SQLDescribeCol is used to get the column size. SQLDescribeCol though returns the column precision. More characters are required to store a float, double etc. than indicated by precision as, in character form, they have the E+000 bit on the end. I made the following change to fix it in my checked out code. (+ = new lines). I have only tried this on windows and only against DB2. B.t.w. sorry for the stupid question but is there a way I can attach a patch to a bug report rather than inline it?

static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
	pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
	struct pdo_column_data *col = &stmt->columns[colno];
	zend_bool dyn = FALSE;
	SWORD	colnamelen;
	SDWORD	colsize;

	rc = SQLDescribeCol(S->stmt, colno+1, S->cols[colno].colname,
			sizeof(S->cols[colno].colname)-1, &colnamelen,
			&S->cols[colno].coltype, &colsize, NULL, NULL);

	if (rc != SQL_SUCCESS) {
		return 0;

+	// The colsize that is returned above is actually the column precision.
+	// For a floating point number this does not represent how many
+	// bytes are required to store it in a char array as you need
+	// to store the E+000 bit as well.
+	rc = SQLColAttribute(S->stmt,
+                         colno+1,
+                         SQL_DESC_DISPLAY_SIZE,
+                         NULL,
+                         0,
+                         NULL,
+                         &colsize);
+	if (rc != SQL_SUCCESS) {
+		pdo_odbc_stmt_error("SQLBindCol");
+		return 0;
+	}
 [2006-10-10 23:11 UTC]
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

Thanks for the patch!
Fix will be in PHP 5.2
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 25 20:05:45 2022 UTC