Home Explore Blog CI



postgresql

51th chunk of `doc/src/sgml/libpq.sgml`
8ddf3070767a25dd8a7417d6e5ef95881fdfdf88ccdb468f0000000100000fa4
 *paramLengths,
                         const int *paramFormats,
                         int resultFormat);
</synopsis>
       </para>

       <para>
        <xref linkend="libpq-PQexecPrepared"/> is like <xref linkend="libpq-PQexecParams"/>,
        but the command to be executed is specified by naming a
        previously-prepared statement, instead of giving a query string.
        This feature allows commands that will be used repeatedly to be
        parsed and planned just once, rather than each time they are
        executed.  The statement must have been prepared previously in
        the current session.
       </para>

       <para>
        The parameters are identical to <xref linkend="libpq-PQexecParams"/>, except that the
        name of a prepared statement is given instead of a query string, and the
        <parameter>paramTypes[]</parameter> parameter is not present (it is not needed since
        the prepared statement's parameter types were determined when it was created).
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="libpq-PQdescribePrepared">
      <term><function>PQdescribePrepared</function><indexterm><primary>PQdescribePrepared</primary></indexterm></term>

      <listitem>
       <para>
        Submits a request to obtain information about the specified
        prepared statement, and waits for completion.
<synopsis>
PGresult *PQdescribePrepared(PGconn *conn, const char *stmtName);
</synopsis>
       </para>

       <para>
        <xref linkend="libpq-PQdescribePrepared"/> allows an application to obtain
        information about a previously prepared statement.
       </para>

       <para>
        <parameter>stmtName</parameter> can be <literal>""</literal> or <symbol>NULL</symbol> to reference
        the unnamed statement, otherwise it must be the name of an existing
        prepared statement.  On success, a <structname>PGresult</structname> with
        status <literal>PGRES_COMMAND_OK</literal> is returned.  The
        functions <xref linkend="libpq-PQnparams"/> and
        <xref linkend="libpq-PQparamtype"/> can be applied to this
        <structname>PGresult</structname> to obtain information about the parameters
        of the prepared statement, and the functions
        <xref linkend="libpq-PQnfields"/>, <xref linkend="libpq-PQfname"/>,
        <xref linkend="libpq-PQftype"/>, etc. provide information about the
        result columns (if any) of the statement.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="libpq-PQdescribePortal">
      <term><function>PQdescribePortal</function><indexterm><primary>PQdescribePortal</primary></indexterm></term>

      <listitem>
       <para>
        Submits a request to obtain information about the specified
        portal, and waits for completion.
<synopsis>
PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
</synopsis>
       </para>

       <para>
        <xref linkend="libpq-PQdescribePortal"/> allows an application to obtain
        information about a previously created portal.
        (<application>libpq</application> does not provide any direct access to
        portals, but you can use this function to inspect the properties
        of a cursor created with a <command>DECLARE CURSOR</command> SQL command.)
       </para>

       <para>
        <parameter>portalName</parameter> can be <literal>""</literal> or <symbol>NULL</symbol> to reference
        the unnamed portal, otherwise it must be the name of an existing
        portal.  On success, a <structname>PGresult</structname> with status
        <literal>PGRES_COMMAND_OK</literal> is returned.  The functions
        <xref linkend="libpq-PQnfields"/>, <xref linkend="libpq-PQfname"/>,
        <xref linkend="libpq-PQftype"/>, etc. can be applied to the
        <structname>PGresult</structname> to obtain information about the result
        columns (if any) of the portal.
       </para>
      </listitem>
     </varlistentry>

Title: PQexecPrepared, PQdescribePrepared, and PQdescribePortal: Executing Prepared Statements and Obtaining Information
Summary
This section details the functions `PQexecPrepared`, `PQdescribePrepared`, and `PQdescribePortal`. `PQexecPrepared` executes a previously prepared statement, using parameters similar to `PQexecParams`. `PQdescribePrepared` obtains information about a prepared statement's parameters and result columns. `PQdescribePortal` retrieves information about a portal, enabling inspection of cursors created with the `DECLARE CURSOR` SQL command.