Cursors used up to this point were related to simple unchanging SQL queries. Cursor parameters allow you to modify the query results.
declare CURSOR crs (fname VARCHAR2) IS SELECT * FROM employees WHERE first_name = fname ORDER BY first_name; rec employees%rowtype; begin open crs ('David'); loop fetch crs into rec; exit when crs%notfound; dbms_output.put_line(rec.first_name || ' ' || rec.last_name); end loop; close crs; end; /
In this example, a cursor named crs is declared that takes a parameter named fname. When the cursor is opened, a value is supplied to the parameter which limits the results of the query.