« March 20, 2007 | Main | March 22, 2007 »

March 21, 2007 Archives

March 21, 2007

Ref Cursor Datasources

Far too many enquiries recently about how to hook BIP up with a REF CURSOR.So here it is, thanks to Juergen in Germany for the sample.

You need to create a function in the database that will return the ref cursor when called, of course you can pass parameters to the function just like any other function. Here's a simple example that selects all the data from the CUSTOMERS table based on the customer id i.e. p_customer_id


create or replace function f_ref_cursor (p_customer_id IN number)

return SYS_REFCURSOR as


TYPE t_cursor is REF CURSOR;

v_cursor t_cursor;


open v_cursor FOR

select * from customers

where customer_id = p_customer_id;


RETURN v_cursor;

end;



Simple stuff, now how do you call the function from your BIP report?
Just use a SQL based data sources thus:

select f_ref_cursor(:cust_id) from dual
The cust_id is from a parameter defined in the report definition.

Ref Cursors ... Done!

About March 2007

This page contains all entries posted to Oracle BI Publisher Blog in March 2007. They are listed from oldest to newest.

March 20, 2007 is the previous archive.

March 22, 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle