8. SQL Statements : ENDSELECT : Description
 
Share this page                  
Description
The ENDSELECT statement terminates embedded SQL select loops. A select loop (see Select Loops) is a block of code delimited by BEGIN and END statements and associated with a SELECT statement. As the SELECT statement retrieves rows from the database, each row is processed by the code in the select loop.
When the ENDSELECT statement is executed, the program stops retrieving rows from the database and program control is transferred to the first statement following the select loop.
The ENDSELECT statement must be inside the select loop that it is intended to terminate. If an ENDSELECT statement is placed inside a forms code block that is syntactically nested within a select loop, the statement ends the code block as well as the select loop.
The statement must be terminated according to the rules of the host language.
Note:  To find out how many rows were retrieved before the ENDSELECT statement was issued, check the sqlerrd(3) variable of the SQLCA. For details about the SQLCA, see the chapter “Working with Embedded SQL.”