When you built the first DataWindow object, you used Quick Select to specify the table and columns. This let you retrieve all the customers without having to use the Select painter.
To build the second DataWindow object, you use the Select painter. You need to define a retrieval argument and WHERE criteria so you can pass an argument to the DataWindow object during execution. In this case, you will pass the customer ID.
In this section, you:
Now you select a data source and define how the data is to be presented.
Click the New button in the PowerBar.
The New dialog box appears.
Click the DataWindow tab if it is not already selected.
Select Freeform from the list of presentation styles and click OK.
Select SQL Select as the data source and select the Retrieve On Preview if it is not already selected.
Since the data source is SQL Select, you go to the Select painter and the Select Tables dialog box displays.
Selecting the Retrieve On Preview check box allows you to view the data returned by a query in the development environment, but you need to provide initial values for any retrieval arguments that you specify.
Click Next.
Now you select the table and the columns from that table to use in the DataWindow object.
Select customer in the list of tables and click Open.
The Select painter displays the customer table and its columns.
Right-click the header area of the Customer table in the Table Layout view.
Select Select All from the pop-up menu.
The column names appear in the Selection List area above the table in the Table Layout view.
The column order in the Selection List reflects the order in which columns are selected. Since you selected all the columns at once, the order displayed is the original order of the columns in the database. You change the column presentation order later.
You can also see the order of selection in the Syntax view. Display the Syntax view by clicking the Syntax tab at the bottom of the stack of tabbed panes. The Syntax view displays the generated Select statement.
Now you define a retrieval argument.
Select Design>Retrieval Arguments from the menu bar.
The Specify Retrieval Arguments dialog box displays.
Type cust_id
in
the Name box.
The default data type is Number, which is what you want.
Click OK.
The retrieval argument is defined.
Now you specify a WHERE clause using the retrieval argument to retrieve a specific customer.
Click the Where tab in the stack.
The Where view displays.
Click in the box below Column in the Where view.
A down arrow displays, and the box becomes a drop-down list box.
Select "customer"."id".
Your selection displays immediately below the Column heading. An equal sign (=) appears in the Operator box. This is correct, so do not change it.
Right-click in the box below the Value column header in the Where view.
Select Arguments from the pop-up menu, select :cust_id
,
and click Paste.
Click the Syntax tab in the stack.
The Syntax view displays the modified SELECT statement.
Scroll down until you see the generated WHERE clause.
You have now created a complete SQL SELECT statement that retrieves data from several columns in the customer table where the id column is equal to an argument that will be supplied during execution.
Now you view the DataWindow in the DataWindow painter using the Design and Preview views.
Click the Return button in the PainterBar
or
Select File>Return To DataWindow Painter from the menu bar.
The DataWindow wizard asks you to select the borders and colors for the new DataWindow object.
Select Raised from the Border drop-down list box for columns.
Click Next.
You have added raised borders to the columns, but not to the labels in the DataWindow object. The DataWindow wizard summarizes your selections.
Click Finish.
Because you selected the Retrieve On Preview check box and because the Preview view is part of the default layout scheme for the DataWindow painter, the Specify Retrieval Arguments dialog box appears.
This dialog box prompts you for an argument value. When you put this DataWindow object into the tutorial application, you write a script that passes the required argument to the DataWindow object automatically.
Type a customer ID (such as 101, 102, or 103) in the Value field.
Click OK.
The DataWindow painter opens. The Design view displays the new DataWindow object.
Changing font sizes If you cannot see all letters in a label, press Ctrl+A to select all the items in the DataWindow, then select a smaller font size in the StyleBar.
The DataWindow Preview view retrieves the requested customer data.
Now you name the DataWindow object and save it. You could wait to save it until you leave the painter, but it is good practice to save your work frequently.
Select File>Save from the menu bar.
The Save DataWindow dialog box displays.
Make sure pbtutor.pbl is selected in the Application Libraries box.
Type d_customer
in
the DataWindows box.
Earlier you saved a DataWindow object as d_custlist.
(Optional) Type the following comments in the Comments box.
This DataWindow retrieves all columns for the Customer table. It is useful as a detail DataWindow.
Click OK.
You return to the DataWindow painter.