pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedStepping through a table.
4+ messages / 2 participants
[nested] [flat]
* Stepping through a table.
@ 1999-08-16 02:58 Matthew Hagerty <matthew@venux.net>
1999-08-16 09:19 ` Re: [SQL] Stepping through a table. Herouth Maoz <herouth@oumail.openu.ac.il>
1999-08-16 20:52 ` Re: [SQL] Stepping through a table. Matthew Hagerty <matthew@venux.net>
1999-08-17 11:13 ` Re: [SQL] Stepping through a table. Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 3 replies; 4+ messages in thread
From: Matthew Hagerty @ 1999-08-16 02:58 UTC (permalink / raw)
To: pgsql-sql
Greetings,
If I need to process each record in a table, how can I step through each
record? I suppose I could write a query to return all records and fetch
each row that way, but that would be a big memory pig, no? Also, the table
could get pretty big. Is there some way to navigate a table, maybe
fetching one record from the disk at a time, or something similar?
Thanks,
Matthew Hagerty
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Stepping through a table.
1999-08-16 02:58 Stepping through a table. Matthew Hagerty <matthew@venux.net>
@ 1999-08-16 09:19 ` Herouth Maoz <herouth@oumail.openu.ac.il>
2 siblings, 0 replies; 4+ messages in thread
From: Herouth Maoz @ 1999-08-16 09:19 UTC (permalink / raw)
To: Matthew Hagerty <matthew@venux.net>; pgsql-sql
At 05:58 +0300 on 16/08/1999, Matthew Hagerty wrote:
> If I need to process each record in a table, how can I step through each
> record? I suppose I could write a query to return all records and fetch
> each row that way, but that would be a big memory pig, no? Also, the table
> could get pretty big. Is there some way to navigate a table, maybe
> fetching one record from the disk at a time, or something similar?
I guess you are looking for cursors. Read about it on page 154 of the
PostgreSQL user guide, or check out the manpage about "declare". Note that
PostgreSQL cursors are readonly, and can't be used to update information.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Stepping through a table.
1999-08-16 02:58 Stepping through a table. Matthew Hagerty <matthew@venux.net>
@ 1999-08-16 20:52 ` Matthew Hagerty <matthew@venux.net>
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Hagerty @ 1999-08-16 20:52 UTC (permalink / raw)
To: Herouth Maoz <herouth@oumail.openu.ac.il>; pgsql-sql
Thanks, I was thinking that's what cursors did, but I can't find a good
source anywhere that actually tells you that you are reading one record at
a time instead of submitting a whole query where the results are place in
memory.
You mentioned that cursors are read only. Can I do update statements while
navigating with cursors? Or do they lock the records they are reading?
Again, thank you.
Matthew
At 12:19 PM 8/16/99 +0300, Herouth Maoz wrote:
>At 05:58 +0300 on 16/08/1999, Matthew Hagerty wrote:
>
>
>> If I need to process each record in a table, how can I step through each
>> record? I suppose I could write a query to return all records and fetch
>> each row that way, but that would be a big memory pig, no? Also, the table
>> could get pretty big. Is there some way to navigate a table, maybe
>> fetching one record from the disk at a time, or something similar?
>
>I guess you are looking for cursors. Read about it on page 154 of the
>PostgreSQL user guide, or check out the manpage about "declare". Note that
>PostgreSQL cursors are readonly, and can't be used to update information.
>
>Herouth
>
>--
>Herouth Maoz, Internet developer.
>Open University of Israel - Telem project
>http://telem.openu.ac.il/~herutma
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Stepping through a table.
1999-08-16 02:58 Stepping through a table. Matthew Hagerty <matthew@venux.net>
@ 1999-08-17 11:13 ` Herouth Maoz <herouth@oumail.openu.ac.il>
2 siblings, 0 replies; 4+ messages in thread
From: Herouth Maoz @ 1999-08-17 11:13 UTC (permalink / raw)
To: Matthew Hagerty <matthew@venux.net>; pgsql-sql
At 23:52 +0300 on 16/08/1999, Matthew Hagerty wrote:
>
> You mentioned that cursors are read only. Can I do update statements while
> navigating with cursors? Or do they lock the records they are reading?
If they do, they only lock them to other transactions. Since you are within
the same connection and thus the same transaction (cursors can only be used
within BEGIN/END transaction blocks), of course the records are not locked.
As far as I know, you can make update statements. What I am not sure about
is what happens if you rewind the cursor and read the updated record again
- whether you will see the updated record or the non-updated one. You'll
have to test this.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1999-08-17 11:13 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-08-16 02:58 Stepping through a table. Matthew Hagerty <matthew@venux.net>
1999-08-16 09:19 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1999-08-16 20:52 ` Matthew Hagerty <matthew@venux.net>
1999-08-17 11:13 ` Herouth Maoz <herouth@oumail.openu.ac.il>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox