Home Explore Blog CI



postgresql

65th chunk of `doc/src/sgml/libpq.sgml`
c0c172dedaad3d31767e1113fe86a9a24f3909c30afb30300000000100000fa6

       rely on <xref linkend="libpq-PQfsize"/> to obtain the actual data
       length.
      </para>
     </listitem>
    </varlistentry>

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

     <listitem>
      <para>
       Returns the number of parameters of a prepared statement.
<synopsis>
int PQnparams(const PGresult *res);
</synopsis>
      </para>

      <para>
       This function is only useful when inspecting the result of
       <xref linkend="libpq-PQdescribePrepared"/>.  For other types of results it
       will return zero.
      </para>
     </listitem>
    </varlistentry>

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

     <listitem>
      <para>
       Returns the data type of the indicated statement parameter.
       Parameter numbers start at 0.
<synopsis>
Oid PQparamtype(const PGresult *res, int param_number);
</synopsis>
      </para>

      <para>
       This function is only useful when inspecting the result of
       <xref linkend="libpq-PQdescribePrepared"/>.  For other types of results it
       will return zero.
      </para>
     </listitem>
    </varlistentry>

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

     <listitem>
      <para>
       Prints out all the rows and,  optionally,  the column names  to
       the specified output stream.
<synopsis>
void PQprint(FILE *fout,      /* output stream */
             const PGresult *res,
             const PQprintOpt *po);
typedef struct
{
    pqbool  header;      /* print output field headings and row count */
    pqbool  align;       /* fill align the fields */
    pqbool  standard;    /* old brain dead format */
    pqbool  html3;       /* output HTML tables */
    pqbool  expanded;    /* expand tables */
    pqbool  pager;       /* use pager for output if needed */
    char    *fieldSep;   /* field separator */
    char    *tableOpt;   /* attributes for HTML table element */
    char    *caption;    /* HTML table caption */
    char    **fieldName; /* null-terminated array of replacement field names */
} PQprintOpt;
</synopsis>
      </para>

      <para>
       This function was formerly used by <application>psql</application>
       to print query results, but this is no longer the case.  Note
       that it assumes all the data is in text format.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </sect2>

  <sect2 id="libpq-exec-nonselect">
   <title>Retrieving Other Result Information</title>

   <para>
    These functions are used to extract other information from
    <structname>PGresult</structname> objects.
   </para>

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

     <listitem>
      <para>
       Returns the command status tag from the SQL command that generated
       the <structname>PGresult</structname>.
<synopsis>
char *PQcmdStatus(PGresult *res);
</synopsis>
      </para>

      <para>
       Commonly this is just the name of the command, but it might include
       additional data such as the number of rows processed. The caller
       should not free the result directly. It will be freed when the
       associated <structname>PGresult</structname> handle is passed to
       <xref linkend="libpq-PQclear"/>.
      </para>
     </listitem>
    </varlistentry>

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

     <listitem>
      <para>
       Returns the number of rows affected by the SQL command.
<synopsis>
char *PQcmdTuples(PGresult *res);
</synopsis>
      </para>

      <para>
       This function returns a string containing

Title: libpq Functions: Prepared Statement Parameter Types, Printing Results, and Retrieving Command Status
Summary
This section describes libpq functions including `PQparamtype` to get the data type of a prepared statement parameter, only useful with PQdescribePrepared result. `PQprint` is an older function for printing query results to a stream. Other functions are for extracting result information, `PQcmdStatus` retrieves the command status tag from the SQL command, and `PQcmdTuples` gets the number of rows affected by the SQL command.