Including Computed Columns Using SQL Select

Computed columns that you define in the SQL Select painter are added to the SQL statement and used by the DBMS to retrieve the data. The expressions you define here follow your DBMS's rules.

Note: You can also 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, dynamic updating may result in slower performance.)

To include computed columns:

  1. Click the Compute tab (or select View > Compute if the Compute view does not currently appear).
    Each row in the Compute view is a place for entering an expression that defines a computed column.
  2. Enter one of the following:
    Option Description
    An expression for the computed column For example: salary/12
    A function supported by your DBMS For example (SQL Anywhere function): substr("employee"."emp_fname",1,2)
  3. Right-click any row in the Compute view to display the context menu, which has options that allow you to select and paste the following into the expression:
    • Names of columns in the tables used in the DataWindow or pipeline
    • Any retrieval arguments you have specified
    • Functions supported by the DBMS (The functions are provided by your DBMS. They are not PowerBuilder functions. You are now defining a SELECT statement to be sent to your DBMS for processing.)
  4. Press the Tab key to move 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 selected columns.