加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 13:55:22 所属栏目:百科 来源:网络整理
导读:解决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


解决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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读