Friday, March 28, 2008

Oracle REF Cursor

To use a cursor, you have to create a package. The convention is to use ref cursor for everything. If it doesn't exist, you can create it by running:


CREATE OR REPLACE PACKAGE types
AS
TYPE ref_cursor IS REF CURSOR;
END;


Then you can use the ref cursor like so;



CREATE OR REPLACE FUNCTION sp_get_stocks(v_price IN NUMBER)
RETURN types.ref_cursor
AS
stock_cursor types.ref_cursor;
BEGIN
OPEN stock_cursor FOR
SELECT ric,price,updated FROM stock_prices
WHERE price <>

No comments:

Labels

Blog Archive

Contributors