Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) Part Number B14308-01 |
|
Applies To
Description
OSqlStmt constructor
Usage
OSqlStmt(void)
OSqlStmt(const OSqlStmt &othersql)
OSqlStmt(const ODatabase &odb, const char *sqlstmt, long options = OSQLSTMT_DEFAULT)
Arguments
Arguments |
Description |
---|---|
othersql |
The OSqlStmt object to copy. |
odb |
The database on which to open this sqlstmt instance. |
sqlstmt |
A valid select SQL statement. |
options |
Options to use to create this sqlstmt instance. |
These methods construct a new OSqlStmt instance. The default constructor constructs an unopened OSqlStmt object. The default constructor method cannot fail. You must open the object before you can use it.
The copy constructor copies another OSqlStmt object. If othersql is open--is a handle on an implementation sqlstmt object--then the new OSqlStmt object becomes a handle to that same sqlstmt object. The copy constructor copies the reference to the sqlstmt object but does not copy any strings that the source OSqlStmt might own. Since the copy constructor can fail, you must check whether the new OSqlStmt is open after the constructor call.
The remaining constructor constructs the sqlstmt object and attempts to open it. Opening a OSqlStmt object creates a new sqlstmt object. An ODatabase and a SQL statement must be given to open the OSqlStmt. The options affect various aspects of the sqlstmt object behavior (see OSqlStmt section for more information). Since the copy and open constructor can fail, you must check whether the OSqlStmt object is open after the constructor call.
Example
Examples of opening OSQlStmt:
// first we need a database ODatabase odb("ExampleDB", "scott", "tiger"); OParameterCollection pcoll = odb.GetParameters(); OParameter p1 = pcoll.Add("EMPNO", 7369, OPARAMETER_INVAR, OTYPE_NUMBER); OParameter p2 = pcoll.Add("ENAME", "me", OPARAMETER_OUTVAR, OTYPE_VARCHAR2); // default constructor OSqlStmt osqlstmt; oboolean isopen = osqlstmt.IsOpen(); // isopen is FALSE // copy constructor OSqlStmt osqlstmt2(osqlstmt); isopen = osqlstmt2.IsOpen(); // isopen is FALSE because osqlstmt was not open // create and open a dynaset OSqlStmt osqlstmt3(odb, "Begin Employee.GetEmpName (:EMPNO, :ENAME); end;"); isopen = osqlstmt3.IsOpen(); // isopen is TRUE - the open was successful // and now if we use a copy constructor OSqlStmt osqlstmt4(osqlstmt3); isopen = osqlstmt.IsOpen(); // isopen is TRUE