In the general use of the forEach statement, a loop iteration retrieves the next element in a list and operates on that element.
In the usage that is specific to SQL, an iteration retrieves the next row in an SQL result set and operates on that row. After processing all rows, the forEach statement closes the result set. If an exception occurs, the result set stays open.
Record myRecordType myString String; myInt Int; end
The following code illustrates the general use of the forEach statement:
myList string[]; myList.appendElement("one"); myList.appendElement("two"); myList.appendElement("three"); myList02 int[]; myList02.appendElement(1); myList02.appendElement(2); myList02.appendElement(3); myList03 MyRecordType[]; myList03.appendElement(new MyRecordType{myString = "01", myInt = 1}); myList03.appendElement(new MyRecordType{myString = "02", myInt = 2}); myList03.appendElement(new MyRecordType{myString = "03", myInt = 3}); forEach(myElement string from myList) SysLib.writeStdOut(myElement); end forEach(myElement02 int from myList02) SysLib.writeStdOut(myElement02); end forEach (myElement03 MyRecordType from myList03) SysLib.writeStdOut(myElement03.myString + " " + myElement03.myInt); end
one two three 1 2 3 01 1 02 2 03 3
Target | Issue |
---|---|
Java | No issues. |
JavaScript | Database access is not supported in JavaScript. However, the forEach statement is available for general use. |