xml - 在 Oracle 存储过程中将 XmlType 转换为 CLOB

标签 xml oracle clob

在我的过程中,我的变量 l_outxml 包含一个 XMLType 值。我想把它转换成 CLOB 类型。我怎样才能做到这一点?如果我更改变量的数据类型,它会抛出一个错误:

PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got -

谁能帮我做这个?

CREATE OR REPLACE
PROCEDURE "test_Dinesh_page_1"
(
i_LRE_PeerGroup_ID IN out number
)
as
l_outxml xmltype := NULL;

 BEGIN
    with xmldata as (
      select es.d_reportentity_id
      , es.d_reportperiod_id
      , es.avgoralhealthscore
      , es.ScorePercentile
      , es.CostPMPM
      , es.topClaimPercent
      , es.topClaimState
      , l.LKP_reportEntity_PeerGroup_id
      , l.d_PeerGroup_ID
      , rp.EndYear
      , rp.EndQuarter
         from   f_ReportEntityScore es
          join  LKP_ReportEntity_PeerGroup l
              on es.d_reportperiod_id = l.d_reportperiod_id
              and es.d_reportEntity_id = l.d_reportEntity_id
          join  d_reportPeriod rp
              on es.d_reportperiod_id = rp.d_reportperiod_id
          where l.LKP_reportEntity_PeerGroup_id = i_LRE_PeerGroup_ID      
    )
    select xmlelement("ReportPage"
      , xmlelement("PageNumber",1)
      , (select xmlforest(
          cast(round(x.avgoralhealthscore,0) as int) as "DentalScore"
          , x.ScorePercentile as "DentalREINPercentile"
        )
        from xmldata x
        where x.LKP_reportEntity_PeerGroup_id = i_LRE_PeerGroup_ID
      )
    )   
     into l_outxml
    from dual;
end;

最佳答案

使用 xmlelement(...).getClobVal() 以转换为 CLOB。

关于xml - 在 Oracle 存储过程中将 XmlType 转换为 CLOB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27751650/

相关文章:

xml - 将节点导入到另一个XML文档

java - 如何获取一段时间内特定日期的出现情况

java - 使用 JDBC 将 clob 数据传递到 Oracle 存储过程时出现错误 ORA-22828

java - 在 java 中将字符串转换为 oracle.sql.clob?

android - Widget.Material.Light.TextView.ListSeparator 在哪里定义的?

Java XML读取问题: read different child tags

php - 'c :/wamp64/bin/php/php7. 0.10/ext/php_oci8_12c.dll' - %1 不是有效的 win32 应用程序

sql - 是否可以使用 SQL 更新 CLOB 内的数据?

java - 在 XML 中设置 Button View 的背景会使按钮不可单击

sql - 如何按时间范围内的组进行分区?