Define a Table Query


When building components in the Grid Builder it is often necessary to pull specific data and records from a given table, be it .dbf or SQL. To do this it is necessary to create a Table Query.

Step 1. To Start With: 

  1. Select Grid > Query (DBF).

  2. Select the data source table from the Table Name list.

Step 2. Creating Table Aliases 

A table alias can make your grid portable, by separating it from direct reference to a table name. as long as a table has the same structure and the same alias, it can use a grid originally built for another table.

  1. Optionally, enter an alias for the table. If you do not enter an alias, it will default to the name of the table.

Step 3. Creating Calculated Fields 

Alpha Anywhere documentation and software has traditionally referred the values that you calculate and place on a layout as "calculated fields". However, these values are not fields, because they are not stored in a table record. They are temporary variables that are created and calculated on demand.

A calculated value may be displayed, but not edited. Typically, you compute a calculated value based on the values of several other fields in each record. To create a calculated value to place on the grid:

  1. Optionally, click Calculated fieldsto display the Define Calculated Fields dialog box.

    • a. Enter calculated value expressions, one per line, in the format = . For example:

      <fullname> = <alltrim(lastname) + ", " + alltrim(firstname)>
    • b. Optionally, click Expression Builder to use the Expression Builder to help you define the calculated value.

    • c. Optionally, click F2 - Fieldsto display a list of table fields to insert into the expression.

    • d. Optionally, click F4 - Functionsto display a list of functions to insert into the expression.

    • e. Optionally, use the and buttons to sort the list of calculated values.

    • f. Optionally, use the , , and buttons to reorganize the sequence of calculated values.

    • g. Click OKto continue or Cancelto discard your inputs.

Step 4. Define Arguments 

  1. Optionally, if you want to provide a value for use in the grid's filter expression, click Define Argumentsto display the Define Arguments dialog box.

Step 5. Enter a Filter Expression 

  1. Optionally, enter a logical expression that selects records from the table into the Filter field. You may click to use the Expression Builder to help you define the expression. A blank filter expression retrieves all records in the table.

  2. Optionally, check Unique records onlyto eliminate records with duplicate values.

Step 6. Enter an Order Expression 

  1. Optionally, enter a character expression that orders selected records into the Order field. You may click to use the Order Builder to help you define the expression. A blank order expression retrieves records in record number order.

  2. Optionally, click Ascendingor Descendingto change the sequence of records.

Step 7. Enable Editing of Records 

  1. Optionally, check Read onlyto indicate that you do not need to define a primary key.

  2. Click Define Primary Key(s)to define the field or character expression that will uniquely identify records.

Since record locking is not possible in a web environment, it is highly desirable to have a way to uniquely identify each record. The default identification for a record is its number, which in some circumstances can change.

See Also