---
name: "SPI_prepare_cursor"
section: "3"
platform: "linux"
package: "postgresql"
version: "18.6-4"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SPI_prepare_cursor"
---

# SPI\_prepare\_cursor(3)

prepare a statement, without executing it yet

## NAME

SPI\_prepare\_cursor - prepare a statement, without executing it yet

## SYNOPSIS

```
SPIPlanPtr SPI_prepare_cursor(const char * command, int nargs,
                              Oid * argtypes, int cursorOptions)
```

## DESCRIPTION

**SPI\_prepare\_cursor** is identical to **SPI\_prepare**, except that it also allows specification of the planner's “cursor options” parameter. This is a bit mask having the values shown in nodes/parsenodes.h for the options field of DeclareCursorStmt. **SPI\_prepare** always takes the cursor options as zero.

This function is now deprecated in favor of **SPI\_prepare\_extended**.

## ARGUMENTS

const char \* *command*

command string

int *nargs*

number of input parameters ($1, $2, etc.)

Oid \* *argtypes*

pointer to an array containing the OIDs of the data types of the parameters

int *cursorOptions*

integer bit mask of cursor options; zero produces default behavior

## RETURN VALUE

**SPI\_prepare\_cursor** has the same return conventions as **SPI\_prepare**.

## NOTES

Useful bits to set in *cursorOptions* include CURSOR\_OPT\_SCROLL, CURSOR\_OPT\_NO\_SCROLL, CURSOR\_OPT\_FAST\_PLAN, CURSOR\_OPT\_GENERIC\_PLAN, and CURSOR\_OPT\_CUSTOM\_PLAN. Note in particular that CURSOR\_OPT\_HOLD is ignored.
