Oracle PL/SQL过程-返回带有XML数据的CLOB变量作为OUT参数

x9ybnkn6  于 2023-05-06  发布在  Oracle
关注(0)|答案(1)|浏览(294)

我有以下XML格式的数据

<OutputParameters xmlns=http://xmlns.oracle.com/cloud/adapter/ xmlns:xsi=http://www.test.org/1998/XMLSchema-instance>
  <Header>
   <Header_item>
      <TRANSACTION_NUMBER>YSCPQ_9876</SOURCE_TRANSACTION_NUMBER>
      <TRANSACTION_SYSTEM>OPS</SOURCE_TRANSACTION_SYSTEM>
   <Lines>
    <lines_item>
      <TRANSACTION_ID>YSCPQ_9876</SOURCE_TRANSACTION_ID>
      <TRANSACTION_LINEID>1</SOURCE_TRANSACTION_LINEID>
    </lines_item>
    <lines_item>
      <TRANSACTION_ID>YSCPQ_9876</SOURCE_TRANSACTION_ID>
      <TRANSACTION_LINEID>2</SOURCE_TRANSACTION_LINEID>
    </lines_item>
   </Lines>
  </Header_item>
 </Header>     
</OutputParameters>

我需要一个过程将此XML输出存储在CLOB变量中,并将其作为OUT参数返回。
任何帮助将不胜感激。

ibrsph3r

ibrsph3r1#

使用OUT变量声明一个过程,并在过程主体中将XML赋给它:

CREATE PROCEDURE generate_data(
  o_data OUT CLOB
)
IS
BEGIN
  o_data := '<OutputParameters xmlns=http://xmlns.oracle.com/cloud/adapter/ xmlns:xsi=http://www.test.org/1998/XMLSchema-instance>
  <Header>
   <Header_item>
      <TRANSACTION_NUMBER>YSCPQ_9876</SOURCE_TRANSACTION_NUMBER>
      <TRANSACTION_SYSTEM>OPS</SOURCE_TRANSACTION_SYSTEM>
   <Lines>
    <lines_item>
      <TRANSACTION_ID>YSCPQ_9876</SOURCE_TRANSACTION_ID>
      <TRANSACTION_LINEID>1</SOURCE_TRANSACTION_LINEID>
    </lines_item>
    <lines_item>
      <TRANSACTION_ID>YSCPQ_9876</SOURCE_TRANSACTION_ID>
      <TRANSACTION_LINEID>2</SOURCE_TRANSACTION_LINEID>
    </lines_item>
   </Lines>
  </Header_item>
 </Header>     
</OutputParameters>';
END;
/

fiddle

相关问题