diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-09-05 11:58:14 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-09-05 11:58:14 +0200 |
commit | d6518580059c6a0d34d7a1683fabc3bfcc4b5e27 (patch) | |
tree | 1d0cb1b8fd8f7fb98b52a8433c5cc4d1ef4383f1 /odb/oracle/auto-handle.cxx | |
parent | 83d687748558cb4f138cecfff2ccbe5cbbc0d761 (diff) |
Add RAII handle management for OCI handles and descriptors
Diffstat (limited to 'odb/oracle/auto-handle.cxx')
-rw-r--r-- | odb/oracle/auto-handle.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/odb/oracle/auto-handle.cxx b/odb/oracle/auto-handle.cxx new file mode 100644 index 0000000..fea92bd --- /dev/null +++ b/odb/oracle/auto-handle.cxx @@ -0,0 +1,39 @@ +// file : odb/oracle/auto-handle.cxx +// author : Constantin Michael <constantin@codesynthesis.com> +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : ODB NCUEL; see accompanying LICENSE file + +#include <oci.h> + +#include <odb/oracle/auto-handle.hxx> + +namespace odb +{ + namespace oracle + { + void + oci_handle_free (void* h, ub4 t) + { + OCIHandleFree (h, t); + } + + void handle_traits<OCISvcCtx>:: + release (OCISvcCtx* h, OCIError* e) + { + OCISessionRelease (h, e, 0, 0, OCI_DEFAULT); + } + + void handle_traits<OCIStmt>:: + release (OCIStmt* h, ub4 m, OCIError* e) + { + OCIStmtRelease (h, e, 0, 0, m); + } + + const ub4 handle_type_traits<OCIEnv>::htype = OCI_HTYPE_ENV; + const ub4 handle_type_traits<OCIError>::htype = OCI_HTYPE_ERROR; + const ub4 handle_type_traits<OCISvcCtx>::htype = OCI_HTYPE_SVCCTX; + const ub4 handle_type_traits<OCIStmt>::htype = OCI_HTYPE_STMT; + const ub4 handle_type_traits<OCIAuthInfo>::htype = OCI_HTYPE_AUTHINFO; + const ub4 handle_type_traits<OCITrans>::htype = OCI_HTYPE_TRANS; + } +} |