Home Explore Blog CI



postgresql

92th chunk of `doc/src/sgml/ecpg.sgml`
ae358b3a0f028ed5005543651b3d13fb9fc01f75ac9c9ac60000000100000fa4
 id="ecpg-informix-sqlda">
   <title>Informix-compatible SQLDA Descriptor Areas</title>
   <para>
    Informix-compatible mode supports a different structure than the one described in
    <xref linkend="ecpg-sqlda-descriptors"/>. See below:
<programlisting>
struct sqlvar_compat
{
    short   sqltype;
    int     sqllen;
    char   *sqldata;
    short  *sqlind;
    char   *sqlname;
    char   *sqlformat;
    short   sqlitype;
    short   sqlilen;
    char   *sqlidata;
    int     sqlxid;
    char   *sqltypename;
    short   sqltypelen;
    short   sqlownerlen;
    short   sqlsourcetype;
    char   *sqlownername;
    int     sqlsourceid;
    char   *sqlilongdata;
    int     sqlflags;
    void   *sqlreserved;
};

struct sqlda_compat
{
    short  sqld;
    struct sqlvar_compat *sqlvar;
    char   desc_name[19];
    short  desc_occ;
    struct sqlda_compat *desc_next;
    void  *reserved;
};

typedef struct sqlvar_compat    sqlvar_t;
typedef struct sqlda_compat     sqlda_t;
</programlisting>
   </para>

   <para>
    The global properties are:
    <variablelist>

     <varlistentry id="ecpg-informix-sqlda-sqld">
     <term><literal>sqld</literal></term>
      <listitem>
       <para>
        The number of fields in the <literal>SQLDA</literal> descriptor.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqlvar">
     <term><literal>sqlvar</literal></term>
      <listitem>
       <para>
        Pointer to the per-field properties.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-desc-name">
     <term><literal>desc_name</literal></term>
      <listitem>
       <para>
        Unused, filled with zero-bytes.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-desc-occ">
     <term><literal>desc_occ</literal></term>
      <listitem>
       <para>
        Size of the allocated structure.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-desc-next">
     <term><literal>desc_next</literal></term>
      <listitem>
       <para>
        Pointer to the next SQLDA structure if the result set contains more than one record.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-reserved">
     <term><literal>reserved</literal></term>
      <listitem>
       <para>
        Unused pointer, contains NULL. Kept for Informix-compatibility.
       </para>
      </listitem>
     </varlistentry>

    </variablelist>

    The per-field properties are below, they are stored in the <literal>sqlvar</literal> array:

    <variablelist>

     <varlistentry id="ecpg-informix-sqlda-sqltype">
     <term><literal>sqltype</literal></term>
      <listitem>
       <para>
        Type of the field. Constants are in <literal>sqltypes.h</literal>
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-sqlda-sqllen">
     <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

Title: Informix-compatible SQLDA Descriptor Areas - Structure and Properties
Summary
This section provides a detailed description of the Informix-compatible SQLDA descriptor area structure (`sqlda_compat`) used in ECPG when in Informix-compatible mode. It presents the structure definition in C code and explains the purpose of each field within both the global `sqlda_compat` structure and the per-field `sqlvar_compat` structure. The description includes fields like `sqld` (number of fields), `sqlvar` (pointer to per-field properties), `desc_name` (unused), `desc_occ` (structure size), `desc_next` (pointer to the next SQLDA structure), `sqltype` (field type), `sqllen` (field data length), `sqldata` (pointer to field data), and `sqlind` (pointer to the NULL indicator).