Exec 47) 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)48) Returns the result of the query. The following status results can be expected: 問い合わせの結果の状態を返します.予期しうる状態は以下の通りです:
PGRES_EMPTY_QUERY |
49) PGRES_COMMAND_OK, if the query was a command |
PGRES_COMMAND_OK(問い合わせがコマンドだった場合) |
50) PGRES_TUPLES_OK, if the query successfully returned tuples |
PGRES_TUPLES_OK(問い合わせがタプルを返すのに成功した場合) |
PGRES_COPY_OUT |
PGRES_COPY_IN |
51) PGRES_BAD_RESPONSE, if an unexpected response was received |
PGRES_BAD_RESPONSE(予期しない応答を受信した場合) |
PGRES_NONFATAL_ERROR |
PGRES_FATAL_ERROR |
ExecCommandOk 52) Sends a command query to the backend server. バックエンドサーバへ問い合わせを送信します.
int PgConnection::ExecCommandOk(const char *query)53) Returns TRUE if the command query succeeds. 問い合わせの実行に成功すれば TRUE を返します.
ExecTuplesOk 54) Sends a command query to the backend server. バックエンドサーバへ問い合わせを送信します.
int PgConnection::ExecTuplesOk(const char *query)55) Returns TRUE if the command query succeeds and there are tuples to be retrieved. 問い合わせの実行に成功し,取り出すタプルが存在すれば TRUE を返します.
ErrorMessage 56) Returns the last error message text. 最後に出力されたエラーメッセージテキストを返します.
const char *PgConnection::ErrorMessage()
Tuples 57) Returns the number of tuples (instances) in the query result. 問い合わせ結果に含まれるタプル(インスタンス)の数を返します.
int PgDatabase::Tuples()
Fields 58) Returns the number of fields (attributes) in each tuple of the query result. 問い合わせ結果のタプルに含まれるフィールド(属性)の数を返します.
int PgDatabase::Fields()
FieldName 59) Returns the field (attribute) name associated with the given field index. Field indices start at 0. 与えられたフィールド(属性)のインデックスに対応するフィールド名を返します. フィールドのインデックスは 0 から始まります.
const char *PgDatabase::FieldName(int field_num)
FieldNum 60) PQfnumber Returns the field (attribute) index associated with the given field name. 与えられたフィールド(属性)名に対応するフィールドのインデックスを返します.
int PgDatabase::FieldNum(const char* field_name)61) -1 is returned if the given name does not match any field. 与えられた名前がどのフィールドとも一致しない場合は -1 を返します.
FieldType 62) 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. 与えられたフィールドのインデックスに対応するフィールドの型を返します. 返された整数は型に対する内部コードです. フィールドのインデックスは 0 から始まります.
Oid PgDatabase::FieldType(int field_num)
FieldType 63) 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)
FieldSize 64) Returns the size in bytes of the field associated with the given field index. Field indices start at 0. 与えられたフィールドのインデックスに対応するフィールドのサイズをバイト数で返します. フィールドのインデックスは 0 から始まります.
short PgDatabase::FieldSize(int field_num)65) Returns 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. タプル内の指定されたフィールド番号に割り当てられた領域のサイズを返します. つまりこれは,このデータ型のサーバにおけるバイナリ表現のサイズです. フィールドが可変長の場合は -1 を返します.
FieldSize 66) Returns the size in bytes of the field associated with the given field index. Field indices start at 0. ※二文とも修正忘れ 与えられたフィールド名に対応するフィールドのサイズをバイト数で返します.
short PgDatabase::FieldSize(const char *field_name)67) Returns 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. タプル内の指定されたフィールド名に割り当てられた領域のサイズを返します. つまりこれは,このデータ型のサーバにおけるバイナリ表現のサイズです. フィールドが可変長の場合は -1 を返します.
GetValue 68) Returns a single field (attribute) value of one tuple of a PGresult. Tuple and field indices start at 0. PGresult からタプルをひとつ取り, その中からフィールド(属性)の値をひとつ返します. タプルとフィールドのインデックスは 0 から始まります.
const char *PgDatabase::GetValue(int tup_num, int field_num)69) For 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 の返す値は属性値を NULL 終端の ASCII 文字列で表現したものとなります. しかし BinaryTuples() が TRUE の場合,GetValue が返す値はバックエンドサーバの内部フォーマットによるバイナリ型表現です. (ただしフィールドが可変長であっても,そのサイズを示すワードは含まれません) したがって,これを正しい C の型にキャストして変換するのはプログラマの責任です. GetValue が返すポインタは PGresult 構造体の記憶領域の一部ですから, これを変更してはいけません. もし値を PGresult 構造体自身の寿命を超えて使うのであれば, 明示的に別の記憶領域にコピーしなければなりません. (BinaryTuples() はまだ実装されていません)
GetValue 70) Returns a single field (attribute) value of one tuple of a PGresult. Tuple and field indices start at 0. ※最後の一文は修正し忘れ PGresult からタプルをひとつ取り, その中からフィールド(属性)の値をひとつ返します. タプルのインデックスは 0 から始まります.
const char *PgDatabase::GetValue(int tup_num, const char *field_name)71) For 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 の返す値は属性値を NULL 終端の ASCII 文字列で表現したものとなります. しかし BinaryTuples() が TRUE の場合,GetValue が返す値はバックエンドサーバの内部フォーマットによるバイナリ型表現です. (ただしフィールドが可変長であっても,そのサイズを示すワードは含まれません) したがって,これを正しい C の型にキャストして変換するのはプログラマの責任です. GetValue が返すポインタは PGresult 構造体の記憶領域の一部ですから, これを変更してはいけません. もし値を PGresult 構造体自身の寿命を超えて使うのであれば, 明示的に別の記憶領域にコピーしなければなりません. (BinaryTuples() はまだ実装されていません)
GetLength 72) Returns the length of a field (attribute) in bytes. Tuple and field indices start at 0. フィールド(属性)の長さをバイト数で返します. タプルとフィールドのインデックスは 0 から始まります.
int PgDatabase::GetLength(int tup_num, int field_num)73) This 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. これは個々のデータ値に対する実際のデータ長で, GetValue が指すオブジェクトのサイズです. なお ASCII 表現の値の場合,このサイズは PQfsize で得られるバイナリサイズとはあまり関連しません.注意してください.
GetLength 74) Returns the length of a field (attribute) in bytes. Tuple and field indices start at 0. ※最後の一文は修正し忘れ フィールド(属性)の長さをバイト数で返します. タプルのインデックスは 0 から始まります.
int PgDatabase::GetLength(int tup_num, const char* field_name)75) This 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. これは個々のデータ値に対する実際のデータ長で, GetValue が指すオブジェクトのサイズです. なお ASCII 表現の値の場合,このサイズは PQfsize で得られるバイナリサイズとはあまり関連しません.注意してください.
DisplayTuples 76) Prints out all the tuples and, optionally, the attribute names to the specified output stream. 指定された出力ストリームへすべてのタプルと,必要なら属性名も表示します.
void PgDatabase::DisplayTuples(FILE *out = 0, int fillAlign = 1, const char* fieldSep = "|",int printHeader = 1, int quiet = 0)
PrintTuples 77) Prints out all the tuples and, optionally, the attribute names to the specified output stream. 指定された出力ストリームへすべてのタプルと,必要なら属性名も表示します.
void PgDatabase::PrintTuples(FILE *out = 0, int printAttName = 1, int terseOutput = 0, int width = 0)
GetLine
int PgDatabase::GetLine(char* string, int length)
PutLine
void PgDatabase::PutLine(const char* string)
OidStatus
const char *PgDatabase::OidStatus()
EndCopy
int PgDatabase::EndCopy()