Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/fetch.sgml`
0350aa4b665cf3d90bec72e2eeed0be6b196781363b158170000000100000f2a
 succeeding row, or
          the <literal>abs(<replaceable
          class="parameter">count</replaceable>)</literal>'th prior
          row if <replaceable class="parameter">count</replaceable> is
          negative.  <literal>RELATIVE 0</literal> re-fetches the
          current row, if any.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><replaceable class="parameter">count</replaceable></term>
        <listitem>
         <para>
          Fetch the next <replaceable
          class="parameter">count</replaceable> rows (same as
          <literal>FORWARD <replaceable
          class="parameter">count</replaceable></literal>).
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>ALL</literal></term>
        <listitem>
         <para>
          Fetch all remaining rows (same as <literal>FORWARD ALL</literal>).
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>FORWARD</literal></term>
        <listitem>
         <para>
          Fetch the next row (same as <literal>NEXT</literal>).
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>FORWARD <replaceable class="parameter">count</replaceable></literal></term>
        <listitem>
         <para>
          Fetch the next <replaceable
          class="parameter">count</replaceable> rows.
          <literal>FORWARD 0</literal> re-fetches the current row.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>FORWARD ALL</literal></term>
        <listitem>
         <para>
          Fetch all remaining rows.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>BACKWARD</literal></term>
        <listitem>
         <para>
          Fetch the prior row (same as <literal>PRIOR</literal>).
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>BACKWARD <replaceable class="parameter">count</replaceable></literal></term>
        <listitem>
         <para>
          Fetch the prior <replaceable
          class="parameter">count</replaceable> rows (scanning
          backwards).  <literal>BACKWARD 0</literal> re-fetches the
          current row.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>BACKWARD ALL</literal></term>
        <listitem>
         <para>
          Fetch all prior rows (scanning backwards).
         </para>
        </listitem>
       </varlistentry>
      </variablelist></para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">count</replaceable></term>
    <listitem>
     <para><replaceable class="parameter">count</replaceable> is a
      possibly-signed integer constant, determining the location or
      number of rows to fetch.  For <literal>FORWARD</literal> and
      <literal>BACKWARD</literal> cases, specifying a negative <replaceable
      class="parameter">count</replaceable> is equivalent to changing
      the sense of <literal>FORWARD</literal> and <literal>BACKWARD</literal>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">cursor_name</replaceable></term>
    <listitem>
     <para>
      An open cursor's name.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1>
  <title>Outputs</title>

  <para>
   On successful completion, a <command>FETCH</command> command returns a command
   tag of the form
<screen>
FETCH <replaceable class="parameter">count</replaceable>
</screen>
   The <replaceable class="parameter">count</replaceable> is the number
   of rows fetched (possibly zero).  Note that in
 

Title: FETCH Parameter Details: FORWARD, BACKWARD, Count, and Cursor Name
Summary
This section details the options for the direction parameter in the FETCH command, including FORWARD and BACKWARD options with and without row counts, as well as the ALL option. It also explains how the 'count' parameter is used to specify the number of rows to fetch and how negative values invert FORWARD/BACKWARD. Finally, it describes the 'cursor_name' parameter, which identifies the open cursor to fetch from. The output of a successful FETCH command includes a count of the rows fetched.