3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "DBLINK_OPEN" "3" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 dblink_open \- opens a cursor in a remote database
35 dblink_open(text cursorname, text sql [, bool fail_on_error]) returns text
36 dblink_open(text connname, text cursorname, text sql [, bool fail_on_error]) returns text
41 opens a cursor in a remote database\&. The cursor can subsequently be manipulated with
44 \fBdblink_close()\fR\&.
49 Name of the connection to use; omit this parameter to use the unnamed connection\&.
54 The name to assign to this cursor\&.
61 statement that you wish to execute in the remote database, for example
62 select * from pg_class\&.
67 If true (the default when omitted) then an error thrown on the remote side of the connection causes an error to also be thrown locally\&. If false, the remote error is locally reported as a NOTICE, and the function\*(Aqs return value is set to
72 Returns status, either
78 Since a cursor can only persist within a transaction,
80 starts an explicit transaction block (\fBBEGIN\fR) on the remote side, if the remote side was not already within a transaction\&. This transaction will be closed again when the matching
82 is executed\&. Note that if you use
84 to change data between
87 \fBdblink_close\fR, and then an error occurs or you use
88 \fBdblink_disconnect\fR
90 \fBdblink_close\fR, your change
92 because the transaction will be aborted\&.
99 SELECT dblink_connect(\*(Aqdbname=postgres options=\-csearch_path=\*(Aq);
101 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
105 SELECT dblink_open(\*(Aqfoo\*(Aq, \*(Aqselect proname, prosrc from pg_proc\*(Aq);
107 \-\-\-\-\-\-\-\-\-\-\-\-\-