|
ITTIA DB SQL C API
5.4.0
|
Data Structures | |
| struct | db_event_t |
| Data change notification event. More... | |
Functions | |
| db_result_t | db_watch_table (db_t, const db_objname_t *, db_flags_t, uint32_t utid) |
| db_result_t | db_unwatch_table (db_t, const db_objname_t *) |
| db_result_t | db_wait (db_t, db_wtime_t, db_event_t *) |
| db_result_t | db_wait_ex (db_t, db_wtime_t, db_event_t *, db_row_t row, db_row_t aux_row) |
| db_result_t db_watch_table | ( | db_t | hdb, |
| const db_objname_t * | table_name, | ||
| db_flags_t | flags, | ||
| uint32_t | utid | ||
| ) |
Set up a notification handler for a particular table.
| hdb | Database handle. |
| table_name | Name of database table. |
| flags | Event types and scope, a bitwise combination of flags.
|
The following flags control the use of the auxiliary row:
| utid | User supplied numeric id for the handler. |
DB_OK when successful.
On failure, one of the following error codes is set:
| db_result_t db_unwatch_table | ( | db_t | hdb, |
| const db_objname_t * | table_name | ||
| ) |
Remove a notification handler for a particular table.
| hdb | Database handle. |
| table_name | Name of database table. |
On failure, one of the following error codes is set:
| db_result_t db_wait | ( | db_t | hdb, |
| db_wtime_t | timeout, | ||
| db_event_t * | event | ||
| ) |
Wait for a notification message from the database.
| hdb | Database handle |
| timeout | Maximum length of time to wait for a notification 0 - returns right away with DB_FAIL if no notification or DB_OK if there was a notification to report. |
| event | Event structure containing information about the event. Check event.u.utid |
On failure, one of the following error codes is set:
This function does not start or require a transaction, but can be used safely within a transaction.
| db_result_t db_wait_ex | ( | db_t | hdb, |
| db_wtime_t | timeout, | ||
| db_event_t * | event, | ||
| db_row_t | hrow, | ||
| db_row_t | haux_row | ||
| ) |
Wait for a notification message from the database.
| hdb | Database handle |
| timeout | Maximum length of time to wait for a notification 0 - returns right away with DB_FAIL if no notification or DB_OK if there was a notification to report. |
| event | Event structure containing information about the event. Check event.u.utid |
| hrow | Destination for some or all fields of the modified row. |
| haux_row | For update events only, a destination for the original values. |
On failure, one of the following error codes is set:
After the event, hrow and haux_row may contain data, depending on how the notification event was configured in db_watch_table. The fields bound to the row will correspond to the table that originated the event. Only fields included in the event are bound to these rows. For fields that are not included in the event, db_is_null will return -1.
db_t hdb = ...; db_result_t rc; db_event_t evt; db_row_t hrow = db_alloc_row(NULL, 1); do { rc = db_wait_ex(hdb, 0, &evt, hrow, NULL); ... } while (1);
This function does not start or require a transaction, but can be used safely within a transaction.