#38065 [NEW]: insert with parameter marker fails
From: john dot enevoldson at pulsen dot se
Operating system: SLES 9.3 64 bit
PHP version: 5.1.4
PHP Bug Type: PDO related
Bug description: insert with parameter marker fails
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 bug report at http://bugs.php.net/?id=38065&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38065&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38065&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38065&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38065&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=38065&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38065&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38065&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38065&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38065&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38065&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=38065&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=38065&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38065&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38065&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38065&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38065&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38065&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38065&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38065&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38065&r=mysqlcfg
Thread (2 messages)
- john dot enevoldson at pulsen dot se