Home Explore Blog CI



postgresql

93th chunk of `doc/src/sgml/ecpg.sgml`
6f52dc3c2eabf2b30c943d403723b9654d44ad666eb75d9f0000000100000fa5
 <term><literal>sqllen</literal></term>
      <listitem>
       <para>
        Length of the field data.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqldata">
     <term><literal>sqldata</literal></term>
      <listitem>
       <para>
        Pointer to the field data. The pointer is of <literal>char *</literal> type,
        the data pointed by it is in a binary format. Example:
<programlisting>
int intval;

switch (sqldata->sqlvar[i].sqltype)
{
    case SQLINTEGER:
        intval = *(int *)sqldata->sqlvar[i].sqldata;
        break;
  ...
}
</programlisting>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlind">
     <term><literal>sqlind</literal></term>
      <listitem>
       <para>
        Pointer to the NULL indicator. If returned by DESCRIBE or FETCH then it's always a valid pointer.
        If used as input for <literal>EXECUTE ... USING sqlda;</literal> then NULL-pointer value means
        that the value for this field is non-NULL. Otherwise a valid pointer and <literal>sqlitype</literal>
        has to be properly set. Example:
<programlisting>
if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
    printf("value is NULL\n");
</programlisting>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlname">
     <term><literal>sqlname</literal></term>
      <listitem>
       <para>
        Name of the field. 0-terminated string.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlformat">
     <term><literal>sqlformat</literal></term>
      <listitem>
       <para>
        Reserved in Informix, value of <xref linkend="libpq-PQfformat"/> for the field.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlitype">
     <term><literal>sqlitype</literal></term>
      <listitem>
       <para>
        Type of the NULL indicator data. It's always SQLSMINT when returning data from the server.
        When the <literal>SQLDA</literal> is used for a parameterized query, the data is treated
        according to the set type.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlilen">
     <term><literal>sqlilen</literal></term>
      <listitem>
       <para>
        Length of the NULL indicator data.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlxid">
     <term><literal>sqlxid</literal></term>
      <listitem>
       <para>
        Extended type of the field, result of <xref linkend="libpq-PQftype"/>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqltypename">
     <term><literal>sqltypename</literal></term>
     <term><literal>sqltypelen</literal></term>
     <term><literal>sqlownerlen</literal></term>
     <term><literal>sqlsourcetype</literal></term>
     <term><literal>sqlownername</literal></term>
     <term><literal>sqlsourceid</literal></term>
     <term><literal>sqlflags</literal></term>
     <term><literal>sqlreserved</literal></term>
      <listitem>
       <para>
        Unused.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlilongdata">
     <term><literal>sqlilongdata</literal></term>
      <listitem>
       <para>
        It equals to <literal>sqldata</literal> if <literal>sqllen</literal> is larger than 32kB.
       </para>
      </listitem>
     </varlistentry>

    </variablelist>

    Example:
<programlisting>
EXEC SQL INCLUDE sqlda.h;

    sqlda_t        *sqlda; /* This doesn't need to be under embedded DECLARE SECTION */

    EXEC SQL BEGIN DECLARE SECTION;
    char *prep_stmt = "select * from table1";
    int i;
    EXEC SQL END DECLARE SECTION;

    ...

    EXEC SQL PREPARE mystmt FROM :prep_stmt;

    EXEC SQL DESCRIBE mystmt INTO sqlda;

    printf("# of fields: %d\n",

Title: Informix-compatible SQLDA: Detailed Field Properties
Summary
This section provides a detailed description of the per-field properties stored in the `sqlvar` array of the Informix-compatible SQLDA descriptor. It defines each field, including `sqllen` (data length), `sqldata` (pointer to field data), `sqlind` (pointer to the NULL indicator), `sqlname` (field name), `sqlformat` (PQfformat value), `sqlitype` (type of NULL indicator data), `sqlilen` (length of NULL indicator data), `sqlxid` (extended field type), `sqltypename`, `sqltypelen`, `sqlownerlen`, `sqlsourcetype`, `sqlownername`, `sqlsourceid`, `sqlflags`, `sqlreserved` (all unused), and `sqlilongdata` (pointer for large data). Code examples are given for accessing data and checking for NULL values.