0

I'm using firedac with Delphi 10.3 with Interbase, when i use an update SQL statement in more forms it will work perfect.

But in one form i do exact the same the table is not updated, but when i close the form and close the application the update is done to the database.

I'm completely lost and i don't know how this is possible.

I found a part of the problem:

When i use Commit it works, but when there is a open command between two update statements i need to use StartTransAction before the open en Commit after the open. Then the second update works:

DM_IB.IBF_VHE.ExecSQL('Update BB_ASML_FORECAST set Uren_Montage = 100, Uren_Berekend = ''Ja'' ' +
                        'where AANMAAK_DATUMTIJD = ''19-10-2022 10:12:38'' and ItemCode = ''4022.472.18632'' ') ;

    DM_IB.IBF_VHE.Commit ;

    ShowMessage('1') ; // Works no problems

  MEM_VPA.DisableControls ;
  MEM_Fouten.DisableControls ;

  Post_Confirm := False ;

  Try
    MEM_VPA.Close ;
    MEM_VPA.Open ;
    MEM_VPA.EmptyTable ;

    MEM_Fouten.Close ;
    MEM_Fouten.Open ;
    MEM_Fouten.EmptyTable ;

    With TFDQuery.Create(nil) do
    Try
      Connection := DM_IB.IBF_VHE ;
      SQL.Text   := 'select * from PL_CAPACITEIT_NPW where ' +
                    '(jaar = ' + FormatDateTime('yyyy', now()) + ' and ' +
                    'Weeknummer > ' + IntToStr(WeekofTheyear(Now())) + ') or ' +
                    '(jaar = ' + FormatDateTime('yyyy', IncYear(Now())) + ' and ' +
                    'weeknummer < ' + IntToStr(52 - (52 - WeekofTheyear(Now()))) + ') order by jaar, weeknummer' ;
    DM_IB.IBF_VHE.StartTransaction ; // when this line is nod add and the commit the update below is not working till i end the application
    Open ;
    DM_IB.IBF_VHE.Commit ;

    DM_IB.IBF_VHE.StartTransaction ;

    DM_IB.IBF_VHE.ExecSQL('Update BB_ASML_FORECAST set Uren_Montage = 100, Uren_Berekend = ''Ja'' ' +
                        'where AANMAAK_DATUMTIJD = ''19-10-2022 10:12:38'' and ItemCode = ''4022.472.88135'' ') ;

    DM_IB.IBF_VHE.Commit ;

    ShowMessage('2') ; // Works only when de above open command is between a transacion.

Thanks in advice,

3
  • It's kind of hard to help when we don't see the code. How do I ask a good question?
    – Eirik A.
    Oct 19, 2022 at 11:37
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Oct 20, 2022 at 5:58
  • Hello, The problem is that the updates are commited to interbase only when i close the complete application. I use a StartTransaction -> Update statement -> CommitRetaining but the data is not stored in de database. When i close the complete application only then the changes are visible.
    – FvS
    Oct 20, 2022 at 10:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.