|Oracle Objects for OLE C++ Class Library
Part Number A95896-01
This method sets up a dynaset to access PLSQL cursor. The SQL statement should be a stored procedure or anonymous block. The Resulting dynaset is READONLY. Attempting to use SetSQL method results in error. The dynaset can be refreshed with new parameters as normal.
oresult PlsqlOpen(const ODatabase &odb, const char * sqlstmt, const char *CursorName,long options = ODYNASET_DEFAULT)
oresult PlsqlOpen(const ODatabase &odb, const char *sqlstmt, const char *CursorName, unsigned int slicesize, unsigned int perblock, unsigned int blocks, unsigned int fetchlimit, unsigned int fetchsize, long options = ODYNASET_DEFAULT)
||The database with which to open this dynaset.
||A valid PLSQL procedure.
||Name of the cursor created in the PLSQL stored procedure.
||Options to be used to create the dynaset.
||A valid select SQL statement.
||Cache slice size.
||Cache slices per block.
||Cache maximum number of blocks.
||Fetch array size.
||Fetch array buffer size.
The first method opens the ODynaset object from the PL/SQL cursor, creating an underlying dynaset object. The dynaset is formed on records retrieved from the database represented by odb and PLSQL cursor describing the SQL select statement. The ODynaset is automatically positioned at the first record after opening.
The SQL statement must be a PLSQL stored procedure with BEGIN and END around the call as if it were executed as an anonymous PL/SQL block .Otherwise an error is returned. CursorName should exactly matches the cursor created inside the stored procedure or anonymous PL/SQL block . Otherwise an error is returned. Cursor created inside the stored procedure should represents the valid SELECT sql statement or an error is returned.
You do not need to bind the PL/SQL cursor variable using OParameterCollection's Add Method, if stored procedure is having cursor as a output parameter. You can use PL/SQL bind variables in conjunction with the OParameterCollection.
The second Open method opens the ODynaset object from the PLSQL cursor using custom cache and fetch parameters.
The options argument can have the following values:
Open Method Options
||Accept the following default behavior: Behave like the default mode for an ODatabase object: Field values not explicitly set are set to NULL, overriding server column defaults. Perform automatic binding of database parameters. Strip trailing blanks from character string data retrieved from the database. Create an updatable dynaset. Cache data on client. Force a MoveFirst on dynaset creation. Maintain read-consistency.
||Do not perform automatic binding of database parameters.
||Do not strip trailing blanks from character string data retrieved from the database.
||Do not create a local dynaset data cache. Without the local cache, previous rows within a dynaset are unavailable; however, increased performance results during retrieval of data from the database (move operations) and from the rows (field operations). Use this option in applications that make single passes through the rows of a dynaset for increased performance and decreased resource usage.
||Does not force a MoveFirst on dynaset creation. BOF and EOF are both TRUE.
This example demonstrates the use of PL/SQL cursor in the PlsqlOpen method. It creates a PLSQL cursor as a dynaset object for the different values of DEPTNO parameter. Make sure that corresponding stored procedure (found in EMPCUR.SQL) is available in the Oracle Server.
// first, open an Odatabase
ODatabase odb("ExampleDB", "scott", "tiger");
OParameterCollection params = odb.GetParameters();
params.Add("DEPTNO", 20, OPARAMETER_INVAR, OTYPE_NUMBER);
// create and open a dynaset
odyn.PlsqlOpen(odb, "Begin Employee.GetEmpData (:DEPTNO,:EmpCursor);
end;", "EmpCursor", 0L);