Skip to Main Content
  • Questions
  • Ora 22288 while trying to wirte an XML file to a clob column

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sattam.

Asked: November 04, 2016 - 2:19 pm UTC

Last updated: November 04, 2016 - 3:45 pm UTC

Version: Release 11.2.0.4.0

Viewed 1000+ times

You Asked

Hi Tom,
I am trying to put the contents of an xml into a clob column of a table in database using a sql query and am not being able to do so. I am getting
<ORA-22288: file or LOB operation FILEOPEN failed
ORA-06512: at "SYS.XMLTYPE", line 296
ORA-06512: at line 1
ORA-06512: at line 3/>

However, that there is no access problem may be established through the fact that I can write to the file alright using utl_file. The only related thread that possibly has similar problem described is
https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::p11_question_id:232814159006
where you have advised to "see Note 261822.1 on metalink. ". However, I do not have access to metalink hence putting up a new question on this site.

The below will establish what I am doing.

<
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0
Connected as orauser@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = <Edited this to DUMMY>)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = V3DEV) ) )

SQL> create or replace directory XML_DIR_PATH as '\\CTSC00321836202\XML_STORAGE';

Directory created

SQL> create table ASTRANSACTION
2 (
3 transactionguid CHAR(36),
4 xmldata CLOB
5 )
6 /

Table Created

SQL>
SQL> Declare
2 file1 utl_file.file_type;
3 Begin
4 file1:= utl_file.fopen('XML_DIR_PATH','SAMPLE_XML.xml','a');
5 utl_file.put_line(file1,'Welcome' );
6 utl_file.fclose(file1);
7
8 end;
9 /

PL/SQL procedure successfully completed

SQL>
SQL> BEGIN
2 INSERT INTO ASTRANSACTION VALUES ('123',XMLTYPE(BFILENAME('XML_DIR_PATH','SAMPLE_XML.xml'), NLS_CHARSET_ID('AL32UTF8'))
3 .GETCLOBVAL());
4 COMMIT;
5 END;
6 /

BEGIN
INSERT INTO ASTRANSACTION VALUES ('123',XMLTYPE(BFILENAME('XML_DIR_PATH','SAMPLE_XML.xml'), NLS_CHARSET_ID('AL32UTF8'))
.GETCLOBVAL());
COMMIT;
END;

ORA-22288: file or LOB operation FILEOPEN failed
ORA-06512: at "SYS.XMLTYPE", line 296
ORA-06512: at line 1
ORA-06512: at line 3

SQL>
/>

and Chris said...

Note 261822.1 refers to UNC drives:

UNC notations are disallowed due to security risks

So, is your directory defined as a Universal Naming Convention drive?

Your code works for me. If you make the file valid XML!

create table ASTRANSACTION (
  transactionguid CHAR(36),
  xmldata CLOB
)
/

Declare

  file1 utl_file.file_type;

begin

  file1:= utl_file.fopen('TMP','test.xml','a');
 utl_file.put_line(file1,'<?xml version="1.0" encoding="UTF-8"?>
<tag>Welcome</tag>' );
  utl_file.fclose(file1);

end;
/

BEGIN

  INSERT INTO ASTRANSACTION VALUES ('123',XMLTYPE(BFILENAME('TMP','test.xml'), NLS_CHARSET_ID('AL32UTF8')).getClobVal());
  COMMIT;

END;
/
select * from ASTRANSACTION;

TRANSACTIONGUID                       XMLDATA                                                       
123                                   <?xml version="1.0" encoding="DEC-MCS"?>
<tag>Welcome</tag>

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A big thank you

Sattam, November 05, 2016 - 9:16 am UTC

Thank you for your reply.

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here