<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/unlisten.sgml,v 1.18 2002/04/21 19:02:39 thomas Exp $
PostgreSQL documentation
-->

<refentry id="SQL-UNLISTEN">
 <refmeta>
  <refentrytitle>UNLISTEN</refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>
 <refnamediv>
  <refname>
   UNLISTEN
  </refname>
  <refpurpose>
   stop listening for a notification
  </refpurpose>
 </refnamediv>
 <refsynopsisdiv>
  <refsynopsisdivinfo>
   <date>1998-10-19</date>
  </refsynopsisdivinfo>
  <synopsis>
UNLISTEN { <replaceable class="PARAMETER">notifyname</replaceable> | * }
  </synopsis>

  <refsect2 id="R2-SQL-UNLISTEN-1">
   <refsect2info>
    <date>1998-10-19</date>
   </refsect2info>
   <title>
    Inputs
   </title>

   <para>
    <variablelist>
     <varlistentry>
      <term><replaceable class="PARAMETER">notifyname</replaceable></term>
      <listitem>
       <para>
	Name of previously registered notify condition.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><literal>*</literal></term>
      <listitem>
       <para>
	All current listen registrations for this backend are cleared.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>

  <refsect2 id="R2-SQL-UNLISTEN-2">
   <refsect2info>
    <date>1998-10-19</date>
   </refsect2info>
   <title>
    Outputs
   </title>
   <para>

    <variablelist>
     <varlistentry>
      <term><computeroutput>
<returnvalue>UNLISTEN</returnvalue>
       </computeroutput></term>
      <listitem>
       <para>
	Acknowledgment that statement has executed.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>
 </refsynopsisdiv>

 <refsect1 id="R1-SQL-UNLISTEN-1">
  <refsect1info>
   <date>1998-10-19</date>
  </refsect1info>
  <title>
   Description
  </title>

  <para>
   <command>UNLISTEN</command>
   is used to remove an existing <command>NOTIFY</command> registration.
   UNLISTEN cancels any existing registration of the current
   <productname>PostgreSQL</productname> session as a listener on the notify
   condition <replaceable class="PARAMETER">notifyname</replaceable>.
   The special condition wildcard <literal>*</literal> cancels all listener registrations
   for the current session.
  </para>

  <para>
   <xref endterm="sql-notify-title" linkend="sql-notify">
   contains a more extensive
   discussion of the use of <command>LISTEN</command> and
   <command>NOTIFY</command>.
  </para>

  <refsect2 id="R2-SQL-UNLISTEN-3">
   <refsect2info>
    <date>1998-10-19</date>
   </refsect2info>
   <title>
    Notes
   </title>
   <para>
    <replaceable class="PARAMETER">notifyname</replaceable>
    need not be a valid class name but can be any string valid
    as a name up to 32 characters long.
   </para>
   <para>
    The backend does not complain if you UNLISTEN something you were not
    listening for.
    Each backend will automatically execute <command>UNLISTEN *</command> when
    exiting.
   </para>
  </refsect2>
 </refsect1>

 <refsect1 id="R1-SQL-UNLISTEN-2">
  <title>
   Usage
  </title>

  <para>
   To subscribe to an existing registration:

<programlisting>
LISTEN virtual;
LISTEN
NOTIFY virtual;
NOTIFY
Asynchronous NOTIFY 'virtual' from backend with pid '8448' received
</programlisting>
  </para>

  <para>
   Once UNLISTEN has been executed, further NOTIFY commands will be
   ignored:

<programlisting>
UNLISTEN virtual;
UNLISTEN
NOTIFY virtual;
NOTIFY
-- notice no NOTIFY event is received
</programlisting>
  </para>
 </refsect1>

 <refsect1 id="R1-SQL-UNLISTEN-3">
  <title>
   Compatibility
  </title>

  <refsect2 id="R2-SQL-UNLISTEN-4">
   <refsect2info>
    <date>1998-10-19</date>
   </refsect2info>
   <title>
    SQL92
   </title>
   <para>
    There is no <command>UNLISTEN</command> in <acronym>SQL92</acronym>.
   </para>
  </refsect2>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
