The ifx_int8cvlong() function

The ifx_int8cvlong() function converts a C long type value into an int8 type value.

Syntax

mint ifx_int8cvlong(lng_val, int8_val)
   int4 lng_val;
   ifx_int8_t *int8_val;
lng_val
The int4 integer that ifx_int8cvlong() converts to an int8 type value.
int8_val
A pointer to the int8 structure where ifx_int8cvlong() places the result of the conversion.

Return codes

0
The conversion was successful.
<0
The conversion failed.

Example

The file int8cvlong.ec in the demo directory contains the following sample program.
/*
   * ifx_int8cvlong.ec *

    The following program converts two longs to INT8
    types and displays the results.
*/

#include <stdio.h>

EXEC SQL include "int8.h";

char result[41];

main()
{
    mint x;
    ifx_int8_t num;
    int4 n;

   printf("IFX_INT8CVLONG Sample ESQL Program running.\n\n");

    printf("Long Integer 1 = 129449233\n");
    if (x = ifx_int8cvlong(129449233L, &num))
        {
        printf("Error %d in converting long to INT8\n", x);
        exit(1);
        }
    if (x = ifx_int8toasc(&num, result, sizeof(result)))
        {
        printf("Error %d in converting INT8 to string\n", x);
        exit(1);
        }
    result[40] = '\0';
    printf("  String for INT8 type value = %s\n", result);

    n = 2147483646;                 /* set n */
    printf("Long Integer 2 = %d\n", n);
    if (x = ifx_int8cvlong(n, &num))
        {
        printf("Error %d in converting long to INT8\n", x);
        exit(1);
        }
    if (x = ifx_int8toasc(&num, result, sizeof(result)))
        {
        printf("Error %d in converting INT8 to string\n", x);
        exit(1);
        }
    result[40] = '\0';
    printf("   String for INT8 type value = %s\n", result);

    printf("\nIFX_INT8CVLONG Sample Program over.\n\n");
    exit(0);
}

Output

IFX_INT8CVLONG Sample ESQL Program running.

Long Integer 1 = 129449233
  String for INT8 type value = 129449233
Long Integer 2 = 2147483646
   String for INT8 type value = 2147483646

IFX_INT8CVLONG Sample Program over.