21. 4GL Statement Glossary : ArrayInsertRow()
 
Share this page                  
ArrayInsertRow()
Inserts a record into an array.
Syntax
returnfield = ] [callproc] arrayinsertrow
 (arrrownumber = integerexpr);
returnfield
Specifies the name of field to which the result is returned. Integer.
You must include a value for returnfield if you omit the callproc keyword; otherwise it is optional.
arr
Specifies the name of an array
integerexpr
Specifies an expression that indicates the record number of the new record
Description
The arrayinsertrow() built-in function inserts a record at the record number you specify and renumbers the record that previously was at that position and the records that follow it. This contrasts with the behavior of insertrow, which inserts a row after the position you specify.
The procedure returns 0 on success, or a non-zero number on failure. Failure occurs when the specified record is not found in the set of records in the array or immediately following the end of the array.
Example
To insert an employee record into the second position in the array emparray:
callproc arrayinsertrow
  (emparray, rownumber = 2);
This inserts a blank record at record 2. The previous record 2 moves down and becomes record 3, and so on. To insert data into the new record:
emparray[2].col1 = 1135;
emparray[2].col2 = "Anderson";