如何在MySQL程序查询中创建XML输出?

时间:2017-11-30 07:43:05

标签: mysql xml stored-procedures

我正在尝试将DB2过程查询迁移到MySQL过程。这是MySQL中的最终转换过程。

CREATE PROCEDURE SAMPLE
   (
   INOUT CLIENT_ID BIGINT,
     OUT CONFIG XML
   )
   BEGIN
   DECLARE CP_ID BIGINT;
   DECLARE CP_NAME VARCHAR(38);
   SET (CP_ID) = (SELECT PROFILE FROM CLIENT WHERE ID=CLIENT_ID LIMIT 1);
   SET (CP_NAME) = (SELECT NAME FROM CLIENT WHERE ID=CP_ID LIMIT 1);

        SET CONFIG = (
                   XMLELEMENT(NAME "characteristic",
                   XMLATTRIBUTES('ClientInfo' AS "name"),
                   (
                     XMLELEMENT(NAME "characteristic",
                       XMLATTRIBUTES('ClientProfileData' AS "name"),                   
                      XMLELEMENT(NAME "param", XMLATTRIBUTES('isSupport' AS "name", 'false' AS "value")),
                      XMLELEMENT(NAME "param", XMLATTRIBUTES('profileId' AS "name", CP_ID AS "value"))
                           )
                    )

                )
             );
 END;

这里我试图从表中输出XMl数据。我在XMLELEMENT中使用XMLATTRIBUTESDB2创建了相同的功能。不幸的是,我没有在MySQL中找到任何替代品。

如何在MySQL中实现相同的程序?任何帮助或建议?

0 个答案:

没有答案