[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: contrib-dblink-get-result.html
File is not writable. Editing disabled.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >dblink_get_result</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 9.2.24 Documentation" HREF="index.html"><LINK REL="UP" TITLE="dblink" HREF="dblink.html"><LINK REL="PREVIOUS" TITLE="dblink_get_notify" HREF="contrib-dblink-get-notify.html"><LINK REL="NEXT" TITLE="dblink_cancel_query" HREF="contrib-dblink-cancel-query.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2017-11-06T22:43:11"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" ><A HREF="index.html" >PostgreSQL 9.2.24 Documentation</A ></TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A TITLE="dblink_get_notify" HREF="contrib-dblink-get-notify.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="dblink.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="20%" ALIGN="right" VALIGN="top" ><A TITLE="dblink_cancel_query" HREF="contrib-dblink-cancel-query.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="CONTRIB-DBLINK-GET-RESULT" ></A >dblink_get_result</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN147665" ></A ><H2 >Name</H2 >dblink_get_result -- gets an async query result</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN147668" ></A ><H2 >Synopsis</H2 ><PRE CLASS="SYNOPSIS" >dblink_get_result(text connname [, bool fail_on_error]) returns setof record</PRE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN147670" ></A ><H2 >Description</H2 ><P > <CODE CLASS="FUNCTION" >dblink_get_result</CODE > collects the results of an asynchronous query previously sent with <CODE CLASS="FUNCTION" >dblink_send_query</CODE >. If the query is not already completed, <CODE CLASS="FUNCTION" >dblink_get_result</CODE > will wait until it is. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN147676" ></A ><H2 >Arguments</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="PARAMETER" >connname</TT ></DT ><DD ><P > Name of the connection to use. </P ></DD ><DT ><TT CLASS="PARAMETER" >fail_on_error</TT ></DT ><DD ><P > 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 returns no rows. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN147689" ></A ><H2 >Return Value</H2 ><P > For an async query (that is, a SQL statement returning rows), the function returns the row(s) produced by the query. To use this function, you will need to specify the expected set of columns, as previously discussed for <CODE CLASS="FUNCTION" >dblink</CODE >. </P ><P > For an async command (that is, a SQL statement not returning rows), the function returns a single row with a single text column containing the command's status string. It is still necessary to specify that the result will have a single text column in the calling <TT CLASS="LITERAL" >FROM</TT > clause. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN147695" ></A ><H2 >Notes</H2 ><P > This function <SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >must</I ></SPAN > be called if <CODE CLASS="FUNCTION" >dblink_send_query</CODE > returned 1. It must be called once for each query sent, and one additional time to obtain an empty set result, before the connection can be used again. </P ><P > When using <CODE CLASS="FUNCTION" >dblink_send_query</CODE > and <CODE CLASS="FUNCTION" >dblink_get_result</CODE >, <SPAN CLASS="APPLICATION" >dblink</SPAN > fetches the entire remote query result before returning any of it to the local query processor. If the query returns a large number of rows, this can result in transient memory bloat in the local session. It may be better to open such a query as a cursor with <CODE CLASS="FUNCTION" >dblink_open</CODE > and then fetch a manageable number of rows at a time. Alternatively, use plain <CODE CLASS="FUNCTION" >dblink()</CODE >, which avoids memory bloat by spooling large result sets to disk. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN147706" ></A ><H2 >Examples</H2 ><PRE CLASS="SCREEN" >contrib_regression=# SELECT dblink_connect('dtest1', 'dbname=contrib_regression'); dblink_connect ---------------- OK (1 row) contrib_regression=# SELECT * FROM contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3') AS t1; t1 ---- 1 (1 row) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+------------ 0 | a | {a0,b0,c0} 1 | b | {a1,b1,c1} 2 | c | {a2,b2,c2} (3 rows) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+---- (0 rows) contrib_regression=# SELECT * FROM contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3; select * from foo where f1 > 6') AS t1; t1 ---- 1 (1 row) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+------------ 0 | a | {a0,b0,c0} 1 | b | {a1,b1,c1} 2 | c | {a2,b2,c2} (3 rows) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+--------------- 7 | h | {a7,b7,c7} 8 | i | {a8,b8,c8} 9 | j | {a9,b9,c9} 10 | k | {a10,b10,c10} (4 rows) contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]); f1 | f2 | f3 ----+----+---- (0 rows)</PRE ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="contrib-dblink-get-notify.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="contrib-dblink-cancel-query.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >dblink_get_notify</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="dblink.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >dblink_cancel_query</TD ></TR ></TABLE ></DIV ></BODY ></HTML >
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 727.96 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A