gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

98 lines
6.6KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>dblink_get_result</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="contrib-dblink-get-notify.html" title="dblink_get_notify" /><link rel="next" href="contrib-dblink-cancel-query.html" title="dblink_cancel_query" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">dblink_get_result</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="contrib-dblink-get-notify.html" title="dblink_get_notify">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="dblink.html" title="F.10. dblink">Up</a></td><th width="60%" align="center">F.10. dblink</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="contrib-dblink-cancel-query.html" title="dblink_cancel_query">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="CONTRIB-DBLINK-GET-RESULT"><div class="titlepage"></div><a id="id-1.11.7.19.18.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">dblink_get_result</span></h2><p>dblink_get_result — gets an async query result</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. dblink_get_result(text connname [, bool fail_on_error]) returns setof record
  4. </pre></div><div class="refsect1" id="id-1.11.7.19.18.5"><h2>Description</h2><p>
  5. <code class="function">dblink_get_result</code> collects the results of an
  6. asynchronous query previously sent with <code class="function">dblink_send_query</code>.
  7. If the query is not already completed, <code class="function">dblink_get_result</code>
  8. will wait until it is.
  9. </p></div><div class="refsect1" id="id-1.11.7.19.18.6"><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>connname</code></em></span></dt><dd><p>
  10. Name of the connection to use.
  11. </p></dd><dt><span class="term"><em class="parameter"><code>fail_on_error</code></em></span></dt><dd><p>
  12. If true (the default when omitted) then an error thrown on the
  13. remote side of the connection causes an error to also be thrown
  14. locally. If false, the remote error is locally reported as a NOTICE,
  15. and the function returns no rows.
  16. </p></dd></dl></div></div><div class="refsect1" id="id-1.11.7.19.18.7"><h2>Return Value</h2><p>
  17. For an async query (that is, a SQL statement returning rows),
  18. the function returns the row(s) produced by the query. To use this
  19. function, you will need to specify the expected set of columns,
  20. as previously discussed for <code class="function">dblink</code>.
  21. </p><p>
  22. For an async command (that is, a SQL statement not returning rows),
  23. the function returns a single row with a single text column containing
  24. the command's status string. It is still necessary to specify that
  25. the result will have a single text column in the calling <code class="literal">FROM</code>
  26. clause.
  27. </p></div><div class="refsect1" id="id-1.11.7.19.18.8"><h2>Notes</h2><p>
  28. This function <span class="emphasis"><em>must</em></span> be called if
  29. <code class="function">dblink_send_query</code> returned 1.
  30. It must be called once for each query
  31. sent, and one additional time to obtain an empty set result,
  32. before the connection can be used again.
  33. </p><p>
  34. When using <code class="function">dblink_send_query</code> and
  35. <code class="function">dblink_get_result</code>, <span class="application">dblink</span> fetches the entire
  36. remote query result before returning any of it to the local query
  37. processor. If the query returns a large number of rows, this can result
  38. in transient memory bloat in the local session. It may be better to open
  39. such a query as a cursor with <code class="function">dblink_open</code> and then fetch a
  40. manageable number of rows at a time. Alternatively, use plain
  41. <code class="function">dblink()</code>, which avoids memory bloat by spooling large result
  42. sets to disk.
  43. </p></div><div class="refsect1" id="id-1.11.7.19.18.9"><h2>Examples</h2><pre class="screen">
  44. contrib_regression=# SELECT dblink_connect('dtest1', 'dbname=contrib_regression');
  45. dblink_connect
  46. ----------------
  47. OK
  48. (1 row)
  49. contrib_regression=# SELECT * FROM
  50. contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 &lt; 3') AS t1;
  51. t1
  52. ----
  53. 1
  54. (1 row)
  55. contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
  56. f1 | f2 | f3
  57. ----+----+------------
  58. 0 | a | {a0,b0,c0}
  59. 1 | b | {a1,b1,c1}
  60. 2 | c | {a2,b2,c2}
  61. (3 rows)
  62. contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
  63. f1 | f2 | f3
  64. ----+----+----
  65. (0 rows)
  66. contrib_regression=# SELECT * FROM
  67. contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 &lt; 3; select * from foo where f1 &gt; 6') AS t1;
  68. t1
  69. ----
  70. 1
  71. (1 row)
  72. contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
  73. f1 | f2 | f3
  74. ----+----+------------
  75. 0 | a | {a0,b0,c0}
  76. 1 | b | {a1,b1,c1}
  77. 2 | c | {a2,b2,c2}
  78. (3 rows)
  79. contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
  80. f1 | f2 | f3
  81. ----+----+---------------
  82. 7 | h | {a7,b7,c7}
  83. 8 | i | {a8,b8,c8}
  84. 9 | j | {a9,b9,c9}
  85. 10 | k | {a10,b10,c10}
  86. (4 rows)
  87. contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
  88. f1 | f2 | f3
  89. ----+----+----
  90. (0 rows)
  91. </pre></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="contrib-dblink-get-notify.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dblink.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="contrib-dblink-cancel-query.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">dblink_get_notify </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> dblink_cancel_query</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1