---
name: "odbx_result"
section: "3"
platform: "linux"
package: "opendbx"
version: "1.4.6-13"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/odbx_result"
---

# odbx\_result(3)

Retrieves a result set from the database server

## NAME

odbx\_result - Retrieves a result set from the database server

## SYNOPSIS

```
FC#include <opendbx/api.h>F[0]
```

FCint **odbx\_result**F\[0\]  FC(odbx\_t\* *handle*, odbx\_result\_t\*\* *result*, struct timeval\* *timeout*, unsigned long *chunk*);F\[0\]

## DESCRIPTION

Retrieves the result of a query statement sent by FC**odbx\_query**F\[0\]() from the database server. After a statement was successfully executed, a dynamically allocated object representing the result set is stored in FCresultF\[0\] which must be freed afterwards by FC**odbx\_result\_finish**F\[0\](). Result sets for SELECT-like statements returned successfully by this function can be processed by calling FC**odbx\_row\_fetch**F\[0\]() until all rows are retrieved. If the statement was an INSERT, UPDATE, DELETE or a similar statement, the number of affected rows is available via FC**odbx\_rows\_affected**F\[0\]().

If a timeout or error occurs, the FCresultF\[0\] pointer is set to NULL. In case of a timeout, FC**odbx\_result**F\[0\]() should be called again because 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 FC**odbx\_query**F\[0\]() will return an error.

The third parameter (FCtimeoutF\[0\]) restricts the time the function is waiting for a result form 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 FC**odbx\_result**F\[0\]() because its content may get changed by the 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 is possible, but there is no guarantee. If not, FC**odbx\_result**F\[0\]() will return not before a responds arrives.

Dependent on the native database library, it may be possible to retrieve all rows at once (if FCchunkF\[0\] is zero), one by one or more than one row at once. All positive values including zero are allowed as values for FCchunkF\[0\] 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.

## RETURN VALUE

FC**odbx\_result**F\[0\]() returns FCODBX\_RES\_ROWSF\[0\] ("3") if a result set is available and zero if no more results will be returned for the last query string sent via FC**odbx\_query**F\[0\]() successfully. FCODBX\_RES\_NOROWSF\[0\] ("2") is returned if the statement was executed successfully but will not return a results set (like for INSERT, UPDATE and DELETE statements) and FCODBX\_RES\_TIMEOUTF\[0\] ("1") indicates a timeout. As soon as FCODBX\_RES\_DONEF\[0\] ("0") 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 is the basis for the application development.

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 feed to FC**odbx\_error**F\[0\]() and FC**odbx\_error\_type**F\[0\]() 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 errornous 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 FC**odbx\_query**F\[0\]() on the same connection again.

## ERRORS

- \-FCODBX\_ERR\_BACKENDF\[0\]

  The native database library returned an error

- \-FCODBX\_ERR\_PARAMF\[0\]

  Either FChandleF\[0\] or FCresultF\[0\] are NULL or FChandleF\[0\] is invalid

- \-FCODBX\_ERR\_NOMEMF\[0\]

  Allocating the required memory for the result failed

- \-FCODBX\_ERR\_RESULTF\[0\]

  Waiting for a response from the server failed because the connection was lost

## SEE ALSO

FC**odbx\_column\_count**F\[0\](), FC**odbx\_column\_name**F\[0\](), FC**odbx\_column\_type**F\[0\](), FC**odbx\_rows\_affected**F\[0\](), FC**odbx\_row\_fetch**F\[0\](), FC**odbx\_result\_finish**F\[0\]()
