MDB2: NULL in LOB fields
| From: | Lukas Smith | Date: | Mon, 17 Jan 2005 13:23:45 +0000 |
| Subject: | MDB2: NULL in LOB fields | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-35533@lists.php.net to get a copy of this message | ||
Hi,
I have a serious problem with the LOB handling in oracle. Specifically it seems like its impossible to insert a NULL value into a LOB field using prepared queries unless that field is set to NULL in the prepared query itself.
MDB2 can already handle doing the necessary changes to a prepared query. But until now this meant doing a prepare call for every execute() call.
The theory beind prepared statements is that you define the structure of the query once and have the RDBMS analyze that and then define the data to be used inside (mutliple) subsequent calls to execute().
For example:
INSERT INTO foo (fetter_blob, netter_clob) VALUES (?, ?)
However if for example you have two LOB fields and you want to insert a binary in one and NULL in the other you have a problem. In order for the query to work only oracle with two LOB fields the query would need to be prepared like so:
INSERT INTO foo (fetter_blob, netter_clob) VALUES (EMPTY_BLOB(), EMPTY_CLOB()) RETURNING 0, 1 INTO :0, :1
In order to be able to insert a NULL value into the clob field the query would have to be prepared like so:
INSERT INTO foo (fetter_blob, netter_clob) VALUES (EMPTY_BLOB(), NULL) RETURNING 0 INTO :0
I actually talked this through with a rep from Oracle and we didnt find a solution. Putting in a hack to generate another prepared statement if a LOB field is set to NULL doesnt seem to be feasible to me. Therefore I guess the solution is to document and leave as is. I dont want to go back to the old solution which did a new prepared statement for every execute() call.
regards,
Lukas