快盘下载:好资源、好软件、快快下载吧!

快盘排行|快盘最新

当前位置:首页软件教程电脑软件教程 → sqlserver-openxml-函数在达梦中实现

sqlserver-openxml-函数在达梦中实现

时间:2022-09-24 21:45:22人气:作者:快盘下载我要评论

sqlserver实现;
DECLARE ;idoc int
DECLARE ;doc varchar(1000)
SET ;doc =;
<ROOT>
<Customer CustomerID=;VINET; ContactName=;Paul Henriot;>
   <Order CustomerID=;VINET; EmployeeID=;5; OrderDate=;1996-07-04T00:00:00;>
      <OrderDetail OrderID=;10248; ProductID=;11; Quantity=;12;/>
      <OrderDetail OrderID=;10248; ProductID=;42; Quantity=;10;/>
   </Order>
</Customer>
<Customer CustomerID=;LILAS; ContactName=;Carlos Gonzlez;>
   <Order CustomerID=;LILAS; EmployeeID=;3; OrderDate=;1996-08-16T00:00:00;>
      <OrderDetail OrderID=;10283; ProductID=;72; Quantity=;3;/>
   </Order>
</Customer>
</ROOT>;
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument ;idoc OUTPUT, ;doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SELECT    *
FROM       OPENXML (;idoc, ;/ROOT/Customer;,1)
            WITH (CustomerID  varchar(10),
                  ContactName varchar(20))
达梦实现;

--提前创建表

create  table xmldata_t(C1 VARCHAR2);

DECLARE ;idoc int;
 ;doc varchar(1000);
 begin
SET ;doc =;
<ROOT>
<Customer CustomerID=;VINET; ContactName=;Paul Henriot;>
   <Order CustomerID=;VINET; EmployeeID=;5; OrderDate=;1996-07-04T00:00:00;>
      <OrderDetail OrderID=;10248; ProductID=;11; Quantity=;12;/>
      <OrderDetail OrderID=;10248; ProductID=;42; Quantity=;10;/>
   </Order>
</Customer>
<Customer CustomerID=;LILAS; ContactName=;Carlos Gonzlez;>
   <Order CustomerID=;LILAS; EmployeeID=;3; OrderDate=;1996-08-16T00:00:00;>
      <OrderDetail OrderID=;10283; ProductID=;72; Quantity=;3;/>
   </Order>
</Customer>
</ROOT>;;
--Create an internal representation of the XML document.
--call sp_xml_preparedocument ;idoc OUTPUT, ;doc
-- Execute a SELECT statement that uses the OPENXML rowset provider.
SF_SET_SESSION_PARA_VALUE(;ENABLE_TABLE_EXP_REF_FLAG;, 1);开启同层列引用该参数
insert into xmldata_t select ;doc ;
SELECT   CustomerID,ContactName
FROM      xmldata_t    ,xmltable(;/ROOT/Customer; PASSING ;doc COLUMNS CustomerID
VARCHAR2 PATH ;;CustomerID;, ContactName VARCHAR2 PATH ;;ContactName;);
       --( select (XMLPARSE(document;doc)));
       --( select (XMLQUERY(;doc, ;/ROOT/Customer;)));
       --( select (sf_xmlquery(;doc, ;/ROOT/Customer;)));
         --WITH (CustomerID  varchar(10),ContactName varchar(20));
delete from  xmldata_t;
end 

相关文章

网友评论

快盘下载暂未开通留言功能。

关于我们| 广告联络| 联系我们| 网站帮助| 免责声明| 软件发布

Copyright 2019-2029 【快快下载吧】 版权所有 快快下载吧 | 豫ICP备10006759号公安备案:41010502004165

声明: 快快下载吧上的所有软件和资料来源于互联网,仅供学习和研究使用,请测试后自行销毁,如有侵犯你版权的,请来信指出,本站将立即改正。