Ranges for multisegment keys

If a key is composed of several segments, you can create ranges based upon several key segments. The clear field and fill statements are often used when setting ranges for multisegment keys. For example, the Purchase_Data table is shown in the following illustration. It has a key composed of the Purchase Date and the Store ID.

[spacer]

Purchase Date

Store ID

Amount

11/16/98

C

100.00

11/17/98

A

50.00

11/17/98

B

75.00

11/17/98

C

22.00

11/18/98

A

175.00

11/18/98

C

60.00

11/19/98

A

45.00

11/19/98

C

16.00

11/20/98

B

100.00


The following script sets a range to include all purchases made on 11/17/98 for all stores. The first segment of the key is set to the date 11/17/98. The second segment is set to its minimum value using the clear field statement, then the start of the range is set. The first segment remains 11/17/98. The second segment is set to its maximum value using the fill statement. Then the end of the range is set. Using the clear field and fill statements on the Store ID fields allows all stores to be selected.

{Clear any previous range for the table.}
range clear table Purchase_Data;
{Set the start of the range.}
'Purchase Date' of table Purchase_Data = setdate('Purchase  Date' of table Purchase_Data, 11, 17, 1998);
clear field 'Store ID' of table Purchase_Data;
range start table Purchase_Data by number 1;
{Set the end of the range.}
'Purchase Date' of table Purchase_Data = setdate('Purchase Date' of table Purchase_Data, 11, 17, 1998);
fill 'Store ID' of table Purchase_Data;
range end table Purchase_Data by number 1;


Documentation Feedback