Board index » delphi » CachedUpdate & Master, Detail table

CachedUpdate & Master, Detail table

The only way I know how to do this is to do the updates in the master
query's OnUpdateRecord event.

When you say ApplyUpdates, Delphi calls the OnUpdateRecord event if
you have any code there. Then, once you're in the OnUpdateRecord
event,
1.update the master record,
2.then use another query to fetch the new id value into your
application,
3. then put that value in the ID.NewValue field of the detail record,
4, then update the detail record.

The problem is that the database creates the new ID value and cached
updates doesn't know what's in the database. There is no automatic
connection. You have to get that new value and put it in the detail
record yourself. The OnUpdateRecord event allows you to handle each
record in the cache separately, so that's the place to do it.

You say that you use autoinc to create a new ID value. I assume that
means that you are using Paradox. I don't know the best way to get the
autoinc value from Paradox. Perhaps someone else here can help.

In some databases, it's possible to use a stored procedure to get the
new ID value. If you can do that, then you can use a stored procedure
component to get the value instead of using a query.

Hope this helps.

Good luck.

Phil Cain

Quote
"DMBLOC" <DMB...@netsgo.com> wrote:
>Hi!

>I have some question about "CachedUpdates".

>In case insert new record to master table that have true CacehedUpdated
>property, ID field (autoincrememt type) of this table have no value.

>In this state, insert new record to detail table make no linked detail field
>value too.

>I can understand so far.

>But, Use ApplyUpdates method of these tables database's, still make no value
>on detail's linked field.

>How can I solve this problem?

 

Re:CachedUpdate & Master, Detail table


Cached updates does not work well with master detail tables, particularly
when you try to use autoincrementing fields.  The only solution in the
situation you describe is to apply updates on the master first so you get a
primary key value then use it when you add the detail records.

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

Re:CachedUpdate & Master, Detail table


Hi!

I have some question about "CachedUpdates".

In case insert new record to master table that have true CacehedUpdated
property, ID field (autoincrememt type) of this table have no value.

In this state, insert new record to detail table make no linked detail field
value too.

I can understand so far.

But, Use ApplyUpdates method of these tables database's, still make no value
on detail's linked field.

How can I solve this problem?

Re:CachedUpdate & Master, Detail table


Thank for your help Bill !

It's much help to me.

-Park.

Re:CachedUpdate & Master, Detail table


Thanks for your help. Philip !
It's much help to me.

I feel differculty on using delphi as much as I use it.

Park.

Other Threads