#38065 [Opn->Fbk]: insert with parameter marker fails
| From: | tony2001@php.net | Date: | Wed, 12 Jul 2006 10:49:47 +0000 |
| Subject: | #38065 [Opn->Fbk]: insert with parameter marker fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-99341@lists.php.net to get a copy of this message | ||
ID: 38065
Updated by: tony2001@php.net
Reported By: john dot enevoldson at pulsen dot se
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: SLES 9.3 64 bit
PHP Version: 5.1.4
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2006-07-11 12:29:20] 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
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38065&edit=1