PGResult

public class PGResult

Encapsulates the server response from executing a query

  • the status returned from the server

    Declaration

    Swift

    public let status: Status
  • true if the result was .commandkOk, .tuplesOk, or .signleTupe

    Declaration

    Swift

    public var wasSuccessful: Bool { get }
  • the server’s description of the status

    Declaration

    Swift

    public var statusMessage: String { get }
  • the error message associated with these results

    Declaration

    Swift

    public var errorMessage: String { get }
  • the number of rows returned

    Declaration

    Swift

    public var rowCount: Int { get }
  • the number of columns returned

    Declaration

    Swift

    public var columnCount: Int { get }
  • true if the status indicates data was returned

    Declaration

    Swift

    public var returnedData: Bool { get }
  • for non-select queries (such as insert/update/deletee) the number of rows affected

    Declaration

    Swift

    public var rowsAffected: Int { get }
  • if a single row was inserted, the Oid of that row. Returns -1 of there is no value

    Declaration

    Swift

    public var insertedOid: Int { get }
  • names of columns indexed by column number

    Declaration

    Swift

    public let columnNames: [String]
  • the type of the column

    Declaration

    Swift

    public let columnTypes: [PGType]
  • returns the value as the actual native type (String, Int, Bool, etc.)

    Throws

    if any parameter is invalid, if the column’s NativeType doesn’t match T

    Declaration

    Swift

    public func getValue<T>(row: Int, column: Int) throws -> T?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value

  • finds the index of the first column matching columnName then calls getValue(from:column:) with it

    Throws

    if any parameter is invalid, if there is no column with the specified name, or if the column’s NativeType doesn’t match T

    Declaration

    Swift

    public func getValue<T>(row: Int, columnName: String) throws -> T?

    Parameters

    row

    row number

    columnName

    column name

    Return Value

    the value

  • Gets the specified value as a data object.

    Throws

    if an invalid column number

    Declaration

    Swift

    public func getDataValue(row: Int, column: Int) throws -> Data?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as a string, or nil if NULL

  • Gets the specified value as a string. This works for more types than nativeType.string

    Throws

    if value not easily convertible to a string, or if an invalid column number

    Declaration

    Swift

    public func getStringValue(row: Int, column: Int) throws -> String?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as a string, or nil if NULL

  • Gets the specified value as a bool if nativeType is .bool

    Throws

    if value not a bool, or if an invalid column number

    Declaration

    Swift

    public func getBoolValue(row: Int, column: Int) throws -> Bool?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as a Bool, or nil if NULL

  • Gets the specified value as a date if columnType.nativeType == .date

    Throws

    if native format is not a date, or if an invalid column number

    Declaration

    Swift

    public func getDateValue(row: Int, column: Int) throws -> Date?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as a date, or nil if NULL

  • Gets the specified value as an integer if columnType.nativeType == .int

    Throws

    if native format is not an integer, or if an invalid column number

    Declaration

    Swift

    public func getIntValue(row: Int, column: Int) throws -> Int?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as an integer, or nil if NULL

  • Gets the specified value as a float if columnType.nativeType == .float

    Throws

    if native format is not float, or if an invalid column number

    Declaration

    Swift

    public func getFloatValue(row: Int, column: Int) throws -> Float?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as a float, or nil if NULL

  • Gets the specified value as a double if columnType.nativeType == .double or .float

    Throws

    if native format is not an double or float, or if an invalid column number

    Declaration

    Swift

    public func getDoubleValue(row: Int, column: Int) throws -> Double?

    Parameters

    row

    row number

    column

    column number

    Return Value

    the value as a double, or nil if NULL

  • the possible status returned from the server

    See more

    Declaration

    Swift

    public enum Status