Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.0

Bug #3281 empty_clob/empty_blob handling does not work with oracle
Submitted: 2005-01-24 14:30 UTC
From: ogmueller Assigned:
Status: Bogus Package: MDB
PHP Version: 4.3.9 OS: Win2003
Roadmaps: (Not assigned)    
Subscription  


 [2005-01-24 14:30 UTC] ogmueller
Description: ------------ When using Oracle and MDB, it is not possible to send inserts or updates with empty LOBs, even if the database schema would allow a null value. E.g. a normal insert might look like this: INSERT INTO table (id, lob_value) VALUES ( 1, :lob_value ); But if the LOB value is null or "", this query must be changed into something like the following: INSERT INTO table (id, lob_value) VALUES ( 1, empty_clob() ); or INSERT INTO table (id, lob_value) VALUES ( 1, empty_blob() ); And in this case no descriptor should be created. With the actual stable version of MDB, the result of an empty LOB is an error message saying: "Do query: Could not upload clob data" (oci8.php line 474) Reproduce code: --------------- Try to execute any insert or update query with an empty LOB value. Expected result: ---------------- Execution should be not problem if the LOB value is allowed to be null (DB schema) Actual result: -------------- Error message: "Do query: Could not upload clob data" (oci8.php line 474)

Comments

 [2005-01-24 15:01 UTC] smith at backendmedia dot com
Are you talking about the CVS version of MDB2? Because there NULL handling for Oracle is broken and likely to not be fixed. In MDB and the last MDB2 it should work ok. Have you tried running the test suite?
 [2005-01-24 17:17 UTC] ogmueller
No, I am using MDB v1.3.0
 [2005-01-24 17:19 UTC] smith at backendmedia dot com
So are you experiencing this problem with when you pass php null or an empty string or only with empty strings?
 [2005-01-24 17:53 UTC] ogmueller
I receive this error message in both cases (null and "").
 [2005-01-24 19:54 UTC] smith at backendmedia dot com
Ok, could you try and run the test suite. You can find it in the tests dir inside your PEAR directory. There is a test that is specifically aimed at testing inserting of null values into LOB's and it worked when I made that release. Also some more information about your particular setup would be helpful. What oracle server are you using? Anything else worth mentioning?
 [2005-01-25 08:20 UTC] ogmueller
More Information: Oracle is in version 9.2. The executed code is like the following: // create LOB $contentCLOB = array( 'Error' => '', 'Data' => $sessionData ); $clob = $DB->createLob($contentCLOB); if( true === MDB::isError( $clob ) ) { return false; } $query = 'INSERT INTO session (user_id, php_id, ip_address, modified, content) VALUES (?, ?, ?, ?, ?)'; $prep = $DB->prepareQuery( $query ); $DB->setParamText( $prep, 1, $userID ); $DB->setParamText( $prep, 2, $phpID ); $DB->setParamText( $prep, 3, $_SERVER['REMOTE_ADDR'] ); $DB->setParamTimestamp( $prep, 4, date( 'Y-m-d H:i:s' ) ); $DB->setParamClob( $prep, 5, $clob, 'CONTENT' ); $res = $DB->execute( $prep ); $DB->destroyLob($clob); I tried to run the test environment, but it is not able to even create the neccessary table, even though the oracle user can create and drop tables: mdb_manager_testcase : Starting testcreatedatabase ... PEAR-Error MDB Error: not supported: Drop database: database dropping is not supported Failure 1 : Database creation not supported expected TRUE, actual FALSE There were 1 failures for testcreatedatabase There were 0 errors for testcreatedatabase Is there any way to turn on a debug mode or something?
 [2005-01-25 12:23 UTC] smith at backendmedia dot com
Actually since oracle lacks the concept of a database like other RDBMS have it, MDB emulates it with "users". I will try to get to finding a way to reproduce this sometime this week. However until early next month I will be stressed out.
 [2005-02-05 11:45 UTC] smith at backendmedia dot com
Finally I got some time to look at things. It seems you are using the API incorrectly: http://cvs.php.net/co.php/pear/MDB/tests/MDB_usage_testcase.php Have a look at line 1067 and following. In MDB its your job to determine if you want to set a value as NULL using the setParamNull() method.
 [2005-02-07 06:45 UTC] ogmueller
I tought MDB should help the user to use databases more transparently and make them much more "compatible". The problem that I had is, that oracle doesn't know the difference between "" and NULL, as good DBMSes do. Basically I did not want to write NULL values, but empty strings into the CLOB. I hoped, that in case of oracle the driver should make the empty string "" oracle compatible and convert it into a null value automatically. (e.g. in case of MySQL it can stay as it is) I agree to you, that it is my business to use emptyClob, if I want to put a NULL value into the DB. This feature would help to increase compatibility even more.
 [2005-02-07 09:16 UTC] smith at backendmedia dot com
I have added this feature into MDB2.