php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38065 insert with parameter marker fails
Submitted: 2006-07-11 12:29 UTC Modified: 2006-07-20 01:00 UTC
From: john dot enevoldson at pulsen dot se Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.1.4 OS: SLES 9.3 64 bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: john dot enevoldson at pulsen dot se
New email:
PHP Version: OS:

 

 [2006-07-11 12:29 UTC] john dot enevoldson at pulsen dot se
Description:
------------
When using a parameter marker with insert the insert fails
with assignment of null value to a not nullable column.
However, all columns in the table are defined with a default value. The same insert but with a hard coded value
works ok.

Reproduce code:
---------------
<?php
print "a - trying to connect...\n";
try
{
  $dbh = new PDO('odbc:zdb2lt01' , 'db2tst01', 'adg680');
  print "b - connect ok...\n";
  echo "Connected\n";
  $dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  $dbh->beginTransaction();
  $dbh->exec("insert into db2tst01.tjedms1 (kol2) values ('php-insert1')");
  echo "first insert ok \n";
  $dbh->commit();

  $stmt = $dbh->prepare("insert into db2tst01.tjedms1 (kol2) values ('php-insert2')");
  $stmt->bindParam();
  $stmt->execute();
  echo "second insert ok \n";
  $stmt = $dbh->prepare("insert into db2tst01.tjedms1 (kol2) values (:kol2)");
  $stmt->bindParam(1, $kol2, PDO::PARAM_STR, 10);
  $kol2 = 'php-insert3';
  $stmt->execute();
  echo "third insert ok \n";
  $dbh->commit();

} catch (PDOexception $e) {
  print_r($stmt->errorInfo());
  echo "Failed: " . $e->getMessage();
}

?>


Expected result:
----------------
all 3 inserts should be processed

Actual result:
--------------
only first 2 inserts processed.

third insert fails with:
Array
(
    [0] => 23502
    [1] => -407
    [2] => [IBM][CLI Driver][DB2/LINUXZ64] SQL0407N  Assignment of a NULL value to a NOT NULL column "TBSPACEID=785, TABLEID=4, COLNO=1" is not allowed.  SQLSTATE=23502
 (SQLExecute[-407] at /home/tje/php/php-5.1.4/ext/pdo_odbc/odbc_stmt.c:133)
    [3] => 23502
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-12 10:49 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-07-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 13:01:34 2025 UTC