DBLINK_OPEN(3)
β¨ DBLINK_OPEN(3) β dblink_open, the remote-cursor queen β¨
okay bestie, welcome to the PostgreSQL 16.15 Documentation page for DBLINK_OPEN(3) β aka your girl dblink_open, who is literally all about opening cursors in a remote database. π
π 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. After that, the cursor can be manipulated with dblink_fetch() and dblink_close(). Itβs giving βopen the door, then fetch and close like a responsible icon.β β¨
π ARGUMENTS π
connnameβ the name of the connection to use. Omit this parameter to use the unnamed connection, bestie.cursornameβ the name you want to assign to this cursor.sqlβ theSELECTstatement you wish to execute in the remote database, for exampleselect * from pg_class.fail_on_errorβ iftrue(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. Thatβs the whole mood. π«
π 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.
β οΈ okay important note, bestie: 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. no cap, that part matters. π
π 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)
π okay thatβs the whole page, bestie β itβs from PostgreSQL 16.15, dated 2026, and yes itβs the DBLINK_OPEN(3) manual page. slay and stay caffeinated β¨π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16-docs 16.15-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