Boban,
Actually it's not a field name but an expression to set relation from parent to child. ie: Suppose you want your child records be related on ID field which is integer but your child table has also a date field which you want to see in descending order.
You start by creating a special index :
index on padl(ParentID,10,'0')+dtoc(mydate,1) tag myRelTag descending
(Having all tag in descending order wouldn't matter for ID part since at a time we'd only seeing a particular ID).
In code you'd set the relation like this :
use myParent
use myChild in 0 order tag myRelTag
*select myParent && Already selected
set relation to padl(ParentID,10,'0') into myChild
This corresponds to :
childalias = "myChild"
parentalias = "myParent"
RelationalExpr = "padl(ParentID,10,'0')" && Expression - parent to child
childorder = "myRelTag" && index tag name
Note that in parent there is no part for myChild.myDate field. That's index controlling it (ie: 012345678920021201 and 012345678920020101 both would match to ParentID 0123456789). We couldn't use just "ParentID" as relational expression because child index needed a type conversion and expression must match with it. If we did it that way we'd still have a relation (provided there is an index for it) but lose date ordering.
Cetin
>I have put name of field instead of name of index in RelationalExpr and it works fine.
>This doesn't seems logical to me.
>In ChildOrder there is name of Index Tag, but in RelationalExpr there is a name of field instead of Index like in ChildOrder. It confused me.
>
>
>>>I have problem which I can't understand.
>>>I have created DE Class for my database which hold two tables and relation between them.
>>>The code is this:
>>>
>>>
>>>
>>>#DEFINE databasepath "C:\mydirectory\"
>>>
>>>DEFINE CLASS CUSTOMERS AS cursor
>>> alias = "CUSTOMERS"
>>> cursorsource = "CUSTOMER"
>>> database = DATABASEPATH + "BUSINESS.DBC"
>>>ENDDEFINE
>>>
>>>DEFINE CLASS ORDERS AS cursor
>>> alias = "ORDERS"
>>> cursorsource = "ORDERS"
>>> database = DATABASEPATH + "BUSINESS.DBC"
>>>ENDDEFINE
>>>
>>>DEFINE CLASS ORDERS_TO_CUSTOMERS AS relation
>>> childalias = "CUSTOMERS"
>>> parentalias = "ORDERS"
>>> RelationalExpr = "CID_ORDER"
>>> childorder = "CID_ORDER"
>>>ENDDEFINE
>>>
>>>DEFINE CLASS businessDE AS DataEnvironment
>>> ADD OBJECT oCUSTOMERS AS CUSTOMERS
>>> ADD OBJECT oORDERS AS ORDERS
>>> ADD OBJECT oORDERS_TO_CUSTOMERS AS ORDERS_TO_CUSTOMERS
>>>
>>> PROCEDURE Init()
>>> this.OpenTables()
>>> ENDPROC
>>>
>>> PROCEDURE Destroy()
>>> this.CloseTables()
>>> ENDPROC
>>>ENDDEFINE
>>>
>>>
>>>
>>>When I try to create instance of this class:
>>>oDE = CREATEOBJECT('businessDE')
>>>it shows this: "Variable 'CID_ORDER' is not found.'.
>>>and it shows (de)bug on this.OpenTables().
>>>
>>>When I remove relation class (ORDERS_TO_CUSTOMERS) creation of instance is OK but there is no relation between table.
>>>
>>>What is the problem? Can anybody help me?
>>
>>Boban,
>>An index tag named 'CID_ORDER' exists but does a field named 'CID_ORDER' exist ? IOW in code can you do this :
>>
>>open data (DATABASEPATH+"Business.dbc")
>>use orders
>>use customer in 0 order tag CID_ORDER alias customers
>>set relation to CID_ORDER into customers && No error here ?
>>
>>Cetin