FOR SELECT version();
</programlisting>
</para>
<para>
An example declaring a cursor for a prepared statement:
<programlisting>
EXEC SQL PREPARE stmt1 AS SELECT version();
EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>DECLARE</command> is specified in the SQL standard.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="ecpg-sql-open"/></member>
<member><xref linkend="sql-close"/></member>
<member><xref linkend="sql-declare"/></member>
</simplelist>
</refsect1>
</refentry>
<refentry id="ecpg-sql-declare-statement">
<refnamediv>
<refname>DECLARE STATEMENT</refname>
<refpurpose>declare SQL statement identifier</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
EXEC SQL [ AT <replaceable class="parameter">connection_name</replaceable> ] DECLARE <replaceable class="parameter">statement_name</replaceable> STATEMENT
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>DECLARE STATEMENT</command> declares an SQL statement identifier.
SQL statement identifier can be associated with the connection.
When the identifier is used by dynamic SQL statements, the statements
are executed using the associated connection.
The namespace of the declaration is the precompile unit, and multiple
declarations to the same SQL statement identifier are not allowed.
Note that if the precompiler runs in Informix compatibility mode and
some SQL statement is declared, "database" can not be used as a cursor
name.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry id="ecpg-sql-declare-statement-connection-name">
<term><replaceable class="parameter">connection_name</replaceable></term>
<listitem>
<para>
A database connection name established by the <command>CONNECT</command> command.
</para>
<para>
AT clause can be omitted, but such statement has no meaning.
</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry id="ecpg-sql-declare-statement-statement-name">
<term><replaceable class="parameter">statement_name</replaceable></term>
<listitem>
<para>
The name of an SQL statement identifier, either as an SQL identifier or a host variable.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
This association is valid only if the declaration is physically placed on top of a dynamic statement.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<programlisting>
EXEC SQL CONNECT TO postgres AS con1;
EXEC SQL AT con1 DECLARE sql_stmt STATEMENT;
EXEC SQL DECLARE 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>