Re: Questions about CURSORS - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Questions about CURSORS
Date
Msg-id 393122DC.3D6E4C94@cupid.suninternet.com
Whole thread Raw
In response to Questions about CURSORS  (Marcos Barreto de Castro <mbdecastro@yahoo.com>)
List pgsql-general
Marcos Barreto de Castro wrote:
>
> Hi,
>
>   Suppose there is a table that's being shared among 5
> computers at the same time.
>   Suppose I've created a CURSOR for a SELECT * FROM
> <that table> GROUP BY <column1>.
>   Suppose I have fetched the 3rd record and am going
> to fetch the 4th and in the meantime someone at
> another computer just DELETED that 4th record from
> that table.    Will the fetch succeed? Will the record
> be shown although it no longer exists in the table?

Yes the fetch will succeed. A cursor is a set of tuples
and after the cursor is created, the tuples will remain
no matter what happend to the actual table.

> And if someone at another computer had inserted a new
> record which, according to my GROUP BY clause, would
> be the 4th, would it be shown for the next fetch?

No.

>   My big questions are: Do CURSORS perform their
> SELECT operations in the TABLE directly or in a file?
> Any changes to rows selected through a CURSOR will be
> shown right away or they will only appear as I perform
> another SELECT?

They will appear in the next SELECT unless it's in the
same transaction.

>   Is there a book that I could read in order to get a
> better knowledge on SQL implementation or even a
> website where I could read about this?

Look like you need to learn about transactions.
Sorry, can't suggest a good site.
--
Martijn van Oosterhout <kleptog@cupid.suninternet.com>
http://cupid.suninternet.com/~kleptog/

pgsql-general by date:

Previous
From: Marcos Barreto de Castro
Date:
Subject: Questions about CURSORS
Next
From: Tom Lane
Date:
Subject: Re: Questions about CURSORS