Postgresql 中文操作指南
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() 在远程数据库中打开游标。随后可以使用 dblink_fetch() 和 dblink_close() 操作游标。
dblink_open() opens a cursor in a remote database. The cursor can subsequently be manipulated with dblink_fetch() and dblink_close().
Arguments
-
connname
-
Name of the connection to use; omit this parameter to use the unnamed connection.
-
-
cursorname
-
The name to assign to this cursor.
-
-
sql
-
The SELECT statement that you wish to execute in the remote database, for example select * from pg_class.
-
-
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.
-
Notes
由于游标只能持久存在于事务中,因此 dblink_open 在远程端启动一个显式事务块 ( BEGIN )(如果远程端尚不在事务中)。当匹配的 dblink_close 执行时,此事务将再次关闭。请注意,如果您使用 dblink_exec 在 dblink_open 和 dblink_close 之间更改数据,然后发生错误,或者您在 dblink_close 之前使用 dblink_disconnect ,则会更改 will be lost ,因为事务将中止。
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 use dblink_exec to change data between dblink_open and dblink_close, and then an error occurs or you use dblink_disconnect before dblink_close, your change will be lost because the transaction will be aborted.