GetSQLSelect method (DataWindows)
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).
Controls
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataWindow control, DataWindowChild object, DataStore |
Web ActiveX |
DataWindow control, DataWindowChild object |
Syntax
[PowerBuilder]
1 |
string <span>dwcontrol</span>.<span>GetSQLSelect</span> ( ) |
[Web ActiveX]
1 |
string <span>dwcontrol</span>.<span>GetSQLSelect</span> ( ) |
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control, |
Return Values
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:
1 |
string old_select, new_select, where_clause |
1 |
// Get old SELECT statement |
1 |
old_select = dw_emp.<span>GetSQLSelect</span>() |
1 |
1 |
// Specify new WHERE clause |
1 |
where_clause = "WHERE ..." |
1 |
// Add the new where clause to old_select |
1 |
new_select = old_select + where_clause |
1 |
1 |
// Set the SELECT statement for the DW |
1 |
dw_emp.SetSQLSelect(new_select) |