Recent

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

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • 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?
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

balazsszekely

  • Guest
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: 1273

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: 99
    • Krzynio's home page
Thank you very much GetMem!
Setting TransactionIsolationLevel to tiReadCommitted does the trick.
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
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 Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018