GetSQLSelect

Description

Reports the SQL SELECT statement associated with a DataWindow if its data source is one that accesses a SQL database (such as SQL Select, Quick Select, or Query).

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object


Syntax

PowerBuilder

string dwcontrol.GetSQLSelect ( )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or child DataWindow


Return value

Returns the current SQL SELECT statement for dwcontrol. GetSQLSelect returns the empty string ("") if it cannot return the statement.

If dwcontrol is null, the method returns null.

Usage

When you want to change the SQL SELECT statement for a DataWindow or DataStore at runtime, you can use GetSQLSelect to save the current SELECT statement before making the change.

When you define a DataWindow, PowerBuilder stores a PowerBuilder SELECT statement (PBSELECT) with the DataWindow. If a database is connected and SetTransObject has been called for the DataWindow, then GetSQLSelect returns the SQL SELECT statement. Otherwise, GetSQLSelect returns the PBSELECT statement.

You can also use Describe to obtain the SQL SELECT statement. The DataWindow object's Table.Select property holds the information.

Examples

The code saves the SELECT statement for dw_emp in the variable old_select. Then it adds a WHERE clause. The example assumes the old SELECT statement did not have one already:

string old_select, new_select, where_clause
// Get old SELECT statement
old_select = dw_emp.GetSQLSelect()
 
// Specify new WHERE clause
where_clause = "WHERE ..."
// Add the new where clause to old_select
new_select = old_select + where_clause
 
// Set the SELECT statement for the DW
dw_emp.SetSQLSelect(new_select)

See also

SetSQLSelect