SYNOPSIS

\*(T<#include <opendbx/api.h>\*(T>

\*(T<int odbx_query\*(T> \kx \*(T<(odbx_t* handle, const char* stmt, unsigned long length);\*(T>

DESCRIPTION

Sends the given statement to the database server associated to \*(T<handle\*(T> by \*(T<odbx_init\*(T>() for execution. The statement can contain non-displayable characters as arguments in conditions but they have to be escaped via \*(T<odbx_escape\*(T>() before adding them to the statement. Even more, every argument whose source is not controlled by the programmer must be escaped first to avoid SQL injection attacks to avoid serious harm!

After invoking \*(T<odbx_query\*(T>(), one or more result sets will be sent back by the server and are available via \*(T<odbx_result\*(T>(). Before these sets aren't processed by calling \*(T<odbx_row_fetch\*(T>(), no other queries can be sent to the database server. Otherwise, \*(T<odbx_query\*(T>() will return a backend error from the native database library.

The first parameter \*(T<handle\*(T> is the connection object created and returned by \*(T<odbx_init\*(T>() which becomes invalid as soon as it was supplied to \*(T<odbx_finish\*(T>().

The statement stored in the \*(T<stmt\*(T> parameter must be a valid statement understood by the receiving database server and it should be terminated by a \0 character. Some backends support multiple statements per query, which can be tested by calling \*(T<odbx_get_option\*(T>().

The \*(T<length\*(T> parameter must contain the length of the statement in bytes without the terminating \0 character. If variable sized character sets like UTF-8 are used, the same rule applies. This function doesn't support the wide character type (wchar_t) which uses two or four bytes per character. If you feed 0 (zero) as \*(T<length\*(T> parameter to the function, it will calculate the size of the statement on its own.

RETURN VALUE

\*(T<odbx_query\*(T>() returns \*(T<ODBX_ERR_SUCCESS\*(T>, or 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 \*(T<odbx_error\*(T>() and \*(T<odbx_error_type\*(T>() to get further details.

ERRORS

-\*(T<ODBX_ERR_BACKEND\*(T>

The native database library returned an error because it wasn't able to handle the statement correctly

-\*(T<ODBX_ERR_PARAM\*(T>

Either \*(T<handle\*(T> or \*(T<stmt\*(T> are NULL or \*(T<handle\*(T> is invalid

-\*(T<ODBX_ERR_NOMEM\*(T>

Allocating the required memory for the statement failed

RELATED TO odbx_query…

\*(T<odbx_error\*(T>(), \*(T<odbx_error_type\*(T>(), \*(T<odbx_escape\*(T>(), \*(T<odbx_result\*(T>()