gooderp18绿色标准版
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

65 lines
5.2KB

  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_exec</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-function.html" title="dblink" /><link rel="next" href="contrib-dblink-open.html" title="dblink_open" /></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_exec</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="contrib-dblink-function.html" title="dblink">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-open.html" title="dblink_open">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="CONTRIB-DBLINK-EXEC"><div class="titlepage"></div><a id="id-1.11.7.19.9.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">dblink_exec</span></h2><p>dblink_exec — executes a command in a remote database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. dblink_exec(text connname, text sql [, bool fail_on_error]) returns text
  4. dblink_exec(text connstr, text sql [, bool fail_on_error]) returns text
  5. dblink_exec(text sql [, bool fail_on_error]) returns text
  6. </pre></div><div class="refsect1" id="id-1.11.7.19.9.5"><h2>Description</h2><p>
  7. <code class="function">dblink_exec</code> executes a command (that is, any SQL statement
  8. that doesn't return rows) in a remote database.
  9. </p><p>
  10. When two <code class="type">text</code> arguments are given, the first one is first
  11. looked up as a persistent connection's name; if found, the command
  12. is executed on that connection. If not found, the first argument
  13. is treated as a connection info string as for <code class="function">dblink_connect</code>,
  14. and the indicated connection is made just for the duration of this command.
  15. </p></div><div class="refsect1" id="id-1.11.7.19.9.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>
  16. Name of the connection to use; omit this parameter to use the
  17. unnamed connection.
  18. </p></dd><dt><span class="term"><em class="parameter"><code>connstr</code></em></span></dt><dd><p>
  19. A connection info string, as previously described for
  20. <code class="function">dblink_connect</code>.
  21. </p></dd><dt><span class="term"><em class="parameter"><code>sql</code></em></span></dt><dd><p>
  22. The SQL command that you wish to execute in the remote database,
  23. for example
  24. <code class="literal">insert into foo values(0,'a','{"a0","b0","c0"}')</code>.
  25. </p></dd><dt><span class="term"><em class="parameter"><code>fail_on_error</code></em></span></dt><dd><p>
  26. If true (the default when omitted) then an error thrown on the
  27. remote side of the connection causes an error to also be thrown
  28. locally. If false, the remote error is locally reported as a NOTICE,
  29. and the function's return value is set to <code class="literal">ERROR</code>.
  30. </p></dd></dl></div></div><div class="refsect1" id="id-1.11.7.19.9.7"><h2>Return Value</h2><p>
  31. Returns status, either the command's status string or <code class="literal">ERROR</code>.
  32. </p></div><div class="refsect1" id="id-1.11.7.19.9.8"><h2>Examples</h2><pre class="screen">
  33. SELECT dblink_connect('dbname=dblink_test_standby');
  34. dblink_connect
  35. ----------------
  36. OK
  37. (1 row)
  38. SELECT dblink_exec('insert into foo values(21,''z'',''{"a0","b0","c0"}'');');
  39. dblink_exec
  40. -----------------
  41. INSERT 943366 1
  42. (1 row)
  43. SELECT dblink_connect('myconn', 'dbname=regression');
  44. dblink_connect
  45. ----------------
  46. OK
  47. (1 row)
  48. SELECT dblink_exec('myconn', 'insert into foo values(21,''z'',''{"a0","b0","c0"}'');');
  49. dblink_exec
  50. ------------------
  51. INSERT 6432584 1
  52. (1 row)
  53. SELECT dblink_exec('myconn', 'insert into pg_class values (''foo'')',false);
  54. NOTICE: sql error
  55. DETAIL: ERROR: null value in column "relnamespace" violates not-null constraint
  56. dblink_exec
  57. -------------
  58. ERROR
  59. (1 row)
  60. </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-function.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-open.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">dblink </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> dblink_open</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1