Click or drag to resize

SQLTable.SetRelation Method (Typed)

X#
Set a relation from this server to the child server; standard database operations are restricted to those records that match the relation.

Namespace:  XSharp.VO.SDK
Assembly:  XSharp.VOSQLClasses (in XSharp.VOSQLClasses.dll) Version: 2.19
Syntax
 VIRTUAL METHOD SetRelation(
	oChild,
	uRelation,
	cRelation
) AS USUAL CLIPPER
Request Example View Source

Parameters

oChild (Optional)
Type: Usual
The server attached to the child server must be specified as a SQLTable object. If omitted, all relations for this server are removed (the recommended way of doing this is the ClearRelations() method).
uRelation (Optional)
Type: Usual
The field name representing the relation for the server. An alias can be used for the field name. (See the SQLSelect:FieldInfo() method to set an alias name).
cRelation (Optional)
Type: Usual
The array of field names representing the relation for the server. The array can also contain complex relational operators (SQL_RELOP_AND, SQL_RELOP_OR, SQL_RELOP_NOT, SQL_RELOP_OPENP, SQL_RELOP_CLOSEP).

Return Value

Type: Usual
TRUE if successful; otherwise, FALSE.
Remarks
In the SQLTable class, SetRelation() functions identically to SetSelectiveRelation(). The relation is implemented as an extension to the WHERE clause. Sends a NotifyRecordChange message to the child server, if successful.
Examples
The API can take these forms:
X#
1oSQLCustomer:SetRelation(oSQLOrders, {||_FIELD->CustNo},"CustNo")
2oSQLCustomer:SetRelation(oSQLOrders,#CustNo)
3oSQLCustomer:SetRelation(oSQLOrders, {#LastName,#Initial,#FirstName})
The following relation is equivalent to the set of orders where ORDER.LASTNAME=CUST.LASTNAME OR (ORDER.INITIAL=CUST.INITIAL AND ORDER.FIRSTNAME=CUST.FIRSTNAME):
X#
1oSQLCustomer:SetRelation(oSQLOrders,{#LastName,
2SQL_RELOP_OR,SQL_RELOP_OPENP,#Initial,
3SQL_RELOP_AND,#FirstName,SQL_RELOP_CLOSEP}
See Also