SetSQLSelect – PB Docs 150

SetSQLSelect method (DataWindows)


Specifies the SQL SELECT
statement for a DataWindow control or DataStore.


DataWindow type

Method applies to


DataWindow control, DataWindowChild object, DataStore


Server component

Web ActiveX

DataWindow control, DataWindowChild object



[Web DataWindow server component]

[Web ActiveX]




The name of the DataWindow control, DataStore,
or child DataWindow for which you want to change the SELECT statement.


A string whose value is the SELECT statement
for the DataWindow object. The statement must structurally match
the current SELECT statement (that is, it must
return the same number of columns, the columns must be the same
datatype, and the columns must be in the same order).

Return Values

SetSQLSelect returns
1 if it succeeds and –1 if the SELECT statement cannot
be changed. If any argument’s value is null, in PowerBuilder
and JavaScript the method returns null.


Use SetSQLSelect to
dynamically change the SQL SELECT statement
for a DataWindow object in a script.

If the DataWindow is updatable, PowerBuilder validates the SELECT statement
against the database and DataWindow column specifications when you
call the SetSQLSelect method.
Each column in the SQL SELECT statement
must match the column type in the DataWindow object. The statement
is validated only if the DataWindow object
is updatable.

You must use the SetTrans or SetTransObject method
to set the transaction object before the SetSQLSelect method will

If the new SELECT statement has a different
table name in the FROM clause and the DataWindow
object is updatable, then PowerBuilder must change the update information
for the DataWindow object. PowerBuilder assumes the key columns
are in the same positions as in the original definition. The following
conditions would make the DataWindow not updatable:

  • There
    is more than one table in the FROM clause

  • A DataWindow update column is a computed column
    in the SELECT statement

If changing the SELECT statement makes
the DataWindow object not updatable, the DataWindow control cannot
execute an Update method call for the DataWindow object in the future.

note.png Limitations to using SetSQLSelect

Use SetSQLSelect only if
the data source for the DataWindow object is a SQL SELECT statement without retrieval
arguments and you want PowerBuilder to modify the update information
for the DataWindow object:

Modify does not verify the SELECT statement
or change the update information, so it is faster but more susceptible
to user error. Although you can use Modify when
arguments are involved, this is not recommended because of the lack
of verification.


If the current SELECT statement
for dw_emp retrieves no rows, the following statements
replace it with the syntax in NewSyn:

See Also

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x