Entering content frame

 Rules for Indicator Variables 

Note the following points when you use indicator variables:

...

·        Declare each indicator variable as a data type long int, int or short int in the declaration segment.

·        Specify the indicator variable behind the corresponding host variable in the embedded SQL statement, divided by a blank character.

·        Observe the same conventions as for host variables.

EXEC SQL BEGIN DECLARE SECTION;

char fname [8], lname [8];

int fnameind, lnameind;

EXEC SQL END DECLARE SECTION;

/* Insert NULL value */

fnameind = -1;

strcpy (lname, "COMPANY X");

lnameind = 0;

EXEC SQL INSERT INTO customer (firstname,lastname)
VALUES (:fname :fnameind, :lname :lnameind);

/* Test for truncation */

EXEC SQL SELECT lastname
INTO :lname :lnameind
FROM customer
WHERE lname = "COMPANY X";

if (lnameind > 0)
printf ("%d      ", lnameind );

 

Leaving content frame