Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataEnvironment Class problem
Message
From
31/12/2002 09:10:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
30/12/2002 13:58:41
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00736556
Message ID:
00736919
Views:
16
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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform