Consultor Eletrônico



Kbase 16504: Example: Using Smart Object foreign key capability (8.1)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Example: Using Smart Object foreign key capability (8.1)

This knowledgebase entry gives a step-by-step example of
how to use the foreign key functionality that is new in
version 8.1.

This example has a Smart Query on customers and a
Smart Browse that shows all customers that have the same
sales rep as the current customer.

Step 1. Create a Smart Query FOR EACH customer. To enable the
query as a foreign key source, do the following:

- Go to the Section Editor.
- Click on List.
- Select "XFTR - Foreign Keys".
- Click on "Insert Key".
- From the field list, select Sales-Rep.
- Make sure that "Sup" (for Foreign Key Supplied) = Yes.
- Save the Query as q-cfk.w

Step 2. Create a Smart Browse with the following query:

FOR EACH salesrep, EACH customer OF salesrep.

...and showing the following fields:
cust-num, name, salesrep

To enable the browse as a foreign key acceptor, do the
following:

- Go to the Section Editor.
- Click on List.
- Select "XFTR - Foreign Keys".
- Click on "Insert Key".
- Select the Salesrep table
- From the field list, select Sales-Rep.
- Make sure that "Acc" (for Foreign Key Accepted) = Yes.
- Save the Browse as b-cfk.w

Step 3. Create a Smart Viewer showing the following customer fields:

cust-num, name, salesrep

Save the Viewer as v-cfk.w

(This step is not required, but it makes the final result more
understandable.)

Step 4. Create a Smart Window with the following Smart Objects:

q-cfk.w
v-cfk.w
b-cfk.w
p-navico.r

Add the following links:

1. Navigator link from p-navico to the query q-cfk
2. Record link from query q-cfk to viewer v-cfk
(This is to be able to see the current query record.)
3. Record link from query q-cfk to browse b-cfk

Step 5. Run. You should see the following:

A viewer showing customer information, with a panel to
navigate through the customers.

A browser that shows all the customers with the same
sales rep as the customer in the viewer.


More information on using foreign keys can be found in chapter 8 and
chapter 14 of the User Interface Builder Developer's Guide.


Progress Software Technical Support Note # 16504