Exercise Seven - Fine Tuning the Customer and Orders Tables

Top  Previous  Next

Back in Exercise Two (2), we imported raw table information into the dictionary. Although this is the fastest and most accurate way of defining your tables in the data dictionary, the file format information that is also imported may not be the best display format for your applications.

For example, a table may store a zip code as a 4-byte integer on disk. A zip code of 33024, using the default picture for that data type, will be displayed as 33,024. If the zip code stores an extension, it may be worse. For example, 330241159 stored in the table would appear as 330,241,159 by default.

Also, some data types should not be accessible to the user, like an order number or customer number. By default, all columns imported into the dictionary are designated as entry data types.

This exercise demonstrates the art of fine tuning your dictionary elements defined.

The more time spent fine tuning your dictionary, the more time you will save generating a near perfect application using the various wizard tools!

 

Auto Number your Numeric Unique Keys

1.

Highlight the Customer table in the DCT Explorer list.

2.

In the Keys View, RIGHT-CLICK on KeyCustNumber, and select Properties from the popup menu.

3.

In the Attributes group, check the Auto Number check box.

This will effectively cause any new customer that we add to automatically be assigned with the next sequential customer number (by default).

4.

Press Save and Close to close the Customer window.

5.

Highlight the Orders table in the DCT Explorer list.

6.

In the Keys View, RIGHT-CLICK on KeyOrderNumber, and select Properties from the popup menu.

7.

In the Attributes group, check the Auto Number check box.

This will effectively cause any new order that we add to automatically be assigned with the next sequential order number (by default).

8.

Press Save and Close to close the ORDERS window.

 

Set the Autonumber Unique Columns as Display Only

After adding the auto numbering capability to our numeric unique keys, we can also change the display characteristics of the auto number column(s). The reason for this is that we do not want the user to be able to modify a number that is automatically assigned. In some applications, developers sometimes like to hide this information all together from the user by not populating it. In our application, we will choose to display this information, but not allow the user to modify it.

1.

Highlight the Customer table in the DCT Explorer list.

2.

RIGHT-CLICK on the CustNumber column in the Fields list, and select Properties from the popup menu.

3.

Select the Controls tab. Change the Control Type: from Entry to String, and press the Save and Close button to close the Customer window.

4.

Highlight the Orders table in the Tables list.

5.

RIGHT-CLICK on the OrderNumber column in the Fields list, and select Properties from the popup menu.

6.

Select the Controls tab. Change the control type from Entry to String, and press the Save and Close button to close the Orders window.

Examine this section carefully before proceeding to the next section. By choosing the properties for a control at this time, you can save time later. Every application you generate from the dictionary, and every procedure in the application will automatically format the control the way you want it. If you don't format it here, and if the control requires custom formatting, you will have to custom format it for each procedure and application later. Let's continue this thought to our next section.

 

Column Display Formatting

Several columns contained in our imported tables will make better sense if we can present that data in a more readable format. For example, a date may be stored as a long integer in our table, but what does 75543 really mean? This could be 75543 days that has occurred from a base date, but is that useful to the user?

1.

In the Orders table, RIGHT-CLICK on the OrderDate column, and select Properties from the popup menu.

2.

In the Screen Picture entry, type @D2. Press the Save and Close button to close the Orders window.

Clarion provides a number of different date and time picture formats that are used with date and time data types. Click here for a brief discussion of the date formats.

3.

Highlight the Customer table in the DCT Explorer list.

4.

RIGHT-CLICK on the ZipCode column in the Columns list, and select Properties from the popup menu.

5.

In the Screen Picture entry, type @P#####P. Press the Save and Close button to close the CUSTOMER window.

The zip codes stored in our Customer table are 5-digit zip codes. However, in the raw picture format, you would see 33,334 for a zip code of 33334, and 6,792 for a zip code of 06792. The picture entered above is called a pattern picture. For a quick look at example pattern pictures, click here.

6.

Press Save and Close from the DCT Explorer toolbar. If you are prompted to save changes to GSLesson.DCT, press the Yes button to save and close the Dictionary Editor.

 

Exercise Eight - Create your Program using the Wizards