如何从Sybase中的存储过程生成XML输出文件?(How to produce an XML output file from a stored procedure in Sybase?)

编程入门 行业动态 更新时间:2024-10-25 23:32:13
如何从Sybase中的存储过程生成XML输出文件?(How to produce an XML output file from a stored procedure in Sybase?)

我有一个事件,每10分钟调用一次存储过程。我希望SP创建一个XML文件,其中包含数据库表的数据。 这可能吗?如果可以的话,我该如何创造呢? 提前致谢

I have an event that calls a stored procedure every 10 minutes.I want that SP creates a XML file with the data of a table of my database. Is that possible?If so,how can I create that? Thanks in advance

最满意答案

我假设我们在这里看Sybase ASE。 您可以通过在末尾添加“for xml”将SQL查询结果转换为XML文档(从t为xml选择a,b,c); 这是最简单的,还有更高级的选项来做到这一点。 生成的XML文档不能大于16384字节。 但是,如果表太大,则必须手动将XML文档组合为文本变量,以格式化每一行,并将写入作为XML文档中的一行。

将XML数据放入文件可以通过各种方式完成。 最简单的方法是打印输出并将输出重定向到客户端的文件。 要在ASE服务器的主机上创建文件,请创建映射到文件的代理表,并将生成的XML行插入到该代理表中。

I'm assuming we're looking at Sybase ASE here. You can turn a SQL query result into an XML document by adding 'for xml' at the end (select a,b,c from t for xml); this is the simplest, there are more advanced options to do this too. Th resulting XML document cannot be bigger than 16384 bytes. If the table is too large however, you're have to manually compose the XML document into a text variable of to format every row and write is as a line in the XML document.

Putting the XML data into a file can be done in various ways. Simplest is to PRINT the output and redirect the output to a file on the client side. For creating a file on the ASE server's host, create a proxy table that's mapped to a file and INSERT the generated lines of XML into that proxy table.

更多推荐

本文发布于:2023-04-29 08:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:存储过程   文件   XML   Sybase   produce

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!