Example Multiple Cursor Return
This example uses the package "GetEmpData()" . Make sure that this package
will be available in the database by executing "empcur.sql" file located in the
ORACLE_HOME\OO4O directory.
// first we need a database
ODatabase odb("exampledb", "scott", "tiger");
OParameterCollection params = odb.GetParameters();
// now add a parameter named 'DEPTNO' to the database
params.Add("DEPTNO", 20, OPARAMETER_INVAR, OTYPE_NUMBER);
// now add a parameter named 'EMPCURSOR' to the database
params.Add("EMPCURSOR", "", OPARAMETER_OUTVAR, OTYPE_CURSOR);
//Execute the SQL statement
odb.ExecuteSQL("BEGIN Employee.GetEmpData (:DEPTNO,:EMPCURSOR); END;");
//retrieve the EMPCUSRSOR oparameter class
OParameter EmpcurParam = params.GetParameter("EMPCURSOR") ;
//retrieve odyn class associated with empcursor
ODynaset EmpcurDynaset;
EmpcurParam.GetValue(&EmpcurDynaset);
//now get the field value
const char *ename;
OField Enamefld = EmpcurDynaset.GetField("ename");
Enamefld.GetValue(&ename);
AfxMessageBox(ename);
//removing this will result in destroying the dynaset associated with cursor
params.Remove("EMPCURSOR");
params.Remove("DEPTNO");