cursor_to_xml()

将游标行转换为 XML 的函数

cursor_to_xml() 是一个系统函数,用于从游标中获取行并将其映射到 XML

cursor_to_xml()PostgreSQL 8.3 中添加。

用法

cursor_to_xml ( cursor refcursor, count integer, nulls boolean, tableforest boolean, targetns text )
         → xml

cursor 是要转换为 XML 的游标输出。请注意,如果提供 NULL,该函数将返回 NULL

count 是要从游标返回的行数。如果游标无法返回任何行,则返回 NULL。

nulls,当设置为 true 时,将在输出中以以下方式表示 NULL 值:

<columnname xsi:nil="true"/>

如果 nulls 设置为 false,则 NULL 值将从输出中省略。

tableforest,当设置为 true 时,返回的每个列集都包装在 <table> 元素中;当设置为 false 时,返回的每个列集都包装在 <row> 元素中,而该 <row> 元素包含在一个外层的 <table> 元素中。

targetns 指定结果的 XML 命名空间。如果提供空字符串,则不使用命名空间。请注意,如果提供 NULL,则函数将返回 NULL

变更历史

示例

cursor_to_xml() 的基本用法示例

postgres=# BEGIN ;
BEGIN

postgres=*# DECLARE foo_cursor CURSOR
                FOR SELECT * FROM foo;
DECLARE CURSOR

postgres=*# SELECT * FROM cursor_to_xml('foo_cursor', 1, false, false,'');
                         cursor_to_xml
---------------------------------------------------------------
 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
                                                              +
 <row>                                                        +
   <id>2</id>                                                 +
 </row>                                                       +
                                                              +
 </table>                                                     +

(1 row)

分类

游标系统函数XML

另请参阅

cursor_to_xmlschema()table_to_xml()query_to_xml()database_to_xml()schema_to_xml()

反馈

提交有关“cursor_to_xml()”的任何评论、建议或更正,请点击 此处