Oracle Objects for OLE C++ Class Library
Release 8.1.7

Part Number A85258-01

Library

Product

Contents

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


 
Oracle
Copyright copy; 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents