A cursor is really any SQL statement that runs DML (selects, inserts, updates, deletes) in your database.
The ref cursor is a pointer to the result set. This is usually used to open a query on a database server, and then leave it to the client to get the desired result. The ref cursor is also a cursor, although the term term cursor is usually used when discussing static SQL.
Link cursors are commonly used to modify the where clause based on user input. For example, this function either opens a query to the emp table or the dept table, depending on what the user has selected:
create or replace function f (input in varchar2) return sys_refcursor as cur sys_refcursor; begin if input = 'EMP' then open cur for select * from emp; elsif input = 'DEPT' then open cur for select * from dept; end if; return cur; end; /
source share