Tuesday, 7 July 2015

REF Cursor vs cursor

A cursor is really any SQL statement that runs DML (select, insert, update, delete) on your database.
A ref cursor is a pointer to a result set. This is normally used to open a query on the database server, then leave it up to the client to fetch the result it needs. A ref cursor is also a cursor, though normally the term cursor is used when discussing static SQL.




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;



No comments:

Post a Comment