Range types

How a range is evaluated depends upon the database manager used for the table. For the Btrieve and c-tree database managers, ranges are evaluated inclusively. For the SQL database manager, ranges are evaluated either inclusively or exclusively.

The following example illustrates the difference between these two methods of evaluating a range. The sample table shown in the following illustration has a key composed of the three segments shown.

[spacer]

Segment 1

Segment 2

Segment 3

A

A

A

A

A

B

A

A

C

A

B

A

A

B

B

A

B

C

A

C

A

A

C

B

A

C

C

B

A

A

B

A

B

B

A

C

B

B

A

B

B

B

B

B

C

B

C

A

B

C

B

B

C

C

C

A

A

C

A

B

C

A

C

C

B

A

C

B

B

C

B

C

C

C

A

C

C

B

C

C

C


The following range is set for the table:

[spacer]

Range start:

A     A     A

Range end:

A     C     B


The following records are included in the inclusive range.

[spacer]

Segment 1

Segment 2

Segment 3

A

A

A

A

A

B

A

A

C

A

B

A

A

B

B

A

B

C

A

C

A

A

C

B


The following records are included in the exclusive range.

[spacer]

Segment 1

Segment 2

Segment 3

A

A

A

A

A

B

A

B

A

A

B

B

A

C

A

A

C

B


Notice that inclusive and exclusive ranges don’t contain the same records. This is an issue when developing an application, because the Btrieve and c-tree database managers always produce inclusive ranges, but the SQL database manager has optimal performance when it produces exclusive ranges. The SQL database manager can be forced to produce inclusive ranges, but the application’s performance may be seriously degraded. To eliminate the discrepancies that result from the two types of ranges, we recommend that you implement “well-behaved” ranges in your application.


Documentation Feedback