Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 1 (10.1)

Part Number B10119-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

GetSQL Method

Applies To

ODynaset

OSqlStmt

Description

This method returns the SQL statement belonging to the dynaset or sqlstmt.

Usage

const char *GetSQL(void) const

Remarks

When an ODynaset is opened, creating a dynaset object, a SQL query is given. Subsequently, the SQL statement may be changed with the SetSQL method of ODynaset. This routine returns the most recent SQL statement given to the dynaset, either through ODynaset::Open or ODynaset::SetSQL.

When an OSqlStmt object is created and opened, a SQL query is given. Subsequently, the SQL statement might be changed with the SetSQL method of OSqlStmt. This routine returns the most recent SQL statement given to the sqlstmt object, either through OSqlStmt::Open or OSqlStmt::SetSQL.

If SetSQL has been called and the dynaset or sqlstmt has not been refreshed, then the SQL statement returned by this method will not correspond to the SQL statement that gives the current result set.

The pointer that is returned is managed by the object. It should not be freed by the caller; it will be freed when the object is destroyed or closed, or the next time SetSQL, Open, or GetSQL is called.

Return Value

This method returns a valid, null terminated const char pointer on success; NULL on failure.

Example

An example showing the use of GetSQL:

// Open a database

ODatabase odb("ExampleDB", "scott", "tiger");

// open a dynaset

ODynaset dyn(odb, "select * from emp");

const char *sql1 = dyn.GetSQL();

// sql1 is equal to "select * from emp"

// now set the SQL of the dynaset

dyn.SetSQL("select * from dept");

// now the sql1 pointer is invalid

// so get sql1 again

sql1 = dyn.GetSQL();

// sql1 is equal to "select * from dept"

// but the current result set is select * from emp

// now refresh the dynaset

dyn.Refresh();

// sql1 is still valid

// and now sql1 and the current result set are in synch