Recent

Author Topic: Firebird data updated from Internet doesn't refresh in Lazarus with ZeosLib  (Read 4135 times)

krzynio

  • Jr. Member
  • **
  • Posts: 89
    • Krzynio's home page
Hi!
I have an application written in Lazarus for managing Firebird database.
I use Lazarus 2.0.12 and ZeosLib 7.2 for this.
When I use only this application for updating table it works fine but when I update the table from the Internet using PHP script data is updated in Firebird, FlameRobin shows it but is not visible in Lazarus application.
For refreshing the data I use ZQuery Close and Open procedures, it doesn't work. To see updated data I have to use ZConnection Disconnect and Connect. This works but I do not want to disconnect from db.
Could someone suggest any solution, please?
Debian Testing x64 with XFCE 4.14 - Lazarus trunk, FPC 3.0.4
Windows 10 x64 - Lazarus 2.0.10, FPC 3.2.0

GetMem

  • Hero Member
  • *****
  • Posts: 3463
Hi krzynio,

The default isolation level in firebird is snapshot, which means that you are unable to see written data from another transaction(php script in this case), unless you close then reopen your own transaction. The solution is simple set the isolation level to read_commited. Unfortunately I'm not familiar with Zeos, so I don't know how exactly it's done, but a quick google search should solve the problem. After the isolation level is set a query.refresh is enough to see the data commited by the php script.
« Last Edit: May 22, 2021, 07:38:40 am by GetMem »

egsuh

  • Hero Member
  • *****
  • Posts: 834

Try to commit or rollback transaction of Lazarus application first, and then re-start transaction and  open the dataset.  Of course after the data is changed.

krzynio

  • Jr. Member
  • **
  • Posts: 89
    • Krzynio's home page
Thank you very much GetMem!
Setting TransactionIsolationLevel to tiReadCommitted does the trick.
Debian Testing x64 with XFCE 4.14 - Lazarus trunk, FPC 3.0.4
Windows 10 x64 - Lazarus 2.0.10, FPC 3.2.0

Zvoni

  • Hero Member
  • *****
  • Posts: 714
Nota Bene: Firebird has an Event-System you can use (instead of polling the server) to get notified when to refresh
https://wiki.freepascal.org/TFBEventMonitor
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircraft

 

TinyPortal © 2005-2018