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

# SPI\_cursor\_fetch(3)

fetch some rows from a cursor

## NAME

SPI\_cursor\_fetch - fetch some rows from a cursor

## SYNOPSIS

```
void SPI_cursor_fetch(Portal portal, bool forward, long count)
```

## DESCRIPTION

**SPI\_cursor\_fetch** fetches some rows from a cursor. This is equivalent to a subset of the SQL command **FETCH** (see **SPI\_scroll\_cursor\_fetch** for more functionality).

## ARGUMENTS

Portal *portal*

portal containing the cursor

bool *forward*

true for fetch forward, false for fetch backward

long *count*

maximum number of rows to fetch

## RETURN VALUE

*SPI\_processed* and *SPI\_tuptable* are set as in **SPI\_execute** if successful.

## NOTES

Fetching backward may fail if the cursor's plan was not created with the CURSOR\_OPT\_SCROLL option.
