1odbx_query(3)                       OpenDBX                      odbx_query(3)
2
3
4

NAME

6       odbx_query - Send a statement to the database server
7

SYNOPSIS

9       #include <opendbx/api.h>
10
11
12       int odbx_query (odbx_t* handle, const char* stmt, unsigned long
13                      length);
14

DESCRIPTION

16       Sends the given statement to the database server associated  to  handle
17       by odbx_init() for execution. The statement can contain non-displayable
18       characters as arguments in conditions but they have to be  escaped  via
19       odbx_escape() before adding them to the statement. Even more, every ar‐
20       gument whose source is not controlled by the programmer must be escaped
21       first to avoid SQL injection attacks to avoid serious harm!
22
23       After  invoking odbx_query(), one or more result sets will be sent back
24       by the server and are available via odbx_result().  Before  these  sets
25       aren't  processed  by calling odbx_row_fetch(), no other queries can be
26       sent to the database server.  Otherwise,  odbx_query()  will  return  a
27       backend error from the native database library.
28
29       The  first  parameter  handle  is the connection object created and re‐
30       turned by odbx_init() which becomes invalid as soon as it was  supplied
31       to odbx_finish().
32
33       The  statement  stored  in the stmt parameter must be a valid statement
34       understood by the receiving database server and it should be terminated
35       by a \0 character. Some backends support multiple statements per query,
36       which can be tested by calling odbx_get_option().
37
38       The length parameter must contain the length of the statement in  bytes
39       without  the terminating \0 character. If variable sized character sets
40       like UTF-8 are used, the same rule applies. This function doesn't  sup‐
41       port the wide character type (wchar_t) which uses two or four bytes per
42       character. If you feed 0 (zero) as length parameter to the function, it
43       will calculate the size of the statement on its own.
44

RETURN VALUE

46       odbx_query()  returns ODBX_ERR_SUCCESS, or an error code whose value is
47       less than zero if one of the operations couldn't be completed  success‐
48       fully.  Possible  error  codes are listed in the error section and they
49       can be feed to odbx_error() and odbx_error_type() to  get  further  de‐
50       tails.
51

ERRORS

53       -ODBX_ERR_BACKEND
54              The  native database library returned an error because it wasn't
55              able to handle the statement correctly
56
57       -ODBX_ERR_PARAM
58              Either handle or stmt are NULL or handle is invalid
59
60       -ODBX_ERR_NOMEM
61              Allocating the required memory for the statement failed
62

SEE ALSO

64       odbx_error(), odbx_error_type(), odbx_escape(), odbx_result()
65
66
67
68                                22 August 2021                   odbx_query(3)
Impressum