1
==================================================================
4
dblink_open -- Opens a cursor on a remote database
8
dblink_open(text cursorname, text sql [, bool fail_on_error])
9
dblink_open(text connname, text cursorname, text sql [, bool fail_on_error])
14
if three arguments are present, the first is taken as the specific
15
connection name to use; otherwise the unnamed connection is assumed
19
a reference name for the cursor
23
sql statement that you wish to execute on the remote host
24
e.g. "select * from pg_class"
28
If true (default when not present) then an ERROR thrown on the remote side
29
of the connection causes an ERROR to also be thrown locally. If false, the
30
remote ERROR is locally treated as a NOTICE, and the return value is set
38
1) dblink_connect(text connstr) must be executed first
39
2) dblink_open starts an explicit transaction. If, after using dblink_open,
40
you use dblink_exec to change data, and then an error occurs or you use
41
dblink_disconnect without a dblink_close first, your change *will* be
42
lost. Also, using dblink_close explicitly ends the transaction and thus
43
effectively closes *all* open cursors.
47
test=# select dblink_connect('dbname=template1');
53
test=# select dblink_open('foo','select proname, prosrc from pg_proc');
59
==================================================================
62
dblink_fetch -- Returns a set from an open cursor on a remote database
66
dblink_fetch(text cursorname, int32 howmany [, bool fail_on_error])
67
dblink_fetch(text connname, text cursorname, int32 howmany [, bool fail_on_error])
72
if three arguments are present, the first is taken as the specific
73
connection name to use; otherwise the unnamed connection is assumed
77
The reference name for the cursor
81
Maximum number of rows to retrieve. The next howmany rows are fetched,
82
starting at the current cursor position, moving forward. Once the cursor
83
has positioned to the end, no more rows are produced.
87
If true (default when not present) then an ERROR thrown on the remote side
88
of the connection causes an ERROR to also be thrown locally. If false, the
89
remote ERROR is locally treated as a NOTICE, and no rows are returned.
97
test=# select dblink_connect('dbname=template1');
103
test=# select dblink_open('foo','select proname, prosrc from pg_proc where proname like ''bytea%''');
109
test=# select * from dblink_fetch('foo',5) as (funcname name, source text);
111
----------+----------
119
test=# select * from dblink_fetch('foo',5) as (funcname name, source text);
121
-----------+-----------
124
bytealike | bytealike
129
test=# select * from dblink_fetch('foo',5) as (funcname name, source text);
131
------------+------------
132
byteanlike | byteanlike
136
test=# select * from dblink_fetch('foo',5) as (funcname name, source text);
141
==================================================================
144
dblink_close -- Closes a cursor on a remote database
148
dblink_close(text cursorname [, bool fail_on_error])
149
dblink_close(text connname, text cursorname [, bool fail_on_error])
154
if two arguments are present, the first is taken as the specific
155
connection name to use; otherwise the unnamed connection is assumed
159
a reference name for the cursor
163
If true (default when not present) then an ERROR thrown on the remote side
164
of the connection causes an ERROR to also be thrown locally. If false, the
165
remote ERROR is locally treated as a NOTICE, and the return value is set
170
Returns status = "OK"
173
dblink_connect(text connstr) or dblink_connect(text connname, text connstr)
174
must be executed first.
178
test=# select dblink_connect('dbname=template1');
184
test=# select dblink_open('foo','select proname, prosrc from pg_proc');
190
test=# select dblink_close('foo');
196
select dblink_connect('myconn','dbname=regression');
202
select dblink_open('myconn','foo','select proname, prosrc from pg_proc');
208
select dblink_close('myconn','foo');