The ifx_getserial8() function

The ifx_getserial8() function returns the SERIAL8 value of the last inserted row into an int8 host variable.

Syntax

void ifx_getserial8(serial8_val)
   ifx_int8_t *serial8_val;
serial8_val
A pointer to the int8 structure where ifx_getserial8() places the newly inserted SERIAL8 value.

Usage

Use the ifx_getserial8() function after you insert a row that contains a SERIAL8 column. The function returns the new SERIAL8 value in the int8 variable, serial8_val, which you declare. If the INSERT statement generated a new SERIAL8 value, the serial8_val points to a value greater than zero. A SERIAL8 value of zero or null indicates an invalid INSERT; the INSERT might have failed or might not have been performed.

Example

EXEC SQL BEGIN DECLARE SECTION;
   int8 order_num;
   int8 rep_num;
   char str[20];
EXEC SQL END DECLARE SECTION;

EXEC SQL create table order2
(
   order_number SERIAL8(1001),
   order_date DATE,
   customer_num INTEGER,
   backlog CHAR(1),
   po_num CHAR(10),
   paid_date DATE,
   sales_rep INT8
);
EXEC SQL insert into order2 (order_number, sales_rep)
   values (0, :rep_num);
if (SQLCODE == 0)
{
   ifx_getserial8(order_num);
   if (ifx_int8toasc(&order_num, str, 20) == 0)
      printf("New order number is %s\n", str);
}