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_EXEC" "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_exec \- executes a command in a remote database
35 dblink_exec(text connname, text sql [, bool fail_on_error]) returns text
36 dblink_exec(text connstr, text sql [, bool fail_on_error]) returns text
37 dblink_exec(text sql [, bool fail_on_error]) returns text
42 executes a command (that is, any SQL statement that doesn\*(Aqt return rows) in a remote database\&.
46 arguments are given, the first one is first looked up as a persistent connection\*(Aqs name; if found, the command is executed on that connection\&. If not found, the first argument is treated as a connection info string as for
47 \fBdblink_connect\fR, and the indicated connection is made just for the duration of this command\&.
52 Name of the connection to use; omit this parameter to use the unnamed connection\&.
57 A connection info string, as previously described for
58 \fBdblink_connect\fR\&.
63 The SQL command that you wish to execute in the remote database, for example
64 insert into foo values(0, \*(Aqa\*(Aq, \*(Aq{"a0","b0","c0"}\*(Aq)\&.
69 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
74 Returns status, either the command\*(Aqs status string or
82 SELECT dblink_connect(\*(Aqdbname=dblink_test_standby\*(Aq);
84 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
88 SELECT dblink_exec(\*(Aqinsert into foo values(21, \*(Aq\*(Aqz\*(Aq\*(Aq, \*(Aq\*(Aq{"a0","b0","c0"}\*(Aq\*(Aq);\*(Aq);
90 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
94 SELECT dblink_connect(\*(Aqmyconn\*(Aq, \*(Aqdbname=regression\*(Aq);
96 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
100 SELECT dblink_exec(\*(Aqmyconn\*(Aq, \*(Aqinsert into foo values(21, \*(Aq\*(Aqz\*(Aq\*(Aq, \*(Aq\*(Aq{"a0","b0","c0"}\*(Aq\*(Aq);\*(Aq);
102 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
106 SELECT dblink_exec(\*(Aqmyconn\*(Aq, \*(Aqinsert into pg_class values (\*(Aq\*(Aqfoo\*(Aq\*(Aq)\*(Aq,false);
108 DETAIL: ERROR: null value in column "relnamespace" violates not\-null constraint
111 \-\-\-\-\-\-\-\-\-\-\-\-\-