odbx_result(3)
π odbx_result β the OpenDBX manual, but make it make sense
okay bestie, buckle up, because this is the page for odbx_result(3) from the OpenDBX manual and it's genuinely iconic β it's the lil function that goes and retrieves a result set from the database server. yes ma'am, the main character of the whole query pipeline. π
β¨ SYNOPSIS β¨
#include <opendbx/api.h>
int odbx_result (odbx_t* handle, odbx_result_t** result, struct timeval*
timeout, unsigned long chunk);
πΈ DESCRIPTION πΈ
So here's the vibe: odbx_result() goes and picks up the result of a query statement that you already sent off with odbx_query() and hands it back to you from the database server. π¦
Once a statement has been executed successfully, a dynamically allocated object representing the result set gets stashed in result β and ngl bestie, you must free it afterwards with odbx_result_finish(). No leaving it hanging, that's not the energy we're bringing. π
If it's a SELECT-like statement, the result sets this function returns successfully can be processed by calling odbx_row_fetch() until all the rows are retrieved. and if the statement was an INSERT, UPDATE, DELETE or something in that family, the number of affected rows is available via odbx_rows_affected(). slay. π₯
If a timeout or an error occurs, the result pointer is set to NULL. In case of a timeout, you should call odbx_result() again, because β and this is the important bit β the query isn't canceled. π This function must be called multiple times until it returns zero, even if the query contains only one statement. Otherwise memory will be leaked and odbx_query() will return an error. like, fr fr, do not skip this step.
π the "call it until it returns zero" rule is not a suggestion, bestie. it's the whole assignment.
π the timeout situation
The third parameter (timeout) restricts the time the function is waiting for a result from the server. It may be NULL to wait until a result arrives. Otherwise, it can contain any number of seconds and microseconds in a timeval structure to wait for.
The timeval structure must be set each time before calling odbx_result() because its content may get changed by the function. π (yes, it will touch your struct. it's that kind of function.)
If the server doesn't respond within the timeout, the query isn't canceled! Instead, the next call to this function will wait for the same result set. Waiting the specified time may be implemented in the backends if it's possible, but there is no guarantee. If it isn't, odbx_result() will return not before a response arrives. π΄
π the chunk situation
Dependent on the native database library, it may be possible to retrieve all rows at once (if chunk is zero), one by one, or more than one row at once. All positive values including zero are allowed as values for chunk.
If paging (more than one row at once) is not supported by the backend, it will use "one by one" or "all at once" if this is the only option provided. iconic adaptive behaviour, honestly. β¨
π RETURN VALUE π
odbx_result() returns ODBX_RES_ROWS ("3") if a result set is available, and zero if no more results will be returned for the last query string sent via odbx_query() successfully. π«Ά
ODBX_RES_NOROWS("2") β returned if the statement was executed successfully but will not return a result set (like forINSERT,UPDATEandDELETEstatements)ODBX_RES_TIMEOUT("1") β indicates a timeoutODBX_RES_DONE("0") β as soon as this is returned, the available result sets were processed β
The named constants are available since OpenDBX 1.3.2, and the numbers in brackets have to be used instead if a previous release is the basis for the application development. iykyk. π
It returns an error code whose value is less than zero if one of the operations couldn't be completed successfully. Possible error codes are listed in the error section and they can be fed to odbx_error() and odbx_error_type() to get further details. π
In this case, the backends are responsible for freeing the data structures they allocated inside the function and to clear the erroneous result set if there's one available. The backends will also set the given result pointer to NULL before returning the error. Nevertheless, if a non-fatal error occurred it's possible to retrieve further result sets β and this is necessary before calling odbx_query() on the same connection again. π§
π ERRORS π
-ODBX_ERR_BACKENDβ the native database library returned an error-ODBX_ERR_PARAMβ eitherhandleorresultareNULLorhandleis invalid-ODBX_ERR_NOMEMβ allocating the required memory for the result failed-ODBX_ERR_RESULTβ waiting for a response from the server failed because the connection was lost
π¦ SEE ALSO π¦
odbx_column_count()odbx_column_name()odbx_column_type()odbx_rows_affected()odbx_row_fetch()odbx_result_finish()
go read those next, bestie, they're all part of the same little friend group. π
that's the whole page! β¨ this cutie was brought to you by OpenDBX, dated 6 February 2026 β written down, signed, sealed, and served with main character energy. mwah. π ππΈ
π¦ where this page comes from
- ubuntu resolute: libopendbx1-dev 1.4.6-18build2
- ubuntu stonking: libopendbx1-dev 1.4.6-18build2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms