|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-12 10:49 UTC] tony2001@php.net
[2006-07-20 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Jun 19 20:00:02 2026 UTC |
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 )