Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 1 (10.1) Part Number B10119-01 |
|
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");