CREATE OR REPLACE FUNCTION j_f_sync_from_xml()
RETURNS boolean AS
$BODY$
DECLARE
myxml xml;
datafile text := 'ABBATE_EMANUELE.xml';
BEGIN
myxml := pg_read_file(datafile, 0, 100000000);
CREATE TABLE james AS
SELECT (xpath('//some_id/text()', x))[1]::text AS id
FROM unnest(xpath('/xml/path/to/datum', myxml)) x;
END;
$BODY$ language plpgsql;
目录是C:\ Program Files \ PostgreSQL \ 9.4 \ data,我插入文件' ABBATE_EMANUELE.xml'在路上。我试过其他文件,但它没有功能。
答案 0 :(得分:1)
无法重现。
检查目录:
postgres=# show data_directory;
data_directory
----------------
/pg/d10
(1 row)
现在正在创建文件并阅读它:
postgres=# \! echo $(date) > /pg/d10/test
postgres=# do $$ declare c text; df text := 'test';
begin
c := pg_read_file(df);
raise info '%', c;
end;
$$
;
INFO: Tue Nov 28 09:59:30 UTC 2017