TOrdInfo

Source: source/classes/tordinfo.prg

Standalone class

TOrdInfo encapsulates index order metadata for DBF tables. It stores the tag name, index bag (file) name, key expression, uniqueness flag, field names, and filter conditions. It can also generate SQL-equivalent ORDER BY and DECLARE statements for migrating indexed DBF logic to SQL backends.

Key DATA Members

DATATypeDescription
cTagNameCharacterIndex tag name
cBagNameCharacterIndex bag (file) name, e.g. "customers.cdx"
cExpKeyCharacterIndex key expression as a string
bExpKeyBlockIndex key expression as a code block
lUniqueLogical.T. if the index enforces unique keys
aFieldNameArrayArray of field names used in the index key

Methods

MethodDescription
New( cTag, cBag, cExpKey, bExpKey, lUniq, cFilt, aAscDsc, cFldRec )Create a new index order information object
SqlOrder()Generate an SQL ORDER BY clause from the index key expression
SqlDeclare()Generate an SQL DECLARE statement for the index

Example: Translate DBF Index to SQL ORDER BY

#include "FiveWin.ch"

function Main()

   local oIdx

   // Describe a DBF index
   oIdx := TOrdInfo():New( "NAME", "customers.cdx", ;
      "UPPER(LAST)+UPPER(FIRST)", .F. )

   ? "Tag:",       oIdx:cTagName
   ? "Bag:",       oIdx:cBagName
   ? "Key expr:",  oIdx:cExpKey
   ? "Unique:",    oIdx:lUnique

   // Generate equivalent SQL ORDER BY
   ? "SQL ORDER BY:", oIdx:SqlOrder()
   // Output: ORDER BY UPPER(LAST), UPPER(FIRST)

   // Generate SQL DECLARE
   ? "SQL DECLARE:", oIdx:SqlDeclare()

return nil

Notes

See Also