Re: Locking rows - Mailing list pgsql-general

From Manfred Koizar
Subject Re: Locking rows
Date
Msg-id a06v5voi0jtqin3sl6nq5ioiuinelrv4d9@4ax.com
Whole thread Raw
In response to Locking rows  (Jean-Christian Imbeault <jc@mega-bucks.co.jp>)
List pgsql-general
On Fri, 28 Feb 2003 19:26:55 +0900, Jean-Christian Imbeault
<jc@mega-bucks.co.jp> wrote:
>I have written an application that prints out data from a database. One
>problem I am encountering is in the time it takes to generate the print
>file the data may have changed.
> [...]
>Is locking the rows the best (or simplest) solution?

The simplest (and IMHO best) solution is:

    BEGIN;
    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
    SELECT <this> ...
    SELECT <that> ...
    SELECT <whatever> ...
    COMMIT;

If your entire report is generated from the result of a single SELECT,
you don't even need that BEGIN/SET TRANSACTION/COMMIT stuff.

Servus
 Manfred

pgsql-general by date:

Previous
From: Jean-Christian Imbeault
Date:
Subject: Re: Locking rows
Next
From: "Ed L."
Date:
Subject: Re: 7.4?