Applies To
OBinder
ODynaset
OSqlStmt
Description
This method sets the SQL statement that will be used the next time the dynaset
or sqlstmt is refreshed.
Usage
oresult SetSQL(const char *sqls)
Arguments
sqls
The new SQL statement.
Remarks
OBinder: This method sets the SQL statement to be used the next time RefreshQuery is called.
ODynaset: This method sets the SQL statement to be used on the next Refresh. The ODynaset copies the SQL statement, so the calling routine does not have to retain it.
(See GetSQL for more discussion.)
The result set of a dynaset is determined by the SQL statement that is
executed to fetch the records. This method enables you to reset the SQL statement of
the dynaset. Resetting the SQL statement does not immediately change the
dynaset's result set.
The dynaset's result set can be changed to correspond to the new SQL statement
by calling ODynaset::Refresh or OBinder::RefreshQuery.
Setting the SQL statement invalidates any pointers to previously returned SQL
statements (from GetSQL).
OSqlStmt: This method sets the SQL statement to use on the next Refresh. The OSqlStmt copies the SQL statement, so the calling routine does not have to retain it.
(See GetSQL for more discussion.)
You can change the sqlstmt object's result set to correspond to the new SQL
statement by calling OSqlStmt::Refresh.
Setting the SQL statement invalidates any pointers to previously returned SQL
statements (from GetSQL).
Return Value
An oresult indicating whether the operation succeeded (OSUCCESS) or not
(OFAILURE).
Example
Change the SQL statement of a dynaset:
// open an ODatabase object
ODatabase odb("ExampleDB", "scott", "tiger");
// open an ODynaset
ODynaset odyn(odb, "select * from emp order by ename");
// ... do some processing ...
// now get the records again, but in a different order
odyn.SetSQL("select * from emp order by empno");
odyn.Refresh();