skip to main content

Embedded SQL : Indicator Variables

Indicator Variables
You can associate any host variable with an optional indicator variable. Each time the host variable is used in a SQL statement, a result code is stored in its associated indicator variable. Thus, indicator variables let you monitor host variables.
Indicator variables must be explicitly declared as PIC S9(4) COMP. Their references must be prefixed with a colon ":" in SQL statements and must immediately follow the host variable they refers to.
Possible values for indicator variables are:
Code example
The content of column1 is stored in the host variable named item1. The indicator variable ind1 is also set.
exec sql include SQLCA end-exec.
77 item1 pic 9(3).
77 ind1 pic s9(4) comp.
procedure division.
exec sql select column1 into :item1:ind1 from table1 where column1 = 1 end-exec.
Note: an indicator variable is implicitly defined for every data-item with a Format 3 picture string.
The following definition:
01  item-1 PIC X(10VARYING.
Is translated by the Compiler to:
01  item-1.
    03  item-1-arr pic X(10).
    03  item-1-len pic S9(4COMP-5.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left