Selecting columns

You can click each column you want to include from the table representations in the Table Layout view. PowerBuilder highlights selected columns and places them in the Selection List at the top of the SQL Select painter.

StepsTo reorder the selected columns:

  1. Drag a column in the Selection List with the mouse. Release the mouse button when the column is in the proper position in the list.

The sample displays a single line. At left, a horizontal scroll area is labeled Selection List. Arranged to the right are four column names.

StepsTo select all columns from a table:

  1. Move the pointer to the table name and select Select All from the pop-up menu.

StepsTo include computed columns:

  1. Click the Compute tab to make the Compute view available (or select View>Compute if the Compute view is not currently displayed).

    Each row in the Compute view is a place for entering an expression that defines a computed column.

  2. Enter one of the following:

    • An expression for the computed column. For example: salary/12

    • A function supported by your DBMS. For example, the following is a SQL Anywhere function:

      substr("employee"."emp_fname",1,2)
      

    You can display the pop-up menu for any row in the Compute view. Using the pop-up menu, you can select and paste the following into the expression:

  3. Press the Tab key to get to the next row to define another computed column, or click another tab to make additional specifications.

    PowerBuilder adds the computed columns to the list of columns you have selected.

About computed columns and computed fields

Computed columns you define in the SQL Select painter are added to the SQL statement and used by the DBMS to retrieve the data. The expression you define here follows your DBMS’s rules.

You can also choose to define computed fields, which are created and processed dynamically by PowerBuilder after the data has been retrieved from the DBMS. There are advantages to doing this. For example, work is offloaded from the database server, and the computed fields update dynamically as data changes in the DataWindow object. (If you have many rows, however, this updating can result in slower performance.) For more information, see Chapter 19, “Enhancing DataWindow Objects.”