Provided you have an active OracleConnection object "connection", you can use the following code:
Code: Select all
// Create an OraclePackage object corresponding to your package
OraclePackage pack = new OraclePackage();
pack.Connection = connection;
pack.PackageName = "PKG_MY";
// Get the collection of parameters needed to execute your function
OracleParameterCollection parms = pack.DescribeProcedure("GetRegions");
// Execute the function, get the resulting object, which is of the OracleCursor type
object o = pack.ExecuteProcedure("GetRegions", parms);
OracleCursor cursor = (OracleCursor)o;
// Get DataReader from the OracleCursor object and populate DataTable with the reader:
OracleDataReader reader = cursor.GetDataReader();
DataTable dt = new DataTable();
dt.Load(reader);