Home Explore Blog CI



postgresql

98th chunk of `doc/src/sgml/ecpg.sgml`
33594bb31688578bc35ef9eed78df5316f3375a50f5629620000000100000fa2
      should be included in the output. If the length of the output buffer,
        which is indicated by <literal>len</literal> is not sufficient to hold the
        textual representation including the trailing zero byte, only a
        single <literal>*</literal> character is stored in the result and -1 is
        returned.
       </para>
       <para>
        The function returns either -1 if the buffer <literal>cp</literal> was too
        small or <literal>ECPG_INFORMIX_OUT_OF_MEMORY</literal> if memory was
        exhausted.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-dectodbl">
      <term><function>dectodbl</function></term>
      <listitem>
       <para>
        Convert a variable of type decimal to a double.
<synopsis>
int dectodbl(decimal *np, double *dblp);
</synopsis>
        The function receives a pointer to the decimal value to convert
        (<literal>np</literal>) and a pointer to the double variable that
        should hold the result of the operation (<literal>dblp</literal>).
       </para>
       <para>
        On success, 0 is returned and a negative value if the conversion
        failed.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-dectoint">
      <term><function>dectoint</function></term>
      <listitem>
       <para>
        Convert a variable of type decimal to an integer.
<synopsis>
int dectoint(decimal *np, int *ip);
</synopsis>
        The function receives a pointer to the decimal value to convert
        (<literal>np</literal>) and a pointer to the integer variable that
        should hold the result of the operation (<literal>ip</literal>).
       </para>
       <para>
        On success, 0 is returned and a negative value if the conversion
        failed. If an overflow occurred, <literal>ECPG_INFORMIX_NUM_OVERFLOW</literal>
        is returned.
       </para>
       <para>
        Note that the ECPG implementation differs from the <productname>Informix</productname>
        implementation. <productname>Informix</productname> limits an integer to the range from -32767 to
        32767, while the limits in the ECPG implementation depend on the
        architecture (<literal>INT_MIN .. INT_MAX</literal>).
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-dectolong">
      <term><function>dectolong</function></term>
      <listitem>
       <para>
        Convert a variable of type decimal to a long integer.
<synopsis>
int dectolong(decimal *np, long *lngp);
</synopsis>
        The function receives a pointer to the decimal value to convert
        (<literal>np</literal>) and a pointer to the long variable that
        should hold the result of the operation (<literal>lngp</literal>).
       </para>
       <para>
        On success, 0 is returned and a negative value if the conversion
        failed. If an overflow occurred, <literal>ECPG_INFORMIX_NUM_OVERFLOW</literal>
        is returned.
       </para>
       <para>
        Note that the ECPG implementation differs from the <productname>Informix</productname>
        implementation. <productname>Informix</productname> limits a long integer to the range from
        -2,147,483,647 to 2,147,483,647, while the limits in the ECPG
        implementation depend on the architecture (<literal>-LONG_MAX ..
        LONG_MAX</literal>).
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="ecpg-informix-functions-rdatestr">
      <term><function>rdatestr</function></term>
      <listitem>
       <para>
        Converts a date to a C char* string.
<synopsis>
int rdatestr(date d, char *str);
</synopsis>
        The function receives two arguments, the first one is the date to
        convert (<literal>d</literal>) and the second one is a pointer to the target
        string. The output format is always <literal>yyyy-mm-dd</literal>, so you need
        to allocate at

Title: Informix Decimal and Date Conversion Functions: dectodbl, dectoint, dectolong, rdatestr
Summary
This section describes more Informix-compatible functions. It covers `dectodbl` (convert decimal to double), `dectoint` (convert decimal to integer, noting differences in range compared to Informix), `dectolong` (convert decimal to long integer, also noting range differences), and `rdatestr` (convert a date to a 'yyyy-mm-dd' formatted string).