Exec Sends a query to the backend server. It's probably more desirable to use one of the next two functions.
ExecStatusType PgConnection::Exec(const char* query)Returns the result of the query. The following status results can be expected:
PGRES_EMPTY_QUERY |
PGRES_COMMAND_OK, if the query was a command |
PGRES_TUPLES_OK, if the query successfully returned tuples |
PGRES_COPY_OUT |
PGRES_COPY_IN |
PGRES_BAD_RESPONSE, if an unexpected response was received |
PGRES_NONFATAL_ERROR |
PGRES_FATAL_ERROR |
ExecCommandOk Sends a command query to the backend server.
int PgConnection::ExecCommandOk(const char *query)Returns TRUE if the command query succeeds.
ExecTuplesOk Sends a command query to the backend server.
int PgConnection::ExecTuplesOk(const char *query)Returns TRUE if the command query succeeds.
ErrorMessage Returns the last error message text.
const char *PgConnection::ErrorMessage()
Tuples Returns the number of tuples (rows) in the query result.
int PgDatabase::Tuples() const
Fields Returns the number of fields (attributes) in each tuple of the query result.
int PgDatabase::Fields()
FieldName Returns the field (attribute) name associated with the given field index. Field indices start at 0.
const char *PgDatabase::FieldName(int field_num) const
FieldNum PQfnumber Returns the field (attribute) index associated with the given field name.
int PgDatabase::FieldNum(const char* field_name) const-1 is returned if the given name does not match any field.
FieldType Returns the field type associated with the given field index. The integer returned is an internal coding of the type. Field indices start at 0.
Oid PgDatabase::FieldType(int field_num) const
FieldType Returns the field type associated with the given field name. The integer returned is an internal coding of the type. Field indices start at 0.
Oid PgDatabase::FieldType(const char* field_name) const
FieldSize Returns the size in bytes of the field associated with the given field index. Field indices start at 0.
int PgDatabase::FieldSize(int field_num) constReturns the space allocated for this field in a database tuple given the field number. In other words the size of the server's binary representation of the data type. -1 is returned if the field is variable size.
FieldSize Returns the size in bytes of the field associated with the given field index. Field indices start at 0.
int PgDatabase::FieldSize(const char *field_name) constReturns the space allocated for this field in a database tuple given the field name. In other words the size of the server's binary representation of the data type. -1 is returned if the field is variable size.
GetValue Returns a single field (attribute) value of one tuple of a PGresult. Tuple and field indices start at 0.
const char *PgDatabase::GetValue(int tup_num, int field_num) constFor most queries, the value returned by GetValue is a null-terminated ASCII string representation of the attribute value. But if BinaryTuples() is TRUE, the value returned by GetValue is the binary representation of the type in the internal format of the backend server (but not including the size word, if the field is variable-length). It is then the programmer's responsibility to cast and convert the data to the correct C type. The pointer returned by GetValue points to storage that is part of the PGresult structure. One should not modify it, and one must explicitly copy the value into other storage if it is to be used past the lifetime of the PGresult structure itself. BinaryTuples() is not yet implemented.
GetValue Returns a single field (attribute) value of one tuple of a PGresult. Tuple and field indices start at 0.
const char *PgDatabase::GetValue(int tup_num, const char *field_name) constFor most queries, the value returned by GetValue is a null-terminated ASCII string representation of the attribute value. But if BinaryTuples() is TRUE, the value returned by GetValue is the binary representation of the type in the internal format of the backend server (but not including the size word, if the field is variable-length). It is then the programmer's responsibility to cast and convert the data to the correct C type. The pointer returned by GetValue points to storage that is part of the PGresult structure. One should not modify it, and one must explicitly copy the value into other storage if it is to be used past the lifetime of the PGresult structure itself. BinaryTuples() is not yet implemented.
GetLength Returns the length of a field (attribute) in bytes. Tuple and field indices start at 0.
int PgDatabase::GetLength(int tup_num, int field_num) constThis is the actual data length for the particular data value, that is the size of the object pointed to by GetValue. Note that for ASCII-represented values, this size has little to do with the binary size reported by PQfsize.
GetLength Returns the length of a field (attribute) in bytes. Tuple and field indices start at 0.
int PgDatabase::GetLength(int tup_num, const char* field_name) constThis is the actual data length for the particular data value, that is the size of the object pointed to by GetValue. Note that for ASCII-represented values, this size has little to do with the binary size reported by PQfsize.
GetIsNull Returns whether a field has the null value.
bool GetIsNull(int tup_num, int field_num) constNote that GetValue will return the empty string for null fields, not the NULL pointer.
GetIsNull Returns whether a field has the null value.
bool GetIsNull(int tup_num, const char *field_name) constNote that GetValue will return the empty string for null fields, not the NULL pointer.
DisplayTuples OBSOLESCENT: Prints out all the tuples and, optionally, the attribute names to the specified output stream.
void PgDatabase::DisplayTuples(FILE *out = 0, bool fillAlign = true, const char* fieldSep = "|",bool printHeader = true, bool quiet = false) const
PrintTuples OBSOLESCENT: Prints out all the tuples and, optionally, the attribute names to the specified output stream.
void PgDatabase::PrintTuples(FILE *out = 0, bool printAttName = true, bool terseOutput = false, bool fillAlign = false) const
CmdTuples Returns the number of rows affected after an INSERT, UPDATE or DELETE. If the command was anything else, it returns -1.
int PgDatabase::CmdTuples() const
OidStatus
const char *PgDatabase::OidStatus() const
GetLine
int PgDatabase::GetLine(char* string, int length)
PutLine
void PgDatabase::PutLine(const char* string)
EndCopy
int PgDatabase::EndCopy()