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>
/>
Note 261822.1 refers to UNC drives:
UNC notations are disallowed due to security risksSo, 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>