cursor_to_xmlschema() 是一个系统函数,它返回一个XML Schema文档,该文档描述了由 cursor_to_xml() 执行的映射。
cursor_to_xmlschema() 在 PostgreSQL 8.3 中被添加。
用法
cursor_to_xmlschema (tableregclass,nullsboolean,tableforestboolean,targetnstext)
→xml
当提供与调用 cursor_to_xml() 完全相同的参数时,table_to_xmlschema() 将返回相应的XML Schema文档。
变更历史
- PostgreSQL 8.3
- 已添加 (commit 355e05ab)
示例
cursor_to_xmlschema() 的基本用法示例
postgres=# BEGIN;
BEGIN
postgres=*# DECLARE foo_cursor CURSOR
FOR SELECT * FROM foo;
DECLARE CURSOR
postgres=*# SELECT * FROM cursor_to_xmlschema('foo_cursor', false, true,'');
cursor_to_xmlschema
----------------------------------------------------------------------------------------------
<xsd:schema +
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
+
<xsd:simpleType name="INTEGER"> +
<xsd:restriction base="xsd:int"> +
<xsd:maxInclusive value="2147483647"/> +
<xsd:minInclusive value="-2147483648"/> +
</xsd:restriction> +
</xsd:simpleType> +
+
<xsd:simpleType name="UDT.postgres.pg_catalog.text"> +
<xsd:restriction base="xsd:string"> +
</xsd:restriction> +
</xsd:simpleType> +
+
<xsd:complexType name="RowType"> +
<xsd:sequence> +
<xsd:element name="id" type="INTEGER" minOccurs="0"></xsd:element> +
<xsd:element name="val" type="UDT.postgres.pg_catalog.text" minOccurs="0"></xsd:element>+
<xsd:element name="x" type="INTEGER" minOccurs="0"></xsd:element> +
</xsd:sequence> +
</xsd:complexType> +
+
<xsd:element name="row" type="RowType"/> +
+
</xsd:schema>
(1 row)
参考资料
- PostgreSQL 文档: 将表映射到 XML
