TDBase
Fuente: source/classes/tdbase.prg
Standalone class
TDBase represents SQL database metadata, storing the database name and up to eight relation definitions with their corresponding INTO clauses. It is used by the SQL query and reporting engine to resolve table relationships in SELECT statements.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cDatabase | Character | Name of the SQL database |
aRelations | Array | Array of relation definitions (up to 8) |
aIntos | Array | Array of INTO clause definitions (up to 8) |
Methods
| Method | Description |
|---|---|
New( cDb, cRel01, cRel02, cRel03, cRel04, cRel05, cRel06, cRel07, cRel08, cInto01, cInto02, cInto03, cInto04, cInto05, cInto06, cInto07, cInto08 ) | Create a new database metadata object with up to 8 relation/INTO pairs |
Example: Define Database Relations
#include "FiveWin.ch"
function Main()
local oDb
// Define a "sales" database with two relations
oDb := TDBase():New( "sales", ;
"CUSTOMER.ID = ORDERS.CUSTID", "ORDERS.ID = ITEMS.ORDERID", , , , , , , ;
"CUSTOMERS", "ORDER_ITEMS" )
? "Database:", oDb:cDatabase
? "Relation 1:", oDb:aRelations[ 1 ]
? "Into 1:", oDb:aIntos[ 1 ]
? "Relation 2:", oDb:aRelations[ 2 ]
? "Into 2:", oDb:aIntos[ 2 ]
return nil
Notes
- TDBase is a lightweight metadata container primarily used to configure the SQL query generator with table relationships.
- Up to eight relation/INTO pairs can be defined. Unused positions should be left empty (skipped).
- The
aRelationsarray stores JOIN condition strings (e.g., "TABLE1.COL = TABLE2.COL"), whileaIntosstores the alias or target table names. - This class is typically used internally by the reporting engine rather than directly in application code.