Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) Part Number B14308-01 |
|
Applies To
Description
Finds the row in the dynaset that matches the clause. The clause can be any valid WHERE clause without the 'WHERE'. The clause can be NULL if a previous Find has been called successfully. If clause matches the last clause from the previous Find, the WHERE clause is not re-parsed.
These methods move the current row directly to a matched row without calling any advisories except when the matched row is reached. If a matching row cannot be found the Nomatch property is set to TRUE and you are left at the row from which you called the Find operation. You should check for BOF or EOF prior to calling any of the Find operations as this will raise an error in all cases.
Usage
oresult FindFirst(const char *sql);
oresult FindNext(const char *sql = 0);
oresult FindPrevious(const char *sql = 0);
oresult FindLast(const char *sql);
Remarks
To include all the rows in your search and not just those that meet a specific condition, use the Move methods to move from row to row. Always check the value of the NoMatch property to determine whether the Find operation has succeeded. If a Find method succeeds, NoMatch returns False. If it fails, NoMatch returns True and the current position is the row from which you called the Find operation.
Return Value
An oresult indicating whether the operation succeeded (OSUCCESS) or not (OFAILURE).
Example
{
long dbopt = 0; //the default is either no option, or the default set
long dynopt = 0; //ditto
char *pCharBuff = NULL;
// first, open an ODatabase
ODatabase odb("ExampleDB", "scott", "tiger");
// create and open a dynaset
ODynaset odyn;
odyn.Open(odb, "select * from emp where empno >= 7654 and empno <= 7844 ");
OField enamefield = odyn.GetField("ename");
//FindClause for job as MANAGER
char *FindClause = "job LIKE '%GER'" ;
odyn.FindFirst(FindClause);
//NoMatch property set to true , if no rows found
oboolean nm = odyn.NoMatch();
if (nm == TRUE)
MessageBox("Couldn't find rows ");
else{
enamefield.GetValue((const char **) &pCharBuff);
MessageBox(pCharBuff); // Should display BLAKE
odyn.FindNext(FindClause);
enamefield.GetValue((const char **) &pCharBuff);
MessageBox(pCharBuff); //Should display CLARK
odyn.FindPrevious(FindClause);
enamefield.GetValue((const char **) &pCharBuff);
MessageBox(pCharBuff); // Should display BLAKE
}
strcpy(FindClause,"job LIKE '%xxx'");
odyn.FindFirst(FindClause);
//NoMatch property set to true , if no rows found
nm = odyn.NoMatch();
if (nm == TRUE)
MessageBox("Couldn't find rows ");
}