Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ApplyUpdates won't repeat sequntuallly

Status
Not open for further replies.

terrytype

Programmer
Jun 1, 2011
97
ZA
My OS is W-XP-Prof and have been using Delphi 6 Enterprise for many years.

In the process I have successfully relied on ApplyUpdates as below.

ModifySQL.Clear;
ModifySQL.Add ('update');

if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL')then
ModifySQL.Add ('''C:\h\StdAcc\'+ IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');

ModifySQL.Add ('set');
ModifySQL.Add ('LAccNo = :LAccNo, LAccNo2 = :LAccNo2, AccDate = :AccDate, Doc = :Doc, FileNo = :FileNo, Vat = :Vat,');
ModifySQL.Add ('OppAccName = :OppAccName, OppAccNo = :OppAccNo, OppAccNo2 = :OppAccNo2, Amount = :Amount, Balance = :Balance, Job = :Job');
ModifySQL.Add ('where');
ModifySQL.Add ('Akv = :OLD_Akv');

InsertSQL.Clear;
InsertSQL.Add ('insert into');

if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL') then
InsertSQL.Add ('''C:\h\StdAcc\' + IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');

//Insert SQL for BOTH Ledger Accounts
InsertSQL.Add ('(LAccNo, LAccNo2, AccDate, Doc, FileNo, Vat, OppAccName, OppAccNo,');
InsertSQL.Add ('OppAccNo2, Amount, Balance, Job)');

InsertSQL.Add ('values');
InsertSQL.Add (':)LAccNo, :LAccNo2, :AccDate, :Doc, :FileNo, :Vat, :OppAccName, :OppAccNo, :OppAccNo2, :Amount, :Balance, :Job)');

DeleteSQL.Clear;
DeleteSQL.Add ('delete from');

if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL') then
DeleteSQL.Add ('''C:\h\StdAcc\' + IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');

DeleteSQL.Add ('where');
DeleteSQL.Add ('Akv = :OLD_Akv');

if dmStdAcc.qryAccount.UpdatesPending then
dmStdAcc.qryAccount.ApplyUpdates;

More recently, after having done some re-engineering elsewhere in the Application, the ApplyUpdates [as above] still works successfully ONCE! BUT in a sequential attempt immediately afterwards I get exception "Update has failed".

What am I missing? What might I have done during re-engineering to upset this?

delphiman

Old Man Delphi
 
Problem solved. In fact the procedure works perfectly when induced sequentially. Problem was given rise to elsewhere in the Application.

Old Man Delphi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top