<para>
Points to the data. The format of the data is described
in <xref linkend="ecpg-variables-type-mapping"/>.
</para>
</listitem>
</varlistentry>
<varlistentry id="ecpg-sqlda-sqlvar-sqlind">
<term><literal>sqlind</literal></term>
<listitem>
<para>
Points to the null indicator. 0 means not null, -1 means
null.
</para>
</listitem>
</varlistentry>
<varlistentry id="ecpg-sqlda-sqlvar-sqlname">
<term><literal>sqlname</literal></term>
<listitem>
<para>
The name of the field.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect4>
<sect4 id="ecpg-sqlda-sqlname">
<title>struct sqlname Structure</title>
<para>
A <type>struct sqlname</type> structure holds a column name. It
is used as a member of the <type>sqlvar_t</type> structure. The
definition of the structure is:
<programlisting>
#define NAMEDATALEN 64
struct sqlname
{
short length;
char data[NAMEDATALEN];
};
</programlisting>
The meaning of the fields is:
<variablelist>
<varlistentry id="ecpg-sqlda-sqlname-length">
<term><literal>length</literal></term>
<listitem>
<para>
Contains the length of the field name.
</para>
</listitem>
</varlistentry>
<varlistentry id="ecpg-sqlda-sqlname-data">
<term><literal>data</literal></term>
<listitem>
<para>
Contains the actual field name.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect4>
</sect3>
<sect3 id="ecpg-sqlda-output">
<title>Retrieving a Result Set Using an SQLDA</title>
<procedure>
<para>
The general steps to retrieve a query result set through an
SQLDA are:
</para>
<step><simpara>Declare an <type>sqlda_t</type> structure to receive the result set.</simpara></step>
<step><simpara>Execute <command>FETCH</command>/<command>EXECUTE</command>/<command>DESCRIBE</command> commands to process a query specifying the declared SQLDA.</simpara></step>
<step><simpara>Check the number of records in the result set by looking at <structfield>sqln</structfield>, a member of the <type>sqlda_t</type> structure.</simpara></step>
<step><simpara>Get the values of each column from <literal>sqlvar[0]</literal>, <literal>sqlvar[1]</literal>, etc., members of the <type>sqlda_t</type> structure.</simpara></step>
<step><simpara>Go to next row (<type>sqlda_t</type> structure) by following the <structfield>desc_next</structfield> pointer, a member of the <type>sqlda_t</type> structure.</simpara></step>
<step><simpara>Repeat above as you need.</simpara></step>
</procedure>
<para>
Here is an example retrieving a result set through an SQLDA.
</para>
<para>
First, declare a <type>sqlda_t</type> structure to receive the result set.
<programlisting>
sqlda_t *sqlda1;
</programlisting>
</para>
<para>
Next, specify the SQLDA in a command. This is
a <command>FETCH</command> command example.
<programlisting>
EXEC SQL FETCH NEXT FROM cur1 INTO DESCRIPTOR sqlda1;
</programlisting>
</para>
<para>
Run a loop following the linked list to retrieve the rows.
<programlisting>
sqlda_t *cur_sqlda;
for (cur_sqlda = sqlda1;
cur_sqlda != NULL;
cur_sqlda = cur_sqlda->desc_next)
{
...
}
</programlisting>
</para>
<para>
Inside the loop, run another loop to retrieve each column data
(<type>sqlvar_t</type> structure) of the row.
<programlisting>
for (i = 0; i < cur_sqlda->sqld; i++)
{
sqlvar_t v