<refpurpose>dynamically prepare and execute a statement</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
EXECUTE IMMEDIATE <replaceable class="parameter">string</replaceable>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>EXECUTE IMMEDIATE</command> immediately prepares and
executes a dynamically specified SQL statement, without
retrieving result rows.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry id="ecpg-sql-execute-immediate-string">
<term><replaceable class="parameter">string</replaceable></term>
<listitem>
<para>
A literal string or a host variable containing the SQL
statement to be executed.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
In typical usage, the <replaceable>string</replaceable> is a host
variable reference to a string containing a dynamically-constructed
SQL statement. The case of a literal string is not very useful;
you might as well just write the SQL statement directly, without
the extra typing of <command>EXECUTE IMMEDIATE</command>.
</para>
<para>
If you do use a literal string, keep in mind that any double quotes
you might wish to include in the SQL statement must be written as
octal escapes (<literal>\042</literal>) not the usual C
idiom <literal>\"</literal>. This is because the string is inside
an <literal>EXEC SQL</literal> section, so the ECPG lexer parses it
according to SQL rules not C rules. Any embedded backslashes will
later be handled according to C rules; but <literal>\"</literal>
causes an immediate syntax error because it is seen as ending the
literal.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
Here is an example that executes an <command>INSERT</command>
statement using <command>EXECUTE IMMEDIATE</command> and a host
variable named <varname>command</varname>:
<programlisting>
sprintf(command, "INSERT INTO test (name, amount, letter) VALUES ('db: ''r1''', 1, 'f')");
EXEC SQL EXECUTE IMMEDIATE :command;
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>EXECUTE IMMEDIATE</command> is specified in the SQL standard.
</para>
</refsect1>
</refentry>
<refentry id="ecpg-sql-get-descriptor">
<refnamediv>
<refname>GET DESCRIPTOR</refname>
<refpurpose>get information from an SQL descriptor area</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> <replaceable class="parameter">:cvariable</replaceable> = <replaceable class="parameter">descriptor_header_item</replaceable> [, ... ]
GET DESCRIPTOR <replaceable class="parameter">descriptor_name</replaceable> VALUE <replaceable class="parameter">column_number</replaceable> <replaceable class="parameter">:cvariable</replaceable> = <replaceable class="parameter">descriptor_item</replaceable> [, ... ]
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>GET DESCRIPTOR</command> retrieves information about a
query result set from an SQL descriptor area and stores it into
host variables. A descriptor area is typically populated
using <command>FETCH</command> or <command>SELECT</command>
before using this command to transfer the information into host
language variables.
</para>
<para>
This command has two forms: The first form retrieves
descriptor <quote>header</quote> items, which apply to the result
set in its entirety. One example is the row count. The second
form, which requires the column number as additional parameter,
retrieves information about a particular column.