Re: Accessing a database via AJAX scripts - Mailing list pgsql-general

From Tom Lane
Subject Re: Accessing a database via AJAX scripts
Date
Msg-id 3464.1281281612@sss.pgh.pa.us
Whole thread Raw
In response to Accessing a database via AJAX scripts  (Glen Eustace <geustace@godzone.net.nz>)
Responses Re: Accessing a database via AJAX scripts
List pgsql-general
Glen Eustace <geustace@godzone.net.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

pgsql-general by date:

Previous
From: Torsten Zühlsdorff
Date:
Subject: Re: MySQL versus Postgres
Next
From: Lew
Date:
Subject: Re: could you tell me this..?