2 .\" Title: SPI_cursor_open
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "SPI_CURSOR_OPEN" "3" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 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
35 Portal SPI_cursor_open(const char * \fIname\fR, SPIPlanPtr \fIplan\fR,
36 Datum * \fIvalues\fR, const char * \fInulls\fR,
42 sets up a cursor (internally, a portal) that will execute a statement prepared by
43 \fBSPI_prepare\fR\&. The parameters have the same meanings as the corresponding parameters to
44 \fBSPI_execute_plan\fR\&.
46 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 C function (it can, in fact, live to the end of the current transaction)\&. Returning the portal name to the C function\*(Aqs caller provides a way of returning a row set as result\&.
48 The passed\-in parameter data will be copied into the cursor\*(Aqs portal, so it can be freed while the cursor still exists\&.
51 const char * \fIname\fR
55 to let the system select a name
60 prepared statement (returned by
66 An array of actual parameter values\&. Must have same length as the statement\*(Aqs number of arguments\&.
69 const char * \fInulls\fR
71 An array describing which parameters are null\&. Must have same length as the statement\*(Aqs number of arguments\&.
79 assumes that no parameters are null\&. Otherwise, each entry of the
83 if the corresponding parameter value is non\-null, or
85 if the corresponding parameter value is null\&. (In the latter case, the actual value in the corresponding
87 entry doesn\*(Aqt matter\&.) Note that
89 is not a text string, just an array: it does not need a
97 for read\-only execution
101 Pointer to portal containing the cursor\&. Note there is no error return convention; any error will be reported via