|
KDBC
Unified C Database Connectivity — SQLite, PostgreSQL, MariaDB, Oracle, MSSQL
|
Functions | |
| int | kdbc_next (kdbc_result *rs) |
| Advance to the next row. | |
| int | kdbc_col_count (kdbc_result *rs) |
| Get the number of columns in the result set. | |
| const char * | kdbc_col_name (kdbc_result *rs, int col) |
| Get a column name by index. | |
| const char * | kdbc_col_label (kdbc_result *rs, int col) |
| Get a column label (alias) by index. | |
| int | kdbc_is_null (kdbc_result *rs, int col) |
| Check if a column value is NULL. | |
| int64_t | kdbc_get_long (kdbc_result *rs, int col) |
| Get a column value as a 64-bit integer. | |
| double | kdbc_get_double (kdbc_result *rs, int col) |
| Get a column value as a double. | |
| const char * | kdbc_get_string (kdbc_result *rs, int col) |
| Get a column value as a UTF-8 string. | |
| const void * | kdbc_get_blob (kdbc_result *rs, int col, size_t *out_len) |
| Get a column value as a binary blob. | |
| int | kdbc_get_timestamp (kdbc_result *rs, int col, int *year, int *month, int *day, int *hour, int *minute, int *second, int *usec) |
| Get a column value as a timestamp (date + time). | |
| int | kdbc_get_date (kdbc_result *rs, int col, int *year, int *month, int *day) |
| Get a column value as a date (no time component). | |
| int | kdbc_get_time (kdbc_result *rs, int col, int *hour, int *minute, int *second, int *usec) |
| Get a column value as a time (no date component). | |
| void | kdbc_result_close (kdbc_result *rs) |
| Close a result set and free resources. | |
Navigate rows and retrieve column values from query results.
All column indices are 1-indexed. String and blob pointers are valid until the next kdbc_next() call or kdbc_result_close().
| int kdbc_next | ( | kdbc_result * | rs | ) |
Advance to the next row.
| rs | A result set. |
| int kdbc_col_count | ( | kdbc_result * | rs | ) |
Get the number of columns in the result set.
| rs | A result set. |
| const char * kdbc_col_name | ( | kdbc_result * | rs, |
| int | col ) |
Get a column name by index.
| rs | A result set. |
| col | Column index (1-indexed). |
| const char * kdbc_col_label | ( | kdbc_result * | rs, |
| int | col ) |
Get a column label (alias) by index.
Falls back to the column name if no alias was specified in the query.
| rs | A result set. |
| col | Column index (1-indexed). |
| int kdbc_is_null | ( | kdbc_result * | rs, |
| int | col ) |
Check if a column value is NULL.
Call this after a kdbc_get_* function to distinguish NULL from zero or empty string.
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| int64_t kdbc_get_long | ( | kdbc_result * | rs, |
| int | col ) |
Get a column value as a 64-bit integer.
For type mismatches, reasonable conversions are attempted. Check kdbc_is_null() to distinguish NULL from 0.
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| double kdbc_get_double | ( | kdbc_result * | rs, |
| int | col ) |
Get a column value as a double.
Check kdbc_is_null() to distinguish NULL from 0.0.
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| const char * kdbc_get_string | ( | kdbc_result * | rs, |
| int | col ) |
Get a column value as a UTF-8 string.
The returned pointer is valid until the next kdbc_next() call or kdbc_result_close().
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| const void * kdbc_get_blob | ( | kdbc_result * | rs, |
| int | col, | ||
| size_t * | out_len ) |
Get a column value as a binary blob.
The returned pointer is valid until the next kdbc_next() call or kdbc_result_close().
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| out_len | Output: blob size in bytes. |
| int kdbc_get_timestamp | ( | kdbc_result * | rs, |
| int | col, | ||
| int * | year, | ||
| int * | month, | ||
| int * | day, | ||
| int * | hour, | ||
| int * | minute, | ||
| int * | second, | ||
| int * | usec ) |
Get a column value as a timestamp (date + time).
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| year | Output: year. |
| month | Output: month (1–12). |
| day | Output: day (1–31). |
| hour | Output: hour (0–23). |
| minute | Output: minute (0–59). |
| second | Output: second (0–59). |
| usec | Output: microseconds (0–999999). |
| int kdbc_get_date | ( | kdbc_result * | rs, |
| int | col, | ||
| int * | year, | ||
| int * | month, | ||
| int * | day ) |
Get a column value as a date (no time component).
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| year | Output: year. |
| month | Output: month (1–12). |
| day | Output: day (1–31). |
| int kdbc_get_time | ( | kdbc_result * | rs, |
| int | col, | ||
| int * | hour, | ||
| int * | minute, | ||
| int * | second, | ||
| int * | usec ) |
Get a column value as a time (no date component).
| rs | A result set (positioned on a row). |
| col | Column index (1-indexed). |
| hour | Output: hour (0–23). |
| minute | Output: minute (0–59). |
| second | Output: second (0–59). |
| usec | Output: microseconds (0–999999). |
| void kdbc_result_close | ( | kdbc_result * | rs | ) |
Close a result set and free resources.
Safe to call with NULL (no-op).
| rs | The result set to close, or NULL. |