Re: Questions about CURSORS

From: Martijn van Oosterhout <kleptog(at)cupid(dot)suninternet(dot)com>
To: Marcos Barreto de Castro <mbdecastro(at)yahoo(dot)com>
Cc: pgsql-general(at)hub(dot)org
Subject: Re: Questions about CURSORS
Date: 2000-05-28 13:45:00
Message-ID: 393122DC.3D6E4C94@cupid.suninternet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)cupid(dot)suninternet(dot)com>
http://cupid.suninternet.com/~kleptog/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-05-28 15:07:18 Re: Questions about CURSORS
Previous Message Marcos Barreto de Castro 2000-05-28 11:53:42 Questions about CURSORS