Home Explore Blog CI



postgresql

84th chunk of `doc/src/sgml/ecpg.sgml`
e2fcc97491f5422efa2909ae2911c5b866f4de24f60dbfa40000000100000fa9
 class="parameter">value</replaceable> [, ... ]
OPEN <replaceable class="parameter">cursor_name</replaceable> USING SQL DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable>
</synopsis>
   </refsynopsisdiv>

   <refsect1>
    <title>Description</title>

    <para>
     <command>OPEN</command> opens a cursor and optionally binds
     actual values to the placeholders in the cursor's declaration.
     The cursor must previously have been declared with
     the <command>DECLARE</command> command.  The execution
     of <command>OPEN</command> causes the query to start executing on
     the server.
    </para>
   </refsect1>

   <refsect1>
    <title>Parameters</title>

    <variablelist>
     <varlistentry id="ecpg-sql-open-cursor-name">
      <term><replaceable class="parameter">cursor_name</replaceable></term>
      <listitem>
       <para>
        The name of the cursor to be opened.  This can be an SQL
        identifier or a host variable.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-sql-open-value">
      <term><replaceable class="parameter">value</replaceable></term>
      <listitem>
       <para>
        A value to be bound to a placeholder in the cursor.  This can
        be an SQL constant, a host variable, or a host variable with
        indicator.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-sql-open-descriptor-name">
      <term><replaceable class="parameter">descriptor_name</replaceable></term>
      <listitem>
       <para>
        The name of a descriptor containing values to be bound to the
        placeholders in the cursor.  This can be an SQL identifier or
        a host variable.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </refsect1>

   <refsect1>
    <title>Examples</title>

<programlisting>
EXEC SQL OPEN a;
EXEC SQL OPEN d USING 1, 'test';
EXEC SQL OPEN c1 USING SQL DESCRIPTOR mydesc;
EXEC SQL OPEN :curname1;
</programlisting>
   </refsect1>

   <refsect1>
    <title>Compatibility</title>

    <para>
     <command>OPEN</command> is specified in the SQL standard.
    </para>
   </refsect1>

   <refsect1>
    <title>See Also</title>

    <simplelist type="inline">
     <member><xref linkend="ecpg-sql-declare"/></member>
     <member><xref linkend="sql-close"/></member>
    </simplelist>
   </refsect1>
  </refentry>

  <refentry id="ecpg-sql-prepare">
   <refnamediv>
    <refname>PREPARE</refname>
    <refpurpose>prepare a statement for execution</refpurpose>
   </refnamediv>

   <refsynopsisdiv>
<synopsis>
PREPARE <replaceable class="parameter">prepared_name</replaceable> FROM <replaceable class="parameter">string</replaceable>
</synopsis>
   </refsynopsisdiv>

   <refsect1>
    <title>Description</title>

    <para>
     <command>PREPARE</command> prepares a statement dynamically
     specified as a string for execution.  This is different from the
     direct SQL statement <xref linkend="sql-prepare"/>, which can also
     be used in embedded programs.  The <xref linkend="sql-execute"/>
     command is used to execute either kind of prepared statement.
    </para>
   </refsect1>

   <refsect1>
    <title>Parameters</title>

    <variablelist>
     <varlistentry id="ecpg-sql-prepare-prepared-name">
      <term><replaceable class="parameter">prepared_name</replaceable></term>
      <listitem>
       <para>
        An identifier for the prepared query.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-sql-prepare-string">
      <term><replaceable class="parameter">string</replaceable></term>
      <listitem>
       <para>
        A literal string or a host variable containing a preparable
        SQL statement, one of SELECT, INSERT, UPDATE, or DELETE.
        Use question marks (<literal>?</literal>) for parameter values
        to be supplied at execution.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </refsect1>

   <refsect1>

Title: ECPG OPEN Command: Parameters, Examples, and Compatibility; Introduction to PREPARE
Summary
This section details the `OPEN` command in ECPG, explaining its parameters like `cursor_name`, `value` (for binding), and `descriptor_name`. It provides examples of how to use `OPEN` with different binding methods. The command's compliance with the SQL standard and related commands are mentioned. The section then introduces the `PREPARE` command, which prepares a dynamically specified SQL statement for execution, contrasting it with the direct SQL `PREPARE` statement. It also describes the parameters for `PREPARE`, including `prepared_name` and `string` (containing the SQL statement).