2
.\" Title: SPI_cursor_open
3
.\" Author: The PostgreSQL Global Development Group
4
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
6
.\" Manual: PostgreSQL 9.3beta1 Documentation
7
.\" Source: PostgreSQL 9.3beta1
10
.TH "SPI_CURSOR_OPEN" "3" "2013-05-06" "PostgreSQL 9.3beta1" "PostgreSQL 9.3beta1 Documentation"
11
.\" -----------------------------------------------------------------
12
.\" * Define some portability stuff
13
.\" -----------------------------------------------------------------
14
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
.\" http://bugs.debian.org/507673
16
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
.\" -----------------------------------------------------------------
21
.\" * set default formatting
22
.\" -----------------------------------------------------------------
23
.\" disable hyphenation
25
.\" disable justification (adjust text to left margin only)
27
.\" -----------------------------------------------------------------
28
.\" * MAIN CONTENT STARTS HERE *
29
.\" -----------------------------------------------------------------
31
SPI_cursor_open \- set up a cursor using a statement created with \fBSPI_prepare\fR
36
Portal SPI_cursor_open(const char * \fIname\fR, SPIPlanPtr \fIplan\fR,
37
Datum * \fIvalues\fR, const char * \fInulls\fR,
44
sets up a cursor (internally, a portal) that will execute a statement prepared by
45
\fBSPI_prepare\fR\&. The parameters have the same meanings as the corresponding parameters to
46
\fBSPI_execute_plan\fR\&.
48
Using a cursor instead of executing the statement directly has two benefits\&. First, the result rows can be retrieved a few at a time, avoiding memory overrun for queries that return many rows\&. Second, a portal can outlive the current procedure (it can, in fact, live to the end of the current transaction)\&. Returning the portal name to the procedure\*(Aqs caller provides a way of returning a row set as result\&.
50
The passed\-in parameter data will be copied into the cursor\*(Aqs portal, so it can be freed while the cursor still exists\&.
53
const char * \fIname\fR
57
to let the system select a name
62
prepared statement (returned by
68
An array of actual parameter values\&. Must have same length as the statement\*(Aqs number of arguments\&.
71
const char * \fInulls\fR
73
An array describing which parameters are null\&. Must have same length as the statement\*(Aqs number of arguments\&.
81
assumes that no parameters are null\&. Otherwise, each entry of the
85
if the corresponding parameter value is non\-null, or
87
if the corresponding parameter value is null\&. (In the latter case, the actual value in the corresponding
89
entry doesn\*(Aqt matter\&.) Note that
91
is not a text string, just an array: it does not need a
99
for read\-only execution
103
Pointer to portal containing the cursor\&. Note there is no error return convention; any error will be reported via