NetTalk Central

Author Topic: When is the primery key updated ?  (Read 4577 times)

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
When is the primery key updated ?
« on: May 19, 2010, 05:11:14 AM »
Hallo,


On my form the primary key is updated when the save button is pressed. I want before the record is saved on disk to prime one field with the value of the primary key value. I try to find the correct embed for get the value of the primary field but did not find.

Thank you,
Robert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: When is the primery key updated ?
« Reply #1 on: May 19, 2010, 07:03:51 AM »
On Form advanced tab tick on "Prime Auto Inc even if not necessary".

cheers
Bruce

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: When is the primery key updated ?
« Reply #2 on: May 20, 2010, 06:24:11 AM »
Now it is ok, but this option will cause more orphans records inserted. There is any options before to write on disk to get the value of primary key ? This way I will prime my ID at the end.

Thank you,
Robert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: When is the primery key updated ?
« Reply #3 on: May 21, 2010, 12:16:52 AM »
>> There is any options before to write on disk to get the value of primary key ? This way I will prime my ID at the end.

No, the primary key value is created by the insert.

You can use the PostInsert / PostUpdate routine to change the record if you like, but you should fetch the record, change it, and write it back yourself. (The ID will be primed at this point for TPS, and also for SQL if you have the necessary Clarion support for priming auto-inc fields turned on for SQL.)

Cheers
Bruce

Robert Iliuta

  • Sr. Member
  • ****
  • Posts: 472
    • View Profile
    • Email
Re: When is the primery key updated ?
« Reply #4 on: May 21, 2010, 05:02:36 AM »
Hallo Bruce,


Yes this way is working. It's much better now because there will not be any orphaned records inserted.
Also is there any attention for this ? It is safe ? or it's better have a process that check for orphans records to delete them?

Thank you,
Robert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: When is the primery key updated ?
« Reply #5 on: May 21, 2010, 09:24:01 PM »
Hi Robert,

I'm not sure what you're asking?

cheers
Bruce