Difference between revisions of "OpenDBX/C API/odbx get option"

From Linuxnetworks
< OpenDBX‎ | C API
Jump to: navigation, search
(Return values:)
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
'''Query backend for implemented options'''
  
  int odbx_get_option(
+
  #include <opendbx/api.h>
    odbx_t* handle,
+
    unsigned int option,
+
    void* value )
+
  
= Description: =
+
int '''odbx_get_option'''(
 +
    odbx_t* '''''handle''''',
 +
    unsigned int '''''option''''',
 +
    void* '''''value''''' )
  
Asks the backend for supported options. Look in odbx.h for available options.
+
== Description ==
  
= Parameters: =
+
[[OpenDBX/API/odbx_get_option|odbx_get_option]]() asks the backend module associated to '''''handle''''' by [[OpenDBX/API/odbx_init|odbx_init]]() for implemented options and their current values. This function can be used at every stage as long as '''''handle''''' points to a valid connection object. Its primary use is to find out supported features of the backend module and to enable them with [[OpenDBX/API/odbx_set_option|odbx_set_option]]() before the connection to the database server is established by calling [[OpenDBX/API/odbx_bind|odbx_bind]]().
  
* handle: Connection object created by [[OpenDBX_init|odbx_init()]]
+
The first parameter '''''handle''''' is the connection object created and returned by [[OpenDBX/API/odbx_init|odbx_init]]() which becomes invalid as soon as it was supplied to [[OpenDBX/API/odbx_finish|odbx_finish]]().
* option: Options defined in odbx.h
+
* value: Pointer to the variable where the option value should be stored
+
  
= Return values: =
+
There are several '''''option''''' values defined as named constants in the odbx.h header file. A few of them are for informational purpose only while most of the options can also be set to different '''''option''''' values by [[OpenDBX/API/odbx_set_option|odbx_set_option]]() to change the behavior of the backend module. The available options are:
  
* ODBX_ERR_SUCCESS on success
+
; ODBX_OPT_API_VERSION : The API version implemented by the backend. Currently, it returns only zero and is reserved for the future
* Less than zero if an error occured
+
; ODBX_OPT_THREAD_SAFE : If it is safe to use this backend and especially the native database client library in an application which uses threads where more than one thread opens database connections via the OpenDBX library
 +
; ODBX_OPT_TLS : The database client library may support transmitting all data securely by encrypting the network traffic via SSL or TLS
 +
; ODBX_OPT_MULTI_STATEMENTS : The database server may be able to support multiple SQL statements in one query string sent via [[OpenDBX/API/odbx_query|odbx_query]]()
 +
; ODBX_OPT_PAGED_RESULTS : All database servers and client libraries are able to transfer the records row by row. Some of them can also transfer multiple rows or even all at once to minimize server load, network traffic and latency. The downside of this is an increased memory consumption
 +
; ODBX_OPT_COMPRESS : Support of compressed network traffic between database client and server. This can lead to higher throughput if the network is the bottleneck
 +
; ODBX_OPT_MODE : Some database servers support different modes of operation, e.g. modes for compliance to other SQL implementations or completely different query languages. This option is available since OpenDBX 1.1.4
  
= Errors: =
+
'''''value''''' must be a pointer to an integer variable where the backend module will store the result for the supplied option. If it's not stated otherwise, the value assigned to the '''''value''''' parameter by [[OpenDBX/API/odbx_get_option|odbx_get_option]]() will be of boolean nature and therefore is ODBX_ENABLE for a supported option or ODBX_DISABLE for an option which isn't supported.
  
* -ODBX_ERR_PARAM: One of the parameters or its content is invalid
+
== Return value ==
* -ODBX_ERR_OPTION: Unknown option
+
  
 +
[[OpenDBX/API/odbx_get_option|odbx_get_option]]() returns ODBX_ERR_SUCCESS, 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 [[OpenDBX/API/odbx_error|odbx_error]]() and [[OpenDBX/API/odbx_error_type|odbx_error_type]]() to get further details.
  
----
+
== Errors ==
Back to [[OpenDBX API|Overview]]
+
 
 +
; -ODBX_ERR_PARAM : One of the supplied parameters is invalid or is NULL and this isn't allowed in the used backend module or in the native database client library
 +
; -ODBX_ERR_OPTION : The value passed to the '''''option''''' parameter isn't one of the values listed in this manual. The content of '''''value''''' remains unchanged if this error occurs
 +
 
 +
== See also ==
 +
 
 +
* [[OpenDBX/API/odbx_bind|odbx_bind]]()
 +
* [[OpenDBX/API/odbx_error|odbx_error]]()
 +
* [[OpenDBX/API/odbx_error_type|odbx_error_type]]()
 +
* [[OpenDBX/API/odbx_init|odbx_init]]()
 +
* [[OpenDBX/API/odbx_set_option|odbx_set_option]]()

Latest revision as of 23:13, 28 April 2009

Query backend for implemented options

#include <opendbx/api.h>
int odbx_get_option(
    odbx_t* handle,
    unsigned int option,
    void* value )

Description

odbx_get_option() asks the backend module associated to handle by odbx_init() for implemented options and their current values. This function can be used at every stage as long as handle points to a valid connection object. Its primary use is to find out supported features of the backend module and to enable them with odbx_set_option() before the connection to the database server is established by calling odbx_bind().

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

There are several option values defined as named constants in the odbx.h header file. A few of them are for informational purpose only while most of the options can also be set to different option values by odbx_set_option() to change the behavior of the backend module. The available options are:

ODBX_OPT_API_VERSION 
The API version implemented by the backend. Currently, it returns only zero and is reserved for the future
ODBX_OPT_THREAD_SAFE 
If it is safe to use this backend and especially the native database client library in an application which uses threads where more than one thread opens database connections via the OpenDBX library
ODBX_OPT_TLS 
The database client library may support transmitting all data securely by encrypting the network traffic via SSL or TLS
ODBX_OPT_MULTI_STATEMENTS 
The database server may be able to support multiple SQL statements in one query string sent via odbx_query()
ODBX_OPT_PAGED_RESULTS 
All database servers and client libraries are able to transfer the records row by row. Some of them can also transfer multiple rows or even all at once to minimize server load, network traffic and latency. The downside of this is an increased memory consumption
ODBX_OPT_COMPRESS 
Support of compressed network traffic between database client and server. This can lead to higher throughput if the network is the bottleneck
ODBX_OPT_MODE 
Some database servers support different modes of operation, e.g. modes for compliance to other SQL implementations or completely different query languages. This option is available since OpenDBX 1.1.4

value must be a pointer to an integer variable where the backend module will store the result for the supplied option. If it's not stated otherwise, the value assigned to the value parameter by odbx_get_option() will be of boolean nature and therefore is ODBX_ENABLE for a supported option or ODBX_DISABLE for an option which isn't supported.

Return value

odbx_get_option() returns ODBX_ERR_SUCCESS, 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 odbx_error() and odbx_error_type() to get further details.

Errors

-ODBX_ERR_PARAM 
One of the supplied parameters is invalid or is NULL and this isn't allowed in the used backend module or in the native database client library
-ODBX_ERR_OPTION 
The value passed to the option parameter isn't one of the values listed in this manual. The content of value remains unchanged if this error occurs

See also