Home > Blockchain >  ORA-22288: passing xml file to SQL Developper
ORA-22288: passing xml file to SQL Developper

Time:12-31

Do you have an idea how to solve this error? The file exists on my computer, but something is going wrong. I have created a XML file, later I have created a schema for it (.xsd) and now I want to connect the schema file with my oracle data base and after this function I would create a table for this schema.

I have also tried to place file in oracle directory, but it doesn't help.

BEGIN
  DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL => 'http://xmlns.oracle.com/xdb/documentation/peldesana.xsd',
    SCHEMADOC => bfilename('MAPE','peldesana.xsd'),
    LOCAL     => TRUE,
    GENTYPES  => FALSE, 
    GENTABLES => FALSE, 
    CSID      => nls_charset_id('AL32UTF8'));
END;

Error:

ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "SYS.DBMS_LOB", line 822
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 131
ORA-06512: at line 2
22285. 00000 - "non-existent directory or file for %s operation"

*Cause: Attempted to access a directory that does not exist, or attempted to access a file in a directory that does not exist.
*Action: Ensure that a system object corresponding to the specified directory exists in the database dictionary, or make sure the name is correct.

CodePudding user response:

Creating a directory isn't enough.

A directory, object which points to a file system directory (folder), is created by SYS.

SQL> connect sys as sysdba
Enter password:
Connected.
SQL> create or replace directory xml_dir as 'c:\temp';

Directory created.

Then you have to grant privileges on that directory to user which will be using it. If you'll only read data from it, grant read; if you'll also create files there, grant write as well:

SQL> grant read, write on directory xml_dir to scott;

Grant succeeded.

SQL>

Now, user scott will be able to access directory and files within.

CodePudding user response:

In the end I have generated.xsd file once more (using the same .xml file). And then I added one more line (OPTIONS => 2), everything works now.

BEGIN
  DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL => 'http://xmlns.oracle.com/xdb/documentation/peldesana2.xsd',
    SCHEMADOC => bfilename('INPUT_DIR','peldesana2.xsd'),
    LOCAL     => TRUE,
    GENTYPES  => FALSE, 
    GENTABLES => FALSE, 
    CSID      => nls_charset_id('AL32UTF8'),
    OPTIONS    => 2);
END;
  • Related