On Wed, Sep 19, 2012 at 1:02 PM, Juan Antonio Ibáñez
<
juani...@gmail.com> wrote:
> But it seems the trigger doesn't gets executed until the transaction is commited so I get always old balance instead new one
Ah, yes, this will be a problem regardless of your database, and it's
not one that I know of a solid way to solve. The real problem is that
your database trigger will take an unknown time to run. In testing, it
could (and probably will) be under a second. In production, depending
on the amount of data and the load on the server, it could take
minutes or even hours. Web browsers will give up after a limited
amount of time, reporting that the remote web server is not
responsive.
I've only got one option, and I really don't like it.
Set up some sort of notification from the server to your app, so that
the database trigger will notify when the calculation is done. The app
can then hold the information in memory, waiting for the web browser
to request it. In the meantime, the browser periodically queries your
app to see if there is an updated balance, displaying "updating" until
it gets a result.