Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | [email protected] |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Squeal.PostgreSQL.Session.Result
Description
Get values from a Result
.
Synopsis
- data Result y where
- getRow :: MonadIO io => Row -> Result y -> io y
- firstRow :: MonadIO io => Result y -> io (Maybe y)
- getRows :: MonadIO io => Result y -> io [y]
- nextRow :: MonadIO io => Row -> Result y -> Row -> io (Maybe (Row, y))
- cmdStatus :: MonadIO io => Result y -> io Text
- cmdTuples :: MonadIO io => Result y -> io (Maybe Row)
- ntuples :: MonadIO io => Result y -> io Row
- nfields :: MonadIO io => Result y -> io Column
- resultStatus :: MonadIO io => Result y -> io ExecStatus
- okResult :: MonadIO io => Result y -> io ()
- resultErrorMessage :: MonadIO io => Result y -> io (Maybe ByteString)
- resultErrorCode :: MonadIO io => Result y -> io (Maybe ByteString)
- liftResult :: MonadIO io => (Result -> IO x) -> Result y -> io x
Documentation
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
.
cmdStatus :: MonadIO io => Result y -> io Text Source #
Returns the command status tag from the SQL command
that generated the Result
.
Commonly this is just the name of the command,
but it might include additional data such as the number of rows processed.
cmdTuples :: MonadIO io => Result y -> io (Maybe Row) Source #
Returns the number of rows affected by the SQL command.
This function returns Just
the number of
rows affected by the SQL statement that generated the Result
.
This function can only be used following the execution of a
SELECT, CREATE TABLE AS, INSERT, UPDATE, DELETE, MOVE, FETCH,
or COPY statement,or an EXECUTE of a prepared query that
contains an INSERT, UPDATE, or DELETE statement.
If the command that generated the PGresult was anything else,
cmdTuples
returns Nothing
.
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 => Result y -> 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.