4.9. Retrieving Field Data by Index

4.9.1. dbi_result_get_char_idx

signed char dbi_result_get_char_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a character (a 1-byte signed integer). This is the default for the "char" type on the x86 platform, as well as on Mac OS X.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.2. dbi_result_get_uchar_idx

unsigned char dbi_result_get_uchar_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains an unsigned character (1-byte unsigned integer). This is the default for the "char" type on Linux for PowerPC.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.3. dbi_result_get_short_idx

short dbi_result_get_short_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a short integer (2-byte signed integer).

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.4. dbi_result_get_ushort_idx

unsigned short dbi_result_get_ushort_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains an unsigned short integer (2-byte unsigned integer).

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.5. dbi_result_get_int_idx

int dbi_result_get_int_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains an integer (4-byte signed integer).

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.6. dbi_result_get_uint_idx

unsigned int dbi_result_get_uint_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains an unsigned integer (4-byte signed integer).

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.7. dbi_result_get_long_idx

int dbi_result_get_long_idx(dbi_result Result, unsigned int fieldidx);

Same as dbi_result_get_int_idx. This function is deprecated as the name implies the wrong return type on 64bit platforms.

4.9.8. dbi_result_get_ulong_idx

unsigned int dbi_result_get_ulong_idx(dbi_result Result, unsigned int fieldidx);

Same as dbi_result_get_uint_idx. This function is deprecated as the name implies the wrong return type on 64bit platforms.

4.9.9. dbi_result_get_longlong_idx

long long dbi_result_get_longlong_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a long long integer (8-byte signed integer).

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.10. dbi_result_get_ulonglong_idx

unsigned long long dbi_result_get_ulonglong_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains an unsigned long long integer (8-byte unsigned integer).

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.11. dbi_result_get_float_idx

float dbi_result_get_float_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a floating-point number.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.12. dbi_result_get_double_idx

double dbi_result_get_double_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a double-precision fractional number.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field, or 0 (zero) if an error occurs. In the latter case the error number is DBI_ERROR_BADTYPE or DBI_ERROR_BADIDX.

4.9.13. dbi_result_get_string_idx

const char *dbi_result_get_string_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a zero-terminated string.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field. If the field contains a NULL value, the function returns a NULL pointer. The string may not be modified, and may not necessairly persist between row fetches. In case of an error, this function returns the string "ERROR". In the latter case the error number is DBI_ERROR_BADTYPE, DBI_ERROR_BADIDX, or DBI_ERROR_BADNAME.

4.9.14. dbi_result_get_string_copy_idx

char *dbi_result_get_string_copy_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains a zero-terminated string, and return it in an allocated buffer.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field. If the field contains a NULL value, the function returns a NULL pointer, and no memory is allocated. The newly allocated string may be modified by the host program, but the program is responsible for freeing the string. In case of an error, this function returns an allocated string reading "ERROR". In the latter case the error number is DBI_ERROR_BADTYPE, DBI_ERROR_BADIDX, or DBI_ERROR_BADNAME.

4.9.15. dbi_result_get_binary_idx

const unsigned char *dbi_result_get_binary_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains binary data. The data may not be modified, and may not necessarily persist between row fetches. If the field contains a NULL value, the function returns a NULL pointer. In case of an error, this function returns the string "ERROR".

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field. The binary data may contain zero bytes and non-printable characters. Use dbi_result_get_field_length or dbi_result_get_field_length_idx to determine the number of bytes contained in the resulting binary string. The data may not be modified, and may not necessarily persist between row fetches. If the field contains a NULL value, the function returns a NULL pointer. In case of an error, this function returns the string "ERROR". In the latter case the error number is DBI_ERROR_BADTYPE, DBI_ERROR_BADIDX, or DBI_ERROR_BADNAME.

4.9.16. dbi_result_get_binary_copy_idx

unsigned char *dbi_result_get_binary_copy_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the speficied field, which contains binary data, and return it in an allocated buffer. The newly allocated memory may be modified by the host program, but the program is responsible for freeing the data. If the field contains a NULL value, the function returns a NULL pointer. In case of an error, this function returns the string "ERROR".

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field. The newly allocated memory may be modified by the host program, but the program is responsible for freeing the data. If the field contains a NULL value, the function returns a NULL pointer. In case of an error, this function returns the string "ERROR". In the latter case the error number is DBI_ERROR_BADTYPE, DBI_ERROR_BADIDX, or DBI_ERROR_BADNAME.

4.9.17. dbi_result_get_datetime_idx

time_t dbi_result_get_datetime_idx(dbi_result Result, unsigned int fieldidx);

Fetch the data stored in the specified field, which contains a DATE and/or TIME value.

Arguments

Result: The target query result.

fieldidx: The index of the target field (starting at 1).

Returns

The data stored in the specified field as a time_t value. To convert this into human-readable dates or times, use the C library functions gmtime (3) and localtime (3). In case of an error this function returns 0 (zero) which resolves to the Unix epoch when converted. In case of an error the error number is DBI_ERROR_BADTYPE, DBI_ERROR_BADIDX, or DBI_ERROR_BADNAME.