Statement

public class Statement : CustomStringConvertible

A prepared SQL statement.

Use Connection.prepareStatement(text:) to create a Statement.

Call Statement.execute(parameterValues:retrieveColumnMetadata:) to execute the Statement, specifying the values of any parameters.

A Statement can be repeatedly executed, and the values of its parameters can be different each time.

When a Statement is no longer required, call Statement.close() to release its Postgres server resources. A Statement is automatically closed by its deinitializer.

A Statement in PostgresClientKit corresponds to a prepared statement on the Postgres server whose name is the id of the Statement.

  • id

    Uniquely identifies this Statement.

    The id of a Statement in PostgresClientKit is also the name of the prepared statement on the Postgres server. The id is also used in logging and to formulate the description.

    Declaration

    Swift

    public let id: String
  • The Connection to which this Statement belongs.

    Declaration

    Swift

    public let connection: Connection
  • The SQL text.

    Declaration

    Swift

    public let text: String
  • Executes this Statement.

    Any previous Cursor for this Connection is closed.

    Throws

    PostgresError if the operation fails

    Declaration

    Swift

    @discardableResult
    public func execute(parameterValues: [PostgresValueConvertible?] = [ ],
                        retrieveColumnMetadata: Bool = false)
        throws -> Cursor

    Parameters

    parameterValues

    the values of the statement’s parameters. Index 0 is the value of $1, index 1 is the value of $2, and so on. A nil element represents SQL NULL.

    retrieveColumnMetadata

    whether to retrieve metadata about the columns in the results

    Return Value

    a Cursor containing the result

  • Whether this Statement is closed.

    To close a Statement, call close().

    Declaration

    Swift

    public var isClosed: Bool { get }
  • Closes this Statement.

    Any previous Cursor for the connection is closed.

    Has no effect if this Statement is already closed.

    Declaration

    Swift

    public func close()
  • A short string that identifies this Statement.

    Declaration

    Swift

    public var description: String { get }