php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58398 ' ' strings as nulls
Submitted: 2008-10-29 05:04 UTC Modified: 2009-05-29 03:56 UTC
From: gonzalo123 at gmail dot com Assigned:
Status: Closed Package: PDO_OCI (PECL)
PHP Version: 5.2.9 OS: Linux 32(Suse)
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: gonzalo123 at gmail dot com
New email:
PHP Version: OS:

 

 [2008-10-29 05:04 UTC] gonzalo123 at gmail dot com
Description:
------------
When I try to insert a space ' ' in a table with a not null value PDO_OCI throws an ORA-01400: cannot insert NULL exception. I know Oracle uses blank spaces as nuls but in this example there is not a blank space. I realice that the same problem occurs not only with a ' '. Even with more spaces. It looks that trims the value before send it to the database ('1 ' => '1').

Reproduce code:
---------------
<?php
// create table WEB.TBLDUMMY (COL1 VARCHAR2(3) not null)
$db = new PDO(
    $dsn, // my DB dsn
    $user, // database username
    $password); // database password
try {
    $db->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $db->beginTransaction();
    $stmt = $db->prepare("INSERT INTO WEB.TBLDUMMY (COL1) VALUES (:COL1)");
    $stmt->bindValue(':COL1', ' ');
    $stmt->execute();
    $db->commit();
} catch (Exception $e) {
    echo $e->getMessage();
}

Expected result:
----------------
Nothing. The script must finish without output

Actual result:
--------------
SQLSTATE[HY000]: General error: 1400 OCIStmtExecute: ORA-01400: cannot insert NULL into ("WEB"."TBLDUMMY"."COL1")
 (/opt/PDO_OCI-1.0/oci_statement.c:142)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-28 17:39 UTC] christopher dot jones at oracle dot com
Thank you for taking the time to report a problem with the package.
Unfortunately you are not using a current version of the package -- 
the problem might already be fixed. Please download a new
version from http://pecl.php.net/packages.php

If you are able to reproduce the bug with one of the latest
versions, please change the package 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 PECL.

----

I can't reproduce this with PHP 5.2.9.  PHP doesn't throw an exception.  After it completes, I can see the inserted data in SQL*Plus:

SQL> select ':'||COL1||':' from TBLDUMMY;

':'||COL1||':'
---------------
: :
 [2009-05-29 03:56 UTC] gonzalo123 at gmail dot com
I didn't test it again when I changed PHP version.
Now with 5.2.9 works perfectly as you say.

Many thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC