INTO clause specifies one or more variables separated by commas that are used to store the values from the rows processed by the FOREACH statement.
Variable List |
A list of one or more variables separated by comas |
The variables must match the columns of the specified table in number, order and data types. The INTO clause in the example above stores the values retrieved from the database table into a program array:
FOREACH c_contact INTO cont_arr[i].*
The INTO clause is optional, it may not be present, if the INTO clause is already present in the SELECT statement for which the cursor used in the FOREACH statement has been declared. However, it is advisable that you include the INTO clause into the SELECT statement only if the rows are not retrieved into a program array, otherwise, use the INTO clause of the FOREACH statement. Below is an example of the INTO clause within the SELECT statement instead of the FOREACH statement.
DECLARE c_contact CURSOR FOR
SELECT company_name INTO comp_name FROM contact
WHERE contact.cont_ord = p_company_id
FOREACH c_contact
END FOREACH