DBLINK_OPEN(3)
π DBLINK_OPEN(3) β dblink_open (PostgreSQL 14.24 docs)
okay so bestie, welcome to the DBLINK_OPEN(3) page from the PostgreSQL 14.24 documentation. Weβre learning how to open a cursor in a remote database, and itβs lowkey giving remote-control cursor energy. iconic. π
πΈ NAME
dblink_open β opens a cursor in a remote database
β¨ SYNOPSIS
dblink_open(text cursorname, text sql [, bool fail_on_error]) returns text
dblink_open(text connname, text cursorname, text sql [, bool fail_on_error]) returns text
π DESCRIPTION
dblink_open() opens a cursor in a remote database. Once itβs open, that cursor can subsequently be manipulated with dblink_fetch() and dblink_close(). Thatβs the whole vibe: open it, fetch from it, close it. slay. π¦
π ARGUMENTS
connnameβ the name of the connection to use. Omit this parameter and itβll use the unnamed connection, no cap.cursornameβ the name youβre assigning to this cursor. Name your cursor, bestie; it deserves one. πsqlβ theSELECTstatement you want to execute in the remote database, for exampleselect * from pg_class.fail_on_errorβ iftrue(which is the default when omitted), then an error thrown on the remote side of the connection causes an error to also be thrown locally. Iffalse, the remote error is locally reported as aNOTICE, and the functionβs return value is set toERROR.
π₯ RETURN VALUE
Returns status, either OK or ERROR. Simple icon behavior. π
π NOTES
Since a cursor can only persist within a transaction, dblink_open starts an explicit transaction block (BEGIN) on the remote side, if the remote side was not already within a transaction. This transaction will be closed again when the matching dblink_close is executed. π
β οΈ Note that if you usedblink_execto change data betweendblink_openanddblink_close, and then an error occurs or you usedblink_disconnectbeforedblink_close, your change will be lost because the transaction will be aborted. So likeβ¦ be careful, bestie. π
π EXAMPLES
SELECT dblink_connect('dbname=postgres options=-csearch_path=');
dblink_connect
----------------
OK
(1 row)
SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
dblink_open
-------------
OK
(1 row)
π Thatβs the whole page, bestie β brought to you by PostgreSQL 14.24, dated 2026, and filed under DBLINK_OPEN(3). Mwah! π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14-docs 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms