Skip Headers
Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 2 (10.2)

Part Number B14308-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

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 script located in the ORACLE_BASE\ORACLE_HOME\oo4o directory.

Note: For more information about sample code, see Sample Code and Applications.

// 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");