Jump to content
Registration disabled at the moment Read more... ×

FLDelphi

Members
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

1 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I have some more testing to do, but I can confirm that using TFDScript behaves like I'd imagine. Thank you very much. So that leaves 2 options so far: * Use TFDScript * Have a 2nd TFDConnection that's in charge of handling multi command transactions.
  2. All right, pretty interesting- Let me go through the logs as I iterate over the code. BTW - I tried to post this in the post, but I was getting Spam blocks. See attached. To me these logs show a very interesting story. FD does not handle transactions like you think it would. Even if you toggle things in the TxOptions, it makes no difference. At least in PG land. FireDAC_PG_Transactions_LogCollection.txt
  3. We rely on parameters - Which cause it to be a prepared statement, which in turn PG does not allow multiple commands in a prepared statement.
  4. I mentioned this offhandedly but, yes we've tried doing something like this (sticking with the same overall pattern): var lNewJournalPkey : String; begin lNewJournalPkey := 'test123456778'; QryFDTemp.ExecSQL('BEGIN; '); try QryFDTemp.Close; QryFDTemp.SQL.Clear; QryFDTemp.SQL.Add('INSERT INTO Journal (JournalPkey) ' + 'SELECT :NewJournalPkey '+ 'FROM Journal WHERE JournalPkey=:OldJournalPkey '); QryFDTemp.ParamByName('NewJournalPkey').AsString := lNewJournalPkey; QryFDTemp.ParamByName('OldJournalPkey').AsString := '207AF8c_2036q\f6'; QryFDTemp.ExecSQL; QryFDTemp.Close; QryFDTemp.SQL.Clear; QryFDTemp.SQL.Add('INSERT INTO JournalDetail (journaldetailpkey, type) '+ 'SELECT :NewJournalDetailPkey AS JournalDetailPkey, type ' + 'FROM JournalDetail WHEE JournalDetailPkey=:JournalDetailPkey '); QryFDTemp.ParamByName('NewJournalDetailPkey').AsString := '1233456789'; QryFDTemp.ParamByName('JournalDetailPkey').AsString := '13242314234'; QryFDTemp.ExecSQL; //right here (the syntax error) is when PG reports the transaction as done - monitor with SELECT pid, backend_xid FROM pg_stat_activity WHERE backend_xid IS NOT NULL; QryFDTemp.ExecSQL('COMMIT;'); except QryFDTemp.ExecSQL('ROLLBACK;'); end; //at this point any other table/query on the TFDConnection fails with "[FireDAC][Phys][PG][libpq] ERROR: current transaction is aborted, commands ignored until end of transaction block" Weirdo - The problem with your example is that it breaks down with use of parameters. PG does not allow multiple commands in a prepared statement. And parameters force it to be a prepared statement. The only other solution we've found is to have an FDConnection on the side just for transactions. That seems so very unnecessary. We could also create PG Stored Procedures but we have dozens and dozens of code blocks like this with so many parameters. This worked fine in Advantage DB.
  5. Delphi 10.4 - PostgreSQL 16 We have a single TFDConnection object running the whole application. Certain areas of the program need a transaction so that all of the table updates happen or none of them do. Typically we handle it like this: DevdatalargeConnection.StartTransaction; QryFDTemp.Close; QryFDTemp.SQL.Clear; QryFDTemp.SQL.Add('INSERT INTO J (JournalPkey, type, venddocno) ' + 'SELECT :NewJournalPkey, type, :VendDocNo '+ 'FROM J WHERE JournalPkey=:OldJournalPkey '); QryFDTemp.ParamByName('NewJournalPkey').AsString := lNewJournalPkey; QryFDTemp.ParamByName('OldJournalPkey').AsString := '207AF8c_2036q\f6'; QryFDTemp.ParamByName('VendDocNo').AsString := 'ABC123'; try QryFDTemp.ExecSQL; except on E: Exception do begin DevdatalargeConnection.Rollback; MessageDlg('Error inserting Journal: ' + E.Message, mtError, [mbOK], 0); Exit; end; end; QryFDTemp.Close; QryFDTemp.SQL.Clear; QryFDTemp.SQL.Add('INSERT INTO JD (journaldetailpkey, type, JournalPkey) '+ 'SELECT :NewJournalDetailPkey AS JournalDetailPkey, type, :JournalPkey ' + 'FROM JD CAUSESYNTAXERROR JournalDetailPkey=:JournalDetailPkey '); QryFDTemp.ParamByName('JournalPkey').AsString := lNewJournalPkey; QryFDTemp.ParamByName('NewJournalDetailPkey').AsString := '1233456789'; QryFDTemp.ParamByName('JournalDetailPkey').AsString := '13242314234'; try QryFDTemp.ExecSQL; except on E: Exception do begin DevdatalargeConnection.Rollback; MessageDlg('Error inserting detail: ' + E.Message, mtError, [mbOK], 0); Exit; end; end; Notice how we have a SQL syntax error on that second ExecSQL? That's on purpose to test the transaction. When that error fires and it excepts out and does the .RollBack, we get error "current transaction is aborted, commands ignored until end of transaction block'." Monitoring active transactions with pg_stat_activity, we can see that FD has somehow closed the transaction on QryFDTemp.ExecSQL - It does not matter what we set TFDConnections.TxOptions.AutoCommit or AutoStop to. This isn't the end of the world though, if FD wants to auto roll back our transaction. The problem is that it bricks every single FDQuery or FDTable in the rest of the application. Anytime we try to refresh/reopen them we get the "current transaction is aborted" error. We've tried issuing our own transactions with QryFDTemp.ExecSQL('BEGIN'), etc. No luck with that. Like I mentioned, toggling the various TxOptions don't seem to matter. We've tried the FD help method of: FDConnection1.StartTransaction; try FDQuery1.ExecSQL; .... FDQuery1.ExecSQL; FDConnection1.Commit; except FDConnection1.Rollback; raise; end; But it's the same issue. BTW - Make sure you open other (unrelated queries/tables) before you attempt the code(s) above. This only happens if something else is open first.
  6. Hey did you ever figure this out? We have encountered it for the first time on a single environment (so far). All of our test environments, and a few customer site environments are working fine, but this recent customer is experiencing it on every PC (including the server) in the network. We found running as Administrator "fixes" the problem but that won't be an appealing answer. Also I found this thread which describes the same (or very similar) problem https://en.delphipraxis.net/topic/4014-tactionmainmenubar-indirectly-kills-application/ stack_trace.txt
  7. FLDelphi

    New User / New UI Tutorial

    We're doing big shifts to our UI and wanted to create a short wizard that introduces people to the new elements. A floating popup (maybe a drop shadow) that says "welcome to the new..." and then prev/next buttons that can direct the users to new elements all over the UI. We'd also want to only show this once for new users. This happens a lot of web pages, but I can't think of many desktop apps that do it. Are there any 3rd party components that can solve some of these requirements? If we have to do it ourselves, what would be the go to standard component? A panel? A frame?
  8. FLDelphi

    How to update and install into new Delphi

    Most components we use are packaged in an installer and they generally want us to completely un-install the components first. This also includes taking them out of Delphi. Do I have to do this for my XE3 where they are installed already? Or just use git to download the latest branch and rebuild/reinstall? I cloned the master branch however many years ago, and I was hoping I could just "Fast-forward" or "Merge", but I'm hesitant to do so since I'm very much not a git expert. Plus with the complexity of already having the components installed. Thanks again
  9. Excuse my ignorance on this topic, but this install method is rare in my environment. In July 2019 I used git to download the Omnithread library source code. I followed the instructions to install into XE3. I would now like to 1) Download the latest master branch and update my XE3 and 2) Install the latest master branch into Delphi Sydney. I realize there's a way to download/install OTL from the GetIt program, but I want to keep my components all in the same folder if possible. Failing that I want full control over where my components are installed. What would be your recommended way of getting my 2 tasks done?
  10. FLDelphi

    Visual Control for selecting a date range

    Oh nice. Those are both what we're looking for. Thanks all!
  11. I've seen some nice controls on the web lately that allows a user to select, essentially 2 dates. They do this by opening a calendar component (usually plus a couple months), and then allowing the user to either click twice on each date, or click and drag. Google Analytics comes to mind as an example. A bit cleaner example is from a mobile communications company (example 2). Does anyone know of any Delphi analogs?
  12. FLDelphi

    Windows Build 1909

    What are the general experiences updating to 1909 and using Delphi? I can't say that past experience has made me at all excited to update. And this blog (http://delphicodemonkey.blogspot.com/2020/03/delphi-seattle-becoming-almost-unusable.html) has got me really spooked. Can anyone offer any other experiences using Windows 10 1909? Specifically we do all of our development in XE3 and Seattle. Edit: Sorry I wanted this to go under Windows, but mistakenly put it into VCL. I couldn't delete my own thread.
×