TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Sorting Problems
 
   
 Posted: 8 January 2002
 
   
 
 Applies to: All versions
 
   
 
Audience: Everyone
 
       
   

Question: Paradox doesn't sort my data properly. Why? How do I fix it?

Answer: In most cases, this occurs because of the language driver assigned to your table. For example, consider the following data values:

   Apple Computers
   Borland Software Company
   Corel Corporation
   Zen mastery
   apple pie
   blueberry muffins
   cornbread
   zucchini bread

By default, tables created using U.S. versions of Paradox use the ascii ANSI language driver. The sort order stems from the order of the characters in the ASCII character set, which lists upper-case characters before lower-case characters.

Most users, However, expect data values to be sorted in so-called "dictionary" order. For example:

   Apple Computers
   apple pie
   blueberry muffins
   Borland Software Corporation
   Corel Corporation
   cornbread
   Zen mastery
   zucchini bread

To do this, change the language driver of your tables (or the default one used by Paradox/BDE) to one that lists characters in the desired order, such as the Paradox int'l driver.

The following steps show how to do this using interactive Paradox (v10):

  1. From the main Paradox menu, choose Tools | Utilities | Restructure.
  2. Select the table in question using the Select File dialog.
  3. In the Field Roster, locate the Table Language drop-down combo-box. (It's near the lower, right corner of the dialog.)
  4. Select the desired language driver from the list of available drivers.
  5. Save your changes.

Notes:

  • Different steps may be needed with different versions of Paradox. In Paradox 5.0 and 7.16, for example, you need to choose Table Language from the Table Properties drop-down combo box near the upper-right corner of the Restructure dialog. For specific steps, refer to the Paradox Help file.

  • To determine the language driver most appropriate for your needs, refer to the Help topics in the BDE Administrator Help file, which list the names of the drivers, their supported character sets, and the collating sequence used to sort data.

  • You can use ObjectPAL to change the language driver for multiple tables. For more information, see the setLanguageDriver topics for the TCursor, Query, and System classes in the ObjectPAL Reference Help file.

  • Most versions of Paradox include a carefully constructed set of Help topics regarding character sets and related issues. Search the main Paradox Help file for a topic called "Character Set issues." This covers the basics and links to other relevant information.

  • You can also change the default language used to create tables. For more information, see our article.

Other Causes for Sorting Problems:

If your table is already using an appropriate language driver and BDE is properly configured, something else may be taking place. Possibilities include:

  1. Corrupted Indexes: Just like tables, indexes can be corrupted. Try deleting your table's indexes (.PX, .X??, and .Y?? files) and then recreating them using the Resturucture dialog. (Of course, this means you should know which indexes your tables are using. We'll discuss this in a future article.)

  2. Sort order overrides: Paradox provides a few ways to change sort orders. For example, if this behavior is appearing with:

    • A Form (or Table window), you may be using an index that displays the data using a different field than you might expect. Check the properties of the form's data model. Check the Order/Range properties using the Range button on the Filter dialog (displayed using Format | Filter in Paradox 10).

    • A Report, group bands may be resorting the data. Check the design of the report itself. (Be sure to check the Range button in the report's Filter dialog as well.)

    • Query results, the query may be sorting the data. Check the Sort tab of the Query properties (QBE queries) or any ORDER BY clause in SQL queries.

    • If you're working with a custom Paradox application, it's probable that the original developer changed one of the above items using ObjectPAL. Review the code that presents the results you're viewing for possibilities.

  3. Finally, the tables (or the ones used to generated the results you're working with) may be corrupted. Use Table Repair to verify and repair your tables as needed.

Generally, there is a clear reason for inappropriately sorted tables, one that is easily uncovered and fixed after a bit of invenstigation.

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 31 May 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]