Home » SQL & PL/SQL » SQL & PL/SQL » dbms_xslprocessor.read2clob read issue (Oracle 11g, Windows 7)
dbms_xslprocessor.read2clob read issue [message #590951] Wed, 24 July 2013 05:58 Go to next message
lokimisc
Messages: 101
Registered: February 2008
Senior Member
Hi,
I'm trying to load xml file into table using dbms_xslprocessor.read2clob package, it loads for small file, but it throws READ ERROR for big file.
I have given READ, WRITE permission on directory and also DBA role to user.
Also I have attached file (change file extension to xml)


Please check below given code and request to help in finding what I'm doing wrong.

CREATE TABLE loadxmlfile (xmldata CLOB);
CREATE TABLE loadxml (id NUMBER, xmldata XMLTYPE);

create or replace PROCEDURE load_xmlfile
  (
     inp_filename  VARCHAR2
    ,inp_dirname   VARCHAR2 DEFAULT NULL   
  ) AS
 
     v_xlob                 CLOB;
     v_dir_not_exists       EXCEPTION;
     v_id NUMBER(5);

  BEGIN
        v_xlob := dbms_xslprocessor.read2clob('SCOTTDIR', inp_filename);
       
        INSERT INTO loadxmlfile VALUES(v_xlob);

        -- Remove non breaking space - CHR(160) with space
        UPDATE loadxmlfile SET xmldata = REPLACE(xmldata, CHR(160), ' ') ;    

        SELECT MAX(id) INTO v_id FROM loadxml;
        INSERT INTO loadxml
           (id, xmldata)
        SELECT v_id, xmltype(xmldata)  FROM loadxmlfile;
   
        COMMIT;
   
  EXCEPTION   
     WHEN v_dir_not_exists THEN
      DBMS_OUTPUT.PUT_LINE('v_dir_not_exists '||SQLERRM);
    
     WHEN utl_file.access_denied THEN
      DBMS_OUTPUT.PUT_LINE('access_denied '||SQLERRM);         
       
     WHEN utl_file.read_error THEN
      DBMS_OUTPUT.PUT_LINE('read_error '||SQLERRM);         

     WHEN OTHERS THEN
           DBMS_OUTPUT.PUT_LINE('OTHERS '||SQLERRM);
  END load_xmlfile;



Note:
Reason I'm doing is to remove NON BREAKING SPACE (NBS) character from xml file

Regards,
Lokesh
Re: dbms_xslprocessor.read2clob read issue [message #590956 is a reply to message #590951] Wed, 24 July 2013 06:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68769
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Remove EXCEPTION part and copy and paste your execution.

Regards
Michel
Re: dbms_xslprocessor.read2clob read issue [message #591096 is a reply to message #590956] Wed, 24 July 2013 14:11 Go to previous messageGo to next message
lokimisc
Messages: 101
Registered: February 2008
Senior Member
Thanks Michel for your response.
create or replace PROCEDURE load_xmlfile
  (
     inp_filename  VARCHAR2
    ,inp_dirname   VARCHAR2 DEFAULT NULL   
  ) AS
 
     v_xlob                 CLOB;
     v_dir_not_exists       EXCEPTION;
     v_id NUMBER(5);

  BEGIN
        v_xlob := dbms_xslprocessor.read2clob('SCOTTDIR', inp_filename);
       
        INSERT INTO loadxmlfile VALUES(v_xlob);

        -- Remove non breaking space - CHR(160) with space
        UPDATE loadxmlfile SET xmldata = REPLACE(xmldata, CHR(160), ' ') ;    

        SELECT MAX(id) INTO v_id FROM loadxml;
        INSERT INTO loadxml
           (id, xmldata)
        SELECT v_id, xmltype(xmldata)  FROM loadxmlfile;
   
        COMMIT;
END;


The above code is throwing READ ERROR exception, even though I have given READ, WRITE permission on the directory and also granted DBA roles.
Also could you please let me know, how to check privilege given to user on DBMS package..?

Thanks & Regards,
Lokesh
Re: dbms_xslprocessor.read2clob read issue [message #591098 is a reply to message #591096] Wed, 24 July 2013 14:40 Go to previous messageGo to next message
Michel Cadot
Messages: 68769
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
The above code is throwing READ ERROR exception


I don't believe you. Prove it.

Regards
Michel
Re: dbms_xslprocessor.read2clob read issue [message #591182 is a reply to message #591098] Thu, 25 July 2013 06:49 Go to previous messageGo to next message
lokimisc
Messages: 101
Registered: February 2008
Senior Member
Michel, I'm getting below given error message when program executed.
Also could you please let me know, how to check whether user been given DBMS packages privilege

Please let me know, if you need more info.

ORA-29284: file read error
ORA-06512: at "SYS.UTL_FILE", line 127
ORA-06512: at "SYS.UTL_FILE", line 1204
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 268
ORA-06512: at "SCOTT_NEW.FILE_LOADER", line 70

Regards,
Lokesh
Re: dbms_xslprocessor.read2clob read issue [message #591193 is a reply to message #591182] Thu, 25 July 2013 07:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68769
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
ORA-29284: file read error
 *Cause:  An attempt to read from a file failed.
 *Action: Verify that the file exists, and that it is accessible, and
          that it is open in read mode.

Regards
Michel
Re: dbms_xslprocessor.read2clob read issue [message #591197 is a reply to message #591096] Thu, 25 July 2013 08:05 Go to previous message
Solomon Yakobson
Messages: 3305
Registered: January 2010
Location: Connecticut, USA
Senior Member
lokimisc wrote on Wed, 24 July 2013 15:11
The above code is throwing READ ERROR exception, even though I have given READ, WRITE permission on the directory and also granted DBA roles.


Do not confuse database read/write privileges with OS permissions. In Oracle you create a database object and grant privileges to users. All that means Oracle user can issue dtabase read/write operation against directory object. It doesn't mean granting read/write of a physical OS directory and/or file in that OS directory. Any file operation triggered by database code runs under OS user oracle (OS user oracle software was installed under, to be precise). So you need to make sure OS user oracle can read that OS file dbms_xslprocessor.read2clob('SCOTTDIR', inp_filename); is pointing to.

SY.
P.S. And, as a sanity check, any file operation you ask database server to do implies database server directory, not a directory on your client box. So if client and database server are two separate boxes you can't access files on your client box this way.
Previous Topic: How to select from a PL/SQL table?
Next Topic: ORA ERROR:01950 NO PRIVILEGES ON TABLESPACE 'USERS'
Goto Forum:
  


Current Time: Tue Sep 02 20:34:44 CDT 2025