NetTalk Central

Author Topic: Updating child records on parent save  (Read 4232 times)

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Updating child records on parent save
« on: September 25, 2007, 12:51:54 PM »
I have a form that consists of the parent  record and multiple child records stored in memory tables.  I need to transer the contents of the memory tables to physical tables when the user clicks Save but only after the primary record has been successfully saved.  Ideally, I would like to wrap all the parent  and child transactions in a log out frame.  At a minimum, I need to confirm successful update of the parent record before transferring the memory records.  The Validate embed points occur before the parent record is saved.  Does  PostUpdate fire if the parent update was not successful? (Sorry, couldn't generate the test condition without stopping the whole program.)  If using a logout frame is possible, where should the following occur:

the logout initiation;
child records transfer;
failure rollback;
success commit;

Any suggestions would be much appreciated.  Thanks.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Updating child records on parent save
« Reply #1 on: October 04, 2007, 10:45:34 PM »
Hi Casey,

>> Does  PostUpdate fire if the parent update was not successful?

yes it does. You can check the success, or failure, of the Write by using the
p_web.Failed property.  For example

If p_web.Failed = 0
  Write child records
End

You can wrap the code in a transaction, but you need to be a little careful.
You should only start the transaction (in the Validate stage) IF the record has passed the validation. So this needs to be the last thing you do, as long as the record has passed the validation ok.

Then complete the transaction in the PostUpdate (or PostInsert) phase.

Cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Updating child records on parent save
« Reply #2 on: October 16, 2007, 02:07:32 PM »
Thanks, Bruce

Sorry for the delayed acknowledgment.  I have been on another project for the last few days and haven't checked the forum.