Home Explore Blog CI



postgresql

79th chunk of `doc/src/sgml/ecpg.sgml`
6cf7c62bcc0f74fa0bc3aa0641415e92ad6929c3f2f357070000000100000fa0
 cursor_name CURSOR FOR sql_stmt;
EXEC SQL PREPARE sql_stmt FROM :dyn_string;
EXEC SQL OPEN cursor_name;
EXEC SQL FETCH cursor_name INTO :column1;
EXEC SQL CLOSE cursor_name;
</programlisting>
   </refsect1>

   <refsect1>
    <title>Compatibility</title>

    <para>
     <command>DECLARE STATEMENT</command> is an extension of the SQL standard,
     but can be used in famous DBMSs.
    </para>
   </refsect1>

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

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

  <refentry id="ecpg-sql-describe">
   <refnamediv>
    <refname>DESCRIBE</refname>
    <refpurpose>obtain information about a prepared statement or result set</refpurpose>
   </refnamediv>

   <refsynopsisdiv>
<synopsis>
DESCRIBE [ OUTPUT ] <replaceable class="parameter">prepared_name</replaceable> USING [ SQL ] DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable>
DESCRIBE [ OUTPUT ] <replaceable class="parameter">prepared_name</replaceable> INTO [ SQL ] DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable>
DESCRIBE [ OUTPUT ] <replaceable class="parameter">prepared_name</replaceable> INTO <replaceable class="parameter">sqlda_name</replaceable>
</synopsis>
   </refsynopsisdiv>

   <refsect1>
    <title>Description</title>

    <para>
     <command>DESCRIBE</command> retrieves metadata information about
     the result columns contained in a prepared statement, without
     actually fetching a row.
    </para>
   </refsect1>

   <refsect1>
    <title>Parameters</title>

    <variablelist>
     <varlistentry id="ecpg-sql-describe-prepared-name">
      <term><replaceable class="parameter">prepared_name</replaceable></term>
      <listitem>
       <para>
        The name of a prepared statement.  This can be an SQL
        identifier or a host variable.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-sql-describe-descriptor-name">
      <term><replaceable class="parameter">descriptor_name</replaceable></term>
      <listitem>
       <para>
        A descriptor name. It is case sensitive.  It can be an SQL
        identifier or a host variable.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-sql-describe-sqlda-name">
      <term><replaceable class="parameter">sqlda_name</replaceable></term>
      <listitem>
       <para>
        The name of an SQLDA variable.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </refsect1>

   <refsect1>
    <title>Examples</title>

<programlisting>
EXEC SQL ALLOCATE DESCRIPTOR mydesc;
EXEC SQL PREPARE stmt1 FROM :sql_stmt;
EXEC SQL DESCRIBE stmt1 INTO SQL DESCRIPTOR mydesc;
EXEC SQL GET DESCRIPTOR mydesc VALUE 1 :charvar = NAME;
EXEC SQL DEALLOCATE DESCRIPTOR mydesc;
</programlisting>
   </refsect1>

   <refsect1>
    <title>Compatibility</title>

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

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

    <simplelist type="inline">
     <member><xref linkend="ecpg-sql-allocate-descriptor"/></member>
     <member><xref linkend="ecpg-sql-get-descriptor"/></member>
    </simplelist>
   </refsect1>
  </refentry>

  <refentry id="ecpg-sql-disconnect">
   <refnamediv>
    <refname>DISCONNECT</refname>
    <refpurpose>terminate a database connection</refpurpose>
   </refnamediv>

   <refsynopsisdiv>
<synopsis>
DISCONNECT <replaceable class="parameter">connection_name</replaceable>
DISCONNECT [ CURRENT ]
DISCONNECT ALL
</synopsis>
   </refsynopsisdiv>

   <refsect1>
    <title>Description</title>

    <para>
     <command>DISCONNECT</command> closes a connection (or all
     connections) to the database.
    </para>
   </refsect1>

   <refsect1>
    <title>Parameters</title>

    <variablelist>

Title: ECPG DESCRIBE Command: Obtaining Metadata from Prepared Statements
Summary
This section describes the ECPG `DESCRIBE` command, used to retrieve metadata information about the result columns of a prepared statement without fetching any rows. It details the parameters: `prepared_name` (the name of the prepared statement), `descriptor_name` (a descriptor name), and `sqlda_name` (the name of an SQLDA variable). An example shows how to allocate a descriptor, prepare a statement, describe it into the descriptor, get a value from the descriptor, and then deallocate the descriptor. The section also mentions that `DESCRIBE` is specified in the SQL standard and lists related commands like `ALLOCATE DESCRIPTOR` and `GET DESCRIPTOR`.