xHarbour Reference Documentation > Function Reference |
Returns the linking expression of a specified relation.
DbRelation( <nRelation> ) --> cLinkExpression
The function returns a character string containing the relation expression specified with <nRelation>, or a null string ("") when no relation exists for <nRelation>.
The DbRelation() function can be used to query the relation expression for a given relation. In conjunction with DbRSelect(), all data required to save and restore relation data using the macro operator (&) can be obtained. Note, however, that this works only if a relation does not refer to lexical variables (GLOBAL, LOCAL, STATIC).
DbRelation() retrieves the expression of the TO clause of the SET RELATION command, while DbRSelect() retrieves the data of the INTO clause. Refer to the SET RELATION command for more information on relations.
By default, DbRelation() operates in the current work area. Use an aliased expression to query relation expressions of different work areas.
See also: | DbFilter(), DbRSelect(), DbSetRelation(), OrdSetRelation(), SET RELATION |
Category: | Database functions |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example opens three databases and defines two relations. // The result of various DbRelation() calls is shown. PROCEDURE Main USE Customer ALIAS Cust NEW EXCLUSIVE INDEX ON CustNo TO CustNo USE Parts ALIAS Part NEW EXCLUSIVE INDEX ON PartNo TO PartNo USE Order ALIAS Ord NEW SET RELATION TO CustNo INTO Cust, ; TO PartNo INTO Part ? Alias() // result: ORD ? DbRelation(1) // result: CustNo ? DbRelation(2) // result: PartNo SELECT Part ? Alias() // result: PART ? DbRelation(1) // result: null string ("") ? Ord->( DbRelation(1) ) // result: CustNo ? Ord->( DbRelation(2) ) // result: PartNo CLOSE ALL RETURN
http://www.xHarbour.com