<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>dblink_error_message</refname>
<refpurpose>gets last error message on the named connection</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
dblink_error_message(text connname) returns text
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<function>dblink_error_message</function> fetches the most recent remote
error message for a given connection.
</para>
</refsect1>
<refsect1>
<title>Arguments</title>
<variablelist>
<varlistentry>
<term><parameter>connname</parameter></term>
<listitem>
<para>
Name of the connection to use.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>
Returns last error message, or <literal>OK</literal> if there has been
no error in this connection.
</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
When asynchronous queries are initiated by
<function>dblink_send_query</function>, the error message associated with
the connection might not get updated until the server's response message
is consumed. This typically means that <function>dblink_is_busy</function>
or <function>dblink_get_result</function> should be called prior to
<function>dblink_error_message</function>, so that any error generated by
the asynchronous query will be visible.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<programlisting>
SELECT dblink_error_message('dtest1');
</programlisting>
</refsect1>
</refentry>
<refentry id="contrib-dblink-send-query">
<indexterm>
<primary>dblink_send_query</primary>
</indexterm>
<refmeta>
<refentrytitle>dblink_send_query</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>dblink_send_query</refname>
<refpurpose>sends an async query to a remote database</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
dblink_send_query(text connname, text sql) returns int
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<function>dblink_send_query</function> sends a query to be executed
asynchronously, that is, without immediately waiting for the result.
There must not be an async query already in progress on the
connection.
</para>
<para>
After successfully dispatching an async query, completion status
can be checked with <function>dblink_is_busy</function>, and the results
are ultimately collected with <function>dblink_get_result</function>.
It is also possible to attempt to cancel an active async query
using <function>dblink_cancel_query</function>.
</para>
</refsect1>
<refsect1>
<title>Arguments</title>
<variablelist>
<varlistentry>
<term><parameter>connname</parameter></term>
<listitem>
<para>
Name of the connection to use.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>sql</parameter></term>
<listitem>
<para>
The SQL statement that you wish to execute in the remote database,
for example <literal>select * from pg_class</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>
Returns 1 if the query was successfully dispatched, 0 otherwise.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<programlisting>
SELECT dblink_send_query('dtest1', 'SELECT * FROM foo WHERE f1 < 3');
</programlisting>
</refsect1>
</refentry>
<refentry id="contrib-dblink-is-busy">
<indexterm>
<primary>dblink_is_busy</primary>
</indexterm>
<refmeta>
<refentrytitle>dblink_is_busy</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>dblink_is_busy</refname>
<refpurpose>checks if connection is busy