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
id
of aStatement
in PostgresClientKit is also the name of the prepared statement on the Postgres server. Theid
is also used in logging and to formulate thedescription
.Declaration
Swift
public let id: String
-
The
Connection
to which thisStatement
belongs.Declaration
Swift
public let connection: Connection
-
The SQL text.
Declaration
Swift
public let text: String
-
Executes this
Statement
.Any previous
Cursor
for thisConnection
is closed.Throws
PostgresError
if the operation failsDeclaration
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. Anil
element represents SQLNULL
.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
, callclose()
.Declaration
Swift
public var isClosed: Bool { get }
-
Closes this
Statement
.Any previous
Cursor
for theconnection
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 }