<small id='JD1yq'></small><noframes id='JD1yq'>

  • <legend id='JD1yq'><style id='JD1yq'><dir id='JD1yq'><q id='JD1yq'></q></dir></style></legend>
      <bdo id='JD1yq'></bdo><ul id='JD1yq'></ul>

  • <tfoot id='JD1yq'></tfoot>
        <i id='JD1yq'><tr id='JD1yq'><dt id='JD1yq'><q id='JD1yq'><span id='JD1yq'><b id='JD1yq'><form id='JD1yq'><ins id='JD1yq'></ins><ul id='JD1yq'></ul><sub id='JD1yq'></sub></form><legend id='JD1yq'></legend><bdo id='JD1yq'><pre id='JD1yq'><center id='JD1yq'></center></pre></bdo></b><th id='JD1yq'></th></span></q></dt></tr></i><div id='JD1yq'><tfoot id='JD1yq'></tfoot><dl id='JD1yq'><fieldset id='JD1yq'></fieldset></dl></div>

        如何在 Oracle PL/SQL 中解析一个简单的 XML 片段并将其加载到全局临时表中?

        How do you parse a simple XML snippet in Oracle PL/SQL and load it in a global temp table?(如何在 Oracle PL/SQL 中解析一个简单的 XML 片段并将其加载到全局临时表中?)

      1. <small id='uNElI'></small><noframes id='uNElI'>

        <legend id='uNElI'><style id='uNElI'><dir id='uNElI'><q id='uNElI'></q></dir></style></legend>
        • <bdo id='uNElI'></bdo><ul id='uNElI'></ul>

            1. <i id='uNElI'><tr id='uNElI'><dt id='uNElI'><q id='uNElI'><span id='uNElI'><b id='uNElI'><form id='uNElI'><ins id='uNElI'></ins><ul id='uNElI'></ul><sub id='uNElI'></sub></form><legend id='uNElI'></legend><bdo id='uNElI'><pre id='uNElI'><center id='uNElI'></center></pre></bdo></b><th id='uNElI'></th></span></q></dt></tr></i><div id='uNElI'><tfoot id='uNElI'></tfoot><dl id='uNElI'><fieldset id='uNElI'></fieldset></dl></div>

              <tfoot id='uNElI'></tfoot>
                <tbody id='uNElI'></tbody>
                  本文介绍了如何在 Oracle PL/SQL 中解析一个简单的 XML 片段并将其加载到全局临时表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 SQL Server 中,很容易解析包含用属性构造的简单 XML 片段的 vachar 变量并将其加载到临时表中 - 请参见下面的示例:

                  In SQL Server it is easy to parse a vachar variable that contains a simple XML snippet constructed with attributes and load it into a temp table - see example below:

                  declare @UpdateXML VARCHAR(8000)
                  
                  set @UpdateXML='<ArrayOfRecords>
                    <Record Field01="130" Field02="1700" Field03="C" />
                    <Record Field01="131" Field02="1701" Field03="C" />
                    <Record Field01="132" Field02="1702" Field03="C" />
                   </ArrayOfRecords>'
                  
                  DECLARE @hdoc int
                  
                  EXEC sp_xml_preparedocument @hdoc OUTPUT, @UpdateXML
                  
                  INSERT 
                  INTO #tblTemp( 
                    [Field01],
                    [Field02],
                    [Field03]
                   )
                  SELECT * 
                  FROM OPENXML(@hdoc, '//ArrayOfRecords/Record') 
                  WITH ( Field01 int,
                    Field02 int,
                    Field03 char(1)
                   )
                  
                  EXEC sp_xml_removedocument @hdoc
                  

                  是否有一个简单的例子可以在 Oracle PL/SQL 中做到这一点?

                  Is there a simple example that does the equivalent of this in Oracle PL/SQL?

                  在 Oracle 中有一个 DBMS_XMLSTORE 包,但它需要使用 ROWSET 和 ROW 元素的特定规范格式的 XML 片段.DBMS_XMLSTORE 似乎不适用于 XML 属性.

                  In Oracle there is an DBMS_XMLSTORE package but it wants the XML snippet in a specific canonical format using ROWSET and ROW elements. DBMS_XMLSTORE does not appear to work with XML attributes.

                  此外,我不确定是否需要为我的 XML 片段创建 XSD 并将其注册到 Oracle 数据库上,然后才能使用任何其他 PL/SQL XML 工具/查询.

                  Also, I am not 100% sure if I need to create an XSD of my XML snippet and register that on the Oracle database before I can use any of the other PL/SQL XML tools/queries.

                  谢谢!

                  推荐答案

                  坦率地说,Oracle 的 XML DB 实现有许多令人眼花缭乱的选项,而且并不总是清楚(至少对我而言)哪个选项适用于任何给定的场景.在这种特殊情况下,您想要的是 XMLTable(),它将 XQuery 转换为一组行.

                  Oracle's XML DB implementation has a frankly bewildering number of options, and it is not always clear (at least to me) which one applies in any given scenario. In this particular case the one you want is XMLTable(), which turns an XQuery into a set of rows.

                  首先我们创建一个表.

                  SQL> create table t23
                    2      (field01 number
                    3       , field02 number
                    4       , field03 char(1)
                    5       )
                    6  /
                  
                  Table created.
                  
                  SQL>
                  

                  然后我们填充它...

                  SQL> declare
                    2      x varchar2(2000) := '<ArrayOfRecords>
                    3                        <Record Field01="130" Field02="1700" Field03="C" />
                    4                        <Record Field01="131" Field02="1701" Field03="C" />
                    5                        <Record Field01="132" Field02="1702" Field03="C" />
                    6                   </ArrayOfRecords>';
                    7  begin
                    8      insert into t23
                    9      select *
                   10      from xmltable
                   11          ( '/ArrayOfRecords/Record'
                   12             passing xmltype (x)
                   13             columns f1 number path '@Field01'
                   14                     , f2 number path '@Field02'
                   15                     , f3 char(1) path '@Field03'
                   16          )
                   17      ;
                   18  end;
                   19  /
                  
                  PL/SQL procedure successfully completed.
                  
                  SQL>
                  

                  最后我们证明它有效......

                  Finally we prove it worked....

                  SQL> select * from t23
                    2  /
                  
                     FIELD01    FIELD02 F
                  ---------- ---------- -
                         130       1700 C
                         131       1701 C
                         132       1702 C
                  
                  SQL>
                  

                  这篇关于如何在 Oracle PL/SQL 中解析一个简单的 XML 片段并将其加载到全局临时表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to call Oracle function or stored procedure using spring persistence framework?(如何使用 Spring 持久化框架调用 Oracle 函数或存储过程?)
                  What can cause intermittent ORA-12519 (TNS: no appropriate handler found) errors(什么会导致间歇性 ORA-12519(TNS:找不到合适的处理程序)错误)
                  SQL to return the number of working days between 2 passed in dates(SQL 返回两个传入日期之间的工作日数)
                  Oracle Date Subtraction(Oracle 日期减法)
                  Is using quot;select *quot; for a cursor in PL/SQL considered bad programming?(正在使用“选择 *PL/SQL 中的游标被认为是糟糕的编程?)
                  Using sql/plsql, how do you find out which character set a text uses?(使用 sql/plsql,你如何找出文本使用的字符集?)
                  <legend id='NVRlW'><style id='NVRlW'><dir id='NVRlW'><q id='NVRlW'></q></dir></style></legend>

                  <small id='NVRlW'></small><noframes id='NVRlW'>

                        <tbody id='NVRlW'></tbody>
                      • <bdo id='NVRlW'></bdo><ul id='NVRlW'></ul>

                        <i id='NVRlW'><tr id='NVRlW'><dt id='NVRlW'><q id='NVRlW'><span id='NVRlW'><b id='NVRlW'><form id='NVRlW'><ins id='NVRlW'></ins><ul id='NVRlW'></ul><sub id='NVRlW'></sub></form><legend id='NVRlW'></legend><bdo id='NVRlW'><pre id='NVRlW'><center id='NVRlW'></center></pre></bdo></b><th id='NVRlW'></th></span></q></dt></tr></i><div id='NVRlW'><tfoot id='NVRlW'></tfoot><dl id='NVRlW'><fieldset id='NVRlW'></fieldset></dl></div>
                      • <tfoot id='NVRlW'></tfoot>