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_get_result
Prev UpF.11. dblink — connect to other PostgreSQL databasesHome Next

dblink_get_result

dblink_get_result — gets an async query result

Synopsis

dblink_get_result(text connname [, bool fail_on_error]) returns setof record

Description

dblink_get_result collects the results of an asynchronous query previously sent with dblink_send_query. If the query is not already completed, dblink_get_result will wait until it is.

Arguments

connname

Name of the connection to use.

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 returns no rows.

Return Value

For an async query (that is, an SQL statement returning rows), the function returns the row(s) produced by the query. To use this function, you will need to specify the expected set of columns, as previously discussed for dblink.

For an async command (that is, an SQL statement not returning rows), the function returns a single row with a single text column containing the command's status string. It is still necessary to specify that the result will have a single text column in the calling FROM clause.

Notes

This function must be called if dblink_send_query returned 1. It must be called once for each query sent, and one additional time to obtain an empty set result, before the connection can be used again.

When using dblink_send_query and dblink_get_result, dblink fetches the entire remote query result before returning any of it to the local query processor. If the query returns a large number of rows, this can result in transient memory bloat in the local session. It may be better to open such a query as a cursor with dblink_open and then fetch a manageable number of rows at a time. Alternatively, use plain dblink(), which avoids memory bloat by spooling large result sets to disk.

Examples

contrib_regression=# SELECT dblink_connect('dtest1', 'dbname=contrib_regression');
 dblink_connect
----------------
 OK
(1 row)

contrib_regression=# SELECT * FROM
contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3') AS t1;
 t1
----
  1
(1 row)

contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
 f1 | f2 |     f3
----+----+------------
  0 | a  | {a0,b0,c0}
  1 | b  | {a1,b1,c1}
  2 | c  | {a2,b2,c2}
(3 rows)

contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
 f1 | f2 | f3
----+----+----
(0 rows)

contrib_regression=# SELECT * FROM
contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3; select * from foo where f1 > 6') AS t1;
 t1
----
  1
(1 row)

contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
 f1 | f2 |     f3
----+----+------------
  0 | a  | {a0,b0,c0}
  1 | b  | {a1,b1,c1}
  2 | c  | {a2,b2,c2}
(3 rows)

contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
 f1 | f2 |      f3
----+----+---------------
  7 | h  | {a7,b7,c7}
  8 | i  | {a8,b8,c8}
  9 | j  | {a9,b9,c9}
 10 | k  | {a10,b10,c10}
(4 rows)

contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
 f1 | f2 | f3
----+----+----
(0 rows)

Prev Up Next
dblink_get_notify Home dblink_cancel_query
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.