7. Embedded SQL for Pascal : Pascal Variables and Data Types : Variable Usage : Array Variables
 
Share this page                  
Array Variables
An array variable is referred to by the syntax:
:arrayname[subscript{,subscript}] {[subscript{,subscript}]}
Note:   
1. The variable must be subscripted because only scalar-valued elements (integers, floating-point and character strings) are legal Embedded SQL values.
2. When the array is declared, the array bounds specification is not parsed by the Embedded SQL preprocessor. Consequently, illegal bounds values will be accepted. Also, when an array is referenced, the subscript is not parsed, allowing the use of illegal subscripts. The preprocessor only confirms the use of an array subscript for an array variable. You must make sure that the subscript is legal and that the correct number of indices are used.
3. An array of characters is not a string unless it is packed or varying.
4. A packed or varying array of characters is considered a simple variable, not an array variable, in its usage. It therefore cannot be subscripted in order to reference a single character. For example, assuming the following variable declaration and subsequent assignment:
exec sql begin declare section;
var
     abc : packed array[1..3] of char;
exec sql end declare section;
     ...
     abc := 'abc';
you could not reference
:abc[1]
to access the character "a." To perform such a task, you should declare the variable as a plain (not packed or varying) array, as, for example:
exec sql begin declare section;
var
     abc : array[1..3] of char;
exec sql end declare section;
     ...
     abc := ('a', 'b', 'c');
5. Arrays of indicator variables used with structure assignments should not include subscripts when referenced.