LOB Locator [message #687622] |
Wed, 19 April 2023 05:38  |
 |
fixxxer
Messages: 45 Registered: August 2014
|
Member |
|
|
Hi there,
This is a general question: I have a table with a BLOB column defined on it. There are records in this table with the BLOB column populated. I have a procedure which will update this BLOB column; it takes an IN parameter that is also of BLOB type. If I do a simple:
UPDATE blob_tbl
SET blob_column = IN_blob_value;
COMMIT;
Will this create a new LOB Locator for the UPDATED value in that BLOB column, or will it update the existing BLOB value with the content from IN_blob_value and retain the same LOB locator value?
I have tried testing this, but I am unaware of anyway to track the "LOB Locator" value, to see if it changes as part of an UPDATE statement on the BLOB column. Is there a way to SELECT/PRINT/VIEW a LOB Locator for a BLOB column?
Thanks in advance.
|
|
|
|
|
Re: LOB Locator [message #687641 is a reply to message #687626] |
Mon, 24 April 2023 02:53   |
 |
fixxxer
Messages: 45 Registered: August 2014
|
Member |
|
|
Thanks for the replies, guys.
@Michel - a BLOB instance is made up of LOB locator and value, regardless of in row or out of row. If it is in row, it is stored a BLOB object (locator and value) in row. If it is out of row, the LOB locator is stored in row, and the LOB value out. Based on the documentation at least:
Quote:
1.4 LOB Locator and LOB Value
A LOB instance has a locator and a value. A LOB locator is a reference, or a pointer, to where the LOB value is physically stored. The LOB value is the data stored in the LOB.
https://docs.oracle.com/en/database/oracle/oracle-database/23/adlob/LOB-locator-and-LOB-value.html
Some context to this question:
We store JSON data in a SecureFile BLOB column.
When the application does a GET call to the database for this BLOB information, the database returns the BLOB instance, and the application's Oracle driver is doing a subsequent RPC with the LOB locator to get the LOB value.
If an UPDATE occurs from another session, on the BLOB column for that record, in-between the JDBC call and the subsequent RPC call, the RPC call gets: ORA-22922: nonexistent LOB value.
It would appear that a direct UPDATE on the BLOB column is overwriting the existing LOB locator and LOB value with the locator and value from BLOB instance provided in the update; that makes sense in hindsight. The application that is performing the update is creating a brand new BLOB instance, and passing that to a stored procedure to update the table with; it would appear that Oracle is overwriting the entire existing BLOB instance with the new one that was instantiated by the application.
Unless I'm mistaken, the best way to guarantee read consistency of the existing LOB locator is to manipulate the existing BLOB object through DBMS_LOB.COPY, rather than a simple UPDATE. We were able to simulate the issue, and when we modified the DB code to perform a DBMS_LOB.COPY, the error disappeared.
[Updated on: Mon, 24 April 2023 02:55] Report message to a moderator
|
|
|
|
Re: LOB Locator [message #687648 is a reply to message #687642] |
Tue, 25 April 2023 03:11  |
 |
fixxxer
Messages: 45 Registered: August 2014
|
Member |
|
|
Hi SY,
Yes, this one example will produce the same error that we are seeing; but: it is not the same scenario. The issue in the example you have provided is due to the fact "dest_lob" is an IN OUT parameter, and the first code sample has only set the IN value, and not registered the OUT value.
Thanks
|
|
|