6. QUEL and EQUEL Statements : Retrieve Cursor Statement--Retrieve Data into Host Variables : Examples
 
Share this page                  
Examples
The following examples provide details.
Example 1:
The following example illustrates typical use of retrieve cursor, with associated cursor statements:
## ename    character_string(26)
## age      integer
## declare cursor cursor1 for
##  retrieve (employee.empname, employee.#age)
##  sort by empname
## open cursor cursor1
loop until no more rows
##  retrieve cursor cursor1 (ename, age)
    print ename, age
end loop
## close cursor cursor1
Example 2:
A param version of the above:
addresses(1) = address_of(name)
addresses(2) = address_of(age)
target_list = "%c, %i4"
## retrieve cursor cursor1 
##  (param (target_list, addresses))
Example 3:
The following example illustrates the use of an indicator variable in a retrieve cursor statement:
## retrieve cursor2 (name, salary:indicator_var)