INDICATOR is a reserved word defined by the SQL standard for embedded SQL. In host-language programs (C, COBOL, PL/SQL, etc.) each column value moved between the database and a host variable can be paired with an indicator variable. The indicator variable stores status information:• 0 – the column value is not NULL and fits in the host variable• -1 – the column value is NULL• >0 – the column value was truncated; the number indicates the original lengthThe keyword INDICATOR explicitly precedes the indicator variable so the pre-compiler can parse the pair unambiguously. Although many implementations allow the shorthand “:host :ind” without the keyword, using INDICATOR keeps code portable across compilers that require it. Indicator variables are normally defined as 2-byte signed integers (SHORT in C, PIC S9(4) COMP in COBOL).INDICATOR is only meaningful inside EXEC SQL … END-EXEC (or BEGIN DECLARE SECTION blocks) and cannot be executed directly by the database engine. It is processed at pre-compile time and removed from the final SQL sent to the server.
NULL, FETCH, CURSOR, EXEC SQL, Host Variables, Embedded SQL, Pre-compiler
SQL-89 (first embedded SQL specification)
It flags a companion variable that tells your program whether a fetched value was NULL or truncated.
Use one whenever the column can be NULL or when you risk truncation. Otherwise it is optional, but many compilers warn if omitted.
Some compilers allow that shorthand, but including the keyword is safer and portable across all ANSI-compliant pre-compilers.
-1 for NULL, 0 for a valid non-truncated value, and a positive number for the original length of truncated data.