6. Embedded SQL for BASIC : BASIC Variables and Data Types : Variable Usage : Array Variables
 
Share this page                  
Array Variables
An array variable is referred to by the syntax:
:arrayname (subscripts)
Syntax Notes:
You must subscript the variable, because only scalar-valued elements (integers, reals, and character strings) are legal SQL values.
When you declare the array, the Embedded SQL preprocessor does not parse the array bounds specification. Consequently, the Embedded SQL preprocessor will accept illegal bounds values. Also, when an array is referenced, the subscript is not parsed. The preprocessor confirms only the use of an array subscript with an array variable. You must ensure that the subscript is legal and that the correct number of indices is used.
Arrays of null indicator variables used with structure assignments should not include subscripts when referenced.
In the following example, a variable is used as a subscript and need not be declared in the declaration section, as it is not parsed.
exec sql begin declare section
    declare string formnames(3)
exec sql end declare section

data 'empform', 'deptform', 'helpform'
 declare integer i

for i = 1 to 3
    read formnames(i)
    exec frs forminit :formnames(i)
 next i