1SPI_CURSOR_OPEN(3) PostgreSQL 9.2.24 Documentation SPI_CURSOR_OPEN(3)
2
3
4
6 SPI_cursor_open - set up a cursor using a statement created with
7 SPI_prepare
8
10 Portal SPI_cursor_open(const char * name, SPIPlanPtr plan,
11 Datum * values, const char * nulls,
12 bool read_only)
13
15 SPI_cursor_open sets up a cursor (internally, a portal) that will
16 execute a statement prepared by SPI_prepare. The parameters have the
17 same meanings as the corresponding parameters to SPI_execute_plan.
18
19 Using a cursor instead of executing the statement directly has two
20 benefits. First, the result rows can be retrieved a few at a time,
21 avoiding memory overrun for queries that return many rows. Second, a
22 portal can outlive the current procedure (it can, in fact, live to the
23 end of the current transaction). Returning the portal name to the
24 procedure's caller provides a way of returning a row set as result.
25
26 The passed-in parameter data will be copied into the cursor's portal,
27 so it can be freed while the cursor still exists.
28
30 const char * name
31 name for portal, or NULL to let the system select a name
32
33 SPIPlanPtr plan
34 prepared statement (returned by SPI_prepare)
35
36 Datum * values
37 An array of actual parameter values. Must have same length as the
38 statement's number of arguments.
39
40 const char * nulls
41 An array describing which parameters are null. Must have same
42 length as the statement's number of arguments. n indicates a null
43 value (entry in values will be ignored); a space indicates a
44 nonnull value (entry in values is valid).
45
46 If nulls is NULL then SPI_cursor_open assumes that no parameters
47 are null.
48
49 bool read_only
50 true for read-only execution
51
53 Pointer to portal containing the cursor. Note there is no error return
54 convention; any error will be reported via elog.
55
56
57
58PostgreSQL 9.2.24 2017-11-06 SPI_CURSOR_OPEN(3)