2

Надо импортировать XML файл в Oracle XMLDB.
Вроде делаю все по правилам:

  1. CREATE TABLE orders OF XMLTYPE
    
  2. CREATE DIRECTORY TT AS '/home/oracle/Desktop/contract_test/'(GRANT READ ON DIRECTORY TT TO superuser;)`
    
  3. INSERT INTO ORDERS VALUES (xmltype(bfilename('TT', 'contract.xml'), nls_charset_id('utf-8')));
    

На выходе получаю эту ошибку:

Error starting at line : 1 in command - INSERT INTO ORDERS VALUES
(xmltype(bfilename('TT', 'contract.xml'), nls_charset_id('utf-8')))
Error report - SQL Error: ORA-22288: file or LOB operation FILEOPEN
failed No such file or directory
22288. 00000 - "file or LOB operation %s failed\n%s"
*Cause: The operation attempted on the file or LOB failed.
*Action: See the next error message in the error stack for more detailed
information. Also, verify that the file or LOB exists and that
the necessary privileges are set for the specified operation. If
the error still persists, report the error to the DBA.

Эта ошибка возникает даже, если я делаю под system аккаунтом. Не только под тем, который я сам создал (с полным доступом).

2
  • В п.2 команда выглядит как то странно, по видимому вы ошиблись при копи+паста. Как в сообщении об ошибке сказано, вставка не может найти файл. Добавте вывод команды ls -la в указаном каталоге.
    – 0xdb
    6 июн 2018 в 18:37
  • Через консоль проверял путь, смотря на ошибку, ещё до поста. Через консоль все отлично 7 июн 2018 в 6:41

1 ответ 1

2

Для импорта XML данных из файловой системы в таблицу, надо поместить файл в папку, для которой существует объект каталога (directory object) в схеме БД. Так же, необходимо дать разрешение на чтение. Прав на чтение на уровне БД недостаточно, нужны также права на уровне файловой системы ОС.

Например, так будет работать:

~$ mkdir inbound; cd inbound
~/inbound$ echo "<id>1</id>" >contract.xml

~/inbound$ chmod o+rx .
~/inbound$ chmod o+r contract.xml

~/inbound$ pwd
/home/db/inbound

SQL> create table contracts of xmlType;
Table created.

SQL> create directory xmldoc as '/home/db/inbound';
Directory created.

SQL> insert into contracts values (
         xmlType (bfilename ('XMLDOC', 'contract.xml'), nls_charset_id ('AL32UTF8')));

1 row created.

SQL> select c.object_value.getClobVal () doc from contracts c ;
DOC
--------------------------------
<id>1</id>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.