Relate update problems or lack of knowledge


#1

I have a Table with several 1:MANY relationships. I have no problems with the relationships in the Templated generated Browsers, Forms and Reports, so I am sure the the relationships are set up correctly.

But if I try to change on of the key fields in the Table use Relate:FileName.Update() in a process or just write the code, nothing happens with the Child Tables. So there must be something I am missing, but I can not figure it out.

Is there someone out there who can give me some help here?

Using Clarion 11, but have the same problem in both C9 and C10.

Trond


#2

Double check that you have action: cascade on update set.
Also the help also indicates

When a parent file has cascade set to true for its child files, a call to Update will not do the cascade unless the Save method is called prior to changing the value of the linking fields.


#3

I am sure I have cascade set for all the child fields, but I have not called the Save method prior to Update. I knew there were something I was missing, but I am not sure how to call that method. So if someone could give me a tip, I will be grateful.

Trond


#4

On the other hand, in Process Properties I have this choice:

Use RI constraints on action

NOTE: Leaving this unchecked will cause the “Action for
Process” to occur only to the primary file. No cascading
action will occur on secondary files.

I can not understand this in any way other than if I check “Use RI constraints on action” the child records should be updated as well.

Trond


#5

For example:

Access:MyFile.Fetch()
Relate:MyFile.Save()
Change key fields
Relate:MyFile.Update()

in a loop
loop while Access:MyFile.Next() = Level:Benign
Relate:MyFile.Save()
Change key fields
Relate:MyFile.Update()
end


#6

Thanks a lot.
Now it works.
But I still do not understand why this is not included in the Process template as long as I check for “Use RI constraints on action”.

But anyway, now it works and that’s all that matters.

Trond


#7

I’d say it is a bug.


#8

Is it a way to use the Save method to copy a record and its relations?

Trond


#9

Interesting, this could be useful to know.

I suspect that the save looks up the previous relations information, which is needed for the relational update.


#10

The relation manager uses a field pairs class to save off the fields that are part of relationships to other tables from current record buffer. Then on the update it compares to see if the linking fields changed. It uses the old value from the field pair class to fetch the related records to the new value.