Difference between revisions of "OpenDBX/C API/odbx unbind"

From Linuxnetworks
< OpenDBX‎ | C API
Jump to: navigation, search
(Return values:)
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
'''Disconnects from the database'''
  
  int odbx_unbind(
+
  #include <opendbx/api.h>
    odbx_t* handle )
+
  
= Description: =
+
int '''odbx_unbind'''(
 +
    odbx_t* '''''handle''''' )
  
Releases the binding to the database and user for the connection opened by [[OpenDBX_bind_simple|odbx_bind_simple()]]. This is useful for switching to another database or binding to the database as a different user. It is also possible to set new connection related options before rebinding to the database server.
+
== Description ==
  
This function must be invoked before calling [[OpenDBX_finish|odbx_finish()]] to avoid memory leaks.
+
Releases the binding of the connection to the database and user associated by [[OpenDBX/API/odbx_bind|odbx_bind]]() to the supplied connection object. This is useful for switching to a different database or binding to the database with different credentials. It is also possible to set new connection related options before rebinding to the database server. If an open transaction exists while this function is executed in the firebird backend, it will be committed to the database and closed. The behavior of the other backends for open transactions may vary.
  
= Parameters: =
+
It's necessary to process all result sets returned by the database server before using this function. Otherwise, it might return an error depending on the native database client library and the backend module. This function must be invoked before calling [[OpenDBX/API/odbx_finish|odbx_finish]]() to avoid memory leaks and connections left open which may block necessary resources later on.
  
* handle: Connection object created by [[OpenDBX_init|odbx_init()]]
+
The '''''handle''''' parameter has to be the connection object created and returned by [[OpenDBX/API/odbx_init|odbx_init]](). It becomes invalid after it was supplied to [[OpenDBX/API/odbx_finish|odbx_finish]]() and [[OpenDBX/API/odbx_unbind|odbx_unbind]]() will return an error in this case.
  
= Return values: =
+
== Return value ==
  
* ODBX_ERR_SUCCESS on success
+
[[OpenDBX/API/odbx_unbind|odbx_unbind]]() 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.
* Less than zero if an error occured
+
  
= Errors: =
+
== Errors ==
  
* -ODBX_ERR_PARAM: Parameter or its content is invalid
+
; -ODBX_ERR_PARAM : '''''handle''''' is NULL or the supplied connection object is invalid
  
 +
== See also ==
  
----
+
* [[OpenDBX/API/odbx_bind|odbx_bind]]()
Back to [[OpenDBX API|Overview]]
+
* [[OpenDBX/API/odbx_error|odbx_error]]()
 +
* [[OpenDBX/API/odbx_finish|odbx_finish]]()

Latest revision as of 22:15, 28 April 2009

Disconnects from the database

#include <opendbx/api.h>
int odbx_unbind(
    odbx_t* handle )

Description

Releases the binding of the connection to the database and user associated by odbx_bind() to the supplied connection object. This is useful for switching to a different database or binding to the database with different credentials. It is also possible to set new connection related options before rebinding to the database server. If an open transaction exists while this function is executed in the firebird backend, it will be committed to the database and closed. The behavior of the other backends for open transactions may vary.

It's necessary to process all result sets returned by the database server before using this function. Otherwise, it might return an error depending on the native database client library and the backend module. This function must be invoked before calling odbx_finish() to avoid memory leaks and connections left open which may block necessary resources later on.

The handle parameter has to be the connection object created and returned by odbx_init(). It becomes invalid after it was supplied to odbx_finish() and odbx_unbind() will return an error in this case.

Return value

odbx_unbind() 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 
handle is NULL or the supplied connection object is invalid

See also