Logical block

Logical block which can be included into the FOR statement has the following structure:

Declaration clause

The optional DEFINE statement

Statement list

Executable statements or special keywords

The logical block can include the DEFINE statement used to declare spot variables. These variables are visible only within the FOREACH statement and cannot be referenced from outside the FOREACH loop. The DEFINE statement of the logical block is optional and can be omitted.

 

The statement list can include the following:

CONTINUE FOREACH keywords

CONTINUE FOREACH keywords terminate the processing of the current row within a FOREACH loop, 4GL comes back to the first statement of the FOREACH loop, fetches the next row and processes it.

DECLARE c_cont CURSOR FOR

      SELECT company_name, company_id, FROM contact

      WHERE contact.cont_loc = p_company_location

FOREACH c_cont INTO cont_arr[i].company_name, cont_arr[i].company_id

LET i = i+1

      IF company_id < 100 AND company_id > 10 THEN

      CONTINUE FOREACH

      END IF

END FOREACH

EXIT FOREACH keywords

EXIT FOREACH statement terminates the execution of the FOREACH loop and 4GL starts executing the first statement that follows the END FOREACH keywords. All the statements between the EXIT FOREACH and END FOREACH keywords are ignored.

FOREACH c_contact INTO cont_arr[i].*

LET i = i+1

      IF i > 50 THEN

      EXIT FOREACH

      END IF

END FOREACH

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.