fetch.l 1.74 KB
Newer Older
Marc G. Fournier's avatar
Marc G. Fournier committed
1 2
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
3
.\" $Header: /cvsroot/pgsql/doc/man/Attic/fetch.l,v 1.2 1996/10/03 15:49:53 momjian Exp $
Marc G. Fournier's avatar
Marc G. Fournier committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
.TH FETCH SQL 01/23/93 Postgres95 Postgres95
.SH NAME
fetch \(em fetch instance(s) from a cursor
.SH SYNOPSIS
.nf
\fBfetch\fR [ (\fBforward\fR | \fBbackward\fR) ] [ ( number | \fBall\fR) ] [\fBin\fR cursor_name]
.fi
.SH DESCRIPTION
.BR Fetch
allows a user to retrieve instances from a cursor named
.IR cursor_name.
The number of instances retrieved is specified by
.IR number .
If the number of instances remaining in the cursor is less than
.IR number ,
then only those available are fetched.  Substituting the keyword
.IR all
in place of a number will cause all remaining instances in the cursor 
to be retrieved.  Instances may be fetched in both
.IR forward
and
.IR backward
directions.  The default direction is
.IR forward .
.PP
Updating data in a cursor is not supported by Postgres, because mapping
cursor updates back to base classes is impossible in general as with
view updates.  Consequently, users must issue explicit replace
commands to update data.
.PP
34
Cursors may only be used inside of transaction blocks marked by 
Marc G. Fournier's avatar
Marc G. Fournier committed
35 36 37 38 39 40 41 42 43 44
.IR begin (l)
and
.IR end (l)
because the data that they store spans multiple user queries.
.SH EXAMPLE
.nf
--
--set up and use a cursor 
--
begin 
45
   declare mycursor cursor for 
Marc G. Fournier's avatar
Marc G. Fournier committed
46 47 48 49 50
   select * from pg-user
end 
.fi
.nf
--
51
--Fetch all the instances available in the cursor FOO
Marc G. Fournier's avatar
Marc G. Fournier committed
52 53 54 55 56
--
fetch all in FOO
.fi
.nf
--
57
--Fetch 5 instances backward in the cursor FOO
Marc G. Fournier's avatar
Marc G. Fournier committed
58 59 60 61 62 63 64 65 66 67 68 69 70
--
fetch backward 5 in FOO
.fi
.SH "SEE ALSO"
begin(l),
end(l),
close(l),
move(l),
select(l).
.SH BUGS
Currently, the smallest transaction in Postgres is a single SQL
command.  It should be possible for a single fetch to be a
transaction.