Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Update issue
Thu, Nov 8 2018 8:51 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi All,

I have 2 tables, service and tasks. Service has a taskno field as
integer and task table has a serviceno as integer so updates in one
table can be reflected in the other, and it works just fine. The issue
here is that if the user deletes the task which service has a pointer
to, the update in section 2 of following code  " with RetOpgave do
begin" does append a row in task table?? I have no insert or append,
just update in the transaction, how can this happen?

I have following code:

  Database.StartTransaction;
  try
      with RetService do begin
      Update;
      Columns['Beskrivelse'].AsString:= BeskrivelseEdit.Text;
      Save;
      end;
      if (RetService.columns['Opgaveid'].asInteger > 0) then begin
      with RetOpgave do begin
      Update;
      Columns['Opgavenavn'].AsString:= BeskrivelseEdit.Text;
      Save;
      end;
      end;
      Database.Commit;
      Showmessage('OK!');
      except
      Database.Rollback;
      raise;
  end;

Thanks in advance,
Hüseyin
Mon, Nov 12 2018 2:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Huseyin,

<< I have 2 tables, service and tasks. Service has a taskno field as integer and task table has a serviceno as integer so updates in one table can be reflected in the other, and it works just fine. The issue here is that if the user deletes the task which service has a pointer to, the update in section 2 of following code " with RetOpgave do begin" does append a row in task table?? I have no insert or append, just update in the transaction, how can this happen? >>

Updates automatically cause an Insert if there are no rows present, so just check the RowCount before doing the Update to make sure that there is a row to update.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Nov 13 2018 4:25 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Tim,

Thanks for the info Smile

Regards,
Hüseyin

Den 12-11-2018 kl. 20:34 skrev Tim Young [Elevate Software]:
> Huseyin,
>
> << I have 2 tables, service and tasks. Service has a taskno field as integer and task table has a serviceno as integer so updates in one table can be reflected in the other, and it works just fine. The issue here is that if the user deletes the task which service has a pointer to, the update in section 2 of following code " with RetOpgave do begin" does append a row in task table?? I have no insert or append, just update in the transaction, how can this happen? >>
>
> Updates automatically cause an Insert if there are no rows present, so just check the RowCount before doing the Update to make sure that there is a row to update.
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Image