日韩小视频-日韩久久一区二区三区-日韩久久一级毛片-日韩久久久精品中文字幕-国产精品亚洲精品影院-国产精品亚洲欧美云霸高清

下載吧 - 綠色安全的游戲和軟件下載中心

軟件下載吧

當前位置:軟件下載吧 > 技術開發 > 數據庫 > PostgreSQL中的XML操作函數代碼

PostgreSQL中的XML操作函數代碼

時間:2024-02-28 13:28作者:下載吧人氣:19

XML內容生成部分
SQL數據生成XML的函數。
1. xmlcomment:生成注釋函數。
xmlcomment(text )
例:

SELECT xmlcomment(‘hello’);
xmlcomment
————–
<!–hello–>

2. xmlconcat:XML連接函數
xmlconcat(xml [, …])
例:
SELECT xmlconcat(‘<abc/>’, ‘<bar>foo</bar>’);

xmlconcat
———————-
<abc/><bar>foo</bar>

連接的XML數據中如果有多個版本聲明的話,連接后的XML只有一個版本聲明。
例:
SELECT xmlconcat(‘<?xml version=”1.1″?><foo/>’, ‘<?xml version=”1.1″ standalone=”no”?><bar/>’);

xmlconcat
———————————–
<?xml version=”1.1″?><foo/><bar/>

3. xmlelement:生成XML元素函數
xmlelement(name name [, xmlattributes( value [AS attname ] [, … ])] [ , content, … ])
例:
SELECT xmlelement(name foo);
xmlelement
————
<foo/>

SELECT xmlelement(name foo, xmlattributes(‘xyz’ as bar));
xmlelement
——————
<foo bar=”xyz”/>

SELECT xmlelement(name foo, xmlattributes(current_date as bar), ‘cont’, ‘ent’);
xmlelement
————————————-
<foo bar=”2007-01-26″>content</foo>

如果有非法字符的話,非常字符會用 16進制的數字表示出來。
例子:SELECT xmlelement(name “foo$bar”, xmlattributes(‘xyz’ as “a&b”));
xmlelement
———————————-
<foo_x0024_bar a_x0026_b=”xyz”/>

4. xmlforest:生成XML FOREST函數
xmlforest(content [AS name ] [, …])
例:
SELECT xmlforest(‘abc’ AS foo, 123 AS bar);
xmlforest
——————————
<foo>abc</foo><bar>123</bar>

SELECT xmlforest(table_name, column_name)
FROM information_schema.columns
WHERE table_schema = ‘pg_catalog’;
xmlforest
——————————————————————————————-
<table_name>pg_authid</table_name><column_name>rolname</column_name>
<table_name>pg_authid</table_name><column_name>rolsuper</column_name>

5. xmlpi:生成XML處理命令函數。
xmlpi(name target [, content ])
例:
SELECT xmlpi(name php, ‘echo “hello world”;’);
xmlpi
—————————–
<?php echo “hello world”;?>

6. xmlroot:修改XML值的根節點屬性函數
xmlroot(xml , version text |no value [, standalone yes|no|no value])
例子:SELECT xmlroot(xmlparse(document ‘<?xml version=”1.1″?><content>abc</content>’),
version ‘1.0’, standalone yes);
xmlroot
—————————————-
<?xml version=”1.0″ standalone=”yes”?>
<content>abc</content>

7. xmlagg:xmlagg是集約函數
xmlagg(xml )
例:
CREATE TABLE test (y int, x xml);
INSERT INTO test VALUES (1, ‘<foo>abc</foo>’);
INSERT INTO test VALUES (2, ‘<bar/>’);
SELECT xmlagg(x) FROM test;
xmlagg
———————-
<foo>abc</foo><bar/>

可以用下面類型的方法改變連接順序。
SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab;
xmlagg
———————-
<bar/><foo>abc</foo>

Processing XML
為了處理XML數據,PostgreSL中提供了xpath函數。
xpath(xpath , xml [, nsarray ])

例:
SELECT xpath(‘/my:a/text()’, ‘<my:a xmlns:my=”http://example.com”>test</my:a>’,
ARRAY[ARRAY[‘my’, ‘http://example.com’]]);
xpath
——–
{test}
(1 row)

XML和table的映射
以下函數可以導出XML。
table_to_xml(tbl regclass, nulls boolean, tableforest boolean, targetns text)
query_to_xml(query text, nulls boolean, tableforest boolean, targetns text)
cursor_to_xml(cursor refcursor, count int, nulls boolean,
tableforest boolean, targetns text)
這些函數的返回值都是XML類型。

還有以下函數。具體內容可以參看用戶手冊。
table_to_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text)
query_to_xmlschema(query text, nulls boolean, tableforest boolean, targetns text)
cursor_to_xmlschema(cursor refcursor, nulls boolean, tableforest boolean, targetns text)
table_to_xml_and_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text)
query_to_xml_and_xmlschema(query text, nulls boolean, tableforest boolean, targetns text)
schema_to_xml(schema name, nulls boolean, tableforest boolean, targetns text)
schema_to_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text)
schema_to_xml_and_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text)
database_to_xml(nulls boolean, tableforest boolean, targetns text)
database_to_xmlschema(nulls boolean, tableforest boolean, targetns text)
database_to_xml_and_xmlschema(nulls boolean, tableforest boolean, targetns text)

標簽[db:關鍵字]

相關下載

查看所有評論+

網友評論

網友
您的評論需要經過審核才能顯示

熱門閱覽

最新排行

公眾號

主站蜘蛛池模板: 国产成人精品视频一区二区不卡 | 久久亚洲精品中文字幕第一区 | 国产伦精品一区二区三区无广告 | 一级毛片在线完整免费观看 | 996热这里有精品青青草原 | 2017天天爽夜夜爽精品视频 | 久久久久久国产精品视频 | 午夜啪啪福利视频 | 一级做a爰全过程免费视频毛片 | 免费五级在线观看日本片 | 免费一级a毛片免费观看欧美大片 | 兔子先生节目在线观看免费 | 99视频有精品 | 亚洲久久久久 | aaa一级 | 久久久久久久久免费影院 | 九九黄色影院 | 欧美日韩国产58香蕉在线视频 | 国产成人久久综合热 | 久久久久久毛片免费播放 | 69成人做爰视频在线观看 | 最新日韩欧美不卡一二三区 | 99精品久久久久久久免费看蜜月 | 久久精品国产三级不卡 | 最新中文字幕乱码在线 | 91九色偷拍| 美国美女一级毛片免费全 | 欧美韩国日本 | 欧美一区二区在线观看 | 亚洲国产高清一区二区三区 | 成人黄色一级片 | 久久99国产亚洲精品 | 女人张开腿让男人桶免费最新 | 在线亚洲播放 | 亚洲爽爽 | 最近韩国日本免费免费版 | 欧美成人一级毛片 | 成人精品一区二区三区 | 久久手机精品视频 | 午夜宅宅宅影院在线观看 | 一区二区三区在线播放视频 |