createorreplacefunctionsp_ListEmpreturntypes.cursortype
as
l_cursortypes.cursorType;
begin
openl_cursorforselectename,empnofromemporderbyename;
returnl_cursor;
end;
/
With7.2onupofthedatabaseyouhavecursorvariables.Cursorvariablesarecursorsopenedbyapl/sqlroutineandfetchedfrombyanotherapplicationorpl/sqlroutine(in7.3pl/sqlroutinescanfetchfromcursorvariablesaswellasopenthem).Thecursorvariablesareopenedwiththeprivelegsoftheowneroftheprocedureandbehavejustliketheywerecompletelycontainedwithinthepl/sqlroutine.Itusestheinputstodecidewhatdatabaseitwillrunaqueryon.
Hereisanexample:
createorreplacepackagetypes
as
typecursorTypeisrefcursor;
end;
/createorreplacefunctionsp_ListEmpreturntypes.cursortype
as
l_cursortypes.cursorType;
begin
openl_cursorforselectename,empnofromemporderbyename;returnl_cursor;
end;
/
examplesforSQLPlus,Pro*C,Java/JDBC,ODBC,ADO/ASP,DBIPerlandOCIfollow:
REMSQL*Pluscommandstouseacursorvariablevariablecrefcursor
exec:c:=sp_ListEmp
printc