Using query mode – PB Docs 126

Using query mode

proc.png To provide query mode to users during execution:

  1. Turn query mode on by coding.

    In PowerBuilder:

    In JavaScript:

    All data displayed in the DataWindow is blanked out, though
    it is still in the DataWindow control’s Primary buffer,
    and the user can enter selection criteria where the data had been.

  2. The user specifies selection criteria in the DataWindow,
    just as you do when using Quick Select to define a DataWindow object’s
    data source.

    Criteria entered in one row are ANDed together; criteria in
    different rows are ORed. Valid operators are =, <>, <, >, <=, >=,
    LIKE, IN, AND, and OR.

    For more information about Quick Select, see
    the PowerBuilder Users Guide.

  3. Call AcceptText and Retrieve, then turn off query
    mode to display the newly retrieved rows.

    In PowerBuilder:

    In JavaScript:

    The DataWindow control adds the newly defined selection criteria
    to the WHERE clause of the SELECT statement, then retrieves and
    displays the specified rows.

note.png Revised SELECT statement

You can look at the revised SELECT statement that is sent
to the DBMS when data is retrieved with criteria. To do so, look
at the sqlsyntax argument in the SQLPreview event of the DataWindow
control.

How the criteria affect the SELECT statement

Criteria specified by the user are added to the SELECT statement
that originally defined the DataWindow object.

For example, if the original SELECT statement was:

and the following criteria are specified:

dadyn4.gif

the new SELECT statement is:

Clearing selection criteria

To clear the selection criteria, Use the QueryClear property.

In PowerBuilder:

In JavaScript:

Sorting in query mode

You can allow users to sort rows in a DataWindow while specifying
criteria in query mode using the QuerySort property. The following
statement makes the first row in the DataWindow
dedicated to sort criteria (just as in Quick Select in the DataWindow
wizard).

In PowerBuilder:

In JavaScript:

Overriding column properties during query mode

By default, query mode uses edit styles and other definitions
of the column (such as the number of allowable characters). If you
want to override these properties during query mode and provide
a standard edit control for the column, use the Criteria.Override_Edit
property for each column.

In PowerBuilder:

In JavaScript:

You can also specify this in the DataWindow painter by checking
Override Edit on the General property page for the column. With
properties overridden for criteria, users can specify any number
of characters in a cell (they are not constrained by the number
of characters allowed in the column in the database).

Forcing users to specify criteria for a column

You can force users to specify criteria for a column during
query mode by coding the following:

In PowerBuilder:

In JavaScript:

You can also specify this in the DataWindow painter by checking
Equality Required on the General property page for the column. Doing
this ensures that the user specifies criteria for the column and
that the criteria for the column use = rather than other
operators, such as < or >=.


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