4 SPI_cursor_open — set up a cursor using a statement created with
9 Portal SPI_cursor_open(const char * name, SPIPlanPtr plan,
10 Datum * values, const char * nulls,
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.
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 C function (it can, in fact, live to the
23 end of the current transaction). Returning the portal name to the C
24 function's caller provides a way of returning a row set as result.
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.
32 name for portal, or NULL to let the system select a name
35 prepared statement (returned by SPI_prepare)
38 An array of actual parameter values. Must have same length as
39 the statement's number of arguments.
42 An array describing which parameters are null. Must have same
43 length as the statement's number of arguments.
45 If nulls is NULL then SPI_cursor_open assumes that no parameters
46 are null. Otherwise, each entry of the nulls array should be ' '
47 if the corresponding parameter value is non-null, or 'n' if the
48 corresponding parameter value is null. (In the latter case, the
49 actual value in the corresponding values entry doesn't matter.)
50 Note that nulls is not a text string, just an array: it does not
51 need a '\0' terminator.
54 true for read-only execution
58 Pointer to portal containing the cursor. Note there is no error return
59 convention; any error will be reported via elog.