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.
-
Uniquely identifies this
Statement.The
idof aStatementin PostgresClientKit is also the name of the prepared statement on the Postgres server. Theidis also used in logging and to formulate thedescription.Declaration
Swift
public let id: String -
The
Connectionto which thisStatementbelongs.Declaration
Swift
public let connection: Connection -
The SQL text.
Declaration
Swift
public let text: String -
Executes this
Statement.Any previous
Cursorfor thisConnectionis closed.Throws
PostgresErrorif the operation failsDeclaration
Swift
@discardableResult public func execute(parameterValues: [PostgresValueConvertible?] = [ ], retrieveColumnMetadata: Bool = false) throws -> CursorParameters
parameterValuesthe values of the statement’s parameters. Index 0 is the value of
$1, index 1 is the value of$2, and so on. Anilelement represents SQLNULL.retrieveColumnMetadatawhether to retrieve metadata about the columns in the results
Return Value
a
Cursorcontaining the result -
Whether this
Statementis closed.To close a
Statement, callclose().Declaration
Swift
public var isClosed: Bool { get } -
Closes this
Statement.Any previous
Cursorfor theconnectionis closed.Has no effect if this
Statementis already closed.Declaration
Swift
public func close()
-
A short string that identifies this
Statement.Declaration
Swift
public var description: String { get }