The ifx_int8cmp() function
The ifx_int8cmp() function compares two int8 type numbers.
Syntax
mint ifx_int8cmp(n1, n2)
ifx_int8_t *n1;
ifx_int8_t *n2;
- n1
- A pointer to the int8 structure that contains the first number to compare.
- n2
- A pointer to the int8 structure that contains the second number to compare.
Return codes
- -1
- The first value is less than the second value.
- 0
- The two values are identical.
- 1
- The first value is greater than the second value.
- INT8UNKNOWN
- Either value is null.
Example
The file int8cmp.ec in
the demo directory contains the following sample
program.
/*
* ifx_int8cmp.ec *
The following program compares INT8s types and displays
the results.
*/
#include <stdio.h>
EXEC SQL include "int8.h";
char string1[] = "-999,888,777,666";
char string2[] = "-12,345,678,956,546";
char string3[] = "123,456,780,555,224,456";
char string4[] = "123,456,780,555,224,456";
char string5[] = "";
main()
{
mint x;
ifx_int8_t num1, num2, num3, num4, num5;
printf("IFX_INT8CMP Sample ESQL Program running.\n\n");
if (x = ifx_int8cvasc(string1, strlen(string1), &num1))
{
printf("Error %d in converting string1 to int8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string2, strlen(string2), &num2))
{
printf("Error %d in converting string2 to int8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string3, strlen(string3), &num3))
{
printf("Error %d in converting string3 to int8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string4, strlen(string4), &num4))
{
printf("Error %d in converting string4 to int8\n", x);
exit(1);
}
if (x = ifx_int8cvasc(string5, strlen(string5), &num5))
{
printf("Error %d in converting string5 to int8\n", x);
exit(1);
}
printf("num1 = %s\nnum2 = %s\n", string1, string2);
printf("num3 = %s\nnum4 = %s\n", string3, string4);
printf("num5 = %s\n", "NULL");
printf("\nExecuting: ifx_int8cmp(&num1, &num2)\n");
printf(" Result = %d\n", ifx_int8cmp(&num1, &num2));
printf("Executing: ifx_int8cmp(&num2, &num3)\n");
printf(" Result = %d\n", ifx_int8cmp(&num2, &num3));
printf("Executing: ifx_int8cmp(&num1, &num3)\n");
printf(" Result = %d\n", ifx_int8cmp(&num1, &num3));
printf("Executing: ifx_int8cmp(&num3, &num4)\n");
printf(" Result = %d\n", ifx_int8cmp(&num3, &num4));
printf("Executing: ifx_int8cmp(&num1, &num5)\n");
x = ifx_int8cmp(&num1, &num5);
if(x == INT8UNKNOWN)
printf("RESULT is INT8UNKNOWN. One of the INT8 values in null.\n");
else
printf(" Result = %d\n", x);
printf("\nIFX_INT8CMP Sample Program over.\n\n");
exit(0);
}
Output
IFX_INT8CMP Sample ESQL Program running.
Number 1 = -999,888,777,666 Number 2 = -12,345,678,956,546
Number 3 = 123,456,780,555,224,456 Number 4 = 123,456,780,555,224,456
Number 5 =
Executing: ifx_int8cmp(&num1, &num2)
Result = 1
Executing: ifx_int8cmp(&num2, &num3)
Result = -1
Executing: ifx_int8cmp(&num1, &num3)
Result = -1
Executing: ifx_int8cmp(&num3, &num4)
Result = 0
Executing: ifx_int8cmp(&num1, &num5)
RESULT is INT8UNKNOWN. One of the INT8 values in null.
IFX_INT8CMP Sample Program over.