1DBLINK_FETCH(3)          PostgreSQL 10.7 Documentation         DBLINK_FETCH(3)
2
3
4

NAME

6       dblink_fetch - returns rows from an open cursor in a remote database
7

SYNOPSIS

9       dblink_fetch(text cursorname, int howmany [, bool fail_on_error]) returns setof record
10       dblink_fetch(text connname, text cursorname, int howmany [, bool fail_on_error]) returns setof record
11

DESCRIPTION

13       dblink_fetch fetches rows from a cursor previously established by
14       dblink_open.
15

ARGUMENTS

17       connname
18           Name of the connection to use; omit this parameter to use the
19           unnamed connection.
20
21       cursorname
22           The name of the cursor to fetch from.
23
24       howmany
25           The maximum number of rows to retrieve. The next howmany rows are
26           fetched, starting at the current cursor position, moving forward.
27           Once the cursor has reached its end, no more rows are produced.
28
29       fail_on_error
30           If true (the default when omitted) then an error thrown on the
31           remote side of the connection causes an error to also be thrown
32           locally. If false, the remote error is locally reported as a
33           NOTICE, and the function returns no rows.
34

RETURN VALUE

36       The function returns the row(s) fetched from the cursor. To use this
37       function, you will need to specify the expected set of columns, as
38       previously discussed for dblink.
39

NOTES

41       On a mismatch between the number of return columns specified in the
42       FROM clause, and the actual number of columns returned by the remote
43       cursor, an error will be thrown. In this event, the remote cursor is
44       still advanced by as many rows as it would have been if the error had
45       not occurred. The same is true for any other error occurring in the
46       local query after the remote FETCH has been done.
47

EXAMPLES

49           SELECT dblink_connect('dbname=postgres options=-csearch_path=');
50            dblink_connect
51           ----------------
52            OK
53           (1 row)
54
55           SELECT dblink_open('foo', 'select proname, prosrc from pg_proc where proname like ''bytea%''');
56            dblink_open
57           -------------
58            OK
59           (1 row)
60
61           SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
62            funcname |  source
63           ----------+----------
64            byteacat | byteacat
65            byteacmp | byteacmp
66            byteaeq  | byteaeq
67            byteage  | byteage
68            byteagt  | byteagt
69           (5 rows)
70
71           SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
72            funcname  |  source
73           -----------+-----------
74            byteain   | byteain
75            byteale   | byteale
76            bytealike | bytealike
77            bytealt   | bytealt
78            byteane   | byteane
79           (5 rows)
80
81           SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
82             funcname  |   source
83           ------------+------------
84            byteanlike | byteanlike
85            byteaout   | byteaout
86           (2 rows)
87
88           SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
89            funcname | source
90           ----------+--------
91           (0 rows)
92
93
94
95PostgreSQL 10.7                      2019                      DBLINK_FETCH(3)
Impressum