oracle把SQL语句的查询解决解析成XML格式


解决OracleXmlSqlException,OracleXmlStore类

如果是数据库移植后出现此错误,可以只执行loadjava命令就可以

1.Make sure you've already loaded the Oracle XML Parser for Java into Oracle8i. The XML SQL Utility depends on it.

 
2.Download the latest release of the Oracle XML SQL Utility from http://technet.oracle.com/tech/xml: •If your database is Oracle8i Release 2 (8.1.6) or later, download the XSU12.tar.gz or XSU12.zip 
•If your database is Oracle8i Release 1 (8.1.5), download the XSU111.tar.gz or XSU111.zip
(安装Oracle的客户端后这2个jar都有)

 
3.Extract the .zip or the .tar.gz file into a convenient directory.
 
4.Change directory to the ./lib subdirectory of the distribution.
 

5.Load the xsu12.jar file (or xsu111.jar for 8.1.5) into your schema:

命令行运行: loadjava -verbose -resolve -user xmlbook/xmlbook xsu12.jar

(安装Oracle的客户端后这2个jar都有)



6.Run the SQL script to create the XML SQL Utility PL/SQL package: sqlplus xmlbook/xmlbook @xmlgenpkg.sql

@xmlgenpkg.sql在服务器上Oracle的目录下有,运行后会在用户下建立一个xmlgen的包。


测试代码(网上找的):

使用Oracle的xmlgen.getXML包生成SQL语句的结果集为XML格式,使用的是java类的方式。可以在存储过程中使用。

CREATE OR REPLACE FUNCTION submissionXML( id NUMBER ) RETURN CLOB IS
  query VARCHAR2(100);
BEGIN
  query := 'SELECT * FROM accepted_submission WHERE id = '||id;

  RETURN xmlgen.getXML(query);

END;

select xmlgen.getXML('select * from scott.emp',1) from dual;



解决OracleXmlSqlException,OracleXmlStore类

XML SQL Utility (XSU)


参考:

https://community.toadworld.com/platforms/oracle/w/wiki/6015.producing-xml-query-results


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值