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

前端之家收集整理的这篇文章主要介绍了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;



XML sql Utility (XSU)

参考:

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

原文链接:https://www.f2er.com/oracle/205926.html

猜你在找的Oracle相关文章