php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57079 SQLSTATE 22005 with DB2
Submitted: 2006-06-12 10:15 UTC Modified: 2006-10-30 06:33 UTC
From: simonslaws at googlemail dot com Assigned: cem (profile)
Status: Not a bug Package: SCA_SDO (PECL)
PHP Version: 5.1.2 OS: Windows XP
Private report: No CVE-ID: None
 [2006-06-12 10:15 UTC] simonslaws at googlemail dot com
Description:
------------
PHP 5.1.2
SDO 1.0.1
DB2 8.2FP12

When creating a a new row in a simple table $das->applyChanges () returns with SQLSTATE 22005 indicating that it thinks that there is a type missmatch between the expected column types and the provided column types. 

It should be noted that this example works with PHP 5.1.4 so maybe this is just a case of pointing out that this problem can arrise with PHP 5.1.2

Reproduce code:
---------------
Simple table

-- CREATE TABLE "INTEROP"."ALLTYPE"  (
CREATE TABLE "SIMON"."ALLTYPE"  (
		  "ASMALLINT" SMALLINT NOT NULL , 
		  "AINT" INT,
		  "AVARCHAR" VARCHAR(14))   
		 IN "USERSPACE1" ; 
ALTER TABLE "SIMON"."ALLTYPE" 
	ADD PRIMARY KEY
		("ASMALLINT");

Simple test to read data and insert a row

    // Describe the structure of the alltype table
    $alltype_table = array('name' => 'alltype',
                           'columns' => array('asmallint', 'aint', 'avarchar'),
                           'PK' => 'asmallint');
...

      // construct the SQL query for alltype retrieval
      $stmt = "select asmallint, aint, avarchar from alltype";
    
      // execute the query to retrieve the departments
      $root = $das->executeQuery($dbh, $stmt);

...
      //create a new row in the table
      $newrow = $root -> createDataObject('alltype');
      
      // set the properties
      $newrow->asmallint = $count;
      $newrow->aint = 4;
      $newrow->avarchar = 'PHP XP';

      $das->applyChanges($dbh, $root);

Gives rise to follwoing error. The test code works fine on MySQL so it would seem that there is something suspect about the SDO/PDO ODBC/DB2 path

SDO/DAS/Relational.php::applyChanges encountered an error when attempting to exe
cute INSERT INTO alltype (asmallint,aint,avarchar) VALUES (?,?,?);
PDO reported no rows affected by the SQL statement.
This may happen if the data that was retrieved and updated has been changed by a
nother processs in the database in the meantime.
The error information returned from PDO::errorInfo() was:
  SQLSTATE: 22005
  Driver-specific error code: -99999
  Driver-specific error message: [IBM][CLI Driver] CLI0112E  Error in assignment
. SQLSTATE=22005 (SQLExecute[-99999] at ext\pdo_odbc\odbc_stmt.c:133)
All changes have been rolled back.<br/><br/>

Expected result:
----------------
I expected a new row to be added to the database

Actual result:
--------------
Failed with SQLSTATE 22005 indicating that DB2 thinks that there is a type missmatch between the expected column types and the provided column types. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-13 04:57 UTC] cem@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PEAR.

It's most likely that what youre seeing here is the same as http://bugs.php.net/bug.php?id=35830, where the same symptom was seen using PDO with DB2. 

That bug was fixed in a later release of PHP/PDO.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Nov 19 21:01:35 2019 UTC