Subject Re: [IBO] OnBeforePost called twice (CallStack attached)
Author Jason Wharton
If the detail dataset has its Post method called then it is the detail
dataset being posted and not the master. But, if the master is in insert
state then it should be clear to you that there isn't a record which will
serve as the master record in order to fulfill the relational integrity of
the relationship. (Yes, this is assuming everyone who does master-detail
relationships also does proper referential constraints.)
So, by doing a PostRetaining of the master dataset the record is actually
inserted to the server in order to satisfy RI and yet the client application
has no visibly apparent evidence the master dataset produced the insert.
When the master dataset does get posted it will know it was already post
retained and so it will do an update instead of an insert in the process of
posting the dssInsert state.

Does this make it more clear?

What I said I should do when calling the Transaction Commit method is have
it so it will be a little more smart about how it will post all datasets.
Right now it just goes through a simple list posting as it goes without any
special considerations. So, if it happens to get to the detail dataset
before it gets to the master dataset and this condition exists it will do
the post retaining and subsequent post of the master. I am suggesting that I
put in the smarts to know if the whole transaction is committing all
datasets that there really is no need for a PostRetaining to take place but
to just post the master dataset fully.

Would that clear up your problem?

Jason Wharton
CPS - Mesa AZ

----- Original Message -----
From: "ehandbury" <ehandbury@...>
To: <>
Sent: Tuesday, April 30, 2002 3:10 PM
Subject: Re: [IBO] OnBeforePost called twice (CallStack attached)

> Jason, thanks for the answer.
> I'm glad that its harmless, but...
> 1) I've got code in the BeforePost that I would prefer to only run
> once.
> 2) Shouldn't the second call stack scenario (the PostRetaining) be
> the only Post sequence that's run. Why have the 2 Post sequences at
> all? Couldn't this be optimized?
> Eric.