postgresql-simple-0.7.0.1: Mid-Level PostgreSQL client library

Copyright | (c) 2011-2012 Leon P Smith (c) 2017 Bardur Arantsson
License | BSD3
Maintainer | Leon P Smith <leon@melding-monads.com>
Safe Haskell | None
Language | Haskell2010

Database.PostgreSQL.Simple.Cursor

Contents

- Types
- Cursor management
- Folding over rows from a cursor

Description

Synopsis

- data Cursor
- declareCursor :: Connection -> Query -> IO Cursor
- closeCursor :: Cursor -> IO ()
- foldForward :: FromRow r => Cursor -> Int -> (a -> r -> IO a) -> a -> IO (Either a a)
- foldForwardWithParser :: Cursor -> RowParser r -> Int -> (a -> r -> IO a) -> a -> IO (Either a a)

# Types

data Cursor Source #

Cursor within a transaction.

# Cursor management

declareCursor :: Connection -> Query -> IO Cursor Source #

Declare a temporary cursor. The cursor is given a unique name for the given connection.

closeCursor :: Cursor -> IO () Source #

Close the given cursor.

# Folding over rows from a cursor

foldForward :: FromRow r => Cursor -> Int -> (a -> r -> IO a) -> a -> IO (Either a a) Source #

Fold over a chunk of rows, calling the supplied fold-like function on each row as it is received. In case the cursor is exhausted, a `Left` value is returned, otherwise a `Right` value is returned.

foldForwardWithParser :: Cursor -> RowParser r -> Int -> (a -> r -> IO a) -> a -> IO (Either a a) Source #

Fold over a chunk of rows from the given cursor, calling the supplied fold-like function on each row as it is received. In case the cursor is exhausted, a `Left` value is returned, otherwise a `Right` value is returned.