From:             jseverson at myersinternet dot com
Operating system: Redhat Linux kernel 2.4.18-3
PHP version:      4.3.4
PHP Bug Type:     OCI8 related
Bug description:  OCI clob column objects inconsistent in result set

Description:
------------
When handling clob columns in Oracle, PHP is inconsistent in the way that
it returns the result set of your query containing that clob column when
the clob is null. In one case, the result set contains an Object, and in
another case, the result set doesn't contain any Object, even though in
both cases, the VALUE of the object after load() is "empty" (column is
null).



We believe what causes these two different cases is that in the case of an
Object being returned, the table being queried had multiple (3) clob
columns. The other case when no Object was returned, the table being
queried had only one (1) clob column.



This makes it nearly impossible to handle your result set data since you
can't call the load() function if the object doesn't exist without getting
an error, but on the other hand, you can't check whether or not the clob
is empty because an Object is present even when the Object has no value.



It seems like the correct behavior would be to always return an Object, so
that you don't have to first check whether or not the Object is empty or
not, before called the load() OCI function.

Reproduce code:
---------------
//table_a has one clob and clob is null

$sql = "select * from test_schema.table_a where primary_key=1";

$stmt = OCIParse($conn_ora, $sql);

OCIExecute($stmt, OCI_DEFAULT);

OCIFetchInto($stmt, $table_a_row, OCI_ASSOC);

OCIFreeStatement($stmt);



echo "<pre>";

var_dump($table_a_row);



//table_b has multiple clobs (3) and all clobs are null

$sql = "select * from test_schema.table_b where primary_key=1";

$stmt = OCIParse($conn_ora, $sql);

OCIExecute($stmt, OCI_DEFAULT);

OCIFetchInto($stmt, $table_b_row, OCI_ASSOC);

OCIFreeStatement($stmt);



echo "<pre>";

var_dump($table_b_row);

Expected result:
----------------
array(1) {

  ["CLOB_1"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(9) of type (oci8 descriptor)

  }

}

array(3) {

  ["CLOB_1"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(10) of type (oci8 descriptor)

  }

  ["CLOB_2"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(11) of type (oci8 descriptor)

  }

  ["CLOB_3"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(12) of type (oci8 descriptor)

  }

}



------------------  OR  -----------------



array(0) {

}

array(0) {

}



Actual result:
--------------
array(0) {

}

array(3) {

  ["CLOB_1"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(9) of type (oci8 descriptor)

  }

  ["CLOB_2"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(10) of type (oci8 descriptor)

  }

  ["CLOB_3"]=>

  object(OCI-Lob)(1) {

    ["descriptor"]=>

    resource(11) of type (oci8 descriptor)

  }

}

-- 
Edit bug report at http://bugs.php.net/?id=27485&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27485&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27485&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27485&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27485&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27485&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27485&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27485&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27485&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27485&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27485&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27485&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27485&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27485&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27485&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27485&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27485&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27485&r=float

Reply via email to