重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1118|回复: 0
打印 上一主题 下一主题

[参考文档] xdb 模式注册报错:ORA-31001

[复制链接]
跳转到指定楼层
楼主
发表于 2023-4-23 12:34:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
In this Document

Symptoms

Cause

Solution

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.1 and later

Oracle Database Cloud Schema Service - Version N/A and later

Oracle Database Exadata Express Cloud Service - Version N/A and later

Oracle Database Exadata Cloud Machine - Version N/A and later

Oracle Cloud Infrastructure - Database Service - Version N/A and later

Information in this document applies to any platform.


SYMPTOMS

The following error is seen when registering a schema as below:



SQL> BEGIN

DBMS_XMLSCHEMA.registerSchema(

'http://localhost:8080/source/schemas/poSource/xsd/purchaseOrder.xsd',

XDBURIType('/source/schemas/poSource/xsd/purchaseOrder.xsd').getClob(),

TRUE,

TRUE,

FALSE,

TRUE);

END;

/

BEGIN

*

ERROR at line 1:

ORA-31001: Invalid resource handle or path name

"/source/schemas/poSource/xsd/purchaseOrder.xsd"

ORA-06512: at "SYS.XDBURITYPE", line 4

ORA-06512: at line 2



The folders for containing the schema document have already been created in the XDB repository:



SQL> declare

res boolean;

begin

res := dbms_xdb.createFolder('/source/');

end;

/


SQL> declare

res boolean;

begin

res := dbms_xdb.createFolder('/source/schemas/');

res := dbms_xdb.createFolder('/source/schemas/poSource/');

res := dbms_xdb.createFolder('/source/schemas/poSource/xsd/');

commit;

end;

/

CAUSE

A resource has NOT been created within the XDB repository for the actual schema document purchaseOrder.xsd.

Hence the registerSchema cannot locate the document, and hence the error:


ORA-31001: Invalid resource handle or path name


When referencing the schema document this way, it must exist where specified.


SOLUTION

To implement the solution execute the following steps:



-- create a directory in Oracle to point to the actual current physical

-- location on your o/s file system where you currently have

-- the purchaseOrder.xsd file located


create or replace directory XMLDIR as '<your_directory_location>';


grant read on directory XMLDIR to public with grant option;


-- create a function to enable the xsd file to be called within a

-- createResource statement


create or replace function getDocument(filename varchar2) return clob

authid current_user is

xbfile bfile;

xclob clob;

destination_offset INTEGER := 1;

source_offset INTEGER := 1;

language_context INTEGER := DBMS_LOB.default_lang_ctx;

warning_message INTEGER;


begin

xbfile := bfilename('XMLDIR',filename);

dbms_lob.open(xbfile);


dbms_lob.createtemporary(xclob,TRUE,dbms_lob.session);

DBMS_LOB.LOADCLOBFROMFILE(xclob,xbfile,

dbms_lob.getlength(xbfile),

destination_offset, source_offset,

NLS_CHARSET_ID('UTF8'),

language_context, warning_message);

dbms_lob.close(xbfile);

return xclob;

end;

/


-- create the resource in the XDB repository under folder

-- '/source/schemas/poSource/xsd/' for

-- the schema document purchaseOrder.xsd


declare

bret boolean;

begin

bret :=

dbms_xdb.createresource('/source/schemas/poSource/xsd/purchaseOrder.xsd',

getDocument('purchaseOrder.xsd'));

end;

/


commit;


-- Now create the schema


SQL> BEGIN

DBMS_XMLSCHEMA.registerSchema(

'http://localhost:8080/source/schemas/poSource/xsd/purchaseOrder.xsd',

XDBURIType('/source/schemas/poSource/xsd/purchaseOrder.xsd').getClob(),

TRUE,

TRUE,

FALSE,

TRUE);

END;

/


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-25 17:27 , Processed in 0.112411 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表