]> begriffs open source - ai-pg/blob - full-docs/txt/contrib-dblink-open.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / contrib-dblink-open.txt
1
2 dblink_open
3
4    dblink_open — opens a cursor in a remote database
5
6 Synopsis
7
8 dblink_open(text cursorname, text sql [, bool fail_on_error]) returns text
9 dblink_open(text connname, text cursorname, text sql [, bool fail_on_error]) ret
10 urns text
11
12 Description
13
14    dblink_open() opens a cursor in a remote database. The cursor can
15    subsequently be manipulated with dblink_fetch() and dblink_close().
16
17 Arguments
18
19    connname
20           Name of the connection to use; omit this parameter to use the
21           unnamed connection.
22
23    cursorname
24           The name to assign to this cursor.
25
26    sql
27           The SELECT statement that you wish to execute in the remote
28           database, for example select * from pg_class.
29
30    fail_on_error
31           If true (the default when omitted) then an error thrown on the
32           remote side of the connection causes an error to also be thrown
33           locally. If false, the remote error is locally reported as a
34           NOTICE, and the function's return value is set to ERROR.
35
36 Return Value
37
38    Returns status, either OK or ERROR.
39
40 Notes
41
42    Since a cursor can only persist within a transaction, dblink_open
43    starts an explicit transaction block (BEGIN) on the remote side, if the
44    remote side was not already within a transaction. This transaction will
45    be closed again when the matching dblink_close is executed. Note that
46    if you use dblink_exec to change data between dblink_open and
47    dblink_close, and then an error occurs or you use dblink_disconnect
48    before dblink_close, your change will be lost because the transaction
49    will be aborted.
50
51 Examples
52
53 SELECT dblink_connect('dbname=postgres options=-csearch_path=');
54  dblink_connect
55 ----------------
56  OK
57 (1 row)
58
59 SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
60  dblink_open
61 -------------
62  OK
63 (1 row)