Services
  • 24×7×365 Technical Support
  • Migration to PostgreSQL
  • High Availability Deployment
  • Database Audit
  • Remote DBA for PostgreSQL
Products
  • Postgres Pro Enterprise
  • Postgres Pro Standard
  • Cloud Solutions
  • Postgres Extensions
Resources
  • Blog
  • Documentation
  • Webinars
  • Videos
  • Presentations
Community
  • Events
  • Training Courses
  • Books
  • Demo Database
  • Mailing List Archives
About
  • Leadership team
  • Partners
  • Customers
  • In the News
  • Press Releases
  • Press Info

Facebook
Postgres Pro
  • Services
    24×7×365 Technical Support Migration to PostgreSQL High Availability Deployment Database Audit Remote DBA for PostgreSQL
  • Products
    Postgres Pro Enterprise Postgres Pro Standard Cloud Solutions Postgres Extensions
  • Resources
    Blog Documentation Webinars Videos Presentations
  • Community
    Events Training Courses Books Demo Database Mailing List Archives
  • About
    Leadership team Partners Customers In the News Press Releases Press Info
Facebook
Downloads
dblink_exec
Prev UpF.11. dblink — connect to other PostgreSQL databasesHome Next

dblink_exec

dblink_exec — executes a command in a remote database

Synopsis

dblink_exec(text connname, text sql [, bool fail_on_error]) returns text
dblink_exec(text connstr, text sql [, bool fail_on_error]) returns text
dblink_exec(text sql [, bool fail_on_error]) returns text

Description

dblink_exec executes a command (that is, any SQL statement that doesn't return rows) in a remote database.

When two text arguments are given, the first one is first looked up as a persistent connection's 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 dblink_connect, and the indicated connection is made just for the duration of this command.

Arguments

connname

Name of the connection to use; omit this parameter to use the unnamed connection.

connstr

A connection info string, as previously described for dblink_connect.

sql

The SQL command that you wish to execute in the remote database, for example insert into foo values(0, 'a', '{"a0","b0","c0"}').

fail_on_error

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's return value is set to ERROR.

Return Value

Returns status, either the command's status string or ERROR.

Examples

SELECT dblink_connect('dbname=dblink_test_standby');
 dblink_connect
----------------
 OK
(1 row)

SELECT dblink_exec('insert into foo values(21, ''z'', ''{"a0","b0","c0"}'');');
   dblink_exec
-----------------
 INSERT 943366 1
(1 row)

SELECT dblink_connect('myconn', 'dbname=regression');
 dblink_connect
----------------
 OK
(1 row)

SELECT dblink_exec('myconn', 'insert into foo values(21, ''z'', ''{"a0","b0","c0"}'');');
   dblink_exec
------------------
 INSERT 6432584 1
(1 row)

SELECT dblink_exec('myconn', 'insert into pg_class values (''foo'')',false);
NOTICE:  sql error
DETAIL:  ERROR:  null value in column "relnamespace" violates not-null constraint

 dblink_exec
-------------
 ERROR
(1 row)

Prev Up Next
dblink Home dblink_open
pdf epub

This page in other versions:

Postgres Pro Standard 17
Postgres Pro Standard 16
Postgres Pro Standard 15
Postgres Pro Standard 14
Postgres Pro Standard 13
Postgres Pro Standard 12
Postgres Pro Standard 11
Postgres Pro Standard 10
Postgres Pro Standard 9.6
Postgres Pro Standard 9.5
Postgres Pro Enterprise 17
Postgres Pro Enterprise 16
Postgres Pro Enterprise 15
Postgres Pro Enterprise 14
Postgres Pro Enterprise 13
Postgres Pro Enterprise 12
Postgres Pro Enterprise 11
Postgres Pro Enterprise 10
Postgres Pro Enterprise 9.6
PostgreSQL 17
PostgreSQL 16
PostgreSQL 15
PostgreSQL 14
PostgreSQL 13
PostgreSQL 12
PostgreSQL 11
PostgreSQL 10
PostgreSQL 9.6
PostgreSQL 9.5
PostgreSQL 9.4
Есть вопросы? Напишите нам!

Соглашаюсь с условиями обработки персональных данных



✖
×
Postgres Pro Standard 17 Postgres Pro Standard 16 Postgres Pro Standard 15 Postgres Pro Standard 14 Postgres Pro Standard 13 Postgres Pro Standard 12 Postgres Pro Standard 11 Postgres Pro Standard 10 Postgres Pro Standard 9.6 Postgres Pro Standard 9.5
Postgres Pro Enterprise 17 Postgres Pro Enterprise 16 Postgres Pro Enterprise 15 Postgres Pro Enterprise 14 Postgres Pro Enterprise 13 Postgres Pro Enterprise 12 Postgres Pro Enterprise 11 Postgres Pro Enterprise 10 Postgres Pro Enterprise 9.6
PostgreSQL 17 PostgreSQL 16 PostgreSQL 15 PostgreSQL 14 PostgreSQL 13 PostgreSQL 12 PostgreSQL 11 PostgreSQL 10 PostgreSQL 9.6 PostgreSQL 9.5 PostgreSQL 9.4
Go to PostgreSQL 17
Services
  • 24×7×365 Technical Support
  • Migration to PostgreSQL
  • High Availability Deployment
  • Database Audit
  • Remote DBA for PostgreSQL
Products
  • Postgres Pro Enterprise
  • Postgres Pro Standard
  • Cloud Solutions
  • Postgres Extensions
Resources
  • Blog
  • Documentation
  • Webinars
  • Videos
  • Presentations
Community
  • Events
  • Training Courses
  • Books
  • Demo Database
  • Mailing List Archives
About
  • Leadership team
  • Partners
  • Customers
  • In the News
  • Press Releases
  • Press Info
Products
  • Postgres Pro Enterprise
  • Postgres Pro Standard
  • Cloud Solutions
  • Postgres Extensions
Resources
  • Blog
  • Documentation
  • Webinars
  • Videos
  • Presentations
Services
  • 24×7×365 Technical Support
  • Migration to Postgres
  • High Availability Deployment
  • Database Audit
  • Remote DBA for PostgreSQL
Community
  • Events
  • Training Courses
  • Intro Book
  • Demo Database
  • Mailing List Archives
About
  • Leadership team
  • Partners
  • Customers
  • In the News
  • Press Releases
  • Press Info
Contacts
  • Neptune House, Marina Bay, office 207, Gibraltar, GX11 1AA
  • info@postgrespro.com
  • Facebook
Get in touch!



© Postgres Professional Europe Limited, 2015 — 2025
EULA EULA for Cloud Environments Privacy Policy GDPR Compliance Commitment
© Postgres Professional Europe Limited, 2015 — 2025
EULA
EULA for Cloud Environments
Privacy Policy
GDPR Compliance Commitment
By continuing to browse this website, you agree to the use of cookies. Go to Privacy Policy.