Solved

DBMS_LOB.ISOPEN throws the error ora-22275 invalid lob locator

Posted on 2011-03-11
4
1,791 Views
Last Modified: 2012-05-11
DBMS_LOB.ISOPEN throws the error below error.

ora-22275 invalid lob locator

The below assume that i am getting the v_lob_length as empty. But i am getting error when it comes to DBMS_LOB.ISOPEN.

Please correct me if i am wrong.

here is my code:


DBMS_LOB.createtemporary(v_xml_clob, TRUE);
DBMS_LOB.open(v_xml_clob, DBMS_LOB.lob_readwrite);

SELECT  DBMS_XMLGEN.getxml ('SELECT object_name, object_type from dba_objects where rownum <= 5')
			)
INTO    v_xml_clob
FROM    DUAL;

v_lob_length    := NVL(DBMS_LOB.getlength(v_xml_clob),0);

v_index       := 1;

fnd_file.put_line(fnd_file.log,'v_lob_length : '||v_lob_length);

WHILE v_index <= v_lob_length
LOOP
    v_read_cnt   := 32767;
    DBMS_LOB.read (
		v_xml_clob, 
		v_read_cnt, 
		v_index, 
		v_chunk
		);

    fnd_file.put(fnd_file.output,v_chunk);
    v_index := v_index + v_read_cnt;
END LOOP; 

IF DBMS_LOB.ISOPEN(v_xml_clob) = 1
THEN
    DBMS_LOB.close(v_xml_clob);
    DBMS_LOB.freetemporary(v_xml_clob);
END IF;

Open in new window

0
Comment
  • 2
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 35109140
The problem is selecting into a CLOB reinitializes the lob locator.  When the select returns no rows the lob is actually NULL and not initialized.

There is no need to create a temporary lob when you are selecting into one.
declare
	v_xml_clob clob;
	v_lob_length number;
	v_index number;
    v_read_cnt number;
	v_chunk varchar2(32767);
begin


SELECT  DBMS_XMLGEN.getxml ('SELECT object_name, object_type from dba_objects where rownum <= 5')
INTO    v_xml_clob
FROM    DUAL;


v_lob_length    := NVL(DBMS_LOB.getlength(v_xml_clob),0);

v_index       := 1;

--fnd_file.put_line(fnd_file.log,'v_lob_length : '||v_lob_length);

WHILE v_index <= v_lob_length
LOOP
    v_read_cnt   := 32767;
    DBMS_LOB.read (
		v_xml_clob, 
		v_read_cnt, 
		v_index, 
		v_chunk
		);

    --fnd_file.put(fnd_file.output,v_chunk);
    v_index := v_index + v_read_cnt;
END LOOP; 

end;
/

Open in new window

0
 

Author Comment

by:Suriyaraj_Sudalaiappan
ID: 35109225
Thanks for your reply. I have another doubt. In your code, no need to use the below condition?? if yes, why?

IF DBMS_LOB.ISOPEN(v_xml_clob) = 1
THEN
    DBMS_LOB.close(v_xml_clob);
END IF;
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35109486
You only need to close a CLOB when you manually open it.
0
 

Author Closing Comment

by:Suriyaraj_Sudalaiappan
ID: 35122678
GOOD ONE
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
help on oracle query 5 52
Oracle DBLINKS From 11g to 8i 3 47
Error in creating a view. 8 19
setting local variables in a cursor block 3 17
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question