1DBLINK_OPEN(3)           PostgreSQL 10.7 Documentation          DBLINK_OPEN(3)
2
3
4

NAME

6       dblink_open - opens a cursor in a remote database
7

SYNOPSIS

9       dblink_open(text cursorname, text sql [, bool fail_on_error]) returns text
10       dblink_open(text connname, text cursorname, text sql [, bool fail_on_error]) returns text
11

DESCRIPTION

13       dblink_open() opens a cursor in a remote database. The cursor can
14       subsequently be manipulated with dblink_fetch() and dblink_close().
15

ARGUMENTS

17       connname
18           Name of the connection to use; omit this parameter to use the
19           unnamed connection.
20
21       cursorname
22           The name to assign to this cursor.
23
24       sql
25           The SELECT statement that you wish to execute in the remote
26           database, for example select * from pg_class.
27
28       fail_on_error
29           If true (the default when omitted) then an error thrown on the
30           remote side of the connection causes an error to also be thrown
31           locally. If false, the remote error is locally reported as a
32           NOTICE, and the function's return value is set to ERROR.
33

RETURN VALUE

35       Returns status, either OK or ERROR.
36

NOTES

38       Since a cursor can only persist within a transaction, dblink_open
39       starts an explicit transaction block (BEGIN) on the remote side, if the
40       remote side was not already within a transaction. This transaction will
41       be closed again when the matching dblink_close is executed. Note that
42       if you use dblink_exec to change data between dblink_open and
43       dblink_close, and then an error occurs or you use dblink_disconnect
44       before dblink_close, your change will be lost because the transaction
45       will be aborted.
46

EXAMPLES

48           SELECT dblink_connect('dbname=postgres options=-csearch_path=');
49            dblink_connect
50           ----------------
51            OK
52           (1 row)
53
54           SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
55            dblink_open
56           -------------
57            OK
58           (1 row)
59
60
61
62PostgreSQL 10.7                      2019                       DBLINK_OPEN(3)
Impressum