Re: Accessing a database via AJAX scripts

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Glen Eustace <geustace(at)godzone(dot)net(dot)nz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Accessing a database via AJAX scripts
Date: 2010-08-08 15:33:32
Message-ID: 3464.1281281612@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Glen Eustace <geustace(at)godzone(dot)net(dot)nz> writes:
> My goal is to have a perl cgi script (that is accessed using AJAX)
> perform some operations in a database using DBI. Some of the actions
> are likely to take a while so my intent was to have a table that the
> backend process periodically writes status messages into. The front end
> web page then uses another AJAX script to watch this table.

Your note is awfully short of concrete details, but I'm guessing the
basic reason why this wasn't working for you was you were doing all the
operations as a single transaction. The results of that transaction
wouldn't be visible to another one until it commits; so in particular
whatever changes it made in the status table wouldn't be visible.
You'd need to break the processing into something like
begin;
insert into status values ('working');
commit;
begin;
... do the useful stuff here ...
commit;
begin;
insert into status values ('done');
commit;

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lew 2010-08-08 18:34:44 Re: could you tell me this..?
Previous Message Torsten Zühlsdorff 2010-08-08 09:45:05 Re: MySQL versus Postgres