squeal-postgresql-0.6.0.1: Squeal PostgreSQL Library

Copyright(c) Eitan Chatav 2019
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Squeal.PostgreSQL.Session.Result

Description

Get values from a Result.

Synopsis

Documentation

data Result y where Source #

Results are generated by running Statements in a MonadPQ.

They contain an underlying Result and a DecodeRow.

Constructors

Result :: SListI row => DecodeRow row y -> Result -> Result y 
Instances
Functor Result Source # 
Instance details

Defined in Squeal.PostgreSQL.Session.Result

Methods

fmap :: (a -> b) -> Result a -> Result b #

(<$) :: a -> Result b -> Result a #

getRow :: MonadIO io => Row -> Result y -> io y Source #

Get a row corresponding to a given row number from a Result, throwing an exception if the row number is out of bounds.

firstRow :: MonadIO io => Result y -> io (Maybe y) Source #

Get the first row if possible from a Result.

getRows :: MonadIO io => Result y -> io [y] Source #

Get all rows from a Result.

nextRow Source #

Arguments

:: MonadIO io 
=> Row

total number of rows

-> Result y

result

-> Row

row number

-> io (Maybe (Row, y)) 

Intended to be used for unfolding in streaming libraries, nextRow takes a total number of rows (which can be found with ntuples) and a Result and given a row number if it's too large returns Nothing, otherwise returning the row along with the next row number.

ntuples :: MonadIO io => Result y -> io Row Source #

Returns the number of rows (tuples) in the query result.

nfields :: MonadIO io => Result y -> io Column Source #

Returns the number of columns (fields) in the query result.

resultStatus :: MonadIO io => Result y -> io ExecStatus Source #

Returns the result status of the command.

okResult :: MonadIO io => K Result row -> io () Source #

Check if a Result's status is either CommandOk or TuplesOk otherwise throw a SQLException.

resultErrorMessage :: MonadIO io => Result y -> io (Maybe ByteString) Source #

Returns the error message most recently generated by an operation on the connection.

resultErrorCode :: MonadIO io => Result y -> io (Maybe ByteString) Source #

Returns the error code most recently generated by an operation on the connection.

https://www.postgresql.org/docs/current/static/errcodes-appendix.html