5. Embedded QUEL : Data Manipulation with Cursors : Example of Cursor Processing
 
Share this page                  
Example of Cursor Processing
The following example uses a cursor to print the names and salaries of all the employees in the table and set any salaries under $10,000 to $10,000.
begin program
## name    character_string(15)
## salary  float
## ingres personnel
## range of e is employee
## declare cursor c1 for
## retrieve
## (e.empname, e.#salary)
## for update of (#salary)
## open cursor c1
loop while more rows
## retrieve cursor c1 (name, salary)
print name, salary
  if salary less than 10000 then
## replace cursor c1 (#salary = 10000)
  end if
/* use the inquire_ingres statement to check endquery 
status for end-of-table*/
 end loop
## close cursor c1
## exit
end program