The ifx_getbigserial() function

The ifx_getbigserial() function returns the BIGSERIAL value of the last inserted row into a bigserial host variable.

Syntax

void ifx_getbigserial(bigserial_val)
   bigserial *bigserial_val;
bigserial_val
A pointer to the bigserial structure where ifx_getbigserial() places the newly inserted BIGSERIAL value.

Usage

Use the ifx_getbigserial() function after you insert a row that contains a BIGSERIAL column. The function returns the new BIGSERIAL value in the bigserial variable, bigserial_val, which you declare. If the INSERT statement generated a new BIGSERIAL value, the bigserial_val points to a value greater than zero. A BIGSERIAL 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;
   bigserial order_num;
   bigserial rep_num;
   char str[20];
EXEC SQL END DECLARE SECTION;

EXEC SQL create table order2
(
   order_number BIGSERIAL(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_getbigserial(&order_num);
   printf("New order number is %lld\n", order_num);
}