Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to check if a clob variable is freed by dbms_lob.freetemporary

Mustafa KALAYCINov 16 2022 — edited Nov 16 2022

Hi,
out of curiosity, I freed a clob via dbms_lob.freetemporary but how can I check if it is freed? I want to recreate a temporary clob but "is null" condition is not working. any operation like getlength in dbms_lob cause invalid lob locator since it is freed. is there a way:

set serveroutput on;


declare
  x_clob clob := 'A';
begin
  dbms_lob.freetemporary(x_clob);
  
  if x_clob is null then
    dbms_output.put_line('it is null, create temporary');
    --x_clob := empty_clob();
    dbms_lob.createtemporary(x_clob, true);
  else
    dbms_output.put_line('not null');
    --return;
  end if;
  x_clob := x_clob || 'a';
end;
/ 

when you run the code above it will show output "not null" and then error because of:
x_clob := x_clob || 'a';
because it tries to read x_clob variable at the right side of the assignment. how can I check if a clob (blob) object is freed. I know I can assign null or empty_clob instead of using dbms_lob.freetemporary but I am curious if there is a way. thanks.

This post has been answered by Jonathan Lewis on Nov 16 2022
Jump to Answer
Comments
Post Details
Added on Nov 16 2022
8 comments
1,052 views