From 3d1f4de1cd4037dca58e9f61278a34cdc5b51251 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 4 May 2020 07:22:55 +0200 Subject: [PATCH 01/62] Massive refactoring: - added ocilib.c implementing all public methods - renaming current methods, making them internal - methods from ocilib.c proxy to internal methods - reorganizing internal headers - Removing legacy ones - changed code control flow - all methods have now an init section and a cleanup section - reduced cyclomatic complexity - removed usage of OCI_STATUS checks - macros renaming - enhanced internal checks and error handling - added new method OCI_ErrorGetLocation that returns the method where the error occurred - added oracle 19 version macros - fixed some internal issues - fixed a bug in ObjectGetRealTypeInfo() - factorized some code - refactor internal management of OCI_ENV_CONTEXT - removed old VS projects for building DLLs --- configure | 2 +- configure.ac | 2 +- include/ocilib.h | 19369 +------------------ include/ocilib_api.h | 17419 +++++++++++++++++ include/ocilib_compat.h | 310 + include/ocilib_config.h | 1248 ++ include/ocilib_types.h | 718 + proj/dll/ocilib_dll_vs2013.sln | 25 - proj/dll/ocilib_dll_vs2013.vcxproj | 371 - proj/dll/ocilib_dll_vs2015.sln | 25 - proj/dll/ocilib_dll_vs2015.vcxproj | 371 - proj/dll/ocilib_dll_vs2017.sln | 25 - proj/dll/ocilib_dll_vs2017.vcxproj | 375 - proj/dll/ocilib_dll_vs2019.vcxproj | 85 +- proj/dll/ocilib_dll_vs2019.vcxproj.filters | 344 + scripts/uncrustify.cfg | 6 +- scripts/uncrustify.cmd | 1 + scripts/uncrustify.txt | 202 +- src/Makefile.am | 166 +- src/Makefile.in | 181 +- src/agent.c | 248 +- src/agent.h | 69 + src/array.c | 258 +- src/array.h | 54 + src/bind.c | 1549 +- src/bind.h | 167 + src/callback.c | 386 +- src/callback.h | 86 + src/collection.c | 723 +- src/collection.h | 137 + src/column.c | 844 +- src/column.h | 133 + src/connection.c | 2593 ++- src/connection.h | 332 + src/database.c | 349 + src/database.h | 55 + src/date.c | 749 +- src/date.h | 197 + src/define.c | 311 +- src/define.h | 67 + src/defs.h | 431 + src/dequeue.c | 911 +- src/dequeue.h | 148 + src/dirpath.c | 1492 +- src/dirpath.h | 170 + src/element.c | 1102 +- src/element.h | 288 + src/enqueue.c | 328 +- src/enqueue.h | 79 + src/{library.c => environment.c} | 1606 +- src/environment.h | 101 + src/error.c | 304 +- src/error.h | 107 + src/event.c | 92 +- src/event.h | 61 + src/exception.c | 931 +- src/exception.h | 217 + src/file.c | 753 +- src/file.h | 145 + src/format.c | 81 +- src/format.h | 34 + src/handle.c | 254 +- src/handle.h | 136 + src/hash.c | 467 +- src/hash.h | 105 + src/helpers.c | 231 + src/helpers.h | 44 + src/{oci_import.h => import.h} | 671 +- src/interval.c | 641 +- src/interval.h | 146 + src/iterator.c | 233 +- src/iterator.h | 51 + src/list.c | 370 +- src/list.h | 96 + src/{oci_loader.h => loader.h} | 127 +- src/lob.c | 1259 +- src/lob.h | 220 + src/long.c | 298 +- src/long.h | 74 + src/macros.h | 436 + src/memory.c | 429 +- src/memory.h | 129 + src/message.c | 1012 + src/message.h | 175 + src/msg.c | 830 - src/mutex.c | 166 +- src/mutex.h | 51 + src/number.c | 729 +- src/number.h | 162 + src/object.c | 1853 +- src/object.h | 384 + src/{oci_api.h => oci/api.h} | 4362 ++--- src/{oci_defs.h => oci/defs.h} | 2126 +- src/{oci_types.h => oci/types.h} | 618 +- src/ocilib.c | 6848 +++++++ src/ocilib_checks.h | 538 - src/ocilib_defs.h | 607 - src/ocilib_internal.h | 1264 -- src/pool.c | 768 +- src/pool.h | 112 + src/queue.c | 987 +- src/queue.h | 119 + src/ref.c | 441 - src/reference.c | 497 + src/reference.h | 105 + src/resultset.c | 2120 +- src/resultset.h | 414 + src/statement.c | 3114 +-- src/statement.h | 757 + src/{string.c => strings.c} | 2572 +-- src/strings.h | 177 + src/subscription.c | 423 +- src/subscription.h | 72 + src/thread.c | 190 +- src/thread.h | 48 + src/threadkey.c | 234 +- src/threadkey.h | 65 + src/timestamp.c | 974 +- src/timestamp.h | 195 + src/transaction.c | 293 +- src/transaction.h | 79 + src/typeinfo.c | 787 +- src/typeinfo.h | 79 + src/{ocilib_types.h => types.h} | 1954 +- 124 files changed, 61147 insertions(+), 44504 deletions(-) create mode 100644 include/ocilib_api.h create mode 100644 include/ocilib_compat.h create mode 100644 include/ocilib_config.h create mode 100644 include/ocilib_types.h delete mode 100644 proj/dll/ocilib_dll_vs2013.sln delete mode 100644 proj/dll/ocilib_dll_vs2013.vcxproj delete mode 100644 proj/dll/ocilib_dll_vs2015.sln delete mode 100644 proj/dll/ocilib_dll_vs2015.vcxproj delete mode 100644 proj/dll/ocilib_dll_vs2017.sln delete mode 100644 proj/dll/ocilib_dll_vs2017.vcxproj create mode 100644 proj/dll/ocilib_dll_vs2019.vcxproj.filters create mode 100644 scripts/uncrustify.cmd create mode 100644 src/agent.h create mode 100644 src/array.h create mode 100644 src/bind.h create mode 100644 src/callback.h create mode 100644 src/collection.h create mode 100644 src/column.h create mode 100644 src/connection.h create mode 100644 src/database.c create mode 100644 src/database.h create mode 100644 src/date.h create mode 100644 src/define.h create mode 100644 src/defs.h create mode 100644 src/dequeue.h create mode 100644 src/dirpath.h create mode 100644 src/element.h create mode 100644 src/enqueue.h rename src/{library.c => environment.c} (56%) create mode 100644 src/environment.h create mode 100644 src/error.h create mode 100644 src/event.h create mode 100644 src/exception.h create mode 100644 src/file.h create mode 100644 src/format.h create mode 100644 src/handle.h create mode 100644 src/hash.h create mode 100644 src/helpers.c create mode 100644 src/helpers.h rename src/{oci_import.h => import.h} (83%) create mode 100644 src/interval.h create mode 100644 src/iterator.h create mode 100644 src/list.h rename src/{oci_loader.h => loader.h} (53%) create mode 100644 src/lob.h create mode 100644 src/long.h create mode 100644 src/macros.h create mode 100644 src/memory.h create mode 100644 src/message.c create mode 100644 src/message.h delete mode 100644 src/msg.c create mode 100644 src/mutex.h create mode 100644 src/number.h create mode 100644 src/object.h rename src/{oci_api.h => oci/api.h} (95%) rename src/{oci_defs.h => oci/defs.h} (98%) rename src/{oci_types.h => oci/types.h} (96%) create mode 100644 src/ocilib.c delete mode 100644 src/ocilib_checks.h delete mode 100644 src/ocilib_defs.h delete mode 100644 src/ocilib_internal.h create mode 100644 src/pool.h create mode 100644 src/queue.h delete mode 100644 src/ref.c create mode 100644 src/reference.c create mode 100644 src/reference.h create mode 100644 src/resultset.h create mode 100644 src/statement.h rename src/{string.c => strings.c} (62%) create mode 100644 src/strings.h create mode 100644 src/subscription.h create mode 100644 src/thread.h create mode 100644 src/threadkey.h create mode 100644 src/timestamp.h create mode 100644 src/transaction.h create mode 100644 src/typeinfo.h rename src/{ocilib_types.h => types.h} (74%) diff --git a/configure b/configure index 6a87f9c3..ebba132a 100755 --- a/configure +++ b/configure @@ -592,7 +592,7 @@ PACKAGE_STRING='ocilib 4.2.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' -ac_unique_file="src/library.c" +ac_unique_file="src/ocilib.c" # Factoring default headers for most tests. ac_includes_default="\ #include diff --git a/configure.ac b/configure.ac index 8673f699..94d1a222 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ AC_INIT(ocilib, m4_esyscmd([tr -d '\n' < VERSION])) m4_pattern_allow([LT_MAJOR]) -AC_CONFIG_SRCDIR([src/library.c]) +AC_CONFIG_SRCDIR([src/ocilib.c]) AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(config.h) AC_CONFIG_MACRO_DIR([m4]) diff --git a/include/ocilib.h b/include/ocilib.h index 4d63fd1b..cc8c6a82 100644 --- a/include/ocilib.h +++ b/include/ocilib.h @@ -38,19372 +38,13 @@ extern "C" { #endif /* __cplusplus */ - -/** - * @defgroup OcilibCApi C API - * @{ - * - */ - -/* --------------------------------------------------------------------------------------------- * - * Platform configuration - * --------------------------------------------------------------------------------------------- */ - -#ifdef HAVE_CONFIG_H - #include -#endif - -/* --------------------------------------------------------------------------------------------- * - * C headers - * --------------------------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* --------------------------------------------------------------------------------------------- * - * MS Windows platform detection - * --------------------------------------------------------------------------------------------- */ - -#ifndef _WINDOWS - #if defined(_WIN32)|| defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(_WIN32_WINNT) - #define _WINDOWS - #endif -#endif - -#ifdef _WINDOWS - #ifdef boolean - #undef boolean - #endif - #include - #ifdef boolean - #undef boolean - #endif -#endif - -/* --------------------------------------------------------------------------------------------- * - * OCILIB version information - * --------------------------------------------------------------------------------------------- */ - -#define OCILIB_MAJOR_VERSION 4 -#define OCILIB_MINOR_VERSION 6 -#define OCILIB_REVISION_VERSION 4 - -/* Import mode */ - -#define OCI_IMPORT_MODE_LINKAGE 1 -#define OCI_IMPORT_MODE_RUNTIME 2 - -#ifdef OCI_IMPORT_RUNTIME - #undef OCI_IMPORT_LINKAGE -#endif - -#ifdef OCI_IMPORT_LINKAGE - #undef OCI_IMPORT_RUNTIME -#endif - -#if !defined(OCI_IMPORT_RUNTIME) && !defined(OCI_IMPORT_LINKAGE) - #define OCI_IMPORT_LINKAGE -#endif - -#ifdef OCI_IMPORT_RUNTIME - #define OCI_IMPORT_MODE OCI_IMPORT_MODE_RUNTIME -#else - #define OCI_IMPORT_MODE OCI_IMPORT_MODE_LINKAGE -#endif - -/* Charset modes */ - -#ifdef OCI_CHARSET_UNICODE - #define OCI_CHARSET_WIDE -#endif - -#ifdef OCI_CHARSET_WIDE - #undef OCI_CHARSET_ANSI -#endif - -#ifdef OCI_CHARSET_ANSI - #undef OCI_CHARSET_ANSI -#endif - -#if !defined(OCI_CHARSET_ANSI) && !defined(OCI_CHARSET_WIDE) - #define OCI_CHARSET_ANSI -#endif - -/* Calling convention */ - -#ifndef OCI_API - #ifdef _MSC_VER - #define OCI_API __stdcall - #else - #define OCI_API - #endif -#endif - -/* Build mode */ - -#ifndef OCI_EXPORT - #define OCI_EXPORT -#endif - -/** - * @defgroup OcilibCApiSupportedCharsets Character sets - * @{ - * - * OCILIB supports both ANSI and Unicode. - * - * Oracle started a real Unicode support with Oracle8i but only for bind and fetch data. - * All SQL and PL/SQ/ statements, database objects names were still only supported in ANSI. - * - * With Oracle 9i, Oracle provides a full Unicode support. - * - * So depending on the compile time Oracle library or the runtime loaded library, Unicode support differs. - * - * OCILIB supports: - * - * - ANSI (char) - * - Unicode (wchar_t) - * - UTF8 strings - * - * OCILIB uses the character type 'otext' that is a define around char and wchar_t depending on the charset mode. - * - * @par Option OCI_CHARSET_ANSI - * - * - otext --> char - * - OTEXT(x) --> x - * - * @par Option OCI_CHARSET_WIDE - * - * - otext --> wchar_t - * - OTEXT(x) --> L ## x - * - * @par Unicode and ISO C - * - * Well, ISO C: - * - does not know anything about Unicode. - * - makes wide characters support tricky because wide character size is not defined and is freely adaptable by implementations. - * - * OCILIB uses char/wchar_t strings for both public interface and internal storage. - * - * Unicode builds of OCILIB initialize OCI in UTF16 Unicode mode. - * Oracle implements this mode with a 2 bytes (fixed length) UTF16 encoding. - * - * @warning - * When using Unicode builds of OCILIB, make sure that the target - * Database charset is also using an Unicode charset or is a superset of UTF16. - * If not, strings may be converted with substitution characters by the Oracle client ! - * - * So, on systems implementing wchar_t as 2 bytes based UTF16 (e.g. Ms Windows), - * strings are directly passed to Oracle and taken back from it. - * - * On other systems (most of the Unix systems) that use UTF32 as encoding, (4 bytes based wchar_t), OCILIB uses: - * - temporary buffers for statements and object names - * - buffer expansion from UTF16 to UTF32 for fetch and bind string: - * - allocation based on sizeof(wchar_t) - * - data filling based on sizeof(short) -> (UTF16 2 bytes) - * - data expansion to sizeof(wchar_t). - * - * Buffer expansion is done in place and has the advantage of not requiring extra buffer. - * That reduces the cost of the Unicode/ISO C handling overhead on Unix systems. - * - * @par UTF8 strings - * - * OCILIB fully supports UTF8 strings : - * - Within OCI_CHARSET_ANSI builds - * - NLS_LANG environment variable must be set to any valid UTF8 Oracle charset string - * - * @par Charset mapping macros - * - * OCILIB main header file provides macro around most common string functions of - * the C standard library. - * - * these macros are based on the model: ostr[libc function name]() - * - * xxx is the standard C library string function name without the character type prefix (str/wcs). - * - * List of available macros: - * - ostrdup - * - ostrcpy - * - ostrncpy - * - ostrcat - * - ostrncat - * - ostrlen - * - ostrcmp - * - ostrcasecmp - * - osprintf - * - ostol - * -**/ - -#if defined(__cplusplus) && defined(_MSC_VER) && (_MSC_VER < 1300) -extern "C++" { -#endif - -#include - -#if defined(__cplusplus) && defined(_MSC_VER) && (_MSC_VER < 1300) -} -#endif - -/* Charset macros */ - -#define OCI_CHAR_ANSI 1 -#define OCI_CHAR_WIDE 2 - -#ifdef OCI_CHARSET_ANSI - typedef char otext; - #define OTEXT(x) x - #define OCI_CHAR_TEXT OCI_CHAR_ANSI -#else - typedef wchar_t otext; - #define OTEXT(x) L ## x - #define OCI_CHAR_TEXT OCI_CHAR_WIDE -#endif - -/* - For ISO conformance, strdup/wcsdup/stricmp/strncasecmp are not used. - All wide char routines are part of the 1995 Normative Addendum 1 to the ISO C90 standard. - OCILIB also needs an ANSI equivalent to swprintf => ocisprintf - Thus OCILIB exports the following helper functions - -*/ - -OCI_EXPORT int ocisprintf -( - char *str, - int size, - const char *format, - ... -); - -OCI_EXPORT char * ocistrdup -( - const char * src -); - -OCI_EXPORT int ocistrcasecmp -( - const char *str1, - const char *str2 -); - -OCI_EXPORT wchar_t * ociwcsdup -( - const wchar_t * src -); - -OCI_EXPORT int ociwcscasecmp -( - const wchar_t *str1, - const wchar_t *str2 -); - -/* special defines for Microsoft C runtime that is not C ISO compliant */ - -#ifdef _WINDOWS - - #define vsnprintf _vsnprintf - #define swprintf _snwprintf - -#endif - -/* helpers mapping macros */ - -#ifdef OCI_CHARSET_ANSI - #define ostrdup ocistrdup - #define ostrcpy strcpy - #define ostrncpy strncpy - #define ostrcat strcat - #define ostrncat strncat - #define ostrlen strlen - #define ostrcmp strcmp - #define ostrcasecmp ocistrcasecmp - #define osprintf ocisprintf - #define ostrtol strtol - #define osscanf sscanf - #define otoupper toupper - #define oisdigit isdigit -#else - #define ostrdup ociwcsdup - #define ostrcpy wcscpy - #define ostrncpy wcsncpy - #define ostrcat wcscat - #define ostrncat wcsncat - #define ostrlen wcslen - #define ostrcmp wcscmp - #define ostrcasecmp ociwcscasecmp - #define osprintf swprintf - #define ostrtol wcstol - #define osscanf swscanf - #define otoupper towupper - #define oisdigit iswdigit - -#endif - -/* string size macros */ - -#define otextsize(s) (ostrlen(s) * sizeof(otext)) - -/** - * @} - */ - -/** - * @defgroup OcilibCApiDatatypes Data types - * @{ - * - * OCILIB implements: - * - * - Oracle Scalar data types through scalar C data types - * - Oracle opaque/complex objects though opaque library handles - * - Library objects for manipulating the database: connections, transactions, statements... - * - * @par Supported Oracle data types - * - * - All Database types are supported excluding REFs. - * - * Here is a summary of the supported data types: - * - * - Scalar types CHAR/NCHAR, VARCHAR2/NVARCHAR2, NUMBER, FLOAT, REAL, RAW, ... - * - Binary types: RAW, LONG RAW, VARRAW, .. - * - Larges Objects (Lobs and Files) : BLOB, CLOB, NCLOB, BFILE - * - LONG types: LONG, VAR LONG - * - Date, Timestamps et Intervals: DATE, TIMESTAMP, INTERVAL - * - PL/SQL types: Ref cursors, PL/SQL Tables - * - Named Types (by value): Built-in system objects and User defined objects - * - VARRAYs and Nested Tables - * - ROWIDs - * - * @par OCILIB library objects - * - * The public OCILIB library interface implements encapsulation for - * representing database objects (such as connections, statements ...) through - * opaque structures (pointers to structures whose definition is kept private) - * - * Instead of directly manipulating the structures and their members, the library - * has functions to access the underlying members. - * - * It's designed to make the user code as more independent as possible of - * the library details. - * -**/ - -/** - * @typedef OCI_Pool - * - * @brief - * Pool object (session or connection) - * - * A pool is a set of pooled objects - * - */ - -typedef struct OCI_Pool OCI_Pool; - -/** - * @typedef OCI_Connection - * - * @brief - * Oracle physical connection. - * - * It holds all information about a connection such as error handling, associated statements, ... - * Error handling and transactions are embedded within a connection object. - * - * @warning - * Multi threaded applications that use multiple connections should use one connection per thread - * as all statements associated with a connection share the same context. - * - */ - -typedef struct OCI_Connection OCI_Connection; - -/** - * @typedef OCI_Statement - * - * @brief - * Oracle SQL or PL/SQL statement. - * - * A Statement object allows users to prepare, execute SQL orders or PL/SQL blocks - * - */ - -typedef struct OCI_Statement OCI_Statement; - -/** - * @typedef OCI_Bind - * - * @brief - * Internal bind representation. - * - * A bind object is an object that holds all information about an Oracle statement binding operation - * - */ - -typedef struct OCI_Bind OCI_Bind; - -/** - * @typedef OCI_Resultset - * - * @brief - * Collection of output columns from a select statement. - * - * A resultset object is the result of 'select' SQL Statement. - * - * It's a set of data (ordered in columns) that can be fetched row by row - * to get data returned by the SQL statement - * - */ - -typedef struct OCI_Resultset OCI_Resultset; - -/** - * @typedef OCI_Column - * - * @brief - * Oracle SQL Column and Type member representation. - * - * A column object represents an output column from a select statement - * - */ - -typedef struct OCI_Column OCI_Column; - -/** - * @typedef OCI_Lob - * - * @brief - * Oracle Internal Large objects: - * - * The following internal Larges Objects are supported: - * - * - BLOBs : Binary large objects - * - CLOBs / NCLOBs : Character large objects - * - * LOBs were introduced by OCI8 to replace Long data types. - * - * It's designed to store really larges objects (buffer, files) inside the database - * - * Oracle encourages programmers to use those objects instead of LONG, LONG RAW, ... - * - * OCILIB supports both LOBs and LONGs - * - */ - -typedef struct OCI_Lob OCI_Lob; - -/** - * @typedef OCI_File - * - * @brief - * Oracle External Large objects: - * - * The following external Larges Objects are supported: - * - * - BFILEs : Binary files - * - CFILEs : Character files - * - * FILEs were introduced by OCI8 in order to store references to files located outside the database. - * - * @warning - * Only Read-only access is allowed on BFILEs - * - * Two way to use FILEs : - * - * - within statement context (query, binding) - * - without statement context (server files reading) through OCI_File properties functions - * - */ - -typedef struct OCI_File OCI_File; - -/** - * @typedef OCI_Transaction - * - * @brief - * Oracle Transaction. - * - * A transaction can be: - * - * - Local: it's implicitly created by OCILIB - * - Global: it's explicitly created by the program - * - */ - -typedef struct OCI_Transaction OCI_Transaction; - -/** - * @typedef OCI_Long - * - * @brief Oracle Long data type. - * - * The following long Objects are supported: - * - * - LONG RAW : Binary long objects - * - LONG : Character long objects - * - * Those types were used in older versions of Oracle (before Oracle8i) to store - * large chunks of data in the database. - * - * It's now depreciated by Oracle that recommends using LOBs - * - * Many databases and applications are still designed to use LONGs that's why - * OCILIB supports Long Objects and piecewise operations - * - */ - -typedef struct OCI_Long OCI_Long; - -/** -* @typedef OCI_Number -* -* @brief -* Oracle NUMBER representation. -* -*/ -typedef struct OCI_Number OCI_Number; - -/** - * @typedef OCI_Date - * - * @brief - * Oracle internal date representation. - * - */ - -typedef struct OCI_Date OCI_Date; - -/** - * @typedef OCI_Timestamp - * - * @brief - * Oracle internal timestamp representation. - * - */ - -typedef struct OCI_Timestamp OCI_Timestamp; - -/** - * @typedef OCI_Interval - * - * @brief - * Oracle internal interval representation. - * - */ - -typedef struct OCI_Interval OCI_Interval; - -/** - * @typedef OCI_Object - * - * @brief - * Oracle Named types representation. - * - */ - -typedef struct OCI_Object OCI_Object; - -/** - * @typedef OCI_Coll - * - * @brief - * Oracle Collections (VARRAYs and Nested Tables) representation. - * - */ - -typedef struct OCI_Coll OCI_Coll; - -/** - * @typedef OCI_Elem - * - * @brief - * Oracle Collection item representation. - * - */ - -typedef struct OCI_Elem OCI_Elem; - -/** - * @typedef OCI_Iter - * - * @brief - * Oracle Collection iterator representation. - * - */ -typedef struct OCI_Iter OCI_Iter; - -/** - * @typedef OCI_TypeInfo - * - * @brief - * Type info metadata handle. - * - */ - -/** - * @typedef OCI_Ref - * - * @brief - * Oracle REF type representation. - * - */ - -typedef struct OCI_Ref OCI_Ref; - -/** - * @typedef OCI_TypeInfo - * - * @brief - * Type info meta data handle. - * - */ - -typedef struct OCI_TypeInfo OCI_TypeInfo; - -/** - * @typedef OCI_HashTable - * - * @brief - * OCILIB implementation of hash tables. - * - */ - -typedef struct OCI_HashTable OCI_HashTable; - -/** - * @typedef OCI_Error - * - * @brief - * Encapsulates an Oracle or OCILIB exception. - * - * The error object is used to raise internal or oracle errors. - * When an error occurs, if the application has provided an error handler, an - * error object is constructed and passed to the handler - * - */ - -typedef struct OCI_Error OCI_Error; - -/** - * @typedef OCI_Mutex - * - * @brief - * OCILIB encapsulation of OCI mutexes. - * - */ - -typedef struct OCI_Mutex OCI_Mutex; - -/** - * @typedef OCI_Thread - * - * @brief - * OCILIB encapsulation of OCI Threads. - * - */ - -typedef struct OCI_Thread OCI_Thread; - -/** - * @typedef OCI_DirPath - * - * @brief - * OCILIB encapsulation of OCI Direct Path handle. - * - */ - -typedef struct OCI_DirPath OCI_DirPath; - -/** - * @typedef OCI_Subscription - * - * @brief - * OCILIB encapsulation of Oracle DCN notification - * - */ - -typedef struct OCI_Subscription OCI_Subscription; - -/** - * @typedef OCI_Event - * - * @brief - * OCILIB encapsulation of Oracle DCN event - * - */ - -typedef struct OCI_Event OCI_Event; - -/** - * @typedef OCI_Msg - * - * @brief - * OCILIB encapsulation of A/Q message - * - */ - -typedef struct OCI_Msg OCI_Msg; - -/** - * @typedef OCI_Agent - * - * @brief - * OCILIB encapsulation of A/Q Agent - * - */ - -typedef struct OCI_Agent OCI_Agent; - -/** - * @typedef OCI_Dequeue - * - * @brief - * OCILIB encapsulation of A/Q dequeuing operations - * - */ - -typedef struct OCI_Dequeue OCI_Dequeue; - -/** - * @typedef OCI_Enqueue - * - * @brief - * OCILIB encapsulation of A/Q enqueuing operations - * - */ - -typedef struct OCI_Enqueue OCI_Enqueue; - -/** - * @var POCI_ERROR - * - * @brief - * Error procedure prototype - * - * @param err - Error handle - * - */ - -typedef void (*POCI_ERROR) -( - OCI_Error *err -); - -/** - * @var POCI_THREAD - * - * @brief - * Thread procedure prototype - * - * @param thread - Thread handle - * @param arg - Pointer passed to OCI_ThreadRun() - * - */ - -typedef void (*POCI_THREAD) -( - OCI_Thread *thread, - void *arg -); - -/** - * @var POCI_THREADKEYDEST - * - * @brief - * Thread key destructor prototype. - * - * @param data - Thread Key current pointer value - * - */ - -typedef void (*POCI_THREADKEYDEST) -( - void *data -); - -/** - * @var POCI_NOTIFY - * - * @brief - * Database Change Notification User callback prototype. - * - * @param event - Event handle - * - */ - -typedef void (*POCI_NOTIFY) -( - OCI_Event *event -); - -/** - * @var POCI_NOTIFY_AQ - * - * @brief - * AQ notification callback prototype. - * - * @param dequeue - dequeue handle - * - */ - -typedef void (*POCI_NOTIFY_AQ) -( - OCI_Dequeue *dequeue -); - -/** - * @var POCI_TAF_HANDLER - * - * @brief - * Failover Notification User callback prototype. - * - * @param con - Connection handle related to the event - * @param type - Event type - * @param event - Event code - * - * @note - * Possible values for parameter 'type' : - * - OCI_FOT_NONE - * - OCI_FOT_SESSION - * - OCI_FOT_SELECT - * - * @note - * Possible values for parameter 'event' : - * - OCI_FOE_END - * - OCI_FOE_ABORT - * - OCI_FOE_REAUTH - * - OCI_FOE_BEGIN - * - OCI_FOE_ERROR - * - * @return - * User callback should return one of the following value : - * - OCI_FOC_OK - * - OCI_FOC_RETRY - * - */ - -typedef unsigned int (*POCI_TAF_HANDLER) -( - OCI_Connection *con, - unsigned int type, - unsigned int event -); - -/** - * @var POCI_HA_HANDLER - * - * @brief - * HA (High Availability) events Notification User callback prototype. - * - * @param con - Connection handle related to the event - * @param source - source of the event - * @param event - type of the event - * @param time - Timestamp of the event - * - * @note - * Currently, Oracle only send HA down events - * - * @note - * Possible values for parameter 'source' : - * - OCI_HES_INSTANCE - * - OCI_HES_DATABASE - * - OCI_HES_NODE - * - OCI_HES_SERVICE - * - OCI_HES_SERVICE_MEMBER - * - OCI_HES_ASM_INSTANCE - * - OCI_HES_PRECONNECT - * - * @note - * Possible values for parameter 'event' : - * - OCI_HET_DOWN : HA event type down - * - OCI_HET_UP : HA event type up - * - */ - -typedef void (*POCI_HA_HANDLER) -( - OCI_Connection *con, - unsigned int source, - unsigned int event, - OCI_Timestamp *time -); - -/* public structures */ - -/** - * @typedef OCI_XID - * - * @brief - * Global transaction identifier - * - */ - -typedef struct OCI_XID { - long formatID; - long gtrid_length; - long bqual_length; - char data[128]; -} OCI_XID; - -/** - * @typedef OCI_Variant - * - * @brief - * Internal Variant type based on union C type. - * - * @note - * Helpful for generic buffer, it reduces the amount of casts - * - */ - -typedef union OCI_Variant { - /* integers */ - int num; - - /* raw data */ - unsigned char *p_bytes; - - /* pointer to c natives types */ - void *p_void; - int *p_int; - float *p_float; - double *p_double; - otext *p_text; - - /* ocilib object types */ - OCI_Date *p_date; - OCI_Interval *p_interval; - OCI_Timestamp *p_timestamp; - OCI_Long *p_long; - OCI_Lob *p_lob; - OCI_File *p_file; - OCI_Statement *p_stmt; - OCI_Column *p_col; - OCI_Object *p_obj; - OCI_Coll *p_coll; - OCI_Iter *p_iter; - OCI_Elem *p_elem; -} OCI_Variant; - -/** -* @typedef OCI_HashValue -* -* @brief -* Hash table entry value -* -* OCILIB implementation of hash tables uses chaining method for dealing with collisions -* -*/ - -typedef struct OCI_HashValue { - OCI_Variant value; - struct OCI_HashValue *next; -} OCI_HashValue; - -/** - * @typedef OCI_HashEntry - * - * @brief - * Hash table entry - * - */ - -typedef struct OCI_HashEntry { - otext *key; - struct OCI_HashValue *values; - struct OCI_HashEntry *next; -} OCI_HashEntry; - -/** - * @typedef big_int - * - * @brief - * big_int is a C scalar integer (32 or 64 bits) depending on compiler support for 64bits integers. - * big_uint is an unsigned big_int - * - */ - -/* check for long long support */ - -#if defined(_LONGLONG) || defined(LONG_LONG_MAX) || defined(LLONG_MAX) || defined(__LONG_LONG_MAX__) - -/* C99 long long supported */ - -typedef long long big_int; -typedef unsigned long long big_uint; - - #define OCI_BIG_UINT_ENABLED - -#elif defined(_WINDOWS) - -/* Microsoft extension supported */ - -typedef __int64 big_int; -typedef unsigned __int64 big_uint; - - #define OCI_BIG_UINT_ENABLED - -#else - -typedef int big_int; -typedef unsigned int big_uint; - -#endif - -/** - * @} - */ - -/* boolean values */ - -#ifndef TRUE - #define TRUE 1 - #define FALSE 0 -#endif - -#ifndef boolean - #define boolean int -#endif - -/* versions extract macros */ - -#define OCI_VER_MAJ(v) (unsigned int) ((v)/100) -#define OCI_VER_MIN(v) (unsigned int) (((v)/10) - (((v)/100)*10)) -#define OCI_VER_REV(v) (unsigned int) ((v) - (((v)/10)*10)) - -#define OCI_VER_MAKE(x, y, z) ((x)*100 + (y)*10 + (z)) - -/* oracle OCI key versions*/ - -#define OCI_8_0 OCI_VER_MAKE( 8, 0, 0) -#define OCI_8_1 OCI_VER_MAKE( 8, 1, 0) -#define OCI_9_0 OCI_VER_MAKE( 9, 0, 0) -#define OCI_9_2 OCI_VER_MAKE( 9, 2, 0) -#define OCI_10_1 OCI_VER_MAKE(10, 1, 0) -#define OCI_10_2 OCI_VER_MAKE(10, 2, 0) -#define OCI_11_1 OCI_VER_MAKE(11, 1, 0) -#define OCI_11_2 OCI_VER_MAKE(11, 2, 0) -#define OCI_12_1 OCI_VER_MAKE(12, 1, 0) -#define OCI_12_2 OCI_VER_MAKE(12, 2, 0) -#define OCI_18_1 OCI_VER_MAKE(18, 1, 0) -#define OCI_18_2 OCI_VER_MAKE(18, 2, 0) -#define OCI_18_3 OCI_VER_MAKE(18, 3, 0) -#define OCI_18_4 OCI_VER_MAKE(18, 4, 0) -#define OCI_18_5 OCI_VER_MAKE(18, 5, 0) -#define OCI_19_3 OCI_VER_MAKE(19, 3, 0) - -/* OCILIB Error types */ - -#define OCI_ERR_ORACLE 1 -#define OCI_ERR_OCILIB 2 -#define OCI_ERR_WARNING 3 - -/* OCILIB Error codes */ - -#define OCI_ERR_NONE 0 -#define OCI_ERR_NOT_INITIALIZED 1 -#define OCI_ERR_LOADING_SHARED_LIB 2 -#define OCI_ERR_LOADING_SYMBOLS 3 -#define OCI_ERR_MULTITHREADED 4 -#define OCI_ERR_MEMORY 5 -#define OCI_ERR_NOT_AVAILABLE 6 -#define OCI_ERR_NULL_POINTER 7 -#define OCI_ERR_DATATYPE_NOT_SUPPORTED 8 -#define OCI_ERR_PARSE_TOKEN 9 -#define OCI_ERR_MAP_ARGUMENT 10 -#define OCI_ERR_OUT_OF_BOUNDS 11 -#define OCI_ERR_UNFREED_DATA 12 -#define OCI_ERR_MAX_BIND 13 -#define OCI_ERR_ATTR_NOT_FOUND 14 -#define OCI_ERR_MIN_VALUE 15 -#define OCI_ERR_NOT_COMPATIBLE 16 -#define OCI_ERR_STMT_STATE 17 -#define OCI_ERR_STMT_NOT_SCROLLABLE 18 -#define OCI_ERR_BIND_ALREADY_USED 19 -#define OCI_ERR_BIND_ARRAY_SIZE 20 -#define OCI_ERR_COLUMN_NOT_FOUND 21 -#define OCI_ERR_DIRPATH_STATE 22 -#define OCI_ERR_CREATE_OCI_ENVIRONMENT 23 -#define OCI_ERR_REBIND_BAD_DATATYPE 24 -#define OCI_ERR_TYPEINFO_DATATYPE 25 -#define OCI_ERR_ITEM_NOT_FOUND 26 -#define OCI_ERR_ARG_INVALID_VALUE 27 -#define OCI_ERR_XA_ENV_FROM_STRING 28 -#define OCI_ERR_XA_CONN_FROM_STRING 29 -#define OCI_ERR_BIND_EXTERNAL_NOT_ALLOWED 30 - -#define OCI_ERR_COUNT 31 - - -/* allocated bytes types */ - -#define OCI_MEM_ORACLE 1 -#define OCI_MEM_OCILIB 2 -#define OCI_MEM_ALL (OCI_MEM_ORACLE | OCI_MEM_OCILIB) - -/* binding */ - -#define OCI_BIND_BY_POS 0 -#define OCI_BIND_BY_NAME 1 -#define OCI_BIND_SIZE 6 -#define OCI_BIND_MAX 65535 - -/* fetching */ - -#define OCI_FETCH_SIZE 20 -#define OCI_PREFETCH_SIZE 20 -#define OCI_LONG_EXPLICIT 1 -#define OCI_LONG_IMPLICIT 2 - -/* unknown value */ - -#define OCI_UNKNOWN 0 - -/* C Data Type mapping */ - -#define OCI_CDT_NUMERIC 1 -#define OCI_CDT_DATETIME 3 -#define OCI_CDT_TEXT 4 -#define OCI_CDT_LONG 5 -#define OCI_CDT_CURSOR 6 -#define OCI_CDT_LOB 7 -#define OCI_CDT_FILE 8 -#define OCI_CDT_TIMESTAMP 9 -#define OCI_CDT_INTERVAL 10 -#define OCI_CDT_RAW 11 -#define OCI_CDT_OBJECT 12 -#define OCI_CDT_COLLECTION 13 -#define OCI_CDT_REF 14 -#define OCI_CDT_BOOLEAN 15 - -/* Data Type codes for OCI_ImmediateXXX() calls */ - -#define OCI_ARG_SHORT 1 -#define OCI_ARG_USHORT 2 -#define OCI_ARG_INT 3 -#define OCI_ARG_UINT 4 -#define OCI_ARG_BIGINT 5 -#define OCI_ARG_BIGUINT 6 -#define OCI_ARG_DOUBLE 7 -#define OCI_ARG_DATETIME 8 -#define OCI_ARG_TEXT 9 -#define OCI_ARG_LOB 10 -#define OCI_ARG_FILE 11 -#define OCI_ARG_TIMESTAMP 12 -#define OCI_ARG_INTERVAL 13 -#define OCI_ARG_RAW 14 -#define OCI_ARG_OBJECT 15 -#define OCI_ARG_COLLECTION 16 -#define OCI_ARG_REF 17 -#define OCI_ARG_FLOAT 18 -#define OCI_ARG_NUMBER 19 - -/* statement types */ - -#define OCI_CST_SELECT 1 -#define OCI_CST_UPDATE 2 -#define OCI_CST_DELETE 3 -#define OCI_CST_INSERT 4 -#define OCI_CST_CREATE 5 -#define OCI_CST_DROP 6 -#define OCI_CST_ALTER 7 -#define OCI_CST_BEGIN 8 -#define OCI_CST_DECLARE 9 -#define OCI_CST_CALL 10 -#define OCI_CST_MERGE 16 - -/* environment modes */ - -#define OCI_ENV_DEFAULT 0 -#define OCI_ENV_THREADED 1 -#define OCI_ENV_CONTEXT 2 -#define OCI_ENV_EVENTS 4 - -/* sessions modes */ - -#define OCI_SESSION_DEFAULT 0x00000000 /* any version */ -#define OCI_SESSION_SYSDBA 0x00000002 /* any version */ -#define OCI_SESSION_SYSOPER 0x00000004 /* any version */ -#define OCI_SESSION_SYSASM 0x00008000 /* From 11gR1 */ -#define OCI_SESSION_SYSBKP 0x00020000 /* From 12cR1 */ -#define OCI_SESSION_SYSDGD 0x00040000 /* From 12cR1 */ -#define OCI_SESSION_SYSKMT 0x00080000 /* From 12cR1 */ -#define OCI_SESSION_SYSRAC 0x00100000 /* From 12cR2 */ - -#define OCI_SESSION_XA 0x00000001 -#define OCI_SESSION_PRELIM_AUTH 0x00000008 - -/* change notification types */ - -#define OCI_CNT_OBJECTS 1 -#define OCI_CNT_ROWS 2 -#define OCI_CNT_DATABASES 4 -#define OCI_CNT_ALL (OCI_CNT_OBJECTS | OCI_CNT_ROWS | OCI_CNT_DATABASES) - -/* event notification types */ - -#define OCI_ENT_STARTUP 1 -#define OCI_ENT_SHUTDOWN 2 -#define OCI_ENT_SHUTDOWN_ANY 3 -#define OCI_ENT_DROP_DATABASE 4 -#define OCI_ENT_DEREGISTER 5 -#define OCI_ENT_OBJECT_CHANGED 6 - -/* event object notification types */ - -#define OCI_ONT_INSERT 0x2 -#define OCI_ONT_UPDATE 0x4 -#define OCI_ONT_DELETE 0x8 -#define OCI_ONT_ALTER 0x10 -#define OCI_ONT_DROP 0x20 -#define OCI_ONT_GENERIC 0x40 - -/* database startup modes */ - -#define OCI_DB_SPM_START 1 -#define OCI_DB_SPM_MOUNT 2 -#define OCI_DB_SPM_OPEN 4 -#define OCI_DB_SPM_FULL (OCI_DB_SPM_START | OCI_DB_SPM_MOUNT | OCI_DB_SPM_OPEN) - -/* database startup flags */ - -#define OCI_DB_SPF_DEFAULT 0 -#define OCI_DB_SPF_FORCE 1 -#define OCI_DB_SPF_RESTRICT 2 - -/* database shutdown modes */ - -#define OCI_DB_SDM_SHUTDOWN 1 -#define OCI_DB_SDM_CLOSE 2 -#define OCI_DB_SDM_DISMOUNT 4 -#define OCI_DB_SDM_FULL (OCI_DB_SDM_SHUTDOWN | OCI_DB_SDM_CLOSE | OCI_DB_SDM_DISMOUNT) - -/* database shutdown flags */ - -#define OCI_DB_SDF_DEFAULT 0 -#define OCI_DB_SDF_TRANS 1 -#define OCI_DB_SDF_TRANS_LOCAL 2 -#define OCI_DB_SDF_IMMEDIATE 3 -#define OCI_DB_SDF_ABORT 4 - -/* charset form types */ - -#define OCI_CSF_NONE 0 -#define OCI_CSF_DEFAULT 1 -#define OCI_CSF_NATIONAL 2 - -/* statement fetch mode */ - -#define OCI_SFM_DEFAULT 0 -#define OCI_SFM_SCROLLABLE 0x08 - -/* statement fetch direction */ - -#define OCI_SFD_ABSOLUTE 0x20 -#define OCI_SFD_RELATIVE 0x40 - -/* bind allocation mode */ - -#define OCI_BAM_EXTERNAL 1 -#define OCI_BAM_INTERNAL 2 - -/* bind direction mode */ - -#define OCI_BDM_IN 1 -#define OCI_BDM_OUT 2 -#define OCI_BDM_IN_OUT (OCI_BDM_IN | OCI_BDM_OUT) - -/* Column property flags */ - -#define OCI_CPF_NONE 0 -#define OCI_CPF_IS_IDENTITY 1 -#define OCI_CPF_IS_GEN_ALWAYS 2 -#define OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL 4 -#define OCI_CPF_IS_LPART 8 -#define OCI_CPF_IS_CONID 16 - -/* Column collation IDs */ - -#define OCI_CCI_NONE 0x00000000 -#define OCI_CCI_NLS_COMP 0x00003FFE -#define OCI_CCI_NLS_SORT 0x00003FFD -#define OCI_CCI_NLS_SORT_CI 0x00003FFC -#define OCI_CCI_NLS_SORT_AI 0x00003FFB -#define OCI_CCI_NLS_SORT_CS 0x00003FFA -#define OCI_CCI_NLS_SORT_VAR1 0x00003FF9 -#define OCI_CCI_NLS_SORT_VAR1_CI 0x00003FF8 -#define OCI_CCI_NLS_SORT_VAR1_AI 0x00003FF7 -#define OCI_CCI_NLS_SORT_VAR1_CS 0x00003FF6 -#define OCI_CCI_BINARY 0x00003FFF -#define OCI_CCI_BINARY_CI 0x00023FFF -#define OCI_CCI_BINARY_AI 0x00013FFF - - -/* Integer sign flag */ - -#define OCI_NUM_UNSIGNED 2 - -/* External Integer types */ - -#define OCI_NUM_SHORT 4 -#define OCI_NUM_INT 8 -#define OCI_NUM_BIGINT 16 -#define OCI_NUM_FLOAT 32 -#define OCI_NUM_DOUBLE 64 -#define OCI_NUM_NUMBER 128 - -#define OCI_NUM_USHORT (OCI_NUM_SHORT | OCI_NUM_UNSIGNED) -#define OCI_NUM_UINT (OCI_NUM_INT | OCI_NUM_UNSIGNED) -#define OCI_NUM_BIGUINT (OCI_NUM_BIGINT | OCI_NUM_UNSIGNED) - -/* timestamp types */ - -#define OCI_TIMESTAMP 1 -#define OCI_TIMESTAMP_TZ 2 -#define OCI_TIMESTAMP_LTZ 3 - -/* interval types */ - -#define OCI_INTERVAL_YM 1 -#define OCI_INTERVAL_DS 2 - -/* long types */ - -#define OCI_BLONG 1 -#define OCI_CLONG 2 - -/* lob types */ - -#define OCI_BLOB 1 -#define OCI_CLOB 2 -#define OCI_NCLOB 3 - -/* lob opening mode */ - -#define OCI_LOB_READONLY 1 -#define OCI_LOB_READWRITE 2 - -/* file types */ - -#define OCI_BFILE 1 -#define OCI_CFILE 2 - -/* lob browsing mode */ - -#define OCI_SEEK_SET 1 -#define OCI_SEEK_END 2 -#define OCI_SEEK_CUR 3 - -/* type info types */ - -#define OCI_TIF_TABLE 1 -#define OCI_TIF_VIEW 2 -#define OCI_TIF_TYPE 3 - -/* object type */ - -#define OCI_OBJ_PERSISTENT 1 -#define OCI_OBJ_TRANSIENT 2 -#define OCI_OBJ_VALUE 3 - -/* collection types */ - -#define OCI_COLL_VARRAY 1 -#define OCI_COLL_NESTED_TABLE 2 -#define OCI_COLL_INDEXED_TABLE 3 - -/* pool types */ - -#define OCI_POOL_CONNECTION 1 -#define OCI_POOL_SESSION 2 - -/* AQ message state */ - -#define OCI_AMS_READY 1 -#define OCI_AMS_WAITING 2 -#define OCI_AMS_PROCESSED 3 -#define OCI_AMS_EXPIRED 4 - -/* AQ sequence deviation */ - -#define OCI_ASD_BEFORE 2 -#define OCI_ASD_TOP 3 - -/* AQ message visibility */ - -#define OCI_AMV_IMMEDIATE 1 -#define OCI_AMV_ON_COMMIT 2 - -/* AQ dequeue mode */ - -#define OCI_ADM_BROWSE 1 -#define OCI_ADM_LOCKED 2 -#define OCI_ADM_REMOVE 3 -#define OCI_ADM_REMOVE_NODATA 4 - -/* AQ dequeue navigation */ - -#define OCI_ADN_FIRST_MSG 1 -#define OCI_ADN_NEXT_TRANSACTION 2 -#define OCI_ADN_NEXT_MSG 3 - -/* AQ queue table purge mode */ - -#define OCI_APM_BUFFERED 1 -#define OCI_APM_PERSISTENT 2 -#define OCI_APM_ALL (OCI_APM_BUFFERED | OCI_APM_PERSISTENT) - -/* AQ queue table grouping mode */ - -#define OCI_AGM_NONE 0 -#define OCI_AGM_TRANSACTIONNAL 1 - -/* AQ queue table type */ - -#define OCI_AQT_NORMAL 0 -#define OCI_AQT_EXCEPTION 1 -#define OCI_AQT_NON_PERSISTENT 2 - -/* direct path processing return status */ - -#define OCI_DPR_COMPLETE 1 -#define OCI_DPR_ERROR 2 -#define OCI_DPR_FULL 3 -#define OCI_DPR_PARTIAL 4 -#define OCI_DPR_EMPTY 5 - -/* direct path conversion modes */ - -#define OCI_DCM_DEFAULT 1 -#define OCI_DCM_FORCE 2 - -/* trace size constants */ - -#define OCI_SIZE_TRACE_ID 64 -#define OCI_SIZE_TRACE_MODULE 48 -#define OCI_SIZE_TRACE_ACTION 32 -#define OCI_SIZE_TRACE_INFO 64 -#define OCI_SIZE_TRACE_OPERATION 32 - -/* trace types */ - -#define OCI_TRC_IDENTITY 1 -#define OCI_TRC_MODULE 2 -#define OCI_TRC_ACTION 3 -#define OCI_TRC_DETAIL 4 -#define OCI_TRC_OPERATION 5 - -/* Network timeout type */ - -#define OCI_NTO_SEND 1 -#define OCI_NTO_RECEIVE 2 -#define OCI_NTO_CALL 3 - -/* HA event type */ - -#define OCI_HET_DOWN 0 -#define OCI_HET_UP 1 - -/* HA event source */ -#define OCI_HES_INSTANCE 0 -#define OCI_HES_DATABASE 1 -#define OCI_HES_NODE 2 -#define OCI_HES_SERVICE 3 -#define OCI_HES_SERVICE_MEMBER 4 -#define OCI_HES_ASM_INSTANCE 5 -#define OCI_HES_PRECONNECT 6 - -/* Fail over types */ - -#define OCI_FOT_NONE 1 -#define OCI_FOT_SESSION 2 -#define OCI_FOT_SELECT 4 - -/* fail over notifications */ - -#define OCI_FOE_END 1 -#define OCI_FOE_ABORT 2 -#define OCI_FOE_REAUTH 4 -#define OCI_FOE_BEGIN 8 -#define OCI_FOE_ERROR 16 - -/* fail over callback return code */ - -#define OCI_FOC_OK 0 -#define OCI_FOC_RETRY 25410 - -/* hash tables support */ - -#define OCI_HASH_STRING 1 -#define OCI_HASH_INTEGER 2 -#define OCI_HASH_POINTER 3 - -/* transaction types */ - -#define OCI_TRS_NEW 0x00000001 -#define OCI_TRS_READONLY 0x00000100 -#define OCI_TRS_READWRITE 0x00000200 -#define OCI_TRS_SERIALIZABLE 0x00000400 -#define OCI_TRS_LOOSE 0x00010000 -#define OCI_TRS_TIGHT 0x00020000 - -/* format types */ - -#define OCI_FMT_DATE 1 -#define OCI_FMT_TIMESTAMP 2 -#define OCI_FMT_NUMERIC 3 -#define OCI_FMT_BINARY_DOUBLE 4 -#define OCI_FMT_BINARY_FLOAT 5 -#define OCI_FMT_TIMESTAMP_TZ 6 - -/* sql function codes */ - -#define OCI_SFC_CREATE_TABLE 1 -#define OCI_SFC_INSERT 2 -#define OCI_SFC_SELECT 3 -#define OCI_SFC_CREATE_CLUSTER 4 -#define OCI_SFC_ALTER_CLUSTER 5 -#define OCI_SFC_UPDATE 6 -#define OCI_SFC_DELETE 7 -#define OCI_SFC_DROP_CLUSTER 8 -#define OCI_SFC_CREATE_INDEX 9 -#define OCI_SFC_DROP_INDEX 10 -#define OCI_SFC_ALTER_INDEX 11 -#define OCI_SFC_DROP_TABLE 12 -#define OCI_SFC_CREATE_SEQUENCE 13 -#define OCI_SFC_ALTER_SEQUENCE 14 -#define OCI_SFC_ALTER_TABLE 15 -#define OCI_SFC_DROP_SEQUENCE 16 -#define OCI_SFC_GRANT_OBJECT 17 -#define OCI_SFC_REVOKE_OBJECT 18 -#define OCI_SFC_CREATE_SYNONYM 19 -#define OCI_SFC_DROP_SYNONYM 20 -#define OCI_SFC_CREATE_VIEW 21 -#define OCI_SFC_DROP_VIEW 22 -#define OCI_SFC_VALIDATE_INDEX 23 -#define OCI_SFC_CREATE_PROCEDURE 24 -#define OCI_SFC_ALTER_PROCEDURE 25 -#define OCI_SFC_LOCK 26 -#define OCI_SFC_NO_OP 27 -#define OCI_SFC_RENAME 28 -#define OCI_SFC_COMMENT 29 -#define OCI_SFC_AUDIT_OBJECT 30 -#define OCI_SFC_NOAUDIT_OBJECT 31 -#define OCI_SFC_CREATE_DATABASE_LINK 32 -#define OCI_SFC_DROP_DATABASE_LINK 33 -#define OCI_SFC_CREATE_DATABASE 34 -#define OCI_SFC_ALTER_DATABASE 35 -#define OCI_SFC_CREATE_ROLLBACK_SEG 36 -#define OCI_SFC_ALTER_ROLLBACK_SEG 37 -#define OCI_SFC_DROP_ROLLBACK_SEG 38 -#define OCI_SFC_CREATE_TABLESPACE 39 -#define OCI_SFC_ALTER_TABLESPACE 40 -#define OCI_SFC_DROP_TABLESPACE 41 -#define OCI_SFC_ALTER_SESSION 42 -#define OCI_SFC_ALTER_USER 43 -#define OCI_SFC_COMMIT 44 -#define OCI_SFC_ROLLBACK 45 -#define OCI_SFC_SAVEPOINT 46 -#define OCI_SFC_PL_SQL_EXECUTE 47 -#define OCI_SFC_SET_TRANSACTION 48 -#define OCI_SFC_ALTER_SYSTEM 49 -#define OCI_SFC_EXPLAIN 50 -#define OCI_SFC_CREATE_USER 51 -#define OCI_SFC_CREATE_ROLE 52 -#define OCI_SFC_DROP_USER 53 -#define OCI_SFC_DROP_ROLE 54 -#define OCI_SFC_SET_ROLE 55 -#define OCI_SFC_CREATE_SCHEMA 56 -#define OCI_SFC_CREATE_CONTROL_FILE 57 -#define OCI_SFC_ALTER_TRACING 58 -#define OCI_SFC_CREATE_TRIGGER 59 -#define OCI_SFC_ALTER_TRIGGER 60 -#define OCI_SFC_DROP_TRIGGER 61 -#define OCI_SFC_ANALYZE_TABLE 62 -#define OCI_SFC_ANALYZE_INDEX 63 -#define OCI_SFC_ANALYZE_CLUSTER 64 -#define OCI_SFC_CREATE_PROFILE 65 -#define OCI_SFC_DROP_PROFILE 66 -#define OCI_SFC_ALTER_PROFILE 67 -#define OCI_SFC_DROP_PROCEDURE 68 -#define OCI_SFC_ALTER_RESOURCE_COST 70 -#define OCI_SFC_CREATE_MATERIALIZED_VIEW_LOG 71 -#define OCI_SFC_ALTER_MATERIALIZED_VIEW_LOG 72 -#define OCI_SFC_DROP_MATERIALIZED_VIEW_LOG 73 -#define OCI_SFC_CREATE_MATERIALIZED_VIEW 74 -#define OCI_SFC_ALTER_MATERIALIZED_VIEW 75 -#define OCI_SFC_DROP_MATERIALIZED_VIEW 76 -#define OCI_SFC_CREATE_TYPE 77 -#define OCI_SFC_DROP_TYPE 78 -#define OCI_SFC_ALTER_ROLE 79 -#define OCI_SFC_ALTER_TYPE 80 -#define OCI_SFC_CREATE_TYPE_BODY 81 -#define OCI_SFC_ALTER_TYPE_BODY 82 -#define OCI_SFC_DROP_TYPE_BODY 83 -#define OCI_SFC_DROP_LIBRARY 84 -#define OCI_SFC_TRUNCATE_TABLE 85 -#define OCI_SFC_TRUNCATE_CLUSTER 86 -#define OCI_SFC_ALTER_VIEW 88 -#define OCI_SFC_SET_CONSTRAINTS 90 -#define OCI_SFC_CREATE_FUNCTION 91 -#define OCI_SFC_ALTER_FUNCTION 92 -#define OCI_SFC_DROP_FUNCTION 93 -#define OCI_SFC_CREATE_PACKAGE 94 -#define OCI_SFC_ALTER_PACKAGE 95 -#define OCI_SFC_DROP_PACKAGE 96 -#define OCI_SFC_CREATE_PACKAGE_BODY 97 -#define OCI_SFC_ALTER_PACKAGE_BODY 98 -#define OCI_SFC_DROP_PACKAGE_BODY 99 -#define OCI_SFC_LOGON 100 -#define OCI_SFC_LOGOFF 101 -#define OCI_SFC_LOGOFF_BY_CLEANUP 102 -#define OCI_SFC_SESSION_REC 103 -#define OCI_SFC_SYSTEM_AUDIT 104 -#define OCI_SFC_SYSTEM_NOAUDIT 105 -#define OCI_SFC_AUDIT_DEFAULT 106 -#define OCI_SFC_NOAUDIT_DEFAULT 107 -#define OCI_SFC_SYSTEM_GRANT 108 -#define OCI_SFC_SYSTEM_REVOKE 109 -#define OCI_SFC_CREATE_PUBLIC_SYNONYM 110 -#define OCI_SFC_DROP_PUBLIC_SYNONYM 111 -#define OCI_SFC_CREATE_PUBLIC_DATABASE_LINK 112 -#define OCI_SFC_DROP_PUBLIC_DATABASE_LINK 113 -#define OCI_SFC_GRANT_ROLE 114 -#define OCI_SFC_REVOKE_ROLE 115 -#define OCI_SFC_EXECUTE_PROCEDURE 116 -#define OCI_SFC_USER_COMMENT 117 -#define OCI_SFC_ENABLE_TRIGGER 118 -#define OCI_SFC_DISABLE_TRIGGER 119 -#define OCI_SFC_ENABLE_ALL_TRIGGERS 120 -#define OCI_SFC_DISABLE_ALL_TRIGGERS 121 -#define OCI_SFC_NETWORK_ERROR 122 -#define OCI_SFC_EXECUTE_TYPE 123 -#define OCI_SFC_READ_DIRECTORY 125 -#define OCI_SFC_WRITE_DIRECTORY 126 -#define OCI_SFC_FLASHBACK 128 -#define OCI_SFC_BECOME_USER 129 -#define OCI_SFC_ALTER_MINING_MODEL 130 -#define OCI_SFC_SELECT_MINING_MODEL 131 -#define OCI_SFC_CREATE_MINING_MODEL 133 -#define OCI_SFC_ALTER_PUBLIC_SYNONYM 134 -#define OCI_SFC_EXECUTE_DIRECTORY 135 -#define OCI_SFC_SQL_LOADER_DIRECT_PATH_LOAD 136 -#define OCI_SFC_DATAPUMP_DIRECT_PATH_UNLOAD 137 -#define OCI_SFC_DATABASE_STARTUP 138 -#define OCI_SFC_DATABASE_SHUTDOWN 139 -#define OCI_SFC_CREATE_SQL_TXLN_PROFILE 140 -#define OCI_SFC_ALTER_SQL_TXLN_PROFILE 141 -#define OCI_SFC_USE_SQL_TXLN_PROFILE 142 -#define OCI_SFC_DROP_SQL_TXLN_PROFILE 143 -#define OCI_SFC_CREATE_MEASURE_FOLDER 144 -#define OCI_SFC_ALTER_MEASURE_FOLDER 145 -#define OCI_SFC_DROP_MEASURE_FOLDER 146 -#define OCI_SFC_CREATE_CUBE_BUILD_PROCESS 147 -#define OCI_SFC_ALTER_CUBE_BUILD_PROCESS 148 -#define OCI_SFC_DROP_CUBE_BUILD_PROCESS 149 -#define OCI_SFC_CREATE_CUBE 150 -#define OCI_SFC_ALTER_CUBE 151 -#define OCI_SFC_DROP_CUBE 152 -#define OCI_SFC_CREATE_CUBE_DIMENSION 153 -#define OCI_SFC_ALTER_CUBE_DIMENSION 154 -#define OCI_SFC_DROP_CUBE_DIMENSION 155 -#define OCI_SFC_CREATE_DIRECTORY 157 -#define OCI_SFC_DROP_DIRECTORY 158 -#define OCI_SFC_CREATE_LIBRARY 159 -#define OCI_SFC_CREATE_JAVA 160 -#define OCI_SFC_ALTER_JAVA 161 -#define OCI_SFC_DROP_JAVA 162 -#define OCI_SFC_CREATE_OPERATOR 163 -#define OCI_SFC_CREATE_INDEXTYPE 164 -#define OCI_SFC_DROP_INDEXTYPE 165 -#define OCI_SFC_ALTER_INDEXTYPE 166 -#define OCI_SFC_DROP_OPERATOR 167 -#define OCI_SFC_ASSOCIATE_STATISTICS 168 -#define OCI_SFC_DISASSOCIATE_STATISTICS 169 -#define OCI_SFC_CALL_METHOD 170 -#define OCI_SFC_CREATE_SUMMARY 171 -#define OCI_SFC_ALTER_SUMMARY 172 -#define OCI_SFC_DROP_SUMMARY 173 -#define OCI_SFC_CREATE_DIMENSION 174 -#define OCI_SFC_ALTER_DIMENSION 175 -#define OCI_SFC_DROP_DIMENSION 176 -#define OCI_SFC_CREATE_CONTEXT 177 -#define OCI_SFC_DROP_CONTEXT 178 -#define OCI_SFC_ALTER_OUTLINE 179 -#define OCI_SFC_CREATE_OUTLINE 180 -#define OCI_SFC_DROP_OUTLINE 181 -#define OCI_SFC_UPDATE_INDEXES 182 -#define OCI_SFC_ALTER_OPERATOR 183 -#define OCI_SFC_CREATE_SPFILE 187 -#define OCI_SFC_CREATE_PFILE 188 -#define OCI_SFC_MERGE 189 -#define OCI_SFC_PASSWORD_CHANGE 190 -#define OCI_SFC_ALTER_SYNONYM 192 -#define OCI_SFC_ALTER_DISKGROUP 193 -#define OCI_SFC_CREATE_DISKGROUP 194 -#define OCI_SFC_DROP_DISKGROUP 195 -#define OCI_SFC_PURGE_RECYCLEBIN 197 -#define OCI_SFC_PURGE_DBA_RECYCLEBIN 198 -#define OCI_SFC_PURGE_TABLESPACE 199 -#define OCI_SFC_PURGE_TABLE 200 -#define OCI_SFC_PURGE_INDEX 201 -#define OCI_SFC_UNDROP_OBJECT 202 -#define OCI_SFC_DROP_DATABASE 203 -#define OCI_SFC_FLASHBACK_DATABASE 204 -#define OCI_SFC_FLASHBACK_TABLE 205 -#define OCI_SFC_CREATE_RESTORE_POINT 206 -#define OCI_SFC_DROP_RESTORE_POINT 207 -#define OCI_SFC_PROXY_AUTHENTICATION_ONLY 208 -#define OCI_SFC_DECLARE_REWRITE_EQUIVALENCE 209 -#define OCI_SFC_ALTER_REWRITE_EQUIVALENCE 210 -#define OCI_SFC_DROP_REWRITE_EQUIVALENCE 211 -#define OCI_SFC_CREATE_EDITION 212 -#define OCI_SFC_ALTER_EDITION 213 -#define OCI_SFC_DROP_EDITION 214 -#define OCI_SFC_DROP_ASSEMBLY 215 -#define OCI_SFC_CREATE_ASSEMBLY 216 -#define OCI_SFC_ALTER_ASSEMBLY 217 -#define OCI_SFC_CREATE_FLASHBACK_ARCHIVE 218 -#define OCI_SFC_ALTER_FLASHBACK_ARCHIVE 219 -#define OCI_SFC_DROP_FLASHBACK_ARCHIVE 220 -#define OCI_SFC_DEBUG_CONNECT 221 -#define OCI_SFC_DEBUG_PROCEDURE 223 -#define OCI_SFC_ALTER_DATABASE_LINK 225 -#define OCI_SFC_CREATE_PLUGGABLE_DATABASE 226 -#define OCI_SFC_ALTER_PLUGGABLE_DATABASE 227 -#define OCI_SFC_DROP_PLUGGABLE_DATABASE 228 -#define OCI_SFC_CREATE_AUDIT_POLICY 229 -#define OCI_SFC_ALTER_AUDIT_POLICY 230 -#define OCI_SFC_DROP_AUDIT_POLICY 231 -#define OCI_SFC_CODE_BASED_GRANT 232 -#define OCI_SFC_CODE_BASED_REVOKE 233 -#define OCI_SFC_CREATE_LOCKDOWN_PROFILE 234 -#define OCI_SFC_DROP_LOCKDOWN_PROFILE 235 -#define OCI_SFC_ALTER_LOCKDOWN_PROFILE 236 -#define OCI_SFC_TRANSLATE_SQL 237 -#define OCI_SFC_ADMINISTER_KEY_MANAGEMENT 238 -#define OCI_SFC_CREATE_MATERIALIZED_ZONEMAP 239 -#define OCI_SFC_ALTER_MATERIALIZED_ZONEMAP 240 -#define OCI_SFC_DROP_MATERIALIZED_ZONEMAP 241 -#define OCI_SFC_DROP_MINING_MODEL 242 -#define OCI_SFC_CREATE_ATTRIBUTE_DIMENSION 243 -#define OCI_SFC_ALTER_ATTRIBUTE_DIMENSION 244 -#define OCI_SFC_DROP_ATTRIBUTE_DIMENSION 245 -#define OCI_SFC_CREATE_HIERARCHY 246 -#define OCI_SFC_ALTER_HIERARCHY 247 -#define OCI_SFC_DROP_HIERARCHY 248 -#define OCI_SFC_CREATE_ANALYTIC_VIEW 249 -#define OCI_SFC_ALTER_ANALYTIC_VIEW 250 -#define OCI_SFC_DROP_ANALYTIC_VIEW 251 -#define OCI_SFC_ALTER_PUBLIC_DATABASE_LINK 305 - - - -/* size constants */ - -#define OCI_SIZE_FORMAT 64 -#define OCI_SIZE_BUFFER 512 -#define OCI_SIZE_LARGE_BUFFER ((64*1024)-1) -#define OCI_SIZE_LONG ((64*1024)-1) -#define OCI_SIZE_DATE 45 -#define OCI_SIZE_TIMESTAMP 54 -#define OCI_SIZE_FORMAT_TODATE 14 -#define OCI_SIZE_NULL 4 -#define OCI_SIZE_PRECISION 10 -#define OCI_SIZE_ROWID 23 -#define OCI_SIZE_DIRECTORY 30 -#define OCI_SIZE_FILENAME 255 -#define OCI_SIZE_FORMAT_NUMS 40 -#define OCI_SIZE_FORMAT_NUML 65 -#define OCI_SIZE_OBJ_NAME 128 - -#define OCI_HASH_DEFAULT_SIZE 256 - -/* string constants */ - -#define OCILIB_DRIVER_NAME OTEXT("OCILIB") -#define OCI_STRING_NULL OTEXT("NULL") -#define OCI_STRING_EMPTY OTEXT("") -#define OCI_STRING_FORMAT_DATE OTEXT("YYYY-MM-DD") -#define OCI_STRING_FORMAT_TIME OTEXT("HH24:MI:SS") -#define OCI_STRING_FORMAT_DATETIME OTEXT("YYYY-MM-DD HH24:MI:SS") -#define OCI_STRING_FORMAT_TIMESTAMP OTEXT("YYYY-MM-DD HH24:MI:SS.FF") -#define OCI_STRING_FORMAT_TIMESTAMP_TZ OTEXT("YYYY-MM-DD HH24:MI:SS.FF TZR") -#define OCI_STRING_DEFAULT_PREC 3 -#define OCI_STRING_FORMAT_NUM \ - OTEXT("FM99999999999999999999999999999999999990.999999999999999999999999") -#define OCI_STRING_FORMAT_NUM_BDOUBLE OTEXT("%lf") -#define OCI_STRING_FORMAT_NUM_BFLOAT OTEXT("%f") -#define OCI_STRING_FORMAT_NUM_SHORT OTEXT("%hd") -#define OCI_STRING_FORMAT_NUM_INT OTEXT("%d") -#define OCI_STRING_TRUE OTEXT("TRUE") -#define OCI_STRING_FALSE OTEXT("FALSE") -#define OCI_STRING_TRUE_SIZE 4 -#define OCI_STRING_FALSE_SIZE 5 -#define OCI_STRING_NULL_SIZE 4 - -#ifdef _WINDOWS - #define OCI_CHAR_SLASH '\\' -#else - #define OCI_CHAR_SLASH '/' -#endif - -/** - * @defgroup OcilibCApiInitialization Initializing the library - * @{ - * - * To use OCILIB, it first needs to be initialized through a call to OCI_Initialize(). - * - * Then, the application connects to server, executes queries... - * - * Finally, OCILIB resources must be released by OCI_Cleanup() - * - * @note - * - * The following objects are automatically freed by the library: - * - Connections - * - pools - * - Statements - * - Type info objects - * - Thread keys - * - * @warning - * - * All other standalone object instances (mutexes, threads, dates, lobs, ...) ARE NOT freed. - * - */ - -/** - * @brief - * Initialize the library - * - * @param err_handler - Pointer to error handler procedure (optional) - * @param lib_path - Oracle shared library path (optional) - * @param mode - Environment mode - * - * Possible values for parameter mode: - * - OCI_ENV_DEFAULT : default mode - * - OCI_ENV_THREADED : multi-threading support - * - OCI_ENV_CONTEXT : thread contextual error handling - * - OCI_ENV_EVENTS : enables events for subscription, HA Events, AQ notifications - * - * @note - * This function must be called before any OCILIB library function. - * - * @warning - * - The parameter 'libpath' is only used if OCILIB has been built with the option OCI_IMPORT_RUNTIME - * - If the parameter 'lib_path' is NULL, the Oracle library is loaded from system environment variables - * - * @warning - * OCI_Initialize() should be called ONCE per application - * - * @return - * TRUE on success otherwise FALSE. - * Possible reasons for failures: - * - when OCI_ErrorGetType() return OCI_ERR_ORACLE, OCI_ErrorGetOCICode() returns: - * - any ORA-XXXXXX error code. Refer to Oracle documentation - * - when OCI_ErrorGetType() return OCI_ERR_OCILIB, possible error code returned by OCI_ErrorGetInternalCode() - * - OCI_ERR_LOADING_SHARED_LIB : OCILIB could not load oracle shared libraries at runtime (32/64bits mismatch, wrong \p lib_path, missing MSVC runtime required by oci.dll (MS Windows) - * - OCI_ERR_LOADING_SYMBOLS : the loaded shared library does not contain OCI symbols - * - OCI_ERR_NOT_AVAILABLE : OCILIb was built with OCI_CHARSET_WIDE and the oracle shared library dos not supports UTF16 (Oracle 8i) - * - OCI_ERR_CREATE_OCI_ENVIRONMENT: Oracle OCI environment initialization failed (in such cases, it is impossible to get the reason) - * - */ - -OCI_EXPORT boolean OCI_API OCI_Initialize -( - POCI_ERROR err_handler, - const otext *lib_path, - unsigned int mode -); - -/** - * @brief - * Clean up all resources allocated by the library - * - * @note - * * This function must be the last OCILIB library function call. - * - It deallocates objects not explicitly freed by the program (connections, statements, ...) - * - It unloads the Oracle shared library if it has been dynamically loaded - * - * @warning - * OCI_Cleanup() should be called ONCE per application - * - * @return TRUE - */ - -OCI_EXPORT boolean OCI_API OCI_Cleanup -( - void -); - -/** - * @brief - * Return the version of OCI used for compilation - * - * @note - * - with linkage build option, the version is determined from the oci.h header through different ways - * - with runtime loading build option, the version is set to the highest version - * of OCI needed by OCILIB, not necessarily the real OCI version - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetOCICompileVersion -( - void -); - -/** - * @brief - * Return the version of OCI used at runtime - * - * @note - * - with linkage build option, the version is determined from the oci.h header - * through different ways - * - with runtime loading build option, the version determined from the symbols - * dynamically loaded. - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetOCIRuntimeVersion -( - void -); - -/** - * @brief - * Return the Oracle shared library import mode - * - * @note - * Possible values are: - * - OCI_IMPORT_MODE_LINKAGE - * - OCI_IMPORT_MODE_RUNTIME - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetImportMode -( - void -); - -/** - * @brief - * Return the OCILIB charset type - * - * @note - * Possible values are: - * - OCI_CHAR_ANSI - * - OCI_CHAR_WIDE - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetCharset -( - void -); - -/** -* @brief -* Return the current number of bytes allocated internally in the library -* -* @param mem_type : type of memory to request -* -* @note -* Possible values are: -* - OCI_MEM_ORACLE : bytes allocated by Oracle client library -* - OCI_MEM_OCILIB : bytes allocated by OCILIB library -* - OCI_MEM_ORACLE : bytes allocated by all libraries -* -*/ - -OCI_EXPORT big_uint OCI_API OCI_GetAllocatedBytes -( - unsigned int mem_type -); - -/** - * @brief - * Enable or disable Oracle warning notifications - * - * @param value - enable/disable warnings - * - * @note - * Default value is FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_EnableWarnings -( - boolean value -); - -/** - * @brief - * Set the global error user handler - * - * @param handler - Pointer to error handler procedure - * - * @note - * Use this call to change or remove the user callback error handler installed by OCI_Initialize() - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetErrorHandler -( - POCI_ERROR handler -); - -/** - * @brief - * Set the High availability (HA) user handler - * - * @param handler - Pointer to HA handler procedure - * - * @note - * See POCI_HA_HANDLER documentation for more details - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * HA events - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns FALSE without throwing any exception. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetHAHandler -( - POCI_HA_HANDLER handler -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiErrorHandling Error handling - * @{ - * - * OCILIB provides two mechanisms for error handling: - * - * - Global error handling through callbacks. - * - Contextual thread error handling - * - * Exceptions are raised: - * - * - On Oracle OCI API call error - * - On Oracle SQL statement error - * - On Internal OCILIB error (type checking, memory allocations ...) - * - On Oracle warnings (OCI API or SQL) - * - * If an error handler was provided to OCI_Initialize(), when an error occurs, the - * library generates an OCI_Error handle and pass it to the error handler. - * - * In order to use the thread contextual error handling, you must call - * OCI_Initialize() with the flag OCI_ENV_CONTEXT for the mode parameter. When - * activated, error handles are stored per thread and the last error within a - * thread can be retrieved with OCI_GetLastError() - * - * Exception properties are accessible through a set of functions - * - * @note - * The two ways to handle errors are not exclusive and can be mixed. - * - * @note - * Thread contextual error is also available for single thread based applications - * - * @par Oracle Warnings - * - * Oracle warnings are raised through OCI_Error API. - * Such error handles have their error type property (OCI_ErrorGetType()) set to OCI_ERR_WARNING. - * Warning handing is disabled by default. To activate/deactivate it, use OCI_EnableWarnings() - * - * @par Example with callbacks - * @include err.c - * - * @par Example with thread context - * @include err_ctx.c - * - * @par Example of warning handling - * @include err_warning.c - * - */ - -/** - * @brief - * Retrieve the last error or warning occurred within the last OCILIB call - * - * @note - * OCI_GetLastError() is based on thread context and thus OCILIB must be - * initialized with the flag OCI_ENV_CONTEXT - * - * @warning - * OCILIB functions that returns a boolean value to indicate their success : - * - return TRUE if no error occurred OR if a warning occurred - * - return FALSE if an error occurred - * - */ - -OCI_EXPORT OCI_Error * OCI_API OCI_GetLastError -( - void -); - -/** - * @brief - * Retrieve error message from error handle - * - * @param err - Error handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_ErrorGetString -( - OCI_Error *err -); - -/** - * @brief - * Retrieve the type of error from error handle - * - * @param err - Error handle - * - * @note - * Returns one of the following values: - * - * - OCI_ERR_ORACLE - * - OCI_ERR_OCILIB - * - OCI_ERR_WARNING - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ErrorGetType -( - OCI_Error *err -); - -/** - * @brief - * Retrieve Oracle Error code from error handle - * - * @param err - Error handle - * - */ - -OCI_EXPORT int OCI_API OCI_ErrorGetOCICode -( - OCI_Error *err -); - -/** - * @brief - * Retrieve Internal Error code from error handle - * - * @param err - Error handle - * - */ - -OCI_EXPORT int OCI_API OCI_ErrorGetInternalCode -( - OCI_Error *err -); - -/** - * @brief - * Retrieve connection handle within the error occurred - * - * @param err - Error handle - * - */ - -OCI_EXPORT OCI_Connection * OCI_API OCI_ErrorGetConnection -( - OCI_Error *err -); - -/** - * @brief - * Retrieve statement handle within the error occurred - * - * @param err - Error handle - * - * @note - * If the error occurred outside of a statement context, it returns NULL - * - */ - -OCI_EXPORT OCI_Statement * OCI_API OCI_ErrorGetStatement -( - OCI_Error *err -); - -/** - * @brief - * Return the row index which caused an error during statement execution - * - * @param err - Error handle - * - * @warning - * Row index start at 1. - * - * @return - * 0 is the error is not related to array DML otherwise the index of the given - * row which caused the error - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ErrorGetRow -( - OCI_Error *err -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiConnections Connecting to Database - * @{ - * - * Connecting to a database server is done with one call to OCI_ConnectionCreate(). - * - * OCI_ConnectionFree() closes the established connection. - * - * Connection properties are accessible through a set of functions - * - * @par Example - * @include conn.c - * - */ - -/** - * @brief - * Create a physical connection to an Oracle database server - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param mode - Session mode - * - * Possible values for parameter mode : - * - OCI_SESSION_DEFAULT - * - OCI_SESSION_SYSDBA - * - OCI_SESSION_SYSOPER - * - OCI_SESSION_XA - * - * @note - * External credentials are supported by supplying a null value for the - * 'user' and 'pwd' parameters. - * If the param 'db' is NULL then a connection to the default local DB is done - * - * @note - * For parameter 'mode', the possible values are exclusive and cannot be combined - * - * @par Oracle XA support - * - * OCILIB supports Oracle XA connectivity. In order to get a connection using - * the XA interface : - * - For parameter 'db' : pass the value of the 'DB' parameter of the given - * XA connection string passed to the Transaction Processing Monitor (TPM) - * - Pass NULL to the 'user' and 'pwd' parameters - * - Pass the value OCI_SESSION_XA to parameter 'mode' - * - * @par Oracle XA Connection String - * - * The XA connection string used in a transaction monitor to connect to Oracle must - * be compatible with OCILIB : - * - * - the XA parameter 'Objects' MUST be set to 'true' - * - If OCI_ENV_THREADED is passed to OCI_Initialize(), the XA parameter 'Threads' must - * be set to 'true', otherwise to 'false' - * - If OCI_ENV_EVENTS is passed to OCI_Initialize(), the XA parameter 'Events' must - * be set to 'true', otherwise to 'false' - * - As Oracle does not support Unicode UTF16 character set through the XA interface, - * Only OCI_CHARSET_ANSI builds of OCILIB can be used - * - You still can use UTF8 if the NLS_LANG environment variable is set with a valid - * UTF8 NLS value - * - DO NOT USE OCI_CHARSET_WIDE OCILIB builds with XA connections - * - * @note - * On success, a local transaction is automatically created and started ONLY for regular - * standalone connections and connections retrieved from connection pools. - * No transaction is created for a XA connection or q connection retrieved from session pools. - * - * @return - * Connection handle on success or NULL on failure - * - */ - -OCI_EXPORT OCI_Connection * OCI_API OCI_ConnectionCreate -( - const otext *db, - const otext *user, - const otext *pwd, - unsigned int mode -); - -/** - * @brief - * Close a physical connection to an Oracle database server - * - * @param con - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ConnectionFree -( - OCI_Connection *con -); - -/** - * @brief - * Returns TRUE is the given connection is still connected otherwise FALSE - * - * @param con - Connection handle - * - */ - -OCI_EXPORT boolean OCI_API OCI_IsConnected -( - OCI_Connection *con -); - -/** - * @brief - * Return the pointer to user data previously associated with the connection - * - * @param con - Connection handle - * - * @note - * Value NULL for parameter \p con is a valid value. - * It returns then previously stored data with global scope (program wide) - * - */ - -OCI_EXPORT void * OCI_API OCI_GetUserData -( - OCI_Connection *con -); - -/** - * @brief - * Associate a pointer to user data to the given connection - * - * @param con - Connection handle - * @param data - User data pointer - * - * @note - * Value NULL for parameter \p con is a valid value. - * It allows users to associate a pointer to user data with global scope (program wide) - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetUserData -( - OCI_Connection *con, - void *data -); - -/** - * @brief - * Associate a tag to the given connection/session - * - * @param con - Connection handle - * @param tag - user tag string - * - * @note - * Use this call only for connections retrieved from a session pool - * See OCI_PoolGetConnection() for more details - * - * @note - * To untag a session, call OCI_SetSessionTag() with 'tag' parameter set to NULL - * - * @warning - * No error is raised if the connection is a standalone connection or retrieved from a connection - * pool - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetSessionTag -( - OCI_Connection *con, - const otext *tag -); - -/** - * @brief - * Return the tag associated the given connection - * - * @param con - Connection handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetSessionTag -( - OCI_Connection *con -); - -/** - * @brief - * Return the name of the connected database/service name - * - * @param con - Connection handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetDatabase -( - OCI_Connection *con -); - -/** - * @brief - * Return the current logged user name - * - * @param con - Connection handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetUserName -( - OCI_Connection *con -); - -/** - * @brief - * Return the current logged user password - * - * @param con - Connection handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetPassword -( - OCI_Connection *con -); - -/** - * @brief - * Change the password of the logged user - * - * @param con - Connection handle - * @param password - New password - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetPassword -( - OCI_Connection *con, - const otext *password -); - -/** - * @brief - * Change the password of the given user on the given database - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param new_pwd - Oracle User New password - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetUserPassword -( - const otext *db, - const otext *user, - const otext *pwd, - const otext *new_pwd -); - -/** - * @brief - * Return the current session mode - * - * @param con - Connection handle - * - * @note - * See OCI_ConnectionCreate() for possible values - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetSessionMode -( - OCI_Connection *con -); - -/** - * @brief - * Return the connected database server version - * - * @param con - Connection handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetVersionServer -( - OCI_Connection *con -); - -/** - * @brief - * Return the major version number of the connected database server - * - * @param con - Connection handle - * - * @return - * Version number or 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetServerMajorVersion -( - OCI_Connection *con -); - -/** - * @brief - * Return the minor version number of the connected database server - * - * @param con - Connection handle - * - * @return - * Version number or 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetServerMinorVersion -( - OCI_Connection *con -); - -/** - * @brief - * Return the revision version number of the connected database server - * - * @param con - Connection handle - * - * @return - * Version number or 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetServerRevisionVersion -( - OCI_Connection *con -); - -/** - * @brief - * Set the format string for implicit string conversions of the given type - * - * @param con - Connection handle (optional) - * @param type - Type of format - * @param format - Format string - * - * Formats can set at 2 levels: - * - Library level: by passing a NULL Connection handle - * - Connection level: by passing a valid Connection handle - * - * When the library needs to perform a string conversion, it search for a valid format using the - * following order: - * - Connection format - * - Library format - * - Default format - * - * @note - * Possible values of parameter 'type' : - * - * - OCI_FMT_DATE : format used to convert DATE to string - * - OCI_FMT_TIMESTAMP : format used to convert TIMESTAMP and TIMESTAMP WITH LOCAL TIMEZONE to string - * - OCI_FMT_TIMESTAMP_TZ : format used to convert TIMESTAMP WITH TIME ZONE to string - * - OCI_FMT_NUMERIC : format used to convert numeric types to string - * - OCI_FMT_BINARY_DOUBLE : format used to convert BINARY_DOUBLE to string - * - OCI_FMT_BINARY FLOAT : format used to convert BINARY_FLOAT to string - * - * @note - * Default format values are : - * - OCI_FMT_DATE : constant OCI_STRING_FORMAT_DATE - * - OCI_FMT_TIMESTAMP : constant OCI_STRING_FORMAT_TIMESTAMP - * - OCI_FMT_TIMESTAMP_TZ : constant OCI_STRING_FORMAT_TIMESTAMP_TZ - * - OCI_FMT_NUMERIC : constant OCI_STRING_FORMAT_NUMERIC - * - OCI_FMT_BINARY_DOUBLE : constant OCI_STRING_FORMAT_BINARY_DOUBLE - * - OCI_FMT_BINARY FLOAT : constant OCI_STRING_FORMAT_BINARY_FLOAT - * - * @note - * Conversions are performed by Oracle built-in functions whenever possible. - * For DATE, TIMESTAMP and numeric types, see documentation of Oracle SQL to_char() function for more details - * For BINARY_DOUBLE and BINARY_FLOAT, refer to the C Standard Library printf() family documentation - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetFormat -( - OCI_Connection *con, - unsigned int type, - const otext *format -); - -/** - * @brief - * Return the format string for implicit string conversions of the given type - * - * @param con - Connection handle - * @param type - Type of format - * - * @note - * See OCI_SetFormat() for possible values - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetFormat -( - OCI_Connection *con, - unsigned int type -); - -/** - * @brief - * Return the current transaction of the connection - * - * @param con - Connection handle - * - * @note - * From v3.9.4, no more default transaction object is created for a new connection - * - */ - -OCI_EXPORT OCI_Transaction * OCI_API OCI_GetTransaction -( - OCI_Connection *con -); - -/** - * @brief - * Set a transaction to a connection - * - * @param con - Connection handle - * @param trans - Transaction handle to assign - * - * @note - * The current transaction (if any) is automatically stopped but the newly assigned is not - * started or resumed - * - * @warning - * Do not set transaction object to XA connection or connection retrieved from a session pool - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetTransaction -( - OCI_Connection *con, - OCI_Transaction *trans -); - -/** - * @brief - * Return the highest Oracle version is supported by the connection - * - * @param con - connection handle - * - * @note - * The highest supported version is the lower version between client and server: - * - * @note - * Returns one of the following values: - * - * - OCI_UNKNOWN - * - OCI_8_0 - * - OCI_8_1 - * - OCI_9_0 - * - OCI_9_2 - * - OCI_10_1 - * - OCI_10_2 - * - OCI_11_1 - * - OCI_11_2 - * - OCI_12_1 - * - OCI_18_3 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetVersionConnection -( - OCI_Connection *con -); - -/** - * @brief - * Set tracing information to the session of the given connection - * - * @param con - connection handle - * @param trace - trace type - * @param value - trace content - * - * Store current trace information to the given connection handle. - * These information: - * - * - is stored in system view V$SESSION and/or V$SQL_MONITOR - * - can be retrieved from the connection property of an OCI_Error handle - * - * @note - * Possible values of parameter 'trace' : - * - * - OCI_TRC_IDENTITY : Specifies the user defined identifier in the session. - * It's recorded in the column CLIENT_IDENTIFIER of the - * system view V$SESSION - * - OCI_TRC_MODULE : name of the current module in the client application. - * It's recorded in the column MODULE of the - * system view V$SESSION - * - OCI_TRC_ACTION : name of the current action within the current module. - * It's recorded in the column ACTION of the - * system view V$SESSION - * - OCI_TRC_DETAIL : Client application additional information. - * It's recorded in the column CLIENT_INFO of the - * system view V$SESSION - * - OCI_TRC_OPERATION: Client application database operation. - * It's recorded in the column DBOP_NAME of the - * system view V$SQL_MONITOR - * @warning - * The system view V$SESSION is updated on Oracle versions >= 10gR1 - * The system view V$SQL_MONITOR is updated on Oracle versions >= 12cR1 - * - * @warning - * Oracle limits the size of these traces content: - * - * - OCI_TRC_IDENTITY : 64 bytes - * - OCI_TRC_MODULE : 48 bytes - * - OCI_TRC_ACTION : 32 bytes - * - OCI_TRC_DETAIL : 64 bytes - * - OCI_TRC_OPERATION: 32 bytes - * - * OCILIB truncates input values to match theses limits - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetTrace -( - OCI_Connection *con, - unsigned int trace, - const otext *value -); - -/** - * @brief - * Get the current trace for the trace type from the given connection. - * - * @param con - connection handle - * @param trace - trace type - * - * @note - * See OCI_SetTrace() for more details. - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetTrace -( - OCI_Connection *con, - unsigned int trace -); - -/** - * @brief - * Makes a round trip call to the server to confirm that the connection and the server are active. - * - * @param con - Connection handle - * - * @note - * Returns TRUE is the connection is still alive otherwise FALSE - * - * @warning - * This call is supported from Oracle 10g. - * For previous versions, it returns FALSE without throwing any exception. - * - */ - -OCI_EXPORT boolean OCI_API OCI_Ping -( - OCI_Connection *con -); - -/** - * @brief - * Set a given timeout for OCI calls that require server round-trips to the given database - * - * @param con - Connection handle - * @param type - Type of timeout to set - * @param value - Timeout in milliseconds - * - * Possible values for parameter 'type': - * - OCI_NTO_SEND - * - Time to wait for send operations completion to the database server - * - Requires Oracle 12cR1 client - * - OCI_NTO_RECEIVE - * - Time to wait for read operations completion from the database server - * - Requires Oracle 12cR1 client - * - OCI_NTO_CALL - * - Time to wait for a database round-trip to complete ( Client processing is not taken into account) - * - Requires Oracle 18c client - * - * OCI client raises an timeout type related error when a given timeout is reached. - * - * @note - * To disable a given timeout, pass the value 0 - * - * @warning - * OCI client is using the following precedence rules when applying timeouts: - * - 1 - Timeout set using OCI_NTO_CALL (all other timeouts are discarded) - * - 2 - Timeouts set using OCI_NTO_SEND and/or OCI_NTO_RECEIVE - * - 3 - Timeouts set in sqlnet.ora file - * - * Here is a summary: - * - * FLAG | Min. Version | OCI Error raised | OCI Error description | sqlnet.ora equivalent | - * --------------- | ------------ | ---------------- | ------------------------------ | --------------------- | - * OCI_NTO_SEND | OCI_12_1 | ORA-12608 | TNS: Send timeout occurred | SQLNET.SEND_TIMEOUT | - * OCI_NTO_RECEIVE | OCI_12_1 | ORA-12609 | TNS: Receive timeout occurred | SQLNET.RECV_TIMEOUT | - * OCI_NTO_CALL | OCI_18_1 | ORA-03136 | inbound connection timed out | --- | - * - * @warning - * Returns FALSE without throwing any exception if the Oracle client does not support the given flag - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetTimeout -( - OCI_Connection *con, - unsigned int type, - unsigned int value -); - -/** - * @brief - * Returns the requested timeout value for OCI calls that require server round-trips to the given database - * - * @param con - Connection handle - * @param type - Type of timeout - * - * @note: - * See OCI_SetTimeout() for more information - * - * @return - * The given timeout value if supported, otherwise 0 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetTimeout -( - OCI_Connection *con, - unsigned int type -); - -/** - * @brief - * Return the Oracle server database name of the connected database/service name - * - * @param con - Connection handle - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns NULL without throwing any exception. - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetDBName -( - OCI_Connection *con -); - -/** - * @brief - * Return the Oracle server Instance name of the connected database/service name - * - * @param con - Connection handle - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns NULL without throwing any exception. - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetInstanceName -( - OCI_Connection *con -); - - -/** - * @brief - * Return the Oracle server service name of the connected database/service name - * - * @param con - Connection handle - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns NULL without throwing any exception. - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetServiceName -( - OCI_Connection *con -); - - -/** - * @brief - * Return the Oracle server machine name of the connected database/service name - * - * @param con - Connection handle - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns NULL without throwing any exception. - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetServerName -( - OCI_Connection *con -); - - -/** - * @brief - * Return the Oracle server domain name of the connected database/service name - * - * @param con - Connection handle - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns NULL without throwing any exception. - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetDomainName -( - OCI_Connection *con -); - - -/** - * @brief - * Return the date and time (Timestamp) server instance start of the - * connected database/service name - * - * @param con - Connection handle - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns NULL without throwing any exception. - * - */ - -OCI_EXPORT OCI_Timestamp * OCI_API OCI_GetInstanceStartTime -( - OCI_Connection *con -); - -/** - * @brief - * Verify if the given connection support TAF events - * - * @param con - Connection handle - * - * @note - * Returns TRUE is the connection supports TAF event otherwise FALSE - * - * @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns FALSE without throwing any exception. - * - */ - -OCI_EXPORT boolean OCI_API OCI_IsTAFCapable -( - OCI_Connection *con -); - -/** - * @brief - * Set the Transparent Application Failover (TAF) user handler - * - * @param con - Connection handle - * @param handler - Pointer to TAF handler procedure - * - * @note - * See POCI_TAF_HANDLER documentation for more details - * -* @warning - * This call is supported from Oracle 10gR2. - * For previous versions, it returns FALSE without throwing any exception. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetTAFHandler -( - OCI_Connection *con, - POCI_TAF_HANDLER handler -); - -/** - * @brief - * Return the maximum number of statements to keep in the statement cache - * - * @param con - Connection handle - * - * @note - * Default value is 20 (value from Oracle Documentation) - * - * @warning - * Requires Oracle Client 9.2 or above - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetStatementCacheSize -( - OCI_Connection *con -); - -/** - * @brief - * Set the maximum number of statements to keep in the statement cache - * - * @param con - Connection handle - * @param value - maximum number of statements in the cache - * - * @warning - * Requires Oracle Client 9.2 or above - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetStatementCacheSize -( - OCI_Connection *con, - unsigned int value -); - -/** - * @brief - * Return the default LOB prefetch buffer size for the connection - * - * @param con - Connection handle - * - * @warning - * Requires Oracle Client AND Server 11gR1 or above - * - * @note - * Prefetch size is: - * - number of bytes for BLOBs and BFILEs - * - number of characters for CLOBs. - * - * @note - * Default is 0 (prefetching disabled) - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetDefaultLobPrefetchSize -( - OCI_Connection *con -); - -/** - * @brief - * Enable or disable prefetching for all LOBs fetched in the connection - * - * @param con - Connection handle - * @param value - default prefetch buffer size - * - * @note - * If parameter 'value': - * - is == 0, it disables prefetching for all LOBs fetched in the connection. - * - is > 0, it enables prefetching for all LOBs fetched in the connection - * and the given buffer size is used for prefetching LOBs - * - * @note - * LOBs prefetching is disabled by default - * - * @warning - * Requires Oracle Client AND Server 11gR1 or above. - * - * @note - * Prefetch size is: - * - number of bytes for BLOBs and BFILEs - * - number of characters for CLOBs. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetDefaultLobPrefetchSize -( - OCI_Connection *con, - unsigned int value -); - - -/** -* @brief -* Return the maximum number of SQL statements that can be opened in one session -* -* @param con - Connection handle -* -* @warning -* Requires Oracle Client AND Server 12cR1 or above -* -* @note -* the returned value is the same as the db parameter 'open_cursors' from server's parameter file -* -* @note -* Return 0 if the client and server version are < 12cR1 -* -*/ - -OCI_EXPORT unsigned int OCI_API OCI_GetMaxCursors -( - OCI_Connection *con -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiPools Oracle Pools - * @{ - * - * OCILIB support the connections and sessions pooling features introduced - * in Oracle 9i. - * - * Let's Oracle talk about this features ! - * - * @par Connection pools (from Oracle Call Interface Programmer's Guide) - * - * Connection pooling is the use of a group (the pool) of reusable physical connections - * by several sessions, in order to balance loads. The management of the pool is done - * by OCI, not the application. Applications that can use connection pooling include - * middle-tier applications for Web application servers and e-mail servers. - * - * @par Session Pools (from Oracle Call Interface Programmer's Guide) - * - * Session pooling means that the application will create and maintain a group of stateless - * sessions to the database. These sessions will be handed over to thin clients as requested. - * If no sessions are available, a new one may be created. When the client is done with - * the session, the client will release it to the pool. Thus, the number of sessions in - * the pool can increase dynamically. - * - * @note - * OCILIB implements homogeneous session pools only. - * - * @par When using Pools (from Oracle Call Interface Programmer's Guide) - * - * If database sessions are not reusable by mid-tier threads (that is, they are stateful) - * and the number of back-end server processes may cause scaling problems on the database, - * use OCI connection pooling. - * - * If database sessions are reusable by mid-tier threads (that is, they are stateless) - * and the number of back-end server processes may cause scaling problems on the database, - * use OCI session pooling. - * - * If database sessions are not reusable by mid-tier threads (that is, they are stateful) - * and the number of back-end server processes will never be large enough to potentially - * cause any scaling issue on the database, there is no need to use any pooling mechanism. - * - * @par Example - * @include pool.c - * - */ - -/** - * @brief - * Create an Oracle pool of connections or sessions - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param type - Type of pool - * @param mode - Session mode - * @param min_con - minimum number of connections/sessions that can be opened. - * @param max_con - maximum number of connections/sessions that can be opened. - * @param incr_con - next increment for connections/sessions to be opened - * - * Possible values for parameter 'type': - * - OCI_POOL_CONNECTION - * - OCI_POOL_SESSION - * - * Possible values for parameter 'mode': - * - OCI_SESSION_DEFAULT - * - OCI_SESSION_SYSDBA (session pools only) - * - * @note - * External credentials are supported by supplying a null value for the 'user' - * and 'pwd' parameters - * If the param 'db' is NULL then a connection to the default local DB is done - * - * @return - * Connection or session pool handle on success or NULL on failure - * - */ - -OCI_EXPORT OCI_Pool * OCI_API OCI_PoolCreate -( - const otext *db, - const otext *user, - const otext *pwd, - unsigned int type, - unsigned int mode, - unsigned int min_con, - unsigned int max_con, - unsigned int incr_con -); - -/** - * @brief - * Destroy a pool object - * - * @param pool - Pool handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_PoolFree -( - OCI_Pool *pool -); - -/** - * @brief - * Get a connection from the pool - * - * @param pool - Pool handle - * @param tag - user tag string - * - * @par Session tagging - * - * Session pools have a nice feature that is 'session tagging' - * It's possible to tag a session with a string identifier - * when the session is returned to the pool, it keeps its tags. - * When requesting a connection from the session pool, it's - * possible to request a session that has the given 'tag' parameter - * If one exists, it is returned. If not and if an untagged session - * is available, it is then returned. So check the connection tag - * property with OCI_GetSessionTag() to find out if the returned - * connection is tagged or not. - * - * This features is described in the OCI developer guide as the following : - * - * "The tags provide a way for users to customize sessions in the pool. - * A client may get a default or untagged session from a pool, set certain - * attributes on the session (such as NLS settings), and return the session - * to the pool, labeling it with an appropriate tag. - * The user may request a session with the same tags in order to have a - * session with the same attributes" - * - * @return - * Connection handle otherwise NULL on failure - */ - -OCI_EXPORT OCI_Connection * OCI_API OCI_PoolGetConnection -( - OCI_Pool *pool, - const otext *tag -); - -/** - * @brief - * Get the idle timeout for connections/sessions in the pool - * - * @param pool - Pool handle - * - * @note - * Connections/sessions idle for more than this time value (in seconds) is terminated - * - * @note - * Timeout is not available for internal pooling implementation (client < 9i) - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetTimeout -( - OCI_Pool *pool -); - -/** - * @brief - * Set the connections/sessions idle timeout - * - * @param pool - Pool handle - * @param value - Timeout value - * - * @note - * connections/sessions idle for more than this time value (in seconds) is terminated - * - * @note - * This call has no effect if pooling is internally implemented (client < 9i) - * - */ - -OCI_EXPORT boolean OCI_API OCI_PoolSetTimeout -( - OCI_Pool *pool, - unsigned int value -); - -/** - * @brief - * Get the waiting mode used when no more connections/sessions are available - * from the pool - * - * @param pool - Pool handle - * - * @return - * - FALSE to wait for an available object if the pool is saturated - * - TRUE to not wait for an available object - * - */ - -OCI_EXPORT boolean OCI_API OCI_PoolGetNoWait -( - OCI_Pool *pool -); - -/** - * @brief - * Set the waiting mode used when no more connections/sessions are available - * from the pool - * - * @param pool - Pool handle - * @param value - wait for object - * - * @note - * Pass : - * - FALSE to wait for an available object if the pool is saturated - * - TRUE to not wait for an available object - * - */ - -OCI_EXPORT boolean OCI_API OCI_PoolSetNoWait -( - OCI_Pool *pool, - boolean value -); - -/** - * @brief - * Return the current number of busy connections/sessions - * - * @param pool - Pool handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetBusyCount -( - OCI_Pool *pool -); - -/** - * @brief - * Return the current number of opened connections/sessions - * - * @param pool - Pool handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetOpenedCount -( - OCI_Pool *pool -); - -/** - * @brief - * Return the minimum number of connections/sessions that can be opened to the database - * - * @param pool - Pool handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetMin -( - OCI_Pool *pool -); - -/** - * @brief - * Return the maximum number of connections/sessions that can be opened to the database - * - * @param pool - Pool handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetMax -( - OCI_Pool *pool -); - -/** - * @brief - * Return the increment for connections/sessions to be opened to the database when the pool is - * not full - * - * @param pool - Pool handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetIncrement -( - OCI_Pool *pool -); - -/** - * @brief - * Return the maximum number of statements to keep in the pool statement cache - * - * @param pool - Pool handle - * - * @note - * Default value is 20 (value from Oracle Documentation) - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_PoolGetStatementCacheSize -( - OCI_Pool *pool -); - -/** - * @brief - * Set the maximum number of statements to keep in the pool statement cache - * - * @param pool - Pool handle - * @param value - maximum number of statements in the cache - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_PoolSetStatementCacheSize -( - OCI_Pool *pool, - unsigned int value -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiTransactions Managing transactions - * @{ - * - * OCILIB supports local and global transactions. - * - * Local transactions are implicit within connection objects and there is no - * specific call or programming step for using it. - * - * In order to control changes made in the database: - * - * - OCI_Commit() validates current pending modifications - * - OCI_Rollback() discards current pending modifications - * - * OCILIB supports a feature called 'Auto Commit' that performs an implicit and - * automatic commit call after every execute call - * - * @note - * Those actions are executed within a connection context and not directly to a transaction. - * - * @warning - * Global transactions are optional and are designed for distributed or global - * transaction environments. - * - * OCILIB supports them by : - * - * - Creating/Destroying explicitly a transaction object - * - Starting/Stopping/Resuming explicitly the transaction - * - Preparing the transaction for specific calls - * - */ - -/** - * @brief - * Commit current pending changes - * - * @param con - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_Commit -( - OCI_Connection *con -); - -/** - * @brief - * Cancel current pending changes - * - * @param con - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_Rollback -( - OCI_Connection *con -); - -/** - * @brief - * Enable / disable auto commit mode - * - * The auto commit mode allows commit changes after every executed SQL order - * - * @param con - Connection handle - * @param enable - Enable (TRUE) or disable (FALSE) - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetAutoCommit -( - OCI_Connection *con, - boolean enable -); - -/** - * @brief - * Get current auto commit mode status - * - * @param con - Connection handle - * - * @return - * TRUE if auto commit mode is activated otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_GetAutoCommit -( - OCI_Connection *con -); - -/** - * @brief - * Create a new global transaction or a serializable/read-only local transaction - * - * @param con - Connection handle - * @param timeout - Time that a transaction stays inactive after being stopped - * @param mode - Transaction mode - * @param pxid - pointer to a global transaction identifier structure - * - * - * @note - * The parameter 'mode' can be one of the following values : - * - * - Global transactions: - * - OCI_TRS_NEW : By default starts a new, tightly coupled and - * migratable branch. - * - OCI_TRS_TIGHT : explicitly specifies a tightly coupled branch - * - OCI_TRS_LOOSE : specifies a loosely coupled branch - * - * - Global and local transactions : - * - OCI_TRS_READONLY - start a read-only transaction - * - OCI_TRS_READWRITE - start a read-write transaction - * - OCI_TRS_SERIALIZABLE : start a serializable transaction - * - * @note - * For local transaction: - * - pass a NULL value for pxid - * - */ - -OCI_EXPORT OCI_Transaction * OCI_API OCI_TransactionCreate -( - OCI_Connection *con, - unsigned int timeout, - unsigned int mode, - OCI_XID *pxid -); - -/** - * @brief - * Free current transaction - * - * @param trans - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TransactionFree -( - OCI_Transaction *trans -); - -/** - * @brief - * Start global transaction - * - * @param trans - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TransactionStart -( - OCI_Transaction *trans -); - -/** - * @brief - * Stop current global transaction - * - * @param trans - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TransactionStop -( - OCI_Transaction *trans -); - -/** - * @brief - * Resume a stopped global transaction - * - * @param trans - Global transaction handle - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_TransactionResume -( - OCI_Transaction *trans -); - -/** - * @brief - * Prepare a global transaction validation - * - * @param trans - Global transaction handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TransactionPrepare -( - OCI_Transaction *trans -); - -/** - * @brief - * Cancel the prepared global transaction validation - * - * @param trans - Global transaction handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TransactionForget -( - OCI_Transaction *trans -); - -/** - * @brief - * Return global transaction mode. - * - * @note: - * see OCI_TransactionCreate() for possible values - * - * @param trans - Global transaction handle - * - * @return - * Transaction mode or OCI_UNKNOW if trans is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_TransactionGetMode -( - OCI_Transaction *trans -); - -/** - * @brief - * Return global transaction Timeout - * - * @param trans - Global transaction handle - * - * @return - * Transaction timeout or 0 if trans is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_TransactionGetTimeout -( - OCI_Transaction *trans -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiStatements Executing statements - * @{ - * - * Executing SQL statements or PL/SQL blocks is really simple with OCILIB. - * - * First, call OCI_StatementCreate() to allocate a statement handle. Then : - * - * - Prepare the SQL with OCI_Prepare() - * - Parse and execute it with OCI_Execute() - * - * These two steps can be done together by calling OCI_ExecuteStmt() that - * prepares and executes in one go. - * - * To find out if the statement has affected any rows, call OCI_GetAffectedRows() - * - * Finally, release the statement and its resources with OCI_StatementFree() - * - * @note - * A statement can be prepared once and executed as many times as needed (see - * Binding variables section) - * - * @note - * An OCI_Statement can be used to prepare and/or execute different SQL and PL/SQL - * statements as many times as needed. - * For example, if the SQL processing of an application is sequential, only - * one statement handle is required - * - * @note - * OCILIB supports nested levels of SQL statement processing. - * An application can loop through the resultset of the statement handle A, - * executing statement B and fetching statement C at every loop, and so on ... - * - * @par Example - * @include exec.c - * - */ - -/** - * @brief - * Create a statement object and return its handle - * - * @param con - Connection handle - * - * @return - * A statement handle on success otherwise NULL - * - */ - -OCI_EXPORT OCI_Statement * OCI_API OCI_StatementCreate -( - OCI_Connection *con -); - -/** - * @brief - * Free a statement and all resources associated to it (resultsets ...) - * - * @param stmt - Connection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_StatementFree -( - OCI_Statement *stmt -); - -/** - * @brief - * Prepare a SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * @param sql - SQL order or PL/SQL block - * - * @note - * Do not call this function for fetched statements (REF cursors) - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_Prepare -( - OCI_Statement *stmt, - const otext *sql -); - -/** - * @brief - * Execute a prepared SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * - * @return - * TRUE on success otherwise FALSE - * - * @warning - * If a SQL warning occurs: - * - the function returns TRUE - * - the SQL warning triggers the global error handler with an OCI_Error having its OCI_ErrorGetType() - * attribute set to OCI_ERR_WARNING - * - If OCILIB is initialized with the OCI_ENV_CONTEXT mode, OCI_GetLastError() will return the OCI_Error - * object corresponding to the warning - * - */ - -OCI_EXPORT boolean OCI_API OCI_Execute -( - OCI_Statement *stmt -); - -/** - * @brief - * Prepare and Execute a SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * @param sql - SQL order - PL/SQL block - * - * @return - * TRUE on success otherwise FALSE - * - * @warning - * If a SQL warning occurs: - * - the function returns TRUE - * - the SQL warning triggers the global error handler with an OCI_Error having its OCI_ErrorGetType() - * attribute set to OCI_ERR_WARNING - * - If OCILIB is initialized with the OCI_ENV_CONTEXT mode, OCI_GetLastError() will return the OCI_Error - * object corresponding to the warning - * - */ - -OCI_EXPORT boolean OCI_API OCI_ExecuteStmt -( - OCI_Statement *stmt, - const otext *sql -); - -/** - * @brief - * Parse a SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * @param sql - SQL order - PL/SQL block - * - * @note - * This call sends the SQL or PL/SQL command to the server for parsing only. - * The command is not executed. - * This call is only useful to check is a command is valid or not. - * - * @note - * This call prepares the statement (internal call to OCI_Prepare()) and ask - * the Oracle server to parse its SQL or PL/SQL command. - * OCI_Execute() can be call after OCI_Parse() in order to execute the - * statement, which means that the server will re-parse again the command. - * - * @warning - * Do not use OCI_Parse() unless you're only interested in the parsing result - * because the statement will be parsed again when executed and thus leading to - * unnecessary server round-trips and less performance - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_Parse -( - OCI_Statement *stmt, - const otext *sql -); - -/** - * @brief - * Describe the select list of a SQL select statement. - * - * @param stmt - Statement handle - * @param sql - SELECT sql statement - * - * @note - * This call sends the SELECT SQL order to the server for retrieving the - * description of the select order only. - * The command is not executed. - * This call is only useful to retrieve information on the associated resultset - * Call OCI_GetResultet() after OCI_Describe() to access to SELECT list - * information - * - * @note - * This call prepares the statement (internal call to OCI_Prepare()) and ask - * the Oracle server to describe the output SELECT list. - * OCI_Execute() can be called after OCI_Describe() in order to execute the - * statement, which means that the server will parse, and describe again the SQL - * order. - * - * @warning - * Do not use OCI_Describe() unless you're only interested in the resultset - * information because the statement will be parsed again when executed and thus - * leading to unnecessary server round-trips and less performance - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_Describe -( - OCI_Statement *stmt, - const otext *sql -); - -/** - * @brief - * Return the last SQL or PL/SQL statement prepared or executed by the statement - * - * @param stmt - Statement handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetSql -( - OCI_Statement *stmt -); - -/** -* @brief -* Returns the statement SQL_ID from the server -* -* @param stmt - Statement handle -* -* @note -* The statement must be executed first -* -* @warning -* Requires Oracle 12cR2 (both client and server side), otherwise it returns NULL -* -*/ - -OCI_EXPORT const otext* OCI_API OCI_GetSqlIdentifier -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the error position (in terms of characters) in the SQL statement - * where the error occurred in case of SQL parsing error - * - * @param stmt - Statement handle - * - * @note - * Positions start at 1. - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetSqlErrorPos -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the number of rows affected by the SQL statement - * - * @param stmt - Statement handle - * - * The returned value is : - * - For UPDATEs : number of rows updated - * - For INSERTs : number of rows inserted - * - For DELETEs : number of rows deleted - * - * @note - * For SELECTs statements, use OCI_GetRowCount() instead - * - * @note - * For PL/SQL blocks performing "select into :": - * - it returns the number of rows selected from PL/SQL - * - Up to version 4.3.0, OCI_Execute() returned FALSE and generated an error ORA-01403 - "No Data Found" - * - From version 4.3.1, OCI_Execute() returns 0 if no data found, otherwise the number of selected rows - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetAffectedRows -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the Oracle SQL code the command held by the statement handle - * - * @param stmt - Statement handle - * - * @warning - * OCI_GetSQLCommand() must be called after the statement has be executed - * because that's the server engine that computes the SQL command code - * - * @return - * The SQL command code of the statement otherwise OCI_UNKOWN - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetSQLCommand -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the verb of the SQL command held by the statement handle - * - * @param stmt - Statement handle - * - * @warning - * OCI_GetSQLVerb() must be called after the statement has been executed - * because that's the server engine that computes the SQL verb - * - * @note - * The SQL verb list is available in Oracle documentations and guides - * - * @return - * The SQL command verb of the statement otherwise NULL - */ - -OCI_EXPORT const otext * OCI_API OCI_GetSQLVerb -( - OCI_Statement *stmt -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiBinding Binding variables and arrays - * @{ - * - * OCILIB supports OCI data binding APIs - * - * Programs variables can be binded to an Oracle SQL PL/SQL statement in order to : - * - * - Provide input data for SQL statement - * - Provide input/output data for PL/SQL blocks - * - * OCILIB provides a set of binding functions to use with: - * - * - Basic data types: string (char/wchar_t *), int, float, double, raw - * - Object data types: lobs, files,longs, dates, cursors, statements, - * timestamps, intervals, objects - * - * To use binding: - * - * - Prepare a statement with OCI_Prepare() (see Executing statements) - * - Bind variables by calling one if the OCI_Bindxxxxx() function for every - * input variable referenced by the SQL statement - * - Setup up values of the program variables - * - Call OCI_Execute() as many times as needed - * - Each OCI_Execute() call may be preceded by an update of the program - * variables (for INSERTs for example) - * - * Bindings can be: - * - IN (host variable are not used anymore after statement execution) - * - OUT (host variable are set during statement execution) - * - IN/OUT (default) - * Use OCI_BindSetDirectionTo() to change a host variable bind direction mode after the binding call but before statement execution. - * Note that each direction mode may have a little overhead depending on the SQL type as OCILIB may have to do checks/conversions/mappings between host variable and buffers. - * Thus, to maximize performances: - * - set direction mode to OCI_BDM_IN if host variable is not updated by statement execution - * - set direction mode to OCI_BDM_OUT if host variable value does not matter prior to statement execution - * - set direction mode to OCI_BDM_IN_OUT when host variable value is used for execution and updated by statement execution - * - * OCILIB supports the OCI array Interface by binding arrays of C scalar types - * and OCILIB object types. - * - * - all types supported the library can be used for array binding except - * OCI_Statement and OCI_Long - * - Array binding is really fast for massive DML operations - * - For string/RAW arrays, the input array MUST BE a contiguous block of data - * and not an array of pointers. So to bind an array of 10 elements for a - * varchar2(30) column, binded variable must be a like array[10][31] - * - * OCILIB does not pre-parse statements (like other frameworks such as JDBC, ...) - * and lets Oracle recognize input variables embedded within the SQL statements. - * - * Bind variables must be preceded in the SQL code by the character ':'. - * - * Oracle and OCILIB supports two ways of binding: - * - * - by name (default mode in OCILIB): Oracle looks for variables in the SQL - * statement by searching their names provided to the binding function. - * So a variable can be binded once and used many times in the statement - * - by position: Oracle binds variables by position, so every variable is - * binded with a position number - * - * OCILIB Default binding mode is OCI_BIND_BY_NAME. - * - * When using binding by position, provide the position to OCI_BindXXXX() call - * through the name parameter. Within this mode the bind name must be the - * position preceded by a semicolon like ':1', ':2', .... - * - * @par Internal Bind allocation mode - * - * Bind variables or arrays can be internally allocated by OCILIB. - * That means that instead of allocating variables or arrays on the stack/heap - * in the user program, bind contents can be allocated internally and thus : - * - minimize the amount of program variables - * - optimize internal memory management for arrays - * - * To do so : - * - Call OCI_SetBindAllocation() with the mode OCI_BAM_INTERNAL - * - pass a NULL variable or array to OCI_BindXXX() calls - * - Retrieve the bind content allocated by OCILIB with OCI_BindGetData() - * - * Internal Bind allocation mode IS compatible with ALL array binding OCI_BindArrayOfxxx() methods. - * - * Internal Bind allocation mode IS NOT compatible with some single variable bind calls : - * - OCI_BindTimestamp() - * - OCI_BindInterval() - * - OCI_BindLob() - * - OCI_BindFile() - * - OCI_BindObject() - * - OCI_BindColl() - * - OCI_BindRef() - * - OCI_BindStatement() - * - OCI_BindLong() - * - * These methods need to know the data sub type (like OCI_CLOB/OCI_BLOB for lobs) in order - * to internally create variables. As these methods prototypes are not passing the sub type, - * calling them with the statement bind mode set to OCI_BAM_INTERNAL will raise - * an OCILIB error of type OCI_ERR_NULL_POINTER - * - * @note - * Rebinding is disabled by default (see OCI_AllowRebinding()) - * When using rebinding feature, host variable re-binded to a previously allocated - * bind MUST be of the SAME data type ! - * - * @par Basic input bind Example - * @include bind.c - * - * @par Array interface Example - * @include array.c - * - * @par Internal Array interface Example - * @include array_internal.c - * - * */ - -/** - * @brief - * Set the input array size for bulk operations - * - * @param stmt - Statement handle - * @param size - Array size - * - * @warning - * Do not use OCI_BindArraySetSize() for PL/SQL tables binding - * - * @note - * OCI_BindArraySetSize() is used to set the size of input bind array when using - * arrays for DML statements. - * OCI_BindArraySetSize() MUST be called to set the maximum size of the arrays - * to bind to the statement before any of its execution. This initial call must - * be bone AFTER OCI_Prepare() and BEFORE any OCI_BindArrayOfxxx() call. - * - * @note - * OCI_BindArraySetSize() can optionally be called before any later OCI_Execute() - * call in order to notify the statement of the exact number of elements - * populating the input arrays for the next execution. The array size passed to - * later OCI_BindArraySetSize() calls cannot be greater than the initial size - * otherwise an exception will be thrown. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindArraySetSize -( - OCI_Statement *stmt, - unsigned int size -); - -/** - * @brief - * Return the current input array size for bulk operations - * - * @param stmt - Statement handle - * - * @return - * Array size value or 0 if OCI_BindArraySetSize() has not been called - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindArrayGetSize -( - OCI_Statement *stmt -); - -/** - * @brief - * Allow different host variables to be binded using the same bind name or - * position between executions of a prepared statement - * - * @param stmt - Statement handle - * @param value - Rebinding mode allowed - * - * @note - * Default value is FALSE - * - * @warning - * When using rebinding feature, host variable re-binded to a previously allocated - * bind MUST be of the same data type ! - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_AllowRebinding -( - OCI_Statement *stmt, - boolean value -); - -/** - * @brief - * Indicate if rebinding is allowed on the given statement - * - * @param stmt - Statement handle - * - * @note - * See OCI_AllowRebinding() for more details - * - * @return - * TRUE if allowed otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_IsRebindingAllowed -( - OCI_Statement *stmt -); - -/** -* @brief -* Bind a boolean variable (PL/SQL ONLY) -* -* @param stmt - Statement handle -* @param name - Variable name -* @param data - Pointer to boolean variable -* -* @note -* parameter 'data' can NULL if the statement bind allocation mode -* has been set to OCI_BAM_INTERNAL -* -* @warning -* - OCI_BindBoolean() CAN ONLY BE USED for PL/SQL boolean type when calling PL/SQL procedures/function -* - ONLY supported by Oracle 12c and above ! -* -* @return -* TRUE on success otherwise FALSE -*/ -OCI_EXPORT boolean OCI_API OCI_BindBoolean -( - OCI_Statement *stmt, - const otext *name, - boolean *data -); - -/** -* @brief -* Bind an Number variable -* -* @param stmt - Statement handle -* @param name - Variable name -* @param data - Pointer to short variable -* -* @note -* parameter 'data' can NULL if the statement bind allocation mode -* has been set to OCI_BAM_INTERNAL -* -* @return -* TRUE on success otherwise FALSE -*/ - -OCI_EXPORT boolean OCI_API OCI_BindNumber -( - OCI_Statement *stmt, - const otext *name, - OCI_Number *data -); - -/** -* @brief -* Bind an array of Number -* -* @param stmt - Statement handle -* @param name - Variable name -* @param data - Array of numbers -* @param nbelem - Number of element in the array (PL/SQL table only) -* -* @warning -* Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. -* For regular DML array operations, pass the value 0. -* -* @note -* parameter 'data' can NULL if the statement bind allocation mode -* has been set to OCI_BAM_INTERNAL -* -* @return -* TRUE on success otherwise FALSE -*/ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfNumbers -( - OCI_Statement *stmt, - const otext *name, - OCI_Number **data, - unsigned int nbelem -); - -/** - * @brief - * Bind an short variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to short variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindShort -( - OCI_Statement *stmt, - const otext *name, - short *data -); - -/** - * @brief - * Bind an array of shorts - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of shorts - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfShorts -( - OCI_Statement *stmt, - const otext *name, - short *data, - unsigned int nbelem -); - -/** - * @brief - * Bind an unsigned short variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to unsigned short variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindUnsignedShort -( - OCI_Statement *stmt, - const otext *name, - unsigned short *data -); - -/** - * @brief - * Bind an array of unsigned shorts - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of unsigned shorts - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedShorts -( - OCI_Statement *stmt, - const otext *name, - unsigned short *data, - unsigned int nbelem -); - -/** - * @brief - * Bind an integer variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to int variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindInt -( - OCI_Statement *stmt, - const otext *name, - int *data -); - -/** - * @brief - * Bind an array of integers - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of int - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfInts -( - OCI_Statement *stmt, - const otext *name, - int *data, - unsigned int nbelem -); - -/** - * @brief - * Bind an unsigned integer variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to unsigned int variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindUnsignedInt -( - OCI_Statement *stmt, - const otext *name, - unsigned int *data -); - -/** - * @brief - * Bind an array of unsigned integers - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of unsigned int - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedInts -( - OCI_Statement *stmt, - const otext *name, - unsigned int *data, - unsigned int nbelem -); - -/** - * @brief - * Bind a big integer variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to big int variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindBigInt -( - OCI_Statement *stmt, - const otext *name, - big_int *data -); - -/** - * @brief - * Bind an array of big integers - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of big int - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfBigInts -( - OCI_Statement *stmt, - const otext *name, - big_int *data, - unsigned int nbelem -); - -/** - * @brief - * Bind an unsigned big integer variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to unsigned big int variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindUnsignedBigInt -( - OCI_Statement *stmt, - const otext *name, - big_uint *data -); - -/** - * @brief - * Bind an array of unsigned big integers - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of unsigned big int - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedBigInts -( - OCI_Statement *stmt, - const otext *name, - big_uint *data, - unsigned int nbelem -); - -/** - * @brief - * Bind a string variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - String to bind - * @param len - Max length of the string (in character without - * the zero null terminal character) - * - * @note - * if len == 0, len is set to the string size - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindString -( - OCI_Statement *stmt, - const otext *name, - otext *data, - unsigned int len -); - -/** - * @brief - * Bind an array of strings - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of string - * @param len - Max length of a single string element (in character without - * the zero null terminal character) - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @warning - * if len <= 0, it returns FALSE - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfStrings -( - OCI_Statement *stmt, - const otext *name, - otext *data, - unsigned int len, - unsigned int nbelem -); - -/** - * @brief - * Bind a raw buffer - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - buffer to bind - * @param len - Max length of the buffer - * - * @note - * if len <= 0, it returns false - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindRaw -( - OCI_Statement *stmt, - const otext *name, - void *data, - unsigned int len -); - -/** - * @brief - * Bind an array of raw buffers - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of buffers - * @param len - Size in bytes on a single RAW array element - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * The buffer must be a contiguous block of data elements - * - * @note - * If len <= 0, it returns FALSE - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfRaws -( - OCI_Statement *stmt, - const otext *name, - void *data, - unsigned int len, - unsigned int nbelem -); - -/** - * @brief - * Bind a double variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to double variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindDouble -( - OCI_Statement *stmt, - const otext *name, - double *data -); - -/** - * @brief - * Bind an array of doubles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of double - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfDoubles -( - OCI_Statement *stmt, - const otext *name, - double *data, - unsigned int nbelem -); - - -/** - * @brief - * Bind a float variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Pointer to float variable - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindFloat -( - OCI_Statement *stmt, - const otext *name, - float *data -); - -/** - * @brief - * Bind an array of floats - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of float - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfFloats -( - OCI_Statement *stmt, - const otext *name, - float *data, - unsigned int nbelem -); - -/** - * @brief - * Bind a date variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Date handle - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindDate -( - OCI_Statement *stmt, - const otext *name, - OCI_Date *data -); - -/** - * @brief - * Bind an array of dates - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of date handle - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfDates -( - OCI_Statement *stmt, - const otext *name, - OCI_Date **data, - unsigned int nbelem -); - -/** - * @brief - * Bind a timestamp variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Timestamp handle - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindTimestamp -( - OCI_Statement *stmt, - const otext *name, - OCI_Timestamp *data -); - -/** - * @brief - * Bind an array of timestamp handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of Timestamp handle - * @param type - Timestamp type - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * See OCI_TimestampCreate() for possible values of parameter 'type' - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfTimestamps -( - OCI_Statement *stmt, - const otext *name, - OCI_Timestamp **data, - unsigned int type, - unsigned int nbelem -); - -/** - * @brief - * Bind an interval variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Interval handle - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindInterval -( - OCI_Statement *stmt, - const otext *name, - OCI_Interval *data -); - -/** - * @brief - * Bind an array of interval handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of Interval handle - * @param type - Interval type - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * See OCI_IntervalCreate() for possible values of parameter 'type' - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfIntervals -( - OCI_Statement *stmt, - const otext *name, - OCI_Interval **data, - unsigned int type, - unsigned int nbelem -); - -/** - * @brief - * Bind a Lob variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Lob handle - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindLob -( - OCI_Statement *stmt, - const otext *name, - OCI_Lob *data -); - -/** - * @brief - * Bind an array of Lob handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of Lob handle - * @param type - Lob type - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * See OCI_LobCreate() for possible values of parameter 'type' - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfLobs -( - OCI_Statement *stmt, - const otext *name, - OCI_Lob **data, - unsigned int type, - unsigned int nbelem -); - -/** - * @brief - * Bind a File variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - File handle - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindFile -( - OCI_Statement *stmt, - const otext *name, - OCI_File *data -); - -/** - * @brief - * Bind an array of File handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of File handle - * @param type - File type - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * See OCI_FileCreate() for possible values of parameter 'type' - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfFiles -( - OCI_Statement *stmt, - const otext *name, - OCI_File **data, - unsigned int type, - unsigned int nbelem -); - -/** - * @brief - * Bind an object (named type) variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Object handle - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindObject -( - OCI_Statement *stmt, - const otext *name, - OCI_Object *data -); - -/** - * @brief - * Bind an array of object handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of object handle - * @param typinf - type info handle - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfObjects -( - OCI_Statement *stmt, - const otext *name, - OCI_Object **data, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -/** - * @brief - * Bind a Collection variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Collection handle to bind - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindColl -( - OCI_Statement *stmt, - const otext *name, - OCI_Coll *data -); - -/** - * @brief - * Bind an array of Collection handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of Collection handle - * @param typinf - Type info handle - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * See OCI_CollCreate() for possible values of parameter 'type' - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfColls -( - OCI_Statement *stmt, - const otext *name, - OCI_Coll **data, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -/** - * @brief - * Bind a Ref variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Ref handle to bind - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindRef -( - OCI_Statement *stmt, - const otext *name, - OCI_Ref *data -); - -/** - * @brief - * Bind an array of Ref handles - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Array of Ref handle - * @param typinf - type info handle - * @param nbelem - Number of element in the array (PL/SQL table only) - * - * @warning - * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. - * For regular DML array operations, pass the value 0. - * - * @note - * parameter 'data' can NULL if the statement bind allocation mode - * has been set to OCI_BAM_INTERNAL - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindArrayOfRefs -( - OCI_Statement *stmt, - const otext *name, - OCI_Ref **data, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -/** - * @brief - * Bind a Statement variable (PL/SQL Ref Cursor) - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Statement handle to bind - * - * @note - * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindStatement -( - OCI_Statement *stmt, - const otext *name, - OCI_Statement *data -); - -/** - * @brief - * Bind a Long variable - * - * @param stmt - Statement handle - * @param name - Variable name - * @param data - Long handle - * @param size - Size of the long buffer in bytes or characters - * - * @note - * Size is expressed in: - * - Bytes for BLONGs - * - Characters for CLONGs - * - * @note - * parameter 'data' CANNOT be NULL whatever the statement bind allocation mode - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindLong -( - OCI_Statement *stmt, - const otext *name, - OCI_Long *data, - unsigned int size -); - -/** - * @brief - * Returns the first or next error that occurred within a DML array statement execution - * - * @param stmt - Statement handle - * - * @return - * The first or next error handle otherwise NULL - */ - -OCI_EXPORT OCI_Error * OCI_API OCI_GetBatchError -( - OCI_Statement *stmt -); - -/** - * @brief - * Returns the number of errors that occurred within the last DML array statement - * - * @param stmt - Statement handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetBatchErrorCount -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the number of binds currently associated to a statement - * - * @param stmt - Statement handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetBindCount -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the bind handle at the given index in the internal array of bind - * handle - * - * @param stmt - Statement handle - * @param index - Bind position - * - * @note - * Index starts at 1. - * - * @note - * Bind handle are created sequentially. For example, the third call to a - * OCI_BindXXX() generates a bind handle of index 3. - * - * @return - * The bind handle or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Bind * OCI_API OCI_GetBind -( - OCI_Statement *stmt, - unsigned int index -); - -/** - * @brief - * Return a bind handle from its name - * - * @param stmt - Statement handle - * @param name - Bind variable name - * - * @note - * Bind names must include a semicolon at the beginning. - * - * @return - * The bind handle or NULL if not found - * - */ - -OCI_EXPORT OCI_Bind * OCI_API OCI_GetBind2 -( - OCI_Statement *stmt, - const otext *name -); - -/** -* @brief -* Return the index of the bind from its name belonging to the given statement -* -* @param stmt - Statement handle -* @param name - Bind variable name -* -* @warning -* The bind name is case insensitive -* -* @note -* Bind indexes start with 1 in OCILIB -* -* @return -* Bind index on success or zero if the bind does not exists or if statement is NULL -* -*/ - -OCI_EXPORT unsigned int OCI_API OCI_GetBindIndex -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Return the name of the given bind - * - * @param bnd - Bind handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_BindGetName -( - OCI_Bind *bnd -); - - -/** - * @brief - * Set the direction mode of a bind handle - * - * @param bnd - Bind handle - * @param direction - direction mode - * - * @note - * Possible values for parameter 'direction' : - * - OCI_BDM_IN : input values (not modified by the server) - * - OCI_BDM_OUT : output values (modified by the server) - * - OCI_BDM_IN_OUT : input and output values - * - * @note - * Default value is OCI_BDM_IN_OUT - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetDirection -( - OCI_Bind *bnd, - unsigned int direction -); - -/** - * @brief - * Get the direction mode of a bind handle - * - * @param bnd - Bind handle - * - * @note - * see OCI_BindSetDirection() for more details - * - * return the bind direction mode on success otherwise OCI_UNKNWON - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetDirection -( - OCI_Bind *bnd -); - -/** - * @brief - * Return the OCILIB type of the given bind - * - * @param bnd - Bind handle - * - * @note - * Possible values are : - * - * - OCI_CDT_NUMERIC : short, int, long long, float, double - * - OCI_CDT_DATETIME : OCI_Date * - * - OCI_CDT_TEXT : otext * - * - OCI_CDT_LONG : OCI_Long * - * - OCI_CDT_CURSOR : OCI_Statement * - * - OCI_CDT_LOB : OCI_Lob * - * - OCI_CDT_FILE : OCI_File * - * - OCI_CDT_TIMESTAMP : OCI_Timestamp * - * - OCI_CDT_INTERVAL : OCI_Interval * - * - OCI_CDT_RAW : void * - * - OCI_CDT_OBJECT : OCI_Object * - * - OCI_CDT_COLLECTION : OCI_Coll * - * - OCI_CDT_REF : OCI_Ref * - * - OCI_CDT_BOOLEAN : boolean - * - * @return - * The column type or OCI_CDT_UNKNOWN on error - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetType -( - OCI_Bind *bnd -); - -/** - * @brief - * Return the OCILIB object subtype of the given bind - * - * @param bnd - Bind handle - * - * @note - * * This call is valid for the following OCILIB types: - * - OCI_CDT_NUMERIC - * - OCI_CDT_LONG - * - OCI_CDT_LOB - * - OCI_CDT_FILE - * - OCI_CDT_TIMESTAMP - * - OCI_CDT_INTERVAL - * - * For numeric binds the possible values are: - * - OCI_NUM_SHORT - * - OCI_NUM_INT - * - OCI_NUM_BIGINT - * - OCI_NUM_USHORT - * - OCI_NUM_UINT - * - OCI_NUM_BIGUINT - * - OCI_NUM_DOUBLE - * - OCI_NUM_FLOAT - * - OCI_NUM_NUMBER - * - * For OCI_Long type the possible values are: - * - OCI_BLONG - * - OCI_CLONG - * - * For OCI_Lob type the possible values are: - * - OCI_BLOB - * - OCI_CLOB - * - OCI_NCLOB - * - * For OCI_File type the possible values are: - * - OCI_BFILE - * - OCI_CFILE - * - * For OCI_Timestamp type the possible values are: - * - OCI_TIMESTAMP - * - OCI_TIMESTAMP_TZ - * - OCI_TIMESTAMP_LTZ - * - * For OCI_Interval type the possible values are: - * - OCI_INTERVAL_YM - * - OCI_INTERVAL_DS - * - * @note - * For all other OCILIB types, it returns OCI_UNKNOWN - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetSubtype -( - OCI_Bind *bnd -); - -/** - * @brief - * Return the number of elements of the bind handle - * - * @param bnd - Bind handle - * - * @return - * - For single binds, it returns 1 - * - For array binds, it returns the number of element in the array - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetDataCount -( - OCI_Bind *bnd -); - -/** - * @brief - * Return the user defined data associated with a bind handle - * - * @param bnd - Bind handle - * - * @return - * - The pointer to variable/array passed to an OCI_BindXXX() or - * OCI_BindArrayOfXXX() call - * - */ - -OCI_EXPORT void * OCI_API OCI_BindGetData -( - OCI_Bind *bnd -); - -/** - * @brief - * Return the statement handle associated with a bind handle - * - * @param bnd - bind handle - * - */ - -OCI_EXPORT OCI_Statement * OCI_API OCI_BindGetStatement -( - OCI_Bind *bnd -); - -/** - * @brief - * Set the actual size of the element held by the given bind handle - * - * @param bnd - bind handle - * @param size - data size - * - * @note - * This call is not mandatory and should ONLY be called for RAWs binds to set - * the real size of the given data if different from the expected column or - * parameter size - * - * @note - * It works as well with string based PL/SQL tables (in or in/out but NOT out) - * even if it's not necessary. - * - * @warning - * For binds of type OCI_CDT_TEXT (strings), the parameter 'size' is expressed in - * number of characters. - * - * @return - * Data size if the bind type is listed above otherwise 0. - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetDataSize -( - OCI_Bind *bnd, - unsigned int size -); - -/** - * @brief - * Set the size of the element at the given position in - * the bind input array - * - * @param bnd - bind handle - * @param position - Position in the array - * @param size - data size - * - * @note - * See OCI_BindSetDataSize() for supported data types - * - * @warning - * Before execution, it returns the max default size for the bind and not the real - * data size, unless a custom size has been set with OCI_BindSetDataSizeXXX() - * After execution, it returns the real data size. - * - * @warning - * For binds of type OCI_CDT_TEXT (strings), the parameter 'size' is expressed in - * number of characters. - * - * @return - * Data size if the bind type is listed above otherwise 0. - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetDataSizeAtPos -( - OCI_Bind *bnd, - unsigned int position, - unsigned int size -); - -/** - * @brief - * Return the actual size of the element held by the given bind handle - * - * @param bnd - bind handle - * - * @note - * See OCI_BindSetDataSize() for supported data types - * - * @warning - * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in - * number of characters. - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSize -( - OCI_Bind *bnd -); - -/** - * @brief - * Return the actual size of the element at the given position in - * the bind input array - * - * @param bnd - bind handle - * @param position - Position in the array - * - * @note - * See OCI_BindSetDataSize() for supported data types - * - * @warning - * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in - * number of characters. - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSizeAtPos -( - OCI_Bind *bnd, - unsigned int position -); - -/** - * @brief - * Set the bind variable to null - * - * @param bnd - Bind handle - * - * @note - * There is no notion of null value in C. - * It's necessary to explicitly tell Oracle that the bind has a null value. - * It must be done before an OCI_Execute() call - * - * @note - * For handled based data types (non scalar types), OCILIB performs an extra - * check on handles and set the bind status to null is the handle is null - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetNull -( - OCI_Bind *bnd -); - -/** - * @brief - * Set to null the entry in the bind variable input array - * - * @param bnd - Bind handle - * @param position - Position in the array - * - * @note - * There is no notion of null value in C. - * It's necessary to explicitly tell Oracle that the bind has a null value. - * It must be done before an OCI_Execute() call - * - * @warning - * Position starts with 1 - * - * @note - * For handled based data types (non scalar types), OCILIB performs an extra - * check on handles and set the bind status to null is the handle is null - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetNullAtPos -( - OCI_Bind *bnd, - unsigned int position -); - -/** - * @brief - * Set the bind variable to NOT null - * - * @param bnd - Bind handle - * - * @note - * There is no notion of null value in C. - * It's necessary to explicitly tell Oracle that the bind has a null value. - * It must be done before an OCI_Execute() call - * - * @note - * For handled based data types (non scalar types), OCILIB performs an extra - * check on handles and set the bind status to null is the handle is null - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetNotNull -( - OCI_Bind *bnd -); - -/** - * @brief - * Set to NOT null the entry in the bind variable input array - * - * @param bnd - Bind handle - * @param position - Position in the array - * - * @note - * There is no notion of null value in C. - * It's necessary to explicitly tell Oracle that the bind has a null value. - * It must be done before an OCI_Execute() call - * - * @warning - * Position starts with 1 - * - * @note - * For handled based data types (non scalar types), OCILIB performs an extra - * check on handles and set the bind status to null is the handle is null - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_BindSetNotNullAtPos -( - OCI_Bind *bnd, - unsigned int position -); - -/** - * @brief - * Check if the current value of the binded variable is marked as NULL - * - * @param bnd - Bind handle - * - * @return - * TRUE if it's null otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindIsNull -( - OCI_Bind *bnd -); - -/** - * @brief - * Check if the current entry value at the given index of the binded array - * is marked as NULL - * - * @param bnd - Bind handle - * @param position - Position in the array - * - * @warning - * Position starts with 1 - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_BindIsNullAtPos -( - OCI_Bind *bnd, - unsigned int position -); - -/** - * @brief - * Set the charset form of the given character based bind variable - * - * @param bnd - Bind handle - * @param csfrm - charset form - * - * @note - * Possible values are : - * - * - OCI_CSF_DEFAULT : the column has default charset - * - OCI_CSF_NATIONAL: the column has national charset - * - * @note - * This call has to be made after OCI_Prepare() but before OCI_Execute() - * - * @warning - * This call does nothing : - * - if the csform is out of range - * - if the bind type is not OCI_CFT_TEXT or OCI_CDT_LONG - * - * @return - * TRUE on success otherwise FALSE - * - */ - -boolean OCI_API OCI_BindSetCharsetForm -( - OCI_Bind *bnd, - unsigned int csfrm -); - -/** - * @brief - * Get the allocation mode of a bind handle - * - * @param bnd - Bind handle - * - * @note - * Possible values are : - * - OCI_BAM_EXTERNAL : bind variable is allocated by user code - * - OCI_BAM_INTERNAL : bind variable is allocated internally - * - * return the allocation mode on success otherwise OCI_UNKNOWN - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_BindGetAllocationMode -( - OCI_Bind *bnd -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiFetching Fetching data - * @{ - * - * OCILIB offers a really easy and smart mechanism to fetch data from a SQL Statement. - * It looks like what's found in JDBC and other object oriented databases frameworks. - * - * ONLY the following statements can return resultsets that can be fetched by host programs: - * - Statements executing SQL SELECT - * - Statements executing SQL INSERT/UPDATE/DELETE using a RETURNING INTO clause - * - Statements binded to PL/SQL OPEN FOR argument - * - Statements binded to PL/SQL procedure OUT variables - * - Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using - * DBMS_SQL.RETURN_RESULT() - * - * These resultsets are encapsulated in OCILIB by OCI_Resultset objects. - * - * Thus, after any successful call to an OCI_Executexxx() function that executed - * a fetchable statement or filled output bind variables, the resultset can be - * retrieved by calling OCI_GetResultset() - * - * The creation of a OCI_Resultset object consists in : - * - * - Describing the output columns of the resultset - * - Allocating memory to hold the content data - * - * OCILIB supports multi-row fetching for increasing performances. Instead of - * fetching data row by row from the server (that induces lots of round-trips - * between the client and the server), the library prefetches data chunk by - * chunks (default is 20 rows). - * So, less network traffic and better performances. - * These mechanisms are completely hidden from the application which fetches the - * resultset row by row. - * - * Once the Resultset handle is retrieved : - * - * - It can be fetched by calling OCI_FetchNext() as long as it returns TRUE. - * - To retrieve the value of a column, call OCI_GetXXXX() where XXXX is the - * type of data you want to fetch. - * - * @note - * In case of a statement that has executed PL/SQL calls or blocks returning implicit resultsets: - * - OCI_GetResultset() return the first available resultset - * - OCI_GetNextResultset() return the next available resultset until no more resultset available - * - * @par Scrollable Resultsets - * - * Oracle 9i introduced scrollable cursors (resultsets in OCILIB) that can be - * fetched: - * - * - Sequentially in both directions: OCI_FetchPrev() and OCI_FetchNext() - * - To a relative position in the resultset: OCI_FetchSeek() with OCI_SFD_RELATIVE - * - To an absolute position in the resultset: OCI_FetchSeek() with OCI_SFD_ABOSLUTE - * - To the first or last row in the resultset: OCI_FetchFirst() and OCI_FetchLast() - * - * Scrollable statements uses more server and client resources and should only - * be used when necessary. - * - * Resultsets are 'forward only' by default. Call OCI_SetFetchMode() with - * OCI_SFM_SCROLLABLE to enable scrollable resultsets for a given statement. - * - * @warning - * Any use of scrollable fetching functions with a resultset that depends on a - * statement with fetch mode set to OCI_SFM_DEFAULT will fail ! - * - * @warning - * If you intend to use OCI_FetchSeek() on a scrollable statement and if any of the - * selected columns is a ref cursor or a nested table, OCILIB will internally set the - * resultset internal array size to 1 and thus ignore any values set using OCI_SetFetchSize() - * This is performed due to an Oracle bug. - * - * @note - * If the column internal data does not match the requested type, OCILIB tries - * to convert the data when it's possible and throws an error if not. - * - * The properties (columns names, types ...) of the resultset are accessible - * through a set of APIs. - * - * @par Implicit conversion to string types - * - * OCI_GetString() performs an implicit conversion from ANY Oracle types: - * - * - Numerics (based on the current connection handle numeric format) - * - Binary doubles and floats (using the standard C Library functions) - * - OCI_Date : uses OCI_DateToText() with current connection date format - * - OCI_Timestamp : uses OCI_TimestampToText() with current connection date format - * - OCI_Interval : uses OCI_IntervalToText() with Oracle default format - * - OCI_Coll : uses OCI_CollToText() - * - OCI_Object : uses OCI_ObjectToText() - * - OCI_Ref : uses OCI_RefToText() - * - OCI_File : returns "$(folder)/$(filename)" - no content returned - * - OCI_Lob : see note above for binary types - * - OCI_Long : see note above for binary types - * - RAWs : see note above for binary types - * - * @note - * For RAWs and BLOBs attributes, their binary values are converted to hexadecimal strings - * For LONG and CLOBs/NCLOBSs attributes, the whole string content is returned - * - * @note - * The following OCILIB types are not supported for implicit conversion: - * - OCI_Statement - * - * @warning - * For Dates and numerics types, OCILIB uses OCI client calls to perform - * the conversion. - * For binary double and binary floats data types, OCI client functions cannot - * handle the full double range of values. Thus, OCILIB is using the - * standard C library to convert theses data types to string - * - * @par Fetching rows into user structures - * - * It is possible to fetch a complete row into a user defined structure. - * Each column of the resultset is mapped to a structure member. - * The mapping rules are : - * - LOBs (CLOB, NCLOB, BLOB) : OCI_Lob * - * - DATE : OCI_Date * - * - TIMESTAMPS : OCI_Timestamp * - * - INTERVALS : OCI_Interval * - * - LONG, LONG RAW : OCI_Long * - * - REFs : OCI_Ref * - * - CURSOR, RESULSET : OCI_Statement * - * - OBJECTS, UDT : OCI_Object * - * - Character columns (CHAR,VARCHAR, etc..) : otext * - * - All NUMERIC types : - * - default : big_int - * - user defined (see OCI_SetStructNumericType()) - * - * See OCI_GetStruct() and OCI_SetStructNumericType() for more details - * - * @par Fetch Example - * @include fetch.c - * - * @par Fetch Rows into user structures Example - * @include fetch_struct.c - * - * @par Meta data Example - * @include meta.c - * - * @par Ref cursor Example - * @include cursor.c - * - * @par Implicit resultset Example - * @include implicit_resultset.c - * - * @par Scrollable resultset Example - * @include scroll.c - * - */ - -/** - * @brief - * Retrieve the resultset handle from an executed statement - * - * @param stmt - Statement handle - * - * @note - * See @ref OcilibCApiFetching for more details about what statements can return resultsets - * - * @warning - * If the statement has not been prepared and executed, no resultset will be returned - * - * @return - * A resultset handle on success otherwise NULL - * - */ - -OCI_EXPORT OCI_Resultset * OCI_API OCI_GetResultset -( - OCI_Statement *stmt -); - -/** - * @brief - * Free the statement resultsets - * - * @param stmt - Statement handle - * - * @note - * This call is optional. Resultsets are automatically freed when the - * statement is destroyed or when it's reused. - * - * @note - * This function has been introduced for releasing big resultsets when the - * application wants to keep the statement alive and does not know when it - * will be destroyed. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ReleaseResultsets -( - OCI_Statement *stmt -); - -/** - * @brief - * Fetch the next row of the resultset - * - * @param rs - Resultset handle - * - * @note - * OCI_FetchNext() works for normal and scrollable resultsets - * - * @return - * TRUE on success otherwise FALSE if : - * - Empty resultset - * - Last row already fetched - * - An error occurred - * - */ - -OCI_EXPORT boolean OCI_API OCI_FetchNext -( - OCI_Resultset *rs -); - -/** - * @brief - * Fetch the previous row of the resultset - * - * @param rs - Resultset handle - * - * @note - * OCI_FetchPrev() works ONLY for scrollable resultsets - * - * @return - * TRUE on success otherwise FALSE if : - * - Empty resultset - * - First row already fetched - * - An error occurred - * - */ - -OCI_EXPORT boolean OCI_API OCI_FetchPrev -( - OCI_Resultset *rs -); - -/** - * @brief - * Fetch the first row of the resultset - * - * @param rs - Resultset handle - * - * @note - * OCI_FetchFirst() works ONLY for scrollable resultsets - * - * @return - * TRUE on success otherwise FALSE if : - * - Empty resultset - * - An error occurred - *f - */ - -OCI_EXPORT boolean OCI_API OCI_FetchFirst -( - OCI_Resultset *rs -); - -/** - * @brief - * Fetch the last row of the resultset - * - * @param rs - Resultset handle - * - * @note - * OCI_FetchLast() works ONLY for scrollable resultsets - * - * @return - * TRUE on success otherwise FALSE if: - * - Empty resultset - * - An error occurred - * - */ - -OCI_EXPORT boolean OCI_API OCI_FetchLast -( - OCI_Resultset *rs -); - -/** - * @brief - * Custom Fetch of the resultset - * - * @param rs - Resultset handle - * @param mode - Fetch direction - * @param offset - Fetch offset - * - * @note - * Possible values for 'direction' parameter are: - * - OCI_SFD_ABSOLUTE - * - OCI_SFD_RELATIVE - * - * @note - * OCI_FetchSeek() works ONLY for scrollable resultsets - * - * @warning - * If you intend to use OCI_FetchSeek() on a scrollable statement and if any of the - * selected columns is a ref cursor or a nested table, you must set the fetching size - * to 1 using OCI_SetFetchSize() before calling OCI_GetResultset() - * Otherwise OCI_FetchSeek() will fails with a OCI-10002 error - * - * @return - * TRUE on success otherwise FALSE if: - * - Empty resultset - * - An error occurred - * - OCI_SetFetchMode() has not been called with OCI_SFM_SCROLLABLE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FetchSeek -( - OCI_Resultset *rs, - unsigned int mode, - int offset -); - -/** - * @brief - * Retrieve the number of rows fetched so far - * - * @param rs - Resultset handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetRowCount -( - OCI_Resultset *rs -); - -/** - * @brief - * Retrieve the current row number - * - * @param rs - Resultset handle - * - * @note - * - OCI_GetCurrentRow() returns the current row number starting from 1 - * - If the resultset has not been fetched or if the resultset is empty, it returns 0 - * - If the resultset has been fully fetched, it returns the last fetched row number - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetCurrentRow -( - OCI_Resultset *rs -); - -/** - * @brief - * Return the number of columns in the resultset - * - * @param rs - Resultset handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetColumnCount -( - OCI_Resultset *rs -); - -/** - * @brief - * Return the column object handle at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @return - * - Column handle on success - * - NULL if index is out of bounds or on error - * - */ - -OCI_EXPORT OCI_Column * OCI_API OCI_GetColumn -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the column object handle from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * - Column handle on success or - * - NULL if no column found with the given name or on error - * - */ - -OCI_EXPORT OCI_Column * OCI_API OCI_GetColumn2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the index of the column in the result from its name - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @note - * Column indexes start with 1 in OCILIB - * - * @return - * Column index on success or zero on error - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetColumnIndex -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the name of the given column - * - * @param col - Column handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_ColumnGetName -( - OCI_Column *col -); - -/** - * @brief - * Return the type of the given column - * - * @param col - Column handle - * - * @note - * Possible values are : - * - * - OCI_CDT_NUMERIC : short, int, long long, float, double - * - OCI_CDT_DATETIME : OCI_Date * - * - OCI_CDT_TEXT : otext * - * - OCI_CDT_LONG : OCI_Long * - * - OCI_CDT_CURSOR : OCI_Statement * - * - OCI_CDT_LOB : OCI_Lob * - * - OCI_CDT_FILE : OCI_File * - * - OCI_CDT_TIMESTAMP : OCI_Timestamp * - * - OCI_CDT_INTERVAL : OCI_Interval * - * - OCI_CDT_RAW : void * - * - OCI_CDT_OBJECT : OCI_Object * - * - OCI_CDT_COLLECTION : OCI_Coll * - * - OCI_CDT_REF : OCI_Ref * - * - OCI_CDT_BOOLEAN : boolean - * - * @return - * The column type or OCI_CDT_UNKNOWN if index is out of bounds - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetType -( - OCI_Column *col -); - -/** - * @brief - * Return the charset form of the given column - * - * @param col - Column handle - * - * @note - * Possible values are : - * - OCI_CSF_NONE : the column is not an character or lob column - * - OCI_CSF_DEFAULT : the column has server default charset - * - OCI_CSF_NATIONAL : the column has national server charset - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetCharsetForm -( - OCI_Column *col -); - -/** - * @brief - * Return the Oracle SQL type name of the column data type - * - * @param col - Column handle - * - * @note - * For possible values, consults Oracle Documentation - * - */ - -OCI_EXPORT const otext * OCI_API OCI_ColumnGetSQLType -( - OCI_Column *col -); - -/** - * @brief - * Return the Oracle SQL Full name including precision and size of the - * column data type - * - * @param col - Column handle - * @param buffer - buffer to store the full column type name and size - * @param len - max size of the buffer in characters - * - * @note - * This function returns a description that matches the one given by SQL*Plus - * - * @note - * Return the number of characters written into the buffer - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetFullSQLType -( - OCI_Column *col, - otext *buffer, - unsigned int len -); - -/** - * @brief - * Return the size of the column - * - * @note - * For all types, the size is expressed is bytes, excepted for character - * based columns that were created with a character based size or of type NCHAR/NVARCHAR - * - * @param col - Column handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetSize -( - OCI_Column *col -); - -/** - * @brief - * Return the scale of the column for numeric columns - * - * @param col - Column handle - * - */ - -OCI_EXPORT int OCI_API OCI_ColumnGetScale -( - OCI_Column *col -); - -/** - * @brief - * Return the precision of the column for numeric columns - * - * @param col - Column handle - * - */ - -OCI_EXPORT int OCI_API OCI_ColumnGetPrecision -( - OCI_Column *col -); - -/** - * @brief - * Return the fractional precision of the column for timestamp and interval columns - * - * @param col - Column handle - * - */ - -OCI_EXPORT int OCI_API OCI_ColumnGetFractionalPrecision -( - OCI_Column *col -); - -/** - * @brief - * Return the leading precision of the column for interval columns - * - * @param col - Column handle - * - */ - -OCI_EXPORT int OCI_API OCI_ColumnGetLeadingPrecision -( - OCI_Column *col -); - -/** - * @brief - * Return the nullable attribute of the column - * - * @param col - Column handle - * - * @return - * Return TRUE if the column is nullable otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ColumnGetNullable -( - OCI_Column *col -); - -/** - * @brief - * Return TRUE if the length of the column is character-length or FALSE if - * it is byte-length - * - * @param col - Column handle - * - * @note - * This was introduced in Oracle 9i. So for version that are not supporting this - * property, it always return FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ColumnGetCharUsed -( - OCI_Column *col -); - -/** - * @brief - * Return the column property flags - * - * @param col - Column handle - * - * For flags are: - * - OCI_CPF_NONE : The column has no flags or the OCI client does not support this call - * - OCI_CPF_IS_IDENTITY: - * - If Set, the column is an IDENTITY column - * - Otherwise, it is not an IDENTITY column - * - OCI_CPF_IS_GEN_ALWAYS: - * - If set, means that the value is "ALWAYS GENERATED" - * - Otherwise means that the value is "GENERATED BY" - * - OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL: - * - If set, means that the value is generated by default on NULL - * - OCI_CPF_IS_LPART: - * - If set, Column is an implicitly generated logical partitioning column for container_map enabled object - * - OCI_CPF_IS_CONID: - * - If set, Column is a CON_ID column implicitly generated by CONTAINERS() or is an ORIGIN_CON_ID column implicitly generated for Extended Data Link - * - * @note - * This was introduced in Oracle 12cR1. - * For earlier versions, it always return OCI_CPF_NONE - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetPropertyFlags -( - OCI_Column *col -); - -/** -* @brief -* Return the column collation ID -* -* @param col - Column handle -* -* Possible values: -* - OCI_CCI_NONE -* - OCI_CCI_NLS_COMP -* - OCI_CCI_NLS_SORT -* - OCI_CCI_NLS_SORT_CI -* - OCI_CCI_NLS_SORT_AI -* - OCI_CCI_NLS_SORT_CS -* - OCI_CCI_NLS_SORT_VAR1 -* - OCI_CCI_NLS_SORT_VAR1_CI -* - OCI_CCI_NLS_SORT_VAR1_AI -* - OCI_CCI_NLS_SORT_VAR1_CS -* - OCI_CCI_BINARY -* - OCI_CCI_BINARY_CI -* - OCI_CCI_BINARY_AI -* -* @note -* This was introduced in Oracle 12cR2. -* For earlier versions, it always return OCI_CCI_NONE -* -*/ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetCollationID -( - OCI_Column *col -); - -/** - * @brief - * Return the type information object associated to the column - * - * @param col - Column handle - * - * @note - * This call is used only for Named Object typed and collection columns. - * It returns NULL if the column is not a Named Object or a collection. - * - */ - -OCI_EXPORT OCI_TypeInfo * OCI_API OCI_ColumnGetTypeInfo -( - OCI_Column *col -); - -/** - * @brief - * Return the OCILIB object subtype of a column - * - * @param col - Column handle - * - * @note - * This call is valid for the following OCILIB types: - * - * - OCI_CDT_LONG - * - OCI_CDT_LOB - * - OCI_CDT_FILE - * - OCI_CDT_TIMESTAMP - * - OCI_CDT_INTERVAL - * - OCI_CDT_NUMERIC - * - * For OCI_Long type the possible values are: - * - OCI_BLONG - * - OCI_CLONG - * - * For OCI_Lob type the possible values are: - * - OCI_BLOB - * - OCI_CLOB - * - OCI_NCLOB - * - * For OCI_File type the possible values are: - * - OCI_BFILE - * - OCI_CFILE - * - * For OCI_Timestamp type the possible values are: - * - OCI_TIMESTAMP - * - OCI_TIMESTAMP_TZ - * - OCI_TIMESTAMP_LTZ - * - * For OCI_Interval type the possible values are: - * - OCI_INTERVAL_YM - * - OCI_INTERVAL_DS - * - * For numeric columns the possible values are: - * - OCI_NUM_SHORT - * - OCI_NUM_INT - * - OCI_NUM_BIGINT - * - OCI_NUM_USHORT - * - OCI_NUM_UINT - * - OCI_NUM_BIGUINT - * - OCI_NUM_DOUBLE - * - OCI_NUM_FLOAT - * - OCI_NUM_NUMBER - * - * @warning - * For numeric columns, the value may be not accurate at all! - * OCI does not allow to find out the real SQL precise type of an numeric column (int, real, ...). - * OCI based libraries can only 'guess' some types in some situations : float, binary_float, binary_float, number. - * For example: - * - with the statement 'select 101 from dual', OCI would report numeric type NUMBER. - * - if a column is declared as "INT", OCI would report also NUMBER. - * - * - * @note - * For all other OCILIB types, it returns OCI_UNKNOWN - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ColumnGetSubType -( - OCI_Column *col -); - -/** - * @brief - * set the numeric data type of the given structure member (identified from position in the - * resultset) to retrieve when calling OCI_GetStruct() - * - * @param rs - Resultset handle - * @param index - Column position - * @param type - Numeric type - * - * @note - * Possible values for parameter 'type' : - * - OCI_NUM_SHORT - * - OCI_NUM_USHORT - * - OCI_NUM_INT - * - OCI_NUM_UINT - * - OCI_NUM_BIGINT - * - OCI_NUM_BIGUINT - * - OCI_NUM_DOUBLE - * - OCI_NUM_FLOAT - * - OCI_NUM_NUMBER - * - * @return - * Return TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetStructNumericType -( - OCI_Resultset *rs, - unsigned int index, - unsigned int type -); - -/** - * @brief - * set the numeric data type of the given structure member (identified from column name in the - * resultset) to retrieve when calling OCI_GetStruct() - * - * @param rs - Resultset handle - * @param name - Column name - * @param type - Numeric type - * - * @note - * Possible values for parameter 'type' : - * - OCI_NUM_SHORT - * - OCI_NUM_USHORT - * - OCI_NUM_INT - * - OCI_NUM_UINT - * - OCI_NUM_BIGINT - * - OCI_NUM_BIGUINT - * - OCI_NUM_DOUBLE - * - OCI_NUM_FLOAT - * - OCI_NUM_NUMBER - * - * @return - * Return TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetStructNumericType2 -( - OCI_Resultset *rs, - const otext *name, - unsigned int type -); - -/** - * @brief - * Return the row columns values into a single structure - * - * @param rs - Resultset handle - * @param row_struct - pointer to user row structure - * @param row_struct_ind - pointer to user indicator structure - * - * @note - * Structure members values are contextual to the current row. - * The returned values can get out of scope when the current row - * changes when calling any OCI_FecthXXX() calls - * - * @par User row structure - * - * The user structure must have the same members than the resultset. - * Each column in the resultset must have its equivalent in the structure. - * Fields must be in the same order. - * - * The mapping rules are : - * - * - LOBs (CLOB, NCLOB, BLOB) : OCI_Lob * - * - DATE : OCI_Date * - * - TIMESTAMPS : OCI_Timestamp * - * - INTERVALS : OCI_Interval * - * - LONG, LONG RAW : OCI_Long * - * - REFs : OCI_Ref * - * - CURSOR, RESULSET : OCI_Statement * - * - OBJECTS, UDT : OCI_Object * - * - Character columns (CHAR,VARCHAR, etc..) : otext * - * - All NUMERIC types : - * - default : big_int - * - user defined (see OCI_SetStructNumericType()) - * - * The user structure pointer is not mandatory - * - * @par User row indicator structure - - * This structure must have one boolean field per column in - * the resultset and respect in the same member order. - * - * If the value of the given member is TRUE, it means the value in - * the user row structure is NOT NULL, otherwise its NULL - * - * The user indicator structure pointer is mandatory - * - * @return - * Return TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_GetStruct -( - OCI_Resultset *rs, - void *row_struct, - void *row_struct_ind -); - -/** -* @brief -* Return the current Number value of the column at the given index in the resultset -* -* @param rs - Resultset handle -* @param index - Column position -* -* @note -* Column position starts at 1. -* -* @return -* The column current row value or 0 if index is out of bounds -* -*/ -OCI_EXPORT OCI_Number * OCI_API OCI_GetNumber -( - OCI_Resultset *rs, - unsigned int index -); - -/** -* @brief -* Return the current number value of the column from its name in the resultset -* -* @param rs - Resultset handle -* @param name - Column name -* -* @note -* The column name is case insensitive -* -* @return -* The column current row value or 0 if no column found with the given name -* -*/ - -OCI_EXPORT OCI_Number * OCI_API OCI_GetNumber2 -( - OCI_Resultset *rs, - const otext *name -); - - -/** - * @brief - * Return the current short value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0 if index is out of bounds - * - */ - -OCI_EXPORT short OCI_API OCI_GetShort -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current short value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0 if no column found with the given name - * - */ - -OCI_EXPORT short OCI_API OCI_GetShort2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current unsigned short value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0 if index is out of bounds - * - */ - -OCI_EXPORT unsigned short OCI_API OCI_GetUnsignedShort -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current unsigned short value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0 if no column found with the given name - * - */ - -OCI_EXPORT unsigned short OCI_API OCI_GetUnsignedShort2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current integer value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0 if index is out of bounds - * - */ - -OCI_EXPORT int OCI_API OCI_GetInt -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current integer value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0 if no column found with the given name - * - */ - -OCI_EXPORT int OCI_API OCI_GetInt2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current unsigned integer value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0 if index is out of bounds - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetUnsignedInt -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current unsigned integer value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0 if no column found with the given name - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetUnsignedInt2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current big integer value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0 if index is out of bounds - * - */ - -OCI_EXPORT big_int OCI_API OCI_GetBigInt -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current big integer value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0 if no column found with the given name - * - */ - -OCI_EXPORT big_int OCI_API OCI_GetBigInt2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current unsigned big integer value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0 if index is out of bounds - * - */ - -OCI_EXPORT big_uint OCI_API OCI_GetUnsignedBigInt -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current unsigned big integer value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0 if no column found with the given name - * - */ - -OCI_EXPORT big_uint OCI_API OCI_GetUnsignedBigInt2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current string value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @note - * OCI_GetString() performs an implicit conversion from the - * following data types: - * - * - Numerics (based on the current connection handle numeric format) - * - Binary doubles and floats (using the standard C Library functions) - * - OCI_Number (based on the current connection handle numeric format) - * - OCI_Date (based on the current connection handle date format) - * - OCI_Timestamp (based on the current connection handle date format) - * - OCI_Interval (based on Oracle default conversion) - * - OCI_Lob (for BLOBs, output is expressed in hexadecimal) - * - OCI_Long (for BLONGs, output is expressed in hexadecimal) - * - OCI_File ("[directory]/[name]" will be output) - * - OCI_Object (Textual SQL string representation) - * - OCI_Coll (Textual SQL string representation) - * - RAW buffer (expressed in hexadecimal) - * - OCI_Statement (SQL statement string or cursor name) - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetString -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current string value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT const otext * OCI_API OCI_GetString2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Copy the current raw value of the column at the given index into the specified buffer - * - * @param rs - Resultset handle - * @param index - Column position - * @param buffer - Buffer that receive the raw value - * @param len - Max size of the input buffer in bytes - * - * @note - * Column position starts at 1. - * - * @return - * Number of bytes copied into the buffer on SUCCESS otherwise 0 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetRaw -( - OCI_Resultset *rs, - unsigned int index, - void *buffer, - unsigned int len -); - -/** - * @brief - * Copy the current raw value of the column from its name into the specified buffer - * - * @param rs - Resultset handle - * @param name - Column name - * @param buffer - Buffer that receive the raw value - * @param len - Max size of the input buffer - * - * @note - * The column name is case insensitive - * - * @return - * Number of bytes copied into the buffer on SUCCESS otherwise 0 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetRaw2 -( - OCI_Resultset *rs, - const otext *name, - void *buffer, - unsigned int len -); - -/** - * @brief - * Return the current double value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0.O if index is out of bounds - * - */ - -OCI_EXPORT double OCI_API OCI_GetDouble -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current double value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0.0 if no column found with the given name - * - */ - -OCI_EXPORT double OCI_API OCI_GetDouble2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current float value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or 0.O if index is out of bounds - * - */ - -OCI_EXPORT float OCI_API OCI_GetFloat -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current float value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @note - * The column name is case insensitive - * - * @return - * The column current row value or 0.0 if no column found with the given name - * - */ - -OCI_EXPORT float OCI_API OCI_GetFloat2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current date value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Date * OCI_API OCI_GetDate -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current date value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Date * OCI_API OCI_GetDate2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current timestamp value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Timestamp * OCI_API OCI_GetTimestamp -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current timestamp value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Timestamp * OCI_API OCI_GetTimestamp2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current interval value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Interval * OCI_API OCI_GetInterval -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current interval value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Interval * OCI_API OCI_GetInterval2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current cursor value (Nested table) of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Statement * OCI_API OCI_GetStatement -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current cursor value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Statement * OCI_API OCI_GetStatement2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current lob value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Lob * OCI_API OCI_GetLob -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current lob value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Lob * OCI_API OCI_GetLob2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current File value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_File * OCI_API OCI_GetFile -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current File value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_File * OCI_API OCI_GetFile2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current Object value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_GetObject -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current Object value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_GetObject2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current Collection value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Coll * OCI_API OCI_GetColl -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current Collection value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Coll * OCI_API OCI_GetColl2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current Ref value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Ref * OCI_API OCI_GetRef -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current Ref value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Ref * OCI_API OCI_GetRef2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the current Long value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row value or NULL if index is out of bounds - * - */ - -OCI_EXPORT OCI_Long * OCI_API OCI_GetLong -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the current Long value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * The column current row value or NULL if no column found with the given name - * - */ - -OCI_EXPORT OCI_Long * OCI_API OCI_GetLong2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Check if the current row value is null for the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * TRUE if it's null otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IsNull -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the size of the value of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @warning - * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in - * number of characters. - * - * @return value size of 0 if the value is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetDataSize -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @brief - * Return the size of the value of the column from its name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @warning - * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in - * number of characters. - * - * @return value size of 0 if the value is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetDataSize2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Check if the current row value is null for the column of the given name in the resultset - * - * @param rs - Resultset handle - * @param name - Column name - * - * @return - * TRUE if it's null otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IsNull2 -( - OCI_Resultset *rs, - const otext *name -); - -/** - * @brief - * Return the statement handle associated with a resultset handle - * - * @param rs - resultset handle - * - */ - -OCI_EXPORT OCI_Statement * OCI_API OCI_ResultsetGetStatement -( - OCI_Resultset *rs -); - -/** - * @brief - * Return the current row data length of the column at the given index in the resultset - * - * @param rs - Resultset handle - * @param index - Column position - * - * @note - * Column position starts at 1. - * - * @return - * The column current row data length or 0 if index is out of bounds - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetDataLength -( - OCI_Resultset *rs, - unsigned int index -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiPlSql PL/SQL Support - * @{ - * - * OCILIB has a strong PL/SQL support : - * - * - Blocks, procedures and function can be used with OCILIB statements. - * - Ref cursors - * - Nested tables - * - Tables (indexed by integer types) - * - Access to the server side output generated by the DBMS_OUTPUT package - * - * Stored procedures/functions calls, blocks declarations are done like regular - * SQL calls using OCI_Prepare(), OCI_Execute(), OCI_ExecuteStmt() and - * OCI_ExecuteStmtFmt() functions. - * - * All PL/SQL statements must: - * - * - start with a 'begin' or 'declare' keyword - * - end with a 'end;' keyword - * - * Binding Host arrays to PL/SQL tables is done with OCI_BindArrayXXX() calls - * - * @par Using a PL/SQL block with OCILIB - * @include plsql_block.c - * - * @par Binding host arrays to PL/SQL tables parameters of a stored procedure - * @include plsql_table.c - * - * @par Retrieve the output generated by the dbms_output package on the server - * @include output.c - * - */ - -/** - * @brief - * Enable the server output - * - * @param con - Connection handle - * @param bufsize - server buffer max size (server side) - * @param arrsize - number of lines to retrieve per server round-trip - * @param lnsize - maximum size of one line - * - * @note - * This call is equivalent to the command 'set serveroutput on' in SQL*PLUS - * - * @note - * 'bufsize' minimum value is 2000, maximum 1000000 with Oracle < 10.2g and can be unlimited above - * - * @note - * 'lnsize' maximum value is 255 with Oracle < 10g R2 and 32767 above - * - * @warning - * If OCI_ServerEnableOutput() is not called, OCI_ServerGetOutput() will return NULL - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ServerEnableOutput -( - OCI_Connection *con, - unsigned int bufsize, - unsigned int arrsize, - unsigned int lnsize -); - -/** - * @brief - * Disable the server output - * - * @param con - Connection handle - * - * @note - * After this call, OCI_ServerGetOutput() will return NULL. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ServerDisableOutput -( - OCI_Connection *con -); - -/** - * @brief - * Retrieve one line of the server buffer - * - * @param con - Connection handle - * - * @note - * Internally, OCILIB gets the server buffer through an array of lines in - * order to minimize round-trips with the server - * - * @return - * return a server output buffer line or NULL if the server buffer is empty - * - */ - -OCI_EXPORT const otext * OCI_API OCI_ServerGetOutput -( - OCI_Connection *con -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiCollections Oracle collections (VARRAYS and Nested Tables) - * @{ - * - * OCILIB supports all Oracle collections: - * - * - PL/SQL Tables: only available in PL/SQL, unbounded, sparse arrays of - homogeneous elements. - * - VARRAYS : available in SQL and PL/SQL, they are bounded arrays of - * homogeneous elements - * - Nested Tables: available in SQL and PL/SQL, they are unbounded arrays of - * homogeneous elements and can become sparse through deletions - * - * PL/SQL tables are implemented by binding regular C arrays with the array - * interface (using OCI_BindArrayOfXXX() calls) - * - * VARRAYS and Nested tables are implemented in OCILIB with the type OCI_Coll. - * It's possible to bind and fetch VARRAYS and Nested tables using OCI_Coll handle. - * - * It's also possible to declare local collections based on some database type without using queries - * - * OCI (and thus OCILIB) offers the possibility to access collection elements : - * - * - directly by index (OCI_CollGetElem() and OCI_CollSetElem()) - * - using an iterator (OCI_Iter) to iterate through the collection - * (OCI_IterGetNext(), OCI_IterGetPrev()) - * - * Collection Items are implemented through the type OCI_Elem and use the series - * of calls OCI_ElemGetXXX() and OCI_ElemSetXXX() to manipulate elements - * content values - * - * @par Example - * @include coll.c - * - */ - -/** - * @brief - * Create a local collection instance - * - * @param typinf - Type info handle of the collection type descriptor - * - * @return - * Return the collection object handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Coll * OCI_API OCI_CollCreate -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Free a local collection - * - * @param coll - Collection handle - * - * @warning - * Only collection created with OCI_CollCreate() should be freed - * by OCI_CollFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollFree -( - OCI_Coll *coll -); - -/** - * @brief - * Create an array of Collection object - * - * @param con - Connection handle - * @param typinf - Object type (type info handle) - * @param nbelem - number of elements in the array - * - * @note - * see OCI_ObjectCreate() for more details - * - * @return - * Return the Collection handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Coll ** OCI_API OCI_CollArrayCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -/** - * @brief - * Free an array of Collection objects - * - * @param colls - Array of Collection objects - * - * @warning - * Only arrays of Collection created with OCI_CollArrayCreate() - * should be freed by OCI_CollArrayFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollArrayFree -( - OCI_Coll **colls -); - -/** - * @brief - * Assign a collection to another one - * - * @param coll - Destination Collection handle - * @param coll_src - Source Collection handle - * - * @note - * Oracle proceeds to a deep copy of the collection content - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollAssign -( - OCI_Coll *coll, - OCI_Coll *coll_src -); - -/** - * @brief - * Return the type info object associated to the collection - * - * @param coll - Collection handle - * - */ - -OCI_EXPORT OCI_TypeInfo * OCI_API OCI_CollGetTypeInfo -( - OCI_Coll *coll -); - -/** - * @brief - * Return the collection type - * - * @param coll - Collection handle - * - * @note - * Current collection types are: - * - * - OCI_COLL_VARRAY: Oracle VARRAY - * - OCI_COLL_NESTED_TABLE: Oracle Nested Table - * - * @return - * Collection type or OCI_UNKNOWN if the collection handle is null - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_CollGetType -( - OCI_Coll *coll -); - -/** - * @brief - * Returns the maximum number of elements of the given collection. - * - * @param coll - Collection handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_CollGetMax -( - OCI_Coll *coll -); - -/** - * @brief - * Returns the total number of elements of the given collection. - * - * @param coll - Collection handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_CollGetSize -( - OCI_Coll *coll -); - -/** - * @brief - * Returns the current number of elements of the given collection. - * - * @note - * - For VARRAYs, it returns the same value than OCI_CollGetSize() as VARRAYs cannot contains holes - * - For Nested Tables that are spare collections that can have holes, it returns the total number - * of elements minus the total of deleted elements - * - * @param coll - Collection handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_CollGetCount -( - OCI_Coll *coll -); - -/** - * @brief - * Trims the given number of elements from the end of the collection - * - * @param coll - Collection handle - * @param nb_elem - Number of elements to trim - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollTrim -( - OCI_Coll *coll, - unsigned int nb_elem -); - -/** - * @brief - * clear all items of the given collection - * - * @param coll - Collection handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollClear -( - OCI_Coll *coll -); - -/** - * @brief - * Return the element at the given position in the collection - * - * @param coll - Collection handle - * @param index - Index of the destination element - * - * @note - * Collection indexes start at position 1. - * - * @return - * Element handle on success otherwise FALSE - * - */ - -OCI_EXPORT OCI_Elem * OCI_API OCI_CollGetElem -( - OCI_Coll *coll, - unsigned int index -); - -/** - * @brief - * Return the element at the given position in the collection - * - * @param coll - Collection handle - * @param index - Index of the destination element - * @param elem - Element handle to hold the collection item data - * - * @note - * Collection indexes start at position 1. - * - * @return - * Element handle on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollGetElem2 -( - OCI_Coll *coll, - unsigned int index, - OCI_Elem *elem -); - -/** - * @brief - * Assign the given element value to the element at the given position in - * the collection - * - * @param coll - Collection handle - * @param index - Index of the destination element - * @param elem - Source element handle to assign - * - * @note - * Collection indexes start at position 1. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollSetElem -( - OCI_Coll *coll, - unsigned int index, - OCI_Elem *elem -); - -/** - * @brief - * Append the given element at the end of the collection - * - * @param coll - Collection handle - * @param elem - Element handle to add - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollAppend -( - OCI_Coll *coll, - OCI_Elem *elem -); - -/** - * @brief - * Convert a collection handle value to a string - * - * @param coll - Collection handle - * @param size - Destination string length pointer in characters - * @param str - Destination string - * - * @note - * In order to compute the needed string length, call the method with a NULL string - * Then call the method again with a valid buffer - * - * @note - * The resulting string is similar to the SQL*PLUS output for collections - * For RAWs and BLOBs attributes, their binary values are converted to hexadecimal strings - * - * @warning - * This convenient method shall not be used when performance matters. It is usually called twice (buffer length - * computation) and must also care about quotes within strings. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollToText -( - OCI_Coll *coll, - unsigned int *size, - otext *str -); - -/** - * @brief - * Delete the element at the given position in the Nested Table Collection - * - * @param coll - Collection handle - * @param index - Index of the element to delete - * - * @note - * Collection indexes start at position 1. - * - * @warning - * OCI_CollDeleteElem() is only valid for nested tables. - * - * @return - * - if the input collection is a nested table, it returns TRUE if the element - * is successfully deleted otherwise FALSE on error - * - if the input collection is a VARRAY, it always returns FALSE without spawning an exception - * - */ - -OCI_EXPORT boolean OCI_API OCI_CollDeleteElem -( - OCI_Coll *coll, - unsigned int index -); - -/** - * @brief - * Create an iterator handle to iterate through a collection - * - * @param coll - Collection handle - * - * @return - * Return the iterator handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Iter * OCI_API OCI_IterCreate -( - OCI_Coll *coll -); - -/** - * @brief - * Free an iterator handle - * - * @param iter - Iterator handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IterFree -( - OCI_Iter *iter -); - -/** - * @brief - * Get the next element in the collection - * - * @param iter - Iterator handle - * - * @return - * Element handle on success otherwise NULL if: - * - Empty collection - * - Iterator already positioned on the last collection element - * - An error occurred - * - */ - -OCI_EXPORT OCI_Elem * OCI_API OCI_IterGetNext -( - OCI_Iter *iter -); - -/** - * @brief - * Get the previous element in the collection - * - * @param iter - Iterator handle - * - * @return - * Element handle on success otherwise NULL if: - * - Empty collection - * - Iterator already positioned on the last collection element - * - An error occurred - * - */ - -OCI_EXPORT OCI_Elem * OCI_API OCI_IterGetPrev -( - OCI_Iter *iter -); - -/** - * @brief - * Get the current element in the collection - * - * @param iter - Iterator handle - * - * @return - * Element handle on success otherwise NULL if: - * - Empty collection - * - Iterator already positioned on the last collection element - * - An error occurred - * - */ - -OCI_EXPORT OCI_Elem * OCI_API OCI_IterGetCurrent -( - OCI_Iter *iter -); - -/** - * @brief - * Create a local collection element instance based on a collection type - * descriptor - * - * @param typinf - Type info handle - * - * @return - * Return the collection element handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Elem * OCI_API OCI_ElemCreate -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Free a local collection element - * - * @param elem - Element handle - * - * @warning - * Only element created with OCI_ElemCreate() should be freed - * by OCI_ElemFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemFree -( - OCI_Elem *elem -); - -/** -* @brief -* Return the boolean value of the given collection element -* -* @param elem - Element handle -* -* @warning -* OCI_ElemGetBoolean() returns a valid value only for collection elements of PL/SQL boolean type -* -* @return -* boolean value or FALSE on failure -* -*/ - -OCI_EXPORT boolean OCI_API OCI_ElemGetBoolean -( - OCI_Elem *elem -); - -/** -* @brief -* Return the number value of the given collection element -* -* @param elem - Element handle -* -* @return -* number handle or NULL on failure -* -*/ - -OCI_EXPORT OCI_Number* OCI_API OCI_ElemGetNumber -( - OCI_Elem *elem -); - -/** - * @brief - * Return the short value of the given collection element - * - * @param elem - Element handle - * - * @return - * Short value or 0 on failure - * - */ - -OCI_EXPORT short OCI_API OCI_ElemGetShort -( - OCI_Elem *elem -); - -/** - * @brief - * Return the unsigned short value of the given collection element - * - * @param elem - Element handle - * - * @return - * Unsigned short value or 0 on failure - * - */ - -OCI_EXPORT unsigned short OCI_API OCI_ElemGetUnsignedShort -( - OCI_Elem *elem -); - -/** - * @brief - * Return the int value of the given collection element - * - * @param elem - Element handle - * - * @return - * Int value or 0 on failure - * - */ - -OCI_EXPORT int OCI_API OCI_ElemGetInt -( - OCI_Elem *elem -); - -/** - * @brief - * Return the unsigned int value of the given collection element - * - * @param elem - Element handle - * - * @return - * Unsigned int value or 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ElemGetUnsignedInt -( - OCI_Elem *elem -); - -/** - * @brief - * Return the big int value of the given collection element - * - * @param elem - Element handle - * - * @return - * Big int value or 0 on failure - * - */ - -OCI_EXPORT big_int OCI_API OCI_ElemGetBigInt -( - OCI_Elem *elem -); - -/** - * @brief - * Return the unsigned big int value of the given collection element - * - * @param elem - Element handle - * - * @return - * Unsigned big int value or 0 on failure - * - */ - -OCI_EXPORT big_uint OCI_API OCI_ElemGetUnsignedBigInt -( - OCI_Elem *elem -); - -/** - * @brief - * Return the Double value of the given collection element - * - * @param elem - Element handle - * - * @return - * Double value or 0 on failure - * - */ - -OCI_EXPORT double OCI_API OCI_ElemGetDouble -( - OCI_Elem *elem -); - -/** - * @brief - * Return the float value of the given collection element - * - * @param elem - Element handle - * - * @return - * Double value or 0 on failure - * - */ - -OCI_EXPORT float OCI_API OCI_ElemGetFloat -( - OCI_Elem *elem -); - -/** - * @brief - * Return the String value of the given collection element - * - * @param elem - Element handle - * - * @return - * String value or NULL on failure - * - */ - -OCI_EXPORT const otext * OCI_API OCI_ElemGetString -( - OCI_Elem *elem -); - -/** - * @brief - * Read the RAW value of the collection element into the given buffer - * - * @param elem - Element handle - * @param value - Buffer to store the RAW value - * @param len - Size of the buffer - * - * @return - * Number of bytes read from the RAW value or 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ElemGetRaw -( - OCI_Elem *elem, - void *value, - unsigned int len -); - -/** -* @brief -* Return the raw attribute value size of the given element handle -* -* @param elem - Element handle -* -* @return -* size in bytes of the RAW value or 0 on failure or wrong attribute type -* -*/ - -OCI_EXPORT unsigned int OCI_API OCI_ElemGetRawSize -( - OCI_Elem *elem -); - -/** - * @brief - * Return the Date value of the given collection element - * - * @param elem - Element handle - * - * @return - * Date handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Date * OCI_API OCI_ElemGetDate -( - OCI_Elem *elem -); - -/** - * @brief - * Return the Timestamp value of the given collection element - * - * @param elem - Element handle - * - * @return - * Timestamp handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Timestamp * OCI_API OCI_ElemGetTimestamp -( - OCI_Elem *elem -); - -/** - * @brief - * Return the Interval value of the given collection element - * - * @param elem - Element handle - * - * @return - * Interval handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Interval * OCI_API OCI_ElemGetInterval -( - OCI_Elem *elem -); - -/** - * @brief - * Return the Lob value of the given collection element - * - * @param elem - Element handle - * - * @return - * Lob handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Lob * OCI_API OCI_ElemGetLob -( - OCI_Elem *elem -); - -/** - * @brief - * Return the File value of the given collection element - * - * @param elem - Element handle - * - * @return - * File handle or NULL on failure - * - */ - -OCI_EXPORT OCI_File * OCI_API OCI_ElemGetFile -( - OCI_Elem *elem -); - -/** - * @brief - * Return the object value of the given collection element - * - * @param elem - Element handle - * - * @return - * Object handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_ElemGetObject -( - OCI_Elem *elem -); - -/** - * @brief - * Return the collection value of the given collection element - * - * @param elem - Element handle - * - * @return - * Collection handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Coll * OCI_API OCI_ElemGetColl -( - OCI_Elem *elem -); - -/** - * @brief - * Return the Ref value of the given collection element - * - * @param elem - Element handle - * - * @return - * Ref handle or NULL on failure - * - */ - -OCI_EXPORT OCI_Ref * OCI_API OCI_ElemGetRef -( - OCI_Elem *elem -); - -/** -* @brief -* Set a boolean value to a collection element -* -* @param elem - Element handle -* @param value - Short value -* -* @warning -* OCI_ElemSetBoolean() is only valid value only for collection elements of PL / SQL boolean type -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_ElemSetBoolean -( - OCI_Elem *elem, - boolean value -); - -/** -* @brief -* Set a number value to a collection element -* -* @param elem - Element handle -* @param value - number value -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_ElemSetNumber -( - OCI_Elem *elem, - OCI_Number *value -); - -/** - * @brief - * Set a short value to a collection element - * - * @param elem - Element handle - * @param value - Short value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetShort -( - OCI_Elem *elem, - short value -); - -/** - * @brief - * Set a unsigned short value to a collection element - * - * @param elem - Element handle - * @param value - Unsigned short value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedShort -( - OCI_Elem *elem, - unsigned short value -); - -/** - * @brief - * Set a int value to a collection element - * - * @param elem - Element handle - * @param value - Int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetInt -( - OCI_Elem *elem, - int value -); - -/** - * @brief - * Set a unsigned int value to a collection element - * - * @param elem - Element handle - * @param value - Unsigned int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedInt -( - OCI_Elem *elem, - unsigned int value -); - -/** - * @brief - * Set a big int value to a collection element - * - * @param elem - Element handle - * @param value - big int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetBigInt -( - OCI_Elem *elem, - big_int value -); - -/** - * @brief - * Set a unsigned big_int value to a collection element - * - * @param elem - Element handle - * @param value - Unsigned big int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedBigInt -( - OCI_Elem *elem, - big_uint value -); - -/** - * @brief - * Set a double value to a collection element - * - * @param elem - Element handle - * @param value - Double value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetDouble -( - OCI_Elem *elem, - double value -); - -/** - * @brief - * Set a float value to a collection element - * - * @param elem - Element handle - * @param value - float value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetFloat -( - OCI_Elem *elem, - float value -); - -/** - * @brief - * Set a string value to a collection element - * - * @param elem - Element handle - * @param value - String value - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetString -( - OCI_Elem *elem, - const otext *value -); - -/** - * @brief - * Set a RAW value to a collection element - * - * @param elem - Element handle - * @param value - Raw value - * @param len - Size of the raw value - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetRaw -( - OCI_Elem *elem, - void *value, - unsigned int len -); - -/** - * @brief - * Assign a Date handle to a collection element - * - * @param elem - Element handle - * @param value - Date Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetDate -( - OCI_Elem *elem, - OCI_Date *value -); - -/** - * @brief - * Assign a Timestamp handle to a collection element - * - * @param elem - Element handle - * @param value - Timestamp Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetTimestamp -( - OCI_Elem *elem, - OCI_Timestamp *value -); - -/** - * @brief - * Assign an Interval handle to a collection element - * - * @param elem - Element handle - * @param value - Interval Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetInterval -( - OCI_Elem *elem, - OCI_Interval *value -); - -/** - * @brief - * Assign a Collection handle to a collection element - * - * @param elem - Element handle - * @param value - Collection Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetColl -( - OCI_Elem *elem, - OCI_Coll *value -); - -/** - * @brief - * Assign an Object handle to a collection element - * - * @param elem - Element handle - * @param value - Object Handle - * - * @warning - * This function assigns a copy of the object to the given attribute. - * Any further modifications of the object passed as the parameter 'value' - * will not be reflected to object 's attribute set with this call - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetObject -( - OCI_Elem *elem, - OCI_Object *value -); - -/** - * @brief - * Assign a Lob handle to a collection element - * - * @param elem - Element handle - * @param value - Lob Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetLob -( - OCI_Elem *elem, - OCI_Lob *value -); - -/** - * @brief - * Assign a File handle to a collection element - * - * @param elem - Element handle - * @param value - File Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetFile -( - OCI_Elem *elem, - OCI_File *value -); - -/** - * @brief - * Assign a Ref handle to a collection element - * - * @param elem - Element handle - * @param value - Ref Handle - * - * @note - * passing a null pointer for value calls OCI_ElemSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetRef -( - OCI_Elem *elem, - OCI_Ref *value -); - -/** - * @brief - * Check if the collection element value is null - * - * @param elem - Element handle - * - * @return - * TRUE if it's null otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemIsNull -( - OCI_Elem *elem -); - -/** - * @brief - * Set a collection element value to null - * - * @param elem - Element handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ElemSetNull -( - OCI_Elem *elem -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiFeatureReturningInto Oracle Returning feature - * @{ - * - * OCILIB supports the Oracle feature 'Returning into' for DML statements. - * - * Let's Oracle talk about this features: - * - * @par - * 'Using the RETURNING clause with a DML statement allows you to essentially - * combine two SQL statements into one, possibly saving you a server round-trip. - * This is accomplished by adding an extra clause to the traditional UPDATE, - * INSERT, and DELETE statements. The extra clause effectively adds a query to - * the DML statement. In the OCI, the values are returned to the application - * through the use of OUT bind variables.' - * - * OCILIB implements this features by providing a set of functions that allows - * to register output placeholders for the returned values. - * Once the DML is executed with OCI_Execute(), the output returned data is - * available through a regular resultset object that can be fetched. - * - * @note - * Array binding interface is also supported with 'returning into' DML statement. - * Every iteration (or row of given arrays) generates an resultset object. - * Once a resultset is fetched, the next on can be retrieved with OCI_GetNextResultset() - * - * @par - * - * @note - * OCI_Long are not supported for 'returning into' clause .This is a limitation imposed by Oracle. - * - * @note - * OCI_Column objects retrieved from output OCI_Resultset have the following - * particularities: - * - * - their names are the provided bind names to the DML statement - * (by example, ':out1'). So any call to the functions OCI_GetXXX2() - * should be aware of it - * - The columns detailed SQL attributes might be not all set or accurate. By - * example, the scale and precision are not set, the SQL type is the one - * chosen by OCILIB regarding the OCILIB object data type and might be - * slightly different from the real one. - * - * @par Example - * @include returning.c - * - */ - -/** - * @brief - * Retrieve the next available resultset - * - * @param stmt - Statement handle - * - * @note - * it is only valid for the following statements: - * - Statements executing SQL UPDATE/DELETE using a RETURNING INTO clause - * - Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using - * DBMS_SQL.RETURN_RESULT() - * - * @note - * SQL statements with a 'returning' clause can return multiple resultsets. - * When arrays of program variables are binded to the statement, Oracle will - * execute the statement for every row (iteration). - * Each iteration generates a resultset that can be fetched like regular ones. - * - * @note - * Starting withOracle 12cR1, PL/SQ procedure and blocks ca return multiple implicit resultsets - * Refer to Oracle documentation for more information. - * - * @return - * A resultset handle on success otherwise NULL - * - */ - -OCI_EXPORT OCI_Resultset * OCI_API OCI_GetNextResultset -( - OCI_Statement *stmt -); - -/** -* @brief -* Register a register output bind placeholder -* -* @param stmt - Statement handle -* @param name - Output bind name -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_RegisterNumber -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register a short output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterShort -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register an unsigned short output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterUnsignedShort -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register an integer output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterInt -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register an unsigned integer output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterUnsignedInt -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register a big integer output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterBigInt -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register an unsigned big integer output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterUnsignedBigInt -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register a string output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param len - Max length of single string (in characters) - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterString -( - OCI_Statement *stmt, - const otext *name, - unsigned int len -); - -/** - * @brief - * Register an raw output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param len - Max length of the buffer (in bytes) - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterRaw -( - OCI_Statement *stmt, - const otext *name, - unsigned int len -); - -/** - * @brief - * Register a double output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterDouble -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register a float output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterFloat -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register a date output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterDate -( - OCI_Statement *stmt, - const otext *name -); - -/** - * @brief - * Register a timestamp output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param type - Timestamp type - * - * @note - * See OCI_TimestampCreate() for possible values of parameter 'type' - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterTimestamp -( - OCI_Statement *stmt, - const otext *name, - unsigned int type -); - -/** - * @brief - * Register an interval output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param type - Interval type - * - * @note - * See OCI_IntervalCreate() for possible values of parameter 'type' - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterInterval -( - OCI_Statement *stmt, - const otext *name, - unsigned int type -); - -/** - * @brief - * Register an object output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param typinf - Type info handle - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterObject -( - OCI_Statement *stmt, - const otext *name, - OCI_TypeInfo *typinf -); - -/** - * @brief - * Register a lob output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param type - Lob type - * - * @note - * See OCI_LobCreate() for possible values of parameter 'type' - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterLob -( - OCI_Statement *stmt, - const otext *name, - unsigned int type -); - -/** - * @brief - * Register a file output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param type - File type - * - * @note - * See OCI_FileCreate() for possible values of parameter 'type' - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterFile -( - OCI_Statement *stmt, - const otext *name, - unsigned int type -); - -/** - * @brief - * Register a Ref output bind placeholder - * - * @param stmt - Statement handle - * @param name - Output bind name - * @param typinf - Type info handle - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RegisterRef -( - OCI_Statement *stmt, - const otext *name, - OCI_TypeInfo *typinf -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiRowIds Oracle Rowids - * @{ - * - * OCILIB supports the Oracle ROWID type through C scalar string types (otext). - * - * - ROWIDs can be retrieved from resultset with OCI_GetString() - * - ROWIDs can be binded to statements with OCI_BindString() - * - * The maximum size of an ROWID buffer is defined by the constant OCI_SIZE_ROWID - * - * @par Example - * @include rowid.c - * - * @} - */ - -/** - * @defgroup OcilibCApiStatementControl Statements control - * @{ - * - * Those functions give extra information about OCILIB statements and can modify their behavior. - * - */ - -/** - * @brief - * Return the type of a SQL statement - * - * @param stmt - Statement handle - * - * @note - * Possible values are : - * - * - OCI_CST_SELECT : select statement - * - OCI_CST_UPDATE : update statement - * - OCI_CST_DELETE : delete statement - * - OCI_CST_INSERT : insert statement - * - OCI_CST_CREATE : create statement - * - OCI_CST_DROP : drop statement - * - OCI_CST_ALTER : alter statement - * - OCI_CST_BEGIN : begin (pl/sql) statement - * - OCI_CST_DECLARE : declare (pl/sql) statement - * - OCI_CST_CALL : kpu call - * - OCI_CST_MERGE : merge statement - * - * @return - * The statement type on success or OCI_UNKOWN on error - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetStatementType -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the fetch mode of a SQL statement - * - * @param stmt - Statement handle - * @param mode - fetch mode value - * - * @warning - * OCI_SetFetchMode() MUST be called before any OCI_ExecuteXXX() call - * - * @note - * Possible values are : - * - OCI_SFM_DEFAULT - * - OCI_SFM_SCROLLABLE - * - * @warning - * if Oracle Client is 9iR1: - * - when setting OCI_SFM_SCROLLABLE, OCI_SetPrefetch() is internally called with value 0 - * to disable prefetching (to avoid an oracle bug). - * - when re-setting OCI_SFM_DEFAULT after having set OCI_SFM_SCROLLABLE, OCI_SetPrefetch() - * is internally called with value OCI_PREFETCH_SIZE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetFetchMode -( - OCI_Statement *stmt, - unsigned int mode -); - -/** - * @brief - * Return the fetch mode of a SQL statement - * - * @param stmt - Statement handle - * - * @note - * See OCI_SetFetchMode() for possible values - * Default value is OCI_SFM_DEFAULT - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetFetchMode -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the binding mode of a SQL statement - * - * @param stmt - Statement handle - * @param mode - binding mode value - * - * @note - * Possible values are : - * - OCI_BIND_BY_POS : position binding - * - OCI_BIND_BY_NAME : name binding - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetBindMode -( - OCI_Statement *stmt, - unsigned int mode -); - -/** - * @brief - * Return the binding mode of a SQL statement - * - * @param stmt - Statement handle - * - * @note - * See OCI_SetBindMode() for possible values - * Default value is OCI_BIND_BY_NAME - * - * @note - * if stmt is NULL, the return value is OCI_UNKNOWN - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetBindMode -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the current bind allocation mode that will be used for subsequent binding calls - * - * @param stmt - Statement handle - * @param mode - bind allocation mode value - * - * @note - * Possible values are : - * - OCI_BAM_EXTERNAL : bind variable are allocated by user code - * - OCI_BAM_INTERNAL : bind variable are allocated internally - * - * @warning - * This call has to be made after preparing a statement as OCI_Prepare() reset it by default to OCI_BAM_EXTERNAL. - * When calling an OCI_BindXXXX() call, this value is used and stored in the OCI_Bind object created during the bind call. - * Each bind can have is own allocation mode that is returned by OCI_BindGetAllocationMode() - * OCI_SetBindAllocation() can be called before each binding call if needed, resulting having some bind allocated externally and other ones internally. - * - * @note - * Refer to the section "Binding variables and arrays" of the documentation about allocation mode as OCI_BAM_INTERNAL is not compatible with all bind calls - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetBindAllocation -( - OCI_Statement *stmt, - unsigned int mode -); - -/** - * @brief - * Return the current bind allocation mode used for subsequent binding calls - * - * @param stmt - Statement handle - * - * @note - * See OCI_SetBindAllocation() for possible values - * Default value is OCI_BAM_EXTERNAL - * - * @warning - * Each OCI_Bind object has its own allocation mode that may differ from the one returned by OCI_GetBindAllocation() - * The return value of OCI_GetBindAllocation() is the mode that will be used for any subsequent OCI_BindXXXX() calls - * - * @note - * if stmt is NULL, the return value is OCI_UNKNOWN - * - */ -OCI_EXPORT unsigned int OCI_API OCI_GetBindAllocation -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the number of rows fetched per internal server fetch call - * - * @param stmt - Statement handle - * @param size - number of rows to fetch - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetFetchSize -( - OCI_Statement *stmt, - unsigned int size -); - -/** - * @brief - * Return the number of rows fetched per internal server fetch call - * - * @param stmt - Statement handle - * - * @note - * Default value is set to constant OCI_FETCH_SIZE - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetFetchSize -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the number of rows pre-fetched by OCI Client - * - * @param stmt - Statement handle - * @param size - number of rows to pre-fetch - * - * @note - * To turn off pre-fetching, set both attributes (size and memory) to 0. - * - * @warning - * Prefetch is not working with scrollable cursors in Oracle 9iR1 - * In that case, argument 'size' is not used and replace by 0. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetPrefetchSize -( - OCI_Statement *stmt, - unsigned int size -); - -/** - * @brief - * Return the number of rows pre-fetched by OCI Client - * - * @param stmt - Statement handle - * - * @note - * Default value is set to constant OCI_PREFETCH_SIZE - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetPrefetchSize -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the amount of memory pre-fetched by OCI Client - * - * @param stmt - Statement handle - * @param size - amount of memory to fetch - * - * @note - * Default value is 0 and the pre-fetch size attribute is used instead. - * When both attributes are set (pre-fetch size and memory) and pre-fetch memory - * value can hold more rows than specified by pre-fetch size, OCI uses pre-fetch - * size instead. - * - * @note - * OCILIB set pre-fetch attribute to OCI_PREFETCH_SIZE when a statement is created. - * To setup a big value for OCI_SetPrefetchMemory(), you must call - * OCI_SetPrefetchSize() to 0 to make OCI consider this attribute. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetPrefetchMemory -( - OCI_Statement *stmt, - unsigned int size -); - -/** - * @brief - * Return the amount of memory used to retrieve rows pre-fetched by OCI Client - * - * @param stmt - Statement handle - * - * @note - * Default value is 0 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetPrefetchMemory -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the LONG data type piece buffer size - * - * @param stmt - Statement handle - * @param size - maximum size for long buffer - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetLongMaxSize -( - OCI_Statement *stmt, - unsigned int size -); - -/** - * @brief - * Return the LONG data type piece buffer size - * - * @param stmt - Statement handle - * - * @note - * Default value is set to constant OCI_SIZE_LONG - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetLongMaxSize -( - OCI_Statement *stmt -); - -/** - * @brief - * Set the long data type handling mode of a SQL statement - * - * @param stmt - Statement handle - * @param mode - long mode value - * - * @note - * Possible values are : - * - * - OCI_LONG_EXPLICIT : LONGs are explicitly handled by OCI_Long type - * - OCI_LONG_IMPLICIT : LONGs are implicitly mapped to string type in the - * limits of VARCHAR2 size capacity - * - * LONG RAWs cannot be handled with OCI_LONG_IMPLICIT - */ - -OCI_EXPORT boolean OCI_API OCI_SetLongMode -( - OCI_Statement *stmt, - unsigned int mode -); - -/** - * @brief - * Return the long data type handling mode of a SQL statement - * - * @param stmt - Statement handle - * - * @note - * See OCI_SetLongMode() for possible values - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_GetLongMode -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the connection handle associated with a statement handle - * - * @param stmt - Statement handle - * - */ - -OCI_EXPORT OCI_Connection * OCI_API OCI_StatementGetConnection -( - OCI_Statement *stmt -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiLobs Internal Large Objects (LOBs) - * @{ - * - * Large Objects (LOBs) were introduced with Oracle 8i to replace LONGs - * - * Oracle OCI supplies a set APIs to manipulate this data type. - * - * OCILIB encapsulates this API by supplying: - * - * - An OCI_Lob C type - * - A set of really easy APIs to manipulate OCI_Lob objects - * - * OCILIB currently supports 3 types of Lobs : - * - * - BLOB : Binary LOBs (replacement for LONG RAW data type) - * - CLOB : Character LOBs (replacement for LONG data type) - * - NCLOB : National Character LOBs - * - * OCI_Lob objects can be : - * - * - Created as standalone instances - * - Used for in/out binding - * - Retrieved from select statements - * - Manipulated (copy, append, ...) - * - * @par Lobs > 4 Go - * - * Oracle 10g extended lobs by increasing maximum size from 4Go to 128 To. - * - * OCILIB, with version 2.1.0, supports now this new limit. - * For handling sizes and offsets up to 128 To, 64 bit integers are requested. - * - * So, A new scalar integer type has been introduced: big_uint (elderly lobsize_t). - * This type can be a 32 bits or 64 bits integer depending on : - * - Compiler support for 64 bits integers (C99 compiler, MS compilers) - * - Oracle client version - * - * big_uint will be a 64 bits integer : - * - if the compiler supports it - * - if OCILIB is build with option OCI_IMPORT_LINKAGE and the Oracle version is >= 10.1 - * - or OCILIB is build with option OCI_IMPORT_RUNTIME (oracle version is not known at - * compilation stage) - * - * @par Example - * @include lob.c - * - */ - -/** - * @brief - * Create a local temporary Lob instance - * - * @param con - Connection handle - * @param type - Lob type - * - * Supported lob types : - * - * - OCI_BLOB : Binary Lob - * - OCI_CLOB : Character Lob - * - OCI_NCLOB ! National Character Lob - * - * @return - * Return the lob handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Lob * OCI_API OCI_LobCreate -( - OCI_Connection *con, - unsigned int type -); - -/** - * @brief - * Free a local temporary lob - * - * @param lob - Lob handle - * - * @warning - * Only lobs created with OCI_LobCreate() should be freed by OCI_LobFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobFree -( - OCI_Lob *lob -); - -/** - * @brief - * Create an array of lob object - * - * @param con - Connection handle - * @param type - Lob type - * @param nbelem - number of elements in the array - * - * @note - * see OCI_LobCreate() for more details - * - * @return - * Return the lob handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Lob ** OCI_API OCI_LobArrayCreate -( - OCI_Connection *con, - unsigned int type, - unsigned int nbelem -); - -/** -* @brief -* Free an array of lob objects -* -* @param lobs - Array of lob objects -* -* @warning -* Only arrays of lobs created with OCI_LobArrayCreate() should be freed -* by OCI_LobArrayFree() -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_LobArrayFree -( - OCI_Lob **lobs -); - -/** - * @brief - * Return the type of the given Lob object - * - * @param lob - Lob handle - * - * @note - * For possible values, see OCI_LobCreate() - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LobGetType -( - OCI_Lob *lob -); - -/** - * @brief - * Perform a seek operation on the OCI_lob content buffer - * - * @param lob - Lob handle - * @param offset - Offset from current position (bytes or characters) - * @param mode - Seek mode - * - * Parameter 'mode' can be one of the following value : - * - * - OCI_SEEK_SET : set the lob current offset to the given absolute offset - * - OCI_SEEK_END : set the lob current offset to the end of the lob - * - OCI_SEEK_CUR : move the lob current offset to the number of bytes or - * characters given by parameter 'offset' - * - * @note - * - For CLOB and CLOB, offset in characters - * - For BLOB and BFILE, offset is in bytes - * - * @note - * Position in the Lob buffer starts at 0. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobSeek -( - OCI_Lob *lob, - big_uint offset, - unsigned int mode -); - -/** - * @brief - * Return the current position in the Lob content buffer - * - * @param lob - Lob handle - * - * @return - * Lob position (starting with 0) or 0 on failure - */ - -OCI_EXPORT big_uint OCI_API OCI_LobGetOffset -( - OCI_Lob *lob -); - -/** - * @brief - * [OBSOLETE] Read a portion of a lob into the given buffer - * - * @param lob - Lob handle - * @param buffer - Pointer to a buffer - * @param len - Length of the buffer (in bytes or characters) - * - * @note - * Length is expressed in : - * - Bytes for BLOBs - * - Characters for CLOBs/NCLOBS - * - * @warning - * This call is obsolete ! Use OCI_LobRead2() instead. - * - * @return - * Number of bytes/characters read on success otherwise 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LobRead -( - OCI_Lob *lob, - void *buffer, - unsigned int len -); - -/** - * @brief - * Read a portion of a lob into the given buffer - * - * @param lob - Lob handle - * @param buffer - Pointer to a buffer - * @param char_count - [in/out] Pointer to maximum number of characters - * @param byte_count - [in/out] Pointer to maximum number of bytes - * - * @note - * In input, 'char_count' and 'byte_count' are values to read into the buffer - * In output, 'char_count' and 'byte_count' are values read into the buffer - * - * @note - * For BLOBs, only the parameter 'byte_count' is used - * For CLOBs, both parameters can be used : - * In input : - * - if 'byte_count' is set to zero, it is computed from 'char_count' - * - if 'char_count' is set to zero, it is computed from 'byte_count' - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobRead2 -( - OCI_Lob *lob, - void *buffer, - unsigned int *char_count, - unsigned int *byte_count -); - -/** - * @brief - * [OBSOLETE] Write a buffer into a LOB - * - * @param lob - Lob handle - * @param buffer - Pointer to a buffer - * @param len - Length of the buffer (in bytes or characters) - * - * @note - * Length is expressed in : - * - Bytes for BLOBs - * - Characters for CLOBs/NCLOBs - * - * @warning - * This call is obsolete ! Use OCI_LobWrite2() instead. - * - * @return - * Number of bytes / characters written on success otherwise 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LobWrite -( - OCI_Lob *lob, - void *buffer, - unsigned int len -); - -/** - * @brief - * Write a buffer into a LOB - * - * @param lob - Lob handle - * @param buffer - Pointer to a buffer - * @param char_count - [in/out] Pointer to maximum number of characters - * @param byte_count - [in/out] Pointer to maximum number of bytes - * - * @note - * In input, 'char_count' and 'byte_count' are values to write from the buffer - * In output, 'char_count' and 'byte_count' are values written from the buffer - * - * @note - * For BLOBs, only the parameter 'byte_count' is used - * For CLOBs, both parameters can be used : - * In input : - * - if 'byte_count' is set to zero, it is computed from 'char_count' - * - if 'char_count' is set to zero, it is computed from 'byte_count' - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobWrite2 -( - OCI_Lob *lob, - void *buffer, - unsigned int *char_count, - unsigned int *byte_count -); - -/** - * @brief - * Truncate the given lob to a shorter length - * - * @param lob - Lob handle - * @param size - New length (in bytes or characters) - * - * @note - * Length is expressed in : - * - Bytes for BLOBs - * - Characters for CLOBs/NCLOBs - * - * @note - * If current offset was beyond the new size, it is then updated to an eof position in order for further write calls to append data - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobTruncate -( - OCI_Lob *lob, - big_uint size -); - -/** - * @brief - * Return the actual length of a lob - * - * @param lob - Lob handle - * - * @note - * The returned value is in bytes for BLOBS and characters for CLOBS/NCLOBs - * - */ - -OCI_EXPORT big_uint OCI_API OCI_LobGetLength -( - OCI_Lob *lob -); - -/** - * @brief - * Returns the chunk size of a LOB - * - * @param lob - Lob handle - * - * @note - * This chunk size corresponds to the chunk size used by the LOB data layer - * when accessing and modifying the LOB value. According to Oracle - * documentation, performance will be improved if the application issues - * read or write requests using a multiple of this chunk size - * - * @note - * The returned value is in bytes for BLOBS and characters for CLOBS/NCLOBs - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LobGetChunkSize -( - OCI_Lob *lob -); - -/** - * @brief - * Erase a portion of the lob at a given position - * - * @param lob - Lob handle - * @param offset - Absolute position in source lob - * @param len - Number of bytes or characters to erase - * - * @note - * Absolute position starts at 0. - * Erasing means "overwriting" the range of values at the given offset with: - * - spaces for CLOB/NCLOB - * - 'zero' bytes for BLOB - * - * @return - * Number of bytes (BLOB) or characters (CLOB/NCLOB) erased on success - * otherwise 0 on failure - * - */ - -OCI_EXPORT big_uint OCI_API OCI_LobErase -( - OCI_Lob *lob, - big_uint offset, - big_uint len -); - -/** - * @brief - * Append a buffer at the end of a LOB - * - * @param lob - Lob handle - * @param buffer - Pointer to a buffer - * @param len - Length of the buffer (in bytes or characters) - * - * @note - * Length is expressed in : - * - Bytes for BLOBs - * - Characters for CLOBs - * - * @return - * Number of bytes / characters written on success otherwise 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LobAppend -( - OCI_Lob *lob, - void *buffer, - unsigned int len -); - -/** - * @brief - * Append a buffer at the end of a LOB - * - * @param lob - Lob handle - * @param buffer - Pointer to a buffer - * @param char_count - [in/out] Pointer to maximum number of characters - * @param byte_count - [in/out] Pointer to maximum number of bytes - * - * @note - * In input, 'char_count' and 'byte_count' are values to write from the buffer - * In output, 'char_count' and 'byte_count' are values written from the buffer - * - * @note - * For BLOBs, only the parameter 'byte_count' is used - * For CLOBs, both parameters can be used : - * In input : - * - if 'byte_count' is set to zero, it is computed from 'char_count' - * - if 'char_count' is set to zero, it is computed from 'byte_count' - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobAppend2 -( - OCI_Lob *lob, - void *buffer, - unsigned int *char_count, - unsigned int *byte_count -); - -/** - * @brief - * Append a source LOB at the end of a destination LOB - * - * @param lob - Destination Lob handle - * @param lob_src - Source Lob handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobAppendLob -( - OCI_Lob *lob, - OCI_Lob *lob_src -); - -/** - * @brief - * Check if the given lob is a temporary lob - * - * @param lob - Lob handle - * - * @return - * TRUE if it's a temporary lob otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobIsTemporary -( - OCI_Lob *lob -); - -/** - * @brief - * Copy a portion of a source LOB into a destination LOB - * - * @param lob - Destination Lob handle - * @param lob_src - Source Lob handle - * @param offset_dst - Absolute position in destination lob - * @param offset_src - Absolute position in source lob - * @param count - Number of bytes or character to copy - * - * @note - * For character LOB (CLOB/NCLOBS) the parameters count, offset_dst and - * offset_src are expressed in characters and not in bytes. - * - * @note - * Absolute position starts at 0. - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobCopy -( - OCI_Lob *lob, - OCI_Lob *lob_src, - big_uint offset_dst, - big_uint offset_src, - big_uint count -); - -/** - * @brief - * Copy a portion of a source FILE into a destination LOB - * - * @param lob - Destination Lob handle - * @param file - Source File handle - * @param offset_dst - Absolute position in destination lob - * @param offset_src - Absolute position in source file - * @param count - Number of bytes to copy - * - * @note - * - For character LOB (CLOB/NCLOB) the parameter offset_src are expressed in - * characters and not in bytes. - * - Offset_src is always in bytes - * - * @note - * Absolute position starts at 0. - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobCopyFromFile -( - OCI_Lob *lob, - OCI_File *file, - big_uint offset_dst, - big_uint offset_src, - big_uint count -); - -/** - * @brief - * Open explicitly a Lob - * - * @param lob - Lob handle - * @param mode - open mode - * - * Possible values for mode are : - * - * - OCI_LOB_READONLY : read only access - * - OCI_LOB_READWRITE : read/write access - * - * @note - * - A call to OCI_LobOpen is not necessary to manipulate a Lob. - * - If a lob has not been opened explicitly, triggers are fired and - * indexes updated at every read/write/append operation - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobOpen -( - OCI_Lob *lob, - unsigned int mode -); - -/** - * @brief - * Close explicitly a Lob - * - * @param lob - Lob handle - * - * @note - * - A call to OCI_LobClose is not necessary to manipulate a Lob. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobClose -( - OCI_Lob *lob -); - -/** - * @brief - * Compare two lob handles for equality - * - * @param lob - Lob handle - * @param lob2 - Lob2 handle - * - * @return - * TRUE is the lobs are not null and equal otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobIsEqual -( - OCI_Lob *lob, - OCI_Lob *lob2 -); - -/** - * @brief - * Assign a lob to another one - * - * @param lob - Destination Lob handle - * @param lob_src - Source Lob handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobAssign -( - OCI_Lob *lob, - OCI_Lob *lob_src -); - -/** - * @brief - * Return the maximum size that the lob can contain - * - * @param lob - Lob handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT big_uint OCI_API OCI_LobGetMaxSize -( - OCI_Lob *lob -); - -/** - * @brief - * Flush Lob content to the server - * - * @param lob - Lob handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobFlush -( - OCI_Lob *lob -); - -/** - * @brief - * Enable / disable buffering mode on the given lob handle - * - * @param lob - Lob handle - * @param value - Enable/disable buffering mode - * - * @note - * Oracle "LOB Buffering Subsystem" allows client applications - * to speedup read/write of small buffers on Lobs Objects. - * Check Oracle Documentation for more details on "LOB Buffering Subsystem". - * This reduces the number of network round trips and LOB versions, thereby - * improving LOB performance significantly. - * - * @warning - * According to Oracle documentation the following operations are not permitted - * on Lobs when buffering is on : OCI_LobCopy(), OCI_LobAppend, OCI_LobErase(), - * OCI_LobGetLength(), OCI_LobTruncate() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LobEnableBuffering -( - OCI_Lob *lob, - boolean value -); - -/** -* @brief -* Retrieve connection handle from the lob handle -* -* @param lob - lob handle -* -*/ - -OCI_EXPORT OCI_Connection * OCI_API OCI_LobGetConnection -( - OCI_Lob *lob -); - -/** -* @brief -* Indicates if the given lob belongs to a local or remote database table -* -* @param lob - lob handle -* -* @warning -* Requires Oracle 12cR2 (both client and server side), otherwise it returns FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_LobIsRemote -( - OCI_Lob *lob -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiFiles External Large Objects (FILEs) - * @{ - * - * External Large Objects (FILEs) were introduced with Oracle 8i - * - * Oracle OCI supplies a set APIs to manipulate this data type. - * - * OCILIB encapsulates this API by supplying: - * - * - An OCI_File C type - * - A set of really easy APIs to manipulate OCI_File objects - * - * OCILIB currently supports 2 types of Lobs : - * - * - BFILE : Binary files - * - CFILE : Character files - * - * @warning - * FILEs are read-only. - * - * OCI_Lob objects can be : - * - * - Created as standalone instances - * - Used for in/out binding - * - Retrieved from select statements - * - Used for reading server files content - * - * @par Files > 4 Go - * - * - New maximum file size limit (128 To) applies to OCI_Files objects. - * - See Internal Large Objects (LOBs) section for Files > 4 Go information - * - * @par Example - * @include file.c - * - */ - -/** - * @brief - * Create a file object instance - * - * @param con - Connection handle - * @param type - File type - * - * Supported file types : - * - * - OCI_BFILE : Binary file - * - OCI_CFILE : Character file - * - * @return - * Return the lob handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_File * OCI_API OCI_FileCreate -( - OCI_Connection *con, - unsigned int type -); - -/** - * @brief - * Free a local File object - * - * @param file - File handle - * - * @warning - * Only Files created with OCI_FileCreate() should be freed by OCI_FileFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileFree -( - OCI_File *file -); - -/** - * @brief - * Create an array of file object - * - * @param con - Connection handle - * @param type - File type - * @param nbelem - number of elements in the array - * - * @note - * see OCI_FileCreate() for more details - * - * @return - * Return the file handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_File ** OCI_API OCI_FileArrayCreate -( - OCI_Connection *con, - unsigned int type, - unsigned int nbelem -); - -/** -* @brief -* Free an array of file objects -* -* @param files - Array of file objects -* -* @warning -* Only arrays of lobs created with OCI_FileArrayCreate() should be freed by OCI_FileArrayFree() -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_FileArrayFree -( - OCI_File **files -); - -/** - * @brief - * Return the type of the given File object - * - * @param file - File handle - * - * @note - * For possible values, see OCI_FileCreate() - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_FileGetType -( - OCI_File *file -); - -/** - * @brief - * Perform a seek operation on the OCI_File content buffer - * - * @param file - File handle - * @param offset - Offset from current position - * @param mode - Seek mode - * - * Mode parameter can be one of the following value : - * - * - OCI_SEEK_SET : set the file current offset to the given absolute offset - * - OCI_SEEK_END : set the file current offset to the end of the lob - * - OCI_SEEK_CUR : move the file current offset to the number of bytes given by - * parameter 'offset' - * - * @note - * Position in the File buffer starts at 0. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileSeek -( - OCI_File *file, - big_uint offset, - unsigned int mode -); - -/** - * @brief - * Return the current position in the file - * - * @param file - File handle - * - * @return - * File position (starting with 0) or 0 on failure - */ - -OCI_EXPORT big_uint OCI_API OCI_FileGetOffset -( - OCI_File *file -); - -/** - * @brief - * Read a portion of a file into the given buffer - * - * @param file - File handle - * @param buffer - Pointer to a buffer - * @param len - Length of the buffer in bytes - * - * @return - * Number of bytes read on success otherwise 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_FileRead -( - OCI_File *file, - void *buffer, - unsigned int len -); - -/** - * @brief - * Return the size in bytes of a file - * - * @param file - File handle - * - */ - -OCI_EXPORT big_uint OCI_API OCI_FileGetSize -( - OCI_File *file -); - -/** - * @brief - * Check if the given file exists on server - * - * @param file - File handle - * - * @note - * For local FILEs object, OCI_LobFileSetName() must be called before to set the filename to check - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileExists -( - OCI_File *file -); - -/** - * @brief - * Set the directory and file name of FILE handle - * - * @param file - File handle - * @param dir - File directory - * @param name - File name - *in - * @note - * - For local FILEs only - * - Files fetched from resultset cannot be assigned a new directory and name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileSetName -( - OCI_File *file, - const otext *dir, - const otext *name -); - -/** - * @brief - * Return the directory of the given file - * - * @param file - File handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_FileGetDirectory -( - OCI_File *file -); - -/** - * @brief - * Return the name of the given file - * - * @param file - File handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_FileGetName -( - OCI_File *file -); - -/** - * @brief - * Open a file for reading - * - * @param file - File handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileOpen -( - OCI_File *file -); - -/** - * @brief - * Check if the specified file is opened within the file handle - * - * @param file - File handle - * - * @return - * TRUE if the file was opened with this handle otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileIsOpen -( - OCI_File *file -); - -/** - * @brief - * Close a file - * - * @param file - File handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileClose -( - OCI_File *file -); - -/** - * @brief - * Compare two file handle for equality - * - * @param file - File handle - * @param file2 - File2 handle - * - * @return - * TRUE is the lobs are not null and equal otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileIsEqual -( - OCI_File *file, - OCI_File *file2 -); - -/** - * @brief - * Assign a file to another one - * - * @param file - Destination File handle - * @param file_src - Source File handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_FileAssign -( - OCI_File *file, - OCI_File *file_src -); - -/** -* @brief -* Retrieve connection handle from the file handle -* -* @param file - file handle -* -*/ - -OCI_EXPORT OCI_Connection * OCI_API OCI_FileGetConnection -( - OCI_File *file -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiLongs Long objects - * @{ - * - * Long Objects encapsulate Oracle LONGs data types and were used to store large - * buffers in Oracle database. - * - * They're still supported but are depreciated. Oracle now provides a - * newer and better way to deal with data that needs large storage : LOBs - * - * OCILIB supports this data type because it was and still is widely used - * - * OCILIB provides a set of API for manipulating LONGs that is really close to - * the one provided for LOBs. - * - * OCILIB currently supports 3 types of Long Objects: - * - * - OCI_BLONG : LONG RAW columns - * - OCI_CLONG : LONG columns - * - * OCI_Lob objects can be : - * - * - Created as standalone instances - * - Used for in/out binding - * - Retrieved from select statement - * - * @par Example - * @include long.c - * - */ - -/** - * @brief - * Create a local temporary Long instance - * - * @param stmt - Statement handle - * @param type - Long type - * - * Supported lob types : - * - * - OCI_BLONG : Binary Long - * - OCI_CLONG : Character Long - * - * @return - * Return the long handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Long * OCI_API OCI_LongCreate -( - OCI_Statement *stmt, - unsigned int type -); - -/** - * @brief - * Free a local temporary long - * - * @param lg - Long handle - * - * @warning - * Only lobs created with OCI_LongCreate() should be freed by OCI_LongFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_LongFree -( - OCI_Long *lg -); - -/** - * @brief - * Return the type of the given Long object - * - * @param lg - Long handle - * - * @note - * For possible values, see OCI_LobCreate() - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LongGetType -( - OCI_Long *lg -); - -/** - * @brief - * Read a portion of a long into the given buffer [Obsolete] - * - * @param lg - Long handle - * @param buffer - Pointer to a buffer - * @param len - Length of the buffer in bytes / characters - * - * @note - * - From version 2.0.0, this function is obsolete because OCILIB fetches now - * all data during OCIFetchNext() call - * - So, this call reads now the internal OCI_Long object allocated buffer - * - The internal buffer can be directly accessed with OCI_LongGetBuffer() - * - * @note - * - For OCI_CLONG, parameter 'len' and returned value are expressed in characters - * - For OCI_BLONG, parameter 'len' and returned value are expressed in bytes - * - * @return - * - Number of bytes/characters read on success - * - 0 if there is nothing more to read - * - 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LongRead -( - OCI_Long *lg, - void *buffer, - unsigned int len -); - -/** - * @brief - * Write a buffer into a Long - * - * @param lg - Long handle - * @param buffer - the pointer to a buffer - * @param len - the length of the buffer in bytes (OCI_BLONG) or - * character (OCI_CLONG) - * - * @return - * Number of bytes (OCI_BLONG) / character (OCI_CLONG) written on success otherwise 0 on failure - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LongWrite -( - OCI_Long *lg, - void *buffer, - unsigned int len -); - -/** - * @brief - * Return the buffer size of a long object in bytes (OCI_BLONG) or character (OCI_CLONG) - * - * @param lg - Long handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_LongGetSize -( - OCI_Long *lg -); - -/** - * @brief - * Return the internal buffer of an OCI_Long object read from a fetch sequence - * - * @param lg - Long handle - * - */ - -OCI_EXPORT void * OCI_API OCI_LongGetBuffer -( - OCI_Long *lg -); - -/** -* @} -*/ - -/** -* @defgroup OcilibCApiOracleNumber Oracle NUMBER manipulation (optional) -* @{ -* -* OCILIB encapsulates Oracle SQL all Numeric types using C native data types. -* But it also provides an optional OCI_Number handle for manipulating and accessing Oracle NUMBER type. -* OCI_Number provides management for some special value that cannot be addressed in C such as positive -* and negative infinity. -* -* @par Example -* @include number.c -* -*/ - -/** -* @brief -* Create a local number object -* -* @param con - Connection handle -* -* @note -* Parameter 'con' can be NULL in order to manipulate numbers -* independently from database connections -* -* @return -* Return the number handle on success otherwise NULL on failure -* -*/ - -OCI_EXPORT OCI_Number * OCI_API OCI_NumberCreate -( - OCI_Connection *con -); - -/** -* @brief -* Free a number object -* -* @param number - Number handle -* -* @warning -* Only Numbers created with OCI_NumberCreate() should be freed by OCI_NumberFree() -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberFree -( - OCI_Number *number -); - -/** -* @brief -* Create an array of number object -* -* @param con - Connection handle -* @param nbelem - number of elements in the array -* -* @note -* see OCI_NumberCreate() for more details -* -* @return -* Return the number handle array on success otherwise NULL on failure -* -*/ - -OCI_EXPORT OCI_Number ** OCI_API OCI_NumberArrayCreate -( - OCI_Connection *con, - unsigned int nbelem -); - -/** -* @brief -* Free an array of number objects -* -* @param numbers - Array of number objects -* -* @warning -* Only arrays of numbers created with OCI_NumberArrayCreate() should be freed by OCI_NumberArrayFree() -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberArrayFree -( - OCI_Number **numbers -); - -/** -* @brief -* Assign the value of a number handle to another one -* -* @param number - Destination number handle -* @param number_src - Source number handle -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT int OCI_API OCI_NumberAssign -( - OCI_Number *number, - OCI_Number *number_src -); - -/** -* @brief -* Convert a number value from the given number handle to a string -* -* @param number - source number handle -* @param fmt - Number format -* @param size - Destination string size in characters -* @param str - Destination date string -* -* @note -* Output string can be one the following 'magic strings': -* - '~' for positive infinity -* - '-~' for negative infinity -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberToText -( - OCI_Number *number, - const otext *fmt, - int size, - otext *str -); - -/** -* @brief -* Convert a string to a number and store it in the given number handle -* -* @param number - Destination number handle -* @param str - Source number string -* @param fmt - Number format -* -* @note -* Input string can be one the following 'magic strings': -* - '~' for positive infinity -* - '-~' for negative infinity -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberFromText -( - OCI_Number *number, - const otext *str, - const otext *fmt -); - -/** -* @brief -* Return the number value content -* -* @param number - number handle -* -* @note -* Returned content is a buffer of 22 bytes corresponding to Oracle C native -* representation of NUMBER values -* See oracle Documentation of its layout -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT unsigned char * OCI_API OCI_NumberGetContent -( - OCI_Number *number -); - -/** -* @brief -* Assign the number value content -* -* @param number - number handle -* @param content - raw number content -* -* @note -* See OCI_NumberSetContent() for more information -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberSetContent -( - OCI_Number *number, - unsigned char *content -); - -/** -* @brief -* Assign the number value with the value of a native C numeric type -* -* @param number - number handle -* @param type - native C type to assign -* @param value - pointer to value to set -* -* @note -* Argument \p param type can be : -* -* - OCI_NUM_SHORT : value is a pointer to a signed short -* - OCI_NUM_USHORT : value is a pointer to an unsigned short -* - OCI_NUM_INT : value is a pointer to a signed int -* - OCI_NUM_UINT : value is a pointer to an unsigned short -* - OCI_NUM_BIGINT : value is a pointer to a signed big_int -* - OCI_NUM_BIGUINT : value is a pointer to an unsigned big_uint -* - OCI_NUM_FLOAT : value is a pointer to an float -* - OCI_NUM_DOUBLE : value is a pointer to a double -* - OCI_NUM_NUMBER : value is a pointer to the return value of OCI_NumberGetContent() -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberSetValue -( - OCI_Number *number, - unsigned int type, - void *value -); - -/** -* @brief -* Assign the number value to a native C numeric type -* -* @param number - number handle -* @param type - native C type to assign -* @param value - pointer to a native C variable -* -* @note -* See OCI_NumberSetValue() for more information -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberGetValue -( - OCI_Number *number, - unsigned int type, - void *value -); - -/** -* @brief -* Add the value of a native C numeric type to the given number -* -* @param number - number handle -* @param type - native C type of the variable -* @param value - pointer to a native C variable to add -* -* @note -* See OCI_NumberSetValue() for more information -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberAdd -( - OCI_Number *number, - unsigned int type, - void *value -); - -/** -* @brief -* Subtract the value of a native C numeric type to the given number -* -* @param number - number handle -* @param type - native C type of the variable -* @param value - pointer to a native C variable to subtract -* -* @note -* See OCI_NumberSetValue() for more information -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberSub -( - OCI_Number *number, - unsigned int type, - void *value -); - -/** -* @brief -* Multiply the given number with the value of a native C numeric -* -* @param number - number handle -* @param type - native C type of the variable -* @param value - pointer to a native C variable to multiply by -* -* @note -* See OCI_NumberSetValue() for more information -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberMultiply -( - OCI_Number *number, - unsigned int type, - void *value -); - -/** -* @brief -* Divide the given number with the value of a native C numeric -* -* @param number - number handle -* @param type - native C type of the variable -* @param value - pointer to a native C variable to divide by -* -* @note -* See OCI_NumberSetValue() for more information -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_NumberDivide -( - OCI_Number *number, - unsigned int type, - void *value -); - -/** - * @brief - * Compares two number handles - * - * @param number1 - number1 handle - * @param number2 - number2 handle - * - * @return - * - -1 if number1 is smaller than number2, - * - 0 if they are equal - * - 1 if number1 is greater than number2. - * - */ - -OCI_EXPORT int OCI_API OCI_NumberCompare -( - OCI_Number *number1, - OCI_Number *number2 -); - -/** -* @} -*/ - -/** - * @} - */ - -/** - * @defgroup OcilibCApiDatetimes Date/time manipulation - * @{ - * - * OCILIB encapsulates Oracle SQL Date data type within OCI_Date structure - * - * Basically, the OCI_Date routines are wrappers around the Oracle OCIDate APIs - * - * @par Example - * @include date.c - * - */ - -/** - * @brief - * Create a local date object - * - * @param con - Connection handle - * - * @note - * From version 2.5.0, parameter 'con' can be NULL in order to manipulate dates - * independently from database connections - * - * @return - * Return the date handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Date * OCI_API OCI_DateCreate -( - OCI_Connection *con -); - -/** - * @brief - * Free a date object - * - * @param date - Date handle - * - * @warning - * Only dates created with OCI_DateCreate() should be freed by OCI_DateFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateFree -( - OCI_Date *date -); - -/** - * @brief - * Create an array of date object - * - * @param con - Connection handle - * @param nbelem - number of elements in the array - * - * @note - * see OCI_DateCreate() for more details - * - * @return - * Return the date handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Date ** OCI_API OCI_DateArrayCreate -( - OCI_Connection *con, - unsigned int nbelem -); - -/** - * @brief - * Free an array of date objects - * - * @param dates - Array of date objects - * - * @warning - * Only arrays of dates created with OCI_DateArrayCreate() should be freed by OCI_DateArrayFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateArrayFree -( - OCI_Date **dates -); - -/** - * @brief - * Add or subtract days to a date handle - * - * @param date - Date handle - * @param nb - Number of days to add/remove - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateAddDays -( - OCI_Date *date, - int nb -); - -/** - * @brief - * Add or subtract months to a date handle - * - * @param date - Date handle - * @param nb - Number of months to add/remove - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateAddMonths -( - OCI_Date *date, - int nb -); - -/** - * @brief - * Assign the value of a date handle to another one - * - * @param date - Destination Date handle - * @param date_src - Source Date handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT int OCI_API OCI_DateAssign -( - OCI_Date *date, - OCI_Date *date_src -); - -/** - * @brief - * Check if the given date is valid - * - * @param date - Date handle - * - * @return - * - Zero if date is valid - * - Any other value means the date is invalid - * - */ - -OCI_EXPORT int OCI_API OCI_DateCheck -( - OCI_Date *date -); - -/** - * @brief - * Compares two date handles - * - * @param date - Date1 handle - * @param date2 - Date2 handle - * - * @return - * - -1 if date1 is smaller than date2, - * - 0 if they are equal - * - 1 if date1 is greater than date2. - * - */ - -OCI_EXPORT int OCI_API OCI_DateCompare -( - OCI_Date *date, - OCI_Date *date2 -); - -/** - * @brief - * Return the number of days betWeen two dates - * - * @param date - Date1 handle - * @param date2 - Date2 handle - * - * The number of days is the difference of (date2 - date) - * - * @return - * Number of days on success otherwise OCI_ERROR on failure - * - */ - -OCI_EXPORT int OCI_API OCI_DateDaysBetween -( - OCI_Date *date, - OCI_Date *date2 -); - -/** - * @brief - * Convert a string to a date and store it in the given date handle - * - * @param date - Destination Date handle - * @param str - Source date string - * @param fmt - Date format - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateFromText -( - OCI_Date *date, - const otext *str, - const otext *fmt -); - -/** - * @brief - * Convert a Date value from the given date handle to a string - * - * @param date - source Date handle - * @param fmt - Date format - * @param size - Destination string size in characters - * @param str - Destination date string - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateToText -( - OCI_Date *date, - const otext *fmt, - int size, - otext *str -); - -/** - * @brief - * Extract the date part from a date handle - * - * @param date - Date handle - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateGetDate -( - OCI_Date *date, - int *year, - int *month, - int *day -); - -/** - * @brief - * Extract the time part from a date handle - * - * @param date - Date handle - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateGetTime -( - OCI_Date *date, - int *hour, - int *min, - int *sec -); - -/** - * @brief - * Extract the date and time parts from a date handle - * - * @param date - Date handle - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateGetDateTime -( - OCI_Date *date, - int *year, - int *month, - int *day, - int *hour, - int *min, - int *sec -); - -/** - * @brief - * Set the date portion if the given date handle - * - * @param date - Date handle - * @param year - Year value - * @param month - Month value - * @param day - Day value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateSetDate -( - OCI_Date *date, - int year, - int month, - int day -); - -/** - * @brief - * Set the time portion if the given date handle - * - * @param date - Date handle - * @param hour - Hour value - * @param min - Minute value - * @param sec - Second value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateSetTime -( - OCI_Date *date, - int hour, - int min, - int sec -); - -/** - * @brief - * Set the date and time portions if the given date handle - * - * @param date - Date handle - * @param year - Year value - * @param month - Month value - * @param day - Day value - * @param hour - Hour value - * @param min - Minute value - * @param sec - Second value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateSetDateTime -( - OCI_Date *date, - int year, - int month, - int day, - int hour, - int min, - int sec -); - -/** - * @brief - * Place the last day of month (from the given date) into the given date - * - * @param date - Date handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateLastDay -( - OCI_Date *date -); - -/** - * @brief - * Gets the date of next day of the week, after a given date - * - * @param date - Date handle - * @param day - Day of the week - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateNextDay -( - OCI_Date *date, - const otext *day -); - -/** - * @brief - * Return the current system date/time into the date handle - * - * @param date - Date handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateSysDate -( - OCI_Date *date -); - -/** - * @brief - * Convert a date from one zone to another zone - * - * @param date - Date handle - * @param zone1 - Source zone - * @param zone2 - Destination zone - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateZoneToZone -( - OCI_Date *date, - const otext *zone1, - const otext *zone2 -); - -/** - * @brief - * Affect an OCI_Date handle value to ISO C time data types - * - * @param date - Date handle - * @param ptm - Pointer to a structure tm to receive date/time values - * @param pt - Pointer to a time_t to hold the date/time in the time_t format - * - * @note - * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateToCTime -( - OCI_Date *date, - struct tm *ptm, - time_t *pt -); - -/** - * @brief - * Affect ISO C time data types values to an OCI_Date handle - * - * @param date - Date handle - * @param ptm - Pointer to a structure tm that hold the date/time value - * @param t - Value (time_t) that hold the date/time in the time_t format - * - * @note - * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. - * If 'ptm' is not null, its value is affected to the OCI_Timestamp handle, - * otherwise the value of 't' is used. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DateFromCTime -( - OCI_Date *date, - struct tm *ptm, - time_t t -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiTimestamps Timestamps and intervals manipulation - * @{ - * - * OCILIB encapsulates Oracle : - * - * - SQL timestamp data type within OCI_Timestamp structure - * - SQL interval data type within OCI_Interval structure - * - * Basically, the OCI_Timestamp and OCI_Interval routines are wrappers around - * the Oracle OCIDatetime and OCIInterval APIs - * - * @par Examples - * @include timestamp.c - * - */ - -/** - * @brief - * Create a local Timestamp instance - * - * @param con - Connection handle - * @param type - Timestamp type - * - * @note - * From version 2.5.0, parameter 'con' can be NULL in order to manipulate - * timestamps independently from database connections - * - * @note - * Timestamp type can be : - * - * - OCI_TIMESTAMP : timestamp - * - OCI_TIMESTAMP_TZ : timestamp with time zone - * - OCI_TIMESTAMP_LTZ : timestamp with local time zone - * - * @return - * Return the Timestamp handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Timestamp * OCI_API OCI_TimestampCreate -( - OCI_Connection *con, - unsigned int type -); - -/** - * @brief - * Free an OCI_Timestamp handle - * - * @param tmsp - Timestamp handle - * - * @warning - * Only Timestamp created with OCI_TimestampCreate() should be freed by OCI_IntervalFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampFree -( - OCI_Timestamp *tmsp -); - -/** - * @brief - * Create an array of timestamp object - * - * @param con - Connection handle - * @param type - Timestamp type - * @param nbelem - number of elements in the array - * - * @note - * see OCI_TimestampCreate() for more details - * - * @return - * Return the timestamp handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Timestamp ** OCI_API OCI_TimestampArrayCreate -( - OCI_Connection *con, - unsigned int type, - unsigned int nbelem -); - -/** - * @brief - * Free an array of timestamp objects - * - * @param tmsps - Array of timestamp objects - * - * @warning - * Only arrays of timestamp created with OCI_TimestampArrayCreate() - * should be freed by OCI_TimestampArrayFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampArrayFree -( - OCI_Timestamp **tmsps -); - -/** - * @brief - * Return the type of the given Timestamp object - * - * @param tmsp - Timestamp handle - * - * @note - * For possible values, see OCI_TimestampCreate() - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_TimestampGetType -( - OCI_Timestamp *tmsp -); - -/** - * @brief - * Assign the value of a timestamp handle to another one - * - * @param tmsp - Destination Timestamp handle - * @param tmsp_src - Source Timestamp handle - * - * @note - * Both timestamp handles must be of the same type - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampAssign -( - OCI_Timestamp *tmsp, - OCI_Timestamp *tmsp_src -); - -/** - * @brief - * Check if the given timestamp is valid - * - * @param tmsp - Timestamp handle - * - * @return - * - Zero if the timestamp value is valid - * - Any other value means the timestamp value is invalid - * - */ - -OCI_EXPORT int OCI_API OCI_TimestampCheck -( - OCI_Timestamp *tmsp -); - -/** - * @brief - * Compares two timestamp handles - * - * @param tmsp - Timestamp1 handle - * @param tmsp2 - Timestamp2 handle - * - * @return - * - -1 if Timestamp1 is smaller than Timestamp2, - * - 0 if they are equal - * - 1 if Timestamp1 is greater than Timestamp2. - * - */ - -OCI_EXPORT int OCI_API OCI_TimestampCompare -( - OCI_Timestamp *tmsp, - OCI_Timestamp *tmsp2 -); - -/** - * @brief - * Set a timestamp handle value - * - * @param tmsp - Timestamp handle - * @param year - Year value - * @param month - Month value - * @param day - Day value - * @param hour - hour value - * @param min - minutes value - * @param sec - seconds value - * @param fsec - fractional part of seconds value - * @param time_zone - name of a time zone to use [optional] - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampConstruct -( - OCI_Timestamp *tmsp, - int year, - int month, - int day, - int hour, - int min, - int sec, - int fsec, - const otext *time_zone -); - -/** - * @brief - * Convert one timestamp value from one type to another. - * - * @param tmsp - Timestamp handle to convert - * @param tmsp_src - Timestamp handle to use for the type conversion - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampConvert -( - OCI_Timestamp *tmsp, - OCI_Timestamp *tmsp_src -); - -/** - * @brief - * Convert a string to a timestamp and store it in the given timestamp handle - * - * @param tmsp - Destination Timestamp handle - * @param str - Source date string - * @param fmt - Date format - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampFromText -( - OCI_Timestamp *tmsp, - const otext *str, - const otext *fmt -); - -/** - * @brief - * Convert a timestamp value from the given timestamp handle to a string - * - * @param tmsp - source Timestamp handle - * @param fmt - Timestamp format - * @param size - Destination string size in characters - * @param str - Destination date string - * @param precision - Precision for fractional part of the seconds - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampToText -( - OCI_Timestamp *tmsp, - const otext *fmt, - int size, - otext *str, - int precision -); - -/** - * @brief - * Extract the date part from a timestamp handle - * - * @param tmsp - Timestamp handle - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampGetDate -( - OCI_Timestamp *tmsp, - int *year, - int *month, - int *day -); - -/** - * @brief - * Extract the time portion from a timestamp handle - * - * @param tmsp - Timestamp handle - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * @param fsec - Place holder for fractional part of second value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampGetTime -( - OCI_Timestamp *tmsp, - int *hour, - int *min, - int *sec, - int *fsec -); - -/** - * @brief - * Extract the date and time parts from a date handle - * - * @param tmsp - Date handle - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * @param fsec - Place holder for fractional part of seconds value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampGetDateTime -( - OCI_Timestamp *tmsp, - int *year, - int *month, - int *day, - int *hour, - int *min, - int *sec, - int *fsec -); - -/** - * @brief - * Return the time zone name of a timestamp handle - * - * @param tmsp - Timestamp handle - * @param size - Destination string size in characters - * @param str - Destination zone name string - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampGetTimeZoneName -( - OCI_Timestamp *tmsp, - int size, - otext *str -); - -/** - * @brief - * Return the time zone (hour, minute) portion of a timestamp handle - * - * @param tmsp - Timestamp handle - * @param hour - Place holder for hour value - * @param min - Place holder for min value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampGetTimeZoneOffset -( - OCI_Timestamp *tmsp, - int *hour, - int *min -); - -/** - * @brief - * Add an interval value to a timestamp value of a timestamp handle - * - * @param tmsp - Timestamp handle - * @param itv - Interval handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampIntervalAdd -( - OCI_Timestamp *tmsp, - OCI_Interval *itv -); - -/** - * @brief - * Subtract an interval value from a timestamp value of a timestamp handle - * - * @param tmsp - Timestamp handle - * @param itv - Interval handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampIntervalSub -( - OCI_Timestamp *tmsp, - OCI_Interval *itv -); - -/** - * @brief - * Store the difference of two timestamp handles into an interval handle - * - * @param tmsp - Timestamp handle (subtrahend) - * @param tmsp2 - Timestamp2 handle (minuend) - * @param itv - Interval handle - * - * @note - * The function acts like tmsp - tmsp2 = itv - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampSubtract -( - OCI_Timestamp *tmsp, - OCI_Timestamp *tmsp2, - OCI_Interval *itv -); - -/** - * @brief - * Stores the system current date and time as a timestamp value with time zone - * into the timestamp handle. - * - * @param tmsp - Timestamp handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampSysTimestamp -( - OCI_Timestamp *tmsp -); - -/** - * @brief - * Affect an OCI_Timestamp handle value to ISO C time data types - * - * @param tmsp - Timestamp handle - * @param ptm - Pointer to a structure tm to receive date/time values - * @param pt - Pointer to a time_t to hold the date/time in the time_t format - * - * @note - * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampToCTime -( - OCI_Timestamp *tmsp, - struct tm *ptm, - time_t *pt -); - -/** - * @brief - * Affect ISO C time data types values to an OCI_Timestamp handle - * - * @param tmsp - Timestamp handle - * @param ptm - Pointer to a structure tm that hold the date/time value - * @param t - Value (time_t) that hold the date/time in the time_t format - * - * @note - * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. - * If 'ptm' is not null, its value is affected to the OCI_Timestamp handle, - * otherwise the value of 't' is used. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TimestampFromCTime -( - OCI_Timestamp *tmsp, - struct tm *ptm, - time_t t -); - -/** - * @brief - * Create a local interval object - * - * @param con - Connection handle - * @param type - Type of Interval - * - * @note - * From version 2.5.0, parameter 'con' can be NULL in order to manipulate - * intervals independently from database connections - * - * @note - * Interval type can be : - * - OCI_INTERVAL_YM : year / month interval - * - OCI_INTERVAL_DS : date/ time interval - * - * @return - * Return the Interval handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Interval * OCI_API OCI_IntervalCreate -( - OCI_Connection *con, - unsigned int type -); - -/** - * @brief - * Free an OCI_Interval handle - * - * @param itv - Interval handle - * - * @warning - * Only Intervals created with OCI_IntervalCreate() should be freed by - * OCI_IntervalFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalFree -( - OCI_Interval *itv -); - -/** - * @brief - * Create an array of Interval object - * - * @param con - Connection handle - * @param type - Type of Interval - * @param nbelem - number of elements in the array - * - * @note - * see OCI_IntervalCreate() for more details - * - * @return - * Return the Interval handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Interval ** OCI_API OCI_IntervalArrayCreate -( - OCI_Connection *con, - unsigned int type, - unsigned int nbelem -); - -/** - * @brief - * Free an array of Interval objects - * - * @param itvs - Array of Interval objects - * - * @warning - * Only arrays of Interval created with OCI_IntervalArrayCreate() should be freed by - * OCI_IntervalArrayFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalArrayFree -( - OCI_Interval **itvs -); - -/** - * @brief - * Return the type of the given Interval object - * - * @param itv - Interval handle - * - * @note - * For possible values, see OCI_IntervalCreate() - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_IntervalGetType -( - OCI_Interval *itv -); - -/** - * @brief - * Assign the value of a interval handle to another one - * - * @param itv - Destination interval handle - * @param itv_src - Source interval handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalAssign -( - OCI_Interval *itv, - OCI_Interval *itv_src -); - -/** - * @brief - * Check if the given interval is valid - * - * @param itv - Interval handle - * - * @return - * - Zero if the interval value is valid - * - Any other value means the interval value is invalid - * - */ - -OCI_EXPORT int OCI_API OCI_IntervalCheck -( - OCI_Interval *itv -); - -/** - * @brief - * Compares two interval handles - * - * @param itv - Interval1 handle - * @param itv2 - Interval2 handle - * - * @return - * - -1 if interval1 is smaller than interval2, - * - 0 if they are equal - * - 1 if interval1 is greater than interval2. - * - */ - -OCI_EXPORT int OCI_API OCI_IntervalCompare -( - OCI_Interval *itv, - OCI_Interval *itv2 -); - -/** - * @brief - * Convert a string to an interval and store it in the given interval handle - * - * @param itv - Destination interval handle - * @param str - Source date string - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalFromText -( - OCI_Interval *itv, - const otext *str -); - -/** - * @brief - * Convert an interval value from the given interval handle to a string - * - * @param itv - source Interval handle - * @param leading_prec - Precision of the leading part - * @param fraction_prec - Precision of the fractional part - * @param size - Destination string size in characters - * @param str - Destination date string - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalToText -( - OCI_Interval *itv, - int leading_prec, - int fraction_prec, - int size, - otext *str -); - -/** - * @brief - * Correct an interval handle value with the given time zone - * - * @param itv - Interval handle - * @param str - Time zone name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalFromTimeZone -( - OCI_Interval *itv, - const otext *str -); - -/** - * @brief - * Return the day / time portion of an interval handle - * - * @param itv - Interval handle - * @param day - Place holder for day value - * @param hour - Place holder for hours value - * @param min - Place holder for minutes value - * @param sec - Place holder for seconds value - * @param fsec - Place holder for fractional part of seconds value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalGetDaySecond -( - OCI_Interval *itv, - int *day, - int *hour, - int *min, - int *sec, - int *fsec -); - -/** - * @brief - * Return the year / month portion of an interval handle - * - * @param itv - Interval handle - * @param year - Place holder for year value - * @param month - Place holder for month value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalGetYearMonth -( - OCI_Interval *itv, - int *year, - int *month -); - -/** - * @brief - * Set the day / time portion if the given interval handle - * - * @param itv - Interval handle - * @param day - day value - * @param hour - Hour value - * @param min - Minute value - * @param sec - Second value - * @param fsec - Fractional part of the seconds - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalSetDaySecond -( - OCI_Interval *itv, - int day, - int hour, - int min, - int sec, - int fsec -); - -/** - * @brief - * Set the year / month portion if the given Interval handle - * - * @param itv - Interval handle - * @param year - Year value - * @param month - Month value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalSetYearMonth -( - OCI_Interval *itv, - int year, - int month -); - -/** - * @brief - * Adds an interval handle value to another - * - * @param itv - Interval handle from witch to add - * @param itv2 - Interval handle to add - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalAdd -( - OCI_Interval *itv, - OCI_Interval *itv2 -); - -/** - * @brief - * Subtract an interval handle value from another - * - * @param itv - Interval handle from witch to remove - * @param itv2 - Interval handle to remove - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_IntervalSubtract -( - OCI_Interval *itv, - OCI_Interval *itv2 -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiUserTypes Oracle Named Types (Oracle OBJECTs) - * @{ - * - * OCILIB implements Oracle Named types (user types and built-in types) through - * the OCI_Object type. - * - * OTT and C structures are not required to use objects in OCILIB. - * - * In order to manipulate objects attributes, OCILIB proposes a set of functions - * to get/set properties for various supported types. - * - * Objects can be: - * - Created as standalone instances (transient objects) - * - Used for binding (persistent / transient objects) - * - Retrieved from select statements (persistent / embedded objects) - * - * References (Oracle type REF) are identifiers (smart pointers) to objects and - * are implemented in OCILIB with the type OCI_Ref. - * - * OCILIB implements Oracle REFs as strong typed Reference (underlying OCI REFs - * are weaker in terms of typing). - * It means it's mandatory to provide type information to: - * - create a local OCI_Ref handle. - * - register an OCI_Ref handle for a 'returning into' clause. - * - * @note - * See Oracle Database SQL Language Reference for more details about REF data type - * - * @warning - * Prior to v3.5.0, OCILIB relied on some OCI routines to set/get objects - * attributes. these OCI calls had known bugs in Unicode mode that has been fixed in Oracle 11gR2. - * From v3.5.0, OCILIB directly sets objects attributes and thus OCILIB objects - * can now be used in Unicode mode. - * - * @par Example : Inserting a local object into a table - * @include object.c - * - * @par Example : Using Object References - * @include ref.c - * - */ - -/** - * @brief - * Create a local object instance - * - * @param con - Connection handle - * @param typinf - Object type (type info handle) - * - * @return - * Return the object handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_ObjectCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf -); - -/** - * @brief - * Free a local object - * - * @param obj - Object handle - * - * @warning - * Only object created with OCI_ObjectCreate() should be freed - * by OCI_ObjectFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectFree -( - OCI_Object *obj -); - -/** - * @brief - * Create an array of Object objects - * - * @param con - Connection handle - * @param typinf - Object type (type info handle) - * @param nbelem - number of elements in the array - * - * @note - * see OCI_ObjectCreate() for more details - * - * @return - * Return the Object handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Object ** OCI_API OCI_ObjectArrayCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -/** - * @brief - * Free an array of Object objects - * - * @param objs - Array of Object objects - * - * @warning - * Only arrays of Object created with OCI_ObjectArrayCreate() - * should be freed by OCI_ObjectArrayFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectArrayFree -( - OCI_Object **objs -); - -/** - * @brief - * Assign an object to another one - * - * @param obj - Destination Object handle - * @param obj_src - Source Object handle - * - * @note - * Oracle proceeds to a deep copy of the object content - * - * @note - * The two object handles must have the same type otherwise an exception is thrown - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectAssign -( - OCI_Object *obj, - OCI_Object *obj_src -); - -/** - * @brief - * Return the type of an object instance - * - * @param obj - Object handle - * - * @note - * Possibles values are : - * - * - OCI_OBJ_PERSISTENT: persistent object from the DB - * - OCI_OBJ_TRANSIENT : local temporary object - * - OCI_OBJ_VALUE : embedded object - * - * @return - * Instance type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ObjectGetType -( - OCI_Object *obj -); - -/** - * @brief - * Retrieve an Oracle Ref handle from an object and assign it to the given - * OCILIB OCI_Ref handle - * - * @param obj - Object handle - * @param ref - Ref handle - * - * @note - * The type information of the object and the ref must be the same, otherwise - * an exception is thrown - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectGetSelfRef -( - OCI_Object *obj, - OCI_Ref *ref -); - -/** - * @brief - * Return the type info object associated to the object - * - * @param obj - Object handle - * - */ - -OCI_EXPORT OCI_TypeInfo * OCI_API OCI_ObjectGetTypeInfo -( - OCI_Object *obj -); - -/** - * @brief - * Return the boolean value of the given object attribute (ONLY for PL/SQL records) - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetBoolean() returns a valid value only for PL/SQL boolean based attributes - * - * @warning - * - ONLY supported by Oracle 12c and above ! - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectGetBoolean -( - OCI_Object *obj, - const otext *attr -); - -/** -* @brief -* Return the number value of the given object attribute -* -* @param obj - Object handle -* @param attr - Attribute name -* -* @note -* If the attribute is found in the object descriptor attributes list, then a -* data type check is performed for integrity. -* OCI_ObjectGetNumber() returns a valid value only for number based attributes -* -* @return -* Attribute value or NULL on failure or wrong attribute type -* -*/ - -OCI_EXPORT OCI_Number* OCI_API OCI_ObjectGetNumber -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the short value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetShort() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT short OCI_API OCI_ObjectGetShort -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the unsigned short value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetUnsignedShort() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT unsigned short OCI_API OCI_ObjectGetUnsignedShort -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the integer value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetInt() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT int OCI_API OCI_ObjectGetInt -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the unsigned integer value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetUnsignedInt() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_ObjectGetUnsignedInt -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the big integer value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetBigInt() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT big_int OCI_API OCI_ObjectGetBigInt -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the unsigned big integer value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetUnsignedBigInt() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT big_uint OCI_API OCI_ObjectGetUnsignedBigInt -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the double value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetDouble() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0.0 on failure or wrong attribute type - * - */ - -OCI_EXPORT double OCI_API OCI_ObjectGetDouble -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the float value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetFloat() returns a valid value only for integer and number based attributes - * - * @return - * Attribute value or 0.0 on failure or wrong attribute type - * - */ - -OCI_EXPORT float OCI_API OCI_ObjectGetFloat -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the string value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * The method can return a string value for any attributes types. - * It performs implicit string conversions using the same - * mechanisms than OCI_GetString(). See its documentation for more details. - * - * @return - * Attribute value or NULL on failure - * - */ - -OCI_EXPORT const otext * OCI_API OCI_ObjectGetString -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the raw attribute value of the given object attribute into the - * given buffer - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Destination buffer - * @param len - Max size to write into buffer - - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetRaw() copies data into the buffer only for raw based attributes - * - * @return - * Number of bytes written to the buffer or 0 on failure or wrong attribute type - * - */ - -OCI_EXPORT int OCI_API OCI_ObjectGetRaw -( - OCI_Object *obj, - const otext *attr, - void *value, - unsigned int len -); - -/** -* @brief -* Return the raw attribute value size of the given object attribute into the -* given buffer -* -* @param obj - Object handle -* @param attr - Attribute name -* -* @note -* If the attribute is found in the object descriptor attributes list, then a -* data type check is performed for integrity. -* -* @return -* size in bytes of the RAW value or 0 on failure or wrong attribute type -* -*/ - -OCI_EXPORT unsigned int OCI_API OCI_ObjectGetRawSize -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the date value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetDate() returns a valid value only for date based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Date * OCI_API OCI_ObjectGetDate -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the timestamp value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetTimestamp() returns a valid value only for timestamps based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Timestamp * OCI_API OCI_ObjectGetTimestamp -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the interval value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetInterval() returns a valid value only for intervals based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Interval * OCI_API OCI_ObjectGetInterval -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the collection value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetColl() returns a valid value only for intervals based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Coll * OCI_API OCI_ObjectGetColl -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the Ref value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetRef() returns a valid value only for Refs based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Ref * OCI_API OCI_ObjectGetRef -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the object value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetObject() returns a valid value only for object based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_ObjectGetObject -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the lob value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetLob() returns a valid value only for lobs based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_Lob * OCI_API OCI_ObjectGetLob -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Return the file value of the given object attribute - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @note - * If the attribute is found in the object descriptor attributes list, then a - * data type check is performed for integrity. - * OCI_ObjectGetFile() returns a valid value only for files based attributes - * - * @return - * Attribute value or NULL on failure or wrong attribute type - * - */ - -OCI_EXPORT OCI_File * OCI_API OCI_ObjectGetFile -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Set an object attribute of type boolean (ONLY for PL/SQL records) - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - boolean value - * - * @warning - * - ONLY supported by Oracle 12c and above ! - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetBoolean -( - OCI_Object *obj, - const otext *attr, - boolean value -); - -/** -* @brief -* Set an object attribute of type number -* -* @param obj - Object handle -* @param attr - Attribute name -* @param value - number value -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetNumber -( - OCI_Object *obj, - const otext *attr, - OCI_Number *value -); - -/** - * @brief - * Set an object attribute of type short - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Short value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetShort -( - OCI_Object *obj, - const otext *attr, - short value -); - -/** - * @brief - * Set an object attribute of type unsigned short - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Unsigned short value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetUnsignedShort -( - OCI_Object *obj, - const otext *attr, - unsigned short value -); - -/** - * @brief - * Set an object attribute of type int - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetInt -( - OCI_Object *obj, - const otext *attr, - int value -); - -/** - * @brief - * Set an object attribute of type unsigned int - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Unsigned int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetUnsignedInt -( - OCI_Object *obj, - const otext *attr, - unsigned int value -); - -/** - * @brief - * Set an object attribute of type big int - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Big int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetBigInt -( - OCI_Object *obj, - const otext *attr, - big_int value -); - -/** - * @brief - * Set an object attribute of type unsigned big int - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Unsigned big int value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetUnsignedBigInt -( - OCI_Object *obj, - const otext *attr, - big_uint value -); - -/** - * @brief - * Set an object attribute of type double - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Double value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetDouble -( - OCI_Object *obj, - const otext *attr, - double value -); - -/** - * @brief - * Set an object attribute of type float - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Float value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetFloat -( - OCI_Object *obj, - const otext *attr, - float value -); - -/** - * @brief - * Set an object attribute of type string - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - String value - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetString -( - OCI_Object *obj, - const otext *attr, - const otext *value -); - -/** - * @brief - * Set an object attribute of type RAW - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Raw value - * @param len - Size of the raw value - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetRaw -( - OCI_Object *obj, - const otext *attr, - void *value, - unsigned int len -); - -/** - * @brief - * Set an object attribute of type Date - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Date Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetDate -( - OCI_Object *obj, - const otext *attr, - OCI_Date *value -); - -/** - * @brief - * Set an object attribute of type Timestamp - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Timestamp Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetTimestamp -( - OCI_Object *obj, - const otext *attr, - OCI_Timestamp *value -); - -/** - * @brief - * Set an object attribute of type Interval - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Interval Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetInterval -( - OCI_Object *obj, - const otext *attr, - OCI_Interval *value -); - -/** - * @brief - * Set an object attribute of type Collection - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Collection Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetColl -( - OCI_Object *obj, - const otext *attr, - OCI_Coll *value -); - -/** - * @brief - * Set an object attribute of type Object - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Object Handle - * - * @warning - * This function assigns a copy of the object to the given attribute. - * Any further modifications of the object passed as the parameter 'value' - * will not be reflected to object 's attribute set with this call - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetObject -( - OCI_Object *obj, - const otext *attr, - OCI_Object *value -); - -/** - * @brief - * Set an object attribute of type Lob - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Lob Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetLob -( - OCI_Object *obj, - const otext *attr, - OCI_Lob *value -); - -/** - * @brief - * Set an object attribute of type File - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - File Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetFile -( - OCI_Object *obj, - const otext *attr, - OCI_File *value -); - -/** - * @brief - * Set an object attribute of type Ref - * - * @param obj - Object handle - * @param attr - Attribute name - * @param value - Ref Handle - * - * @note - * passing a null pointer for value calls OCI_ObjectSetNull() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetRef -( - OCI_Object *obj, - const otext *attr, - OCI_Ref *value -); - -/** - * @brief - * Check if an object attribute is null - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @return - * FALSE if the attribute is not null otherwise TRUE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectIsNull -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Set an object attribute to null - * - * @param obj - Object handle - * @param attr - Attribute name - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectSetNull -( - OCI_Object *obj, - const otext *attr -); - -/** - * @brief - * Retrieve the underlying C (OTT/OCI style) structure of an OCI_Object handle - * - * @param obj - Object handle - * @param pp_struct - Address of a pointer that retrieve the C structure of data - * @param pp_ind - Address of a pointer that retrieve the C structure of indicators - * - * @note - * See Oracle OCI programming guide for more details about OTT structures. - * The members of these structures are OCI data types like OCINumber, OCIString - * that requires mixing OCILIB code and raw OCI code. - * OCI Object API headers have to be included to handle this data types using OCI object functions - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectGetStruct -( - OCI_Object *obj, - void **pp_struct, - void **pp_ind -); - -/** - * @brief - * Convert an object handle value to a string - * - * @param obj - Object handle - * @param size - Destination string length pointer in characters - * @param str - Destination string - * - * @note - * In order to compute the needed string length, call the method with a NULL string - * Then call the method again with a valid buffer - * - * @note - * The resulting string is similar to the SQL*PLUS output for UDTs (user types and objects) - * For RAWs and BLOBs attributes, their binary values are converted to hexadecimal strings - * - * @warning - * This convenient method shall not be used when performance matters. It is usually called twice (buffer length - * computation) and must also care about quotes within strings. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ObjectToText -( - OCI_Object *obj, - unsigned int *size, - otext *str -); - -/** - * @brief - * Create a local Ref instance - * - * @param con - Connection handle - * @param typinf - Ref type - * - * @return - * Return the Ref handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Ref * OCI_API OCI_RefCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf -); - -/** - * @brief - * Free a local Ref - * - * @param ref - Ref handle - * - * @warning - * Only Refs created with OCI_RefCreate() should be freed - * by OCI_RefFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RefFree -( - OCI_Ref *ref -); - -/** - * @brief - * Create an array of Ref object - * - * @param con - Connection handle - * @param typinf - Object type (type info handle) - * @param nbelem - number of elements in the array - * - * @note - * see OCI_RefCreate() for more details - * - * @return - * Return the Ref handle array on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Ref ** OCI_API OCI_RefArrayCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -/** - * @brief - * Free an array of Ref objects - * - * @param refs - Array of Ref objects - * - * @warning - * Only arrays of Ref created with OCI_RefArrayCreate() - * should be freed by OCI_RefArrayFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RefArrayFree -( - OCI_Ref **refs -); - -/** - * @brief - * Assign a Ref to another one - * - * @param ref - Destination Ref handle - * @param ref_src - Source Ref handle - * - * @note - * The two Ref handles must have the same type otherwise an exception is thrown - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RefAssign -( - OCI_Ref *ref, - OCI_Ref *ref_src -); - -/** - * @brief - * Return the type info object associated to the Ref - * - * @param ref - Ref handle - * - */ - -OCI_EXPORT OCI_TypeInfo * OCI_API OCI_RefGetTypeInfo -( - OCI_Ref *ref -); - -/** - * @brief - * Returns the object pointed by the Ref handle. - * - * @param ref - Ref handle - * - * @return - * The object handle is the ref is not null otherwise NULL - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_RefGetObject -( - OCI_Ref *ref -); - -/** - * @brief - * Check if the Ref points to an object or not. - * - * @param ref - Ref handle - * - * @return - * TRUE if it does not point to a valid object otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RefIsNull -( - OCI_Ref *ref -); - -/** - * @brief - * Nullify the given Ref handle - * - * @param ref - Ref handle - * - * @note - * this call clears the reference to object pointed by the Ref handle. - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_RefSetNull -( - OCI_Ref *ref -); - -/** - * @brief - * Returns the size of the hex representation of the given Ref handle - * - * @param ref - Ref handle - * - * @note - * the returned size is the number of character needed to store the - * hex representation of the Ref that can be retrieved with OCI_RefToText() - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_RefGetHexSize -( - OCI_Ref *ref -); - -/** - * @brief - * Converts a Ref handle value to a hexadecimal string. - * - * @param ref - Ref handle - * @param size - Destination string size in characters - * @param str - Destination string - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_RefToText -( - OCI_Ref *ref, - unsigned int size, - otext *str -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiAbort Aborting long operations - * @{ - * - * The Oracle OCI provides the ability to establish a server connection in : - * - * - blocking mode: each call to an OCI function returns control to the - * application when the call completes - * - non-blocking mode (based on polling paradigm) : the application have to - * call each function until its has completed its job - * - * OCILIB implements OCI in blocking mode. The application has to wait for OCI - * calls to complete to continue. - * - * Some operations can be long to be processed by the server. - * - * In order to cancel the current pending call, OCILIB provides OCI_Break() that - * cancel the last internal OCI Call and then raise an OCI abortion error code. - * - * @note - * Any call to OCI_Break() has to be done from a separate thread because the - * thread that has executed a long OCI call is waiting for its OCI call to complete. - * - * @par Example - * @include abort.c - * - */ - -/** - * @brief - * Perform an immediate abort of any currently Oracle OCI call - * - * @param con - connection handle - * - * @note - * The current call will abort and generate an error - * - * @return - * Returns FALSE if connection handle is NULL otherwise TRUE - */ - -OCI_EXPORT boolean OCI_API OCI_Break -( - OCI_Connection *con -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiMetadata Describing Schema Meta data and Objects - * @{ - * - * - * @par Example - * @include desc.c - * - */ - -/** - * @brief - * Retrieve the available type info information - * - * @param con - Connection handle - * @param name - Table/view name to query for - * @param type - Type of object - * - * @note - * Possible values for parameter type are : - * - * - OCI_UNKNOWN - * - OCI_TIF_TABLE - * - OCI_TIF_VIEW - * - OCI_TIF_TYPE - * - * @return - * - Type info handle on success - = - NULL if the object does not exist - * - NULL on failure - * - */ - -OCI_EXPORT OCI_TypeInfo * OCI_API OCI_TypeInfoGet -( - OCI_Connection *con, - const otext *name, - unsigned int type -); - -/** - * @brief - * Return the type of the type info object - * - * @param typinf - Type info handle - * - * @note - * Possible values for parameter type are : - * - * - OCI_UNKNOWN - * - OCI_TIF_TABLE - * - OCI_TIF_VIEW - * - OCI_TIF_TYPE - * - * @return - * Object type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetType -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Retrieve connection handle from the type info handle - * - * @param typinf - Type info handle - * - */ - -OCI_EXPORT OCI_Connection * OCI_API OCI_TypeInfoGetConnection -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Free a type info object - * - * @param typinf - Type info handle - * - * @note - * this call is optional. - * OCI_TypeInfo object are internally tracked and - * automatically freed when their related connection is freed - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_TypeInfoFree -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Return the number of columns of a table/view/object - * - * @param typinf - Type info handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetColumnCount -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Return the column object handle at the given index in the table - * - * @param typinf - Type info handle - * @param index - Column position - * - * @return - * - Column handle on success - * - NULL if index is out of bounds or on error - * - */ - -OCI_EXPORT OCI_Column * OCI_API OCI_TypeInfoGetColumn -( - OCI_TypeInfo *typinf, - unsigned int index -); - -/** - * @brief - * Return the name described by the type info object - * - * @param typinf - Type info handle - * - */ - -OCI_EXPORT const otext * OCI_API OCI_TypeInfoGetName -( - OCI_TypeInfo *typinf -); - -/** -* @brief -* Indicate if the given UDT type if final -* -* @note -* Non-final types are virtual UDT type that can be inherited -* -* @param typinf - Type info handle -* -* @note -* This property is only valid for UDTs (OCI_TIF_TYPE) -* -* @return -* - when OCI_TypeInfoGetType() returns OCI_UNKNOWN, OCI_TIF_TABLE, OCI_TIF_VIEW: returns TRUE -* - when OCI_TypeInfoGetType() returns OCI_TIF_TYPE: returns TRUE if the type is final and FALSE if it is virtual -* -*/ - -OCI_EXPORT boolean OCI_API OCI_TypeInfoIsFinalType -( - OCI_TypeInfo *typinf -); - -/** -* @brief -* Return the super type of the given type (e.g. parent type for a derived ORACLE UDT type) -* -* @param typinf - Type info handle -* -* @note -* This property is only valid for UDTs (OCI_TIF_TYPE) -* -* @return -* - when OCI_TypeInfoGetType() returns OCI_UNKNOWN, OCI_TIF_TABLE, OCI_TIF_VIEW: -* - returns NULL -* - when OCI_TypeInfoGetType() returns OCI_TIF_TYPE: -* - returns the TypeInfo handle wrapping the parent super type -* - returns NULL if the given type is NOT deriving from a base type -* -*/ - -OCI_EXPORT OCI_TypeInfo* OCI_API OCI_TypeInfoGetSuperType -( - OCI_TypeInfo *typinf -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiFormatting Formatted functions - * @{ - * - * OCILIB offers some smart routines that takes a variable number of arguments - * in order to minimize OCILIB function calls and reduce the amount of code lines - * - * On Windows platforms, the target programming language must support the __cdecl - * calling convention - * - * @note - * OCI_Immediate() and OCI_ImmediateFmt() support all OCILIB supported types - * for output result, except : - * - OCI_Long - * - OCI_Statement - * If a query output result contains one of these unsupported types, the function returns FALSE - * - * @note - * In the parameter list, every output placeholder MUST be preceded by - * an integer parameter that indicates the type of the placeholder - * in order to handle correctly the given pointer. - * - * Possible values for indicating placeholders type : - * - * - OCI_ARG_SHORT ------> short * - * - OCI_ARG_USHORT -----> unsigned short * - * - OCI_ARG_INT --------> int * - * - OCI_ARG_UINT -------> unsigned int* - * - OCI_ARG_BIGINT -----> big_int * - * - OCI_ARG_BIGUINT ----> unsigned big_int * - * - OCI_ARG_DOUBLE ----> double * - * - OCI_ARG_FLOAT ------> float * - * - OCI_ARG_NUMBER -----> OCI_Number * - * - OCI_ARG_TEXT -------> otext * - * - OCI_ARG_RAW --------> void * - * - OCI_ARG_DATETIME ---> OCI_Date * - * - OCI_ARG_LOB --------> OCI_Lob * - * - OCI_ARG_FILE -------> OCI_File * - * - OCI_ARG_TIMESTAMP --> OCI_Timestamp * - * - OCI_ARG_INTERVAL ---> OCI_Interval * - * - OCI_ARG_OBJECT -----> OCI_Object * - * - OCI_ARG_COLLECTION -> OCI_Coll * - * - OCI_ARG_REF --------> OCI_Ref * - * - * @note - * For output strings and Raws, returned data is copied to the given buffer - * instead of returning a pointer the real data. - * So these buffers must be big enough to hold the column content. No size check is performed. - * - * - For strings, only the real string is copied. - * - For Raws, the number of bytes copied is the column size - * - * @warning - * Input parameters for formatted function only support a restricted set of data types ! - * - * Supported input identifiers : - * - * - '%s' : (otext *) ----------> input string (quotes are added) - * - '%m' : (otext *) ----------> meta data string (no quotes added) - * - '%t' : (OCI_Date *) -------> Date - * - '%p' : (OCI_Timestamp *) --> timestamp - * - '%v' : (OCI_Interval *) ---> Interval - * - '%i' : (int) --------------> signed 32 bits integer - * - '%u' : (unsigned int) -----> unsigned 32 bits integer - * - '%li' : (big_int) ----------> signed 64 bits integer - * - '%lu' : (big_uint) ---------> unsigned 64 bits integer - * - '%hi' : (short) ------------> signed 16 bits integer - * - '%hu' : (unsigned short) ---> unsigned 16 bits integer - * - '%g' : (double, float ) ---> Numerics - * - '%n' : (OCI_Number *) -----> Number - * - '%r' : (OCI_Ref *) --------> Reference - * - '%o' : (OCI_Object *) -----> Object (not implemented yet) - * - '%c' : (OCI_Coll *) -------> collection (not implemented yet) - * - * @par Example - * @include format.c - * - */ - -/** - * @brief - * Perform 3 calls (prepare+execute+fetch) in 1 call - * - * @param con - Connection handle - * @param sql - SQL statement - * @param ... - List of program variables address to store the result of fetch operation - * - * @note - * Every output parameter MUST be preceded by an integer parameter that indicates the type - * of the placeholder in order to handle correctly the given pointer. - * - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_Immediate -( - OCI_Connection *con, - const otext *sql, - ... -); - -/** - * @brief - * Performs 4 call (prepare+bind+execute+fetch) in 1 call - * - * @param con - Connection handle - * @param sql - SQL statement - * @param ... - List of program values to format the SQL followed by the - * output variables addresses for the fetch operation - * - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_ImmediateFmt -( - OCI_Connection *con, - const otext *sql, - ... -); - -/** - * @brief - * Prepare a formatted SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * @param sql - SQL statement - * @param ... - List of program values to format the SQL - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_PrepareFmt -( - OCI_Statement *stmt, - const otext *sql, - ... -); - -/** - * @brief - * Execute a formatted SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * @param sql - SQL statement - * @param ... - List of program values to format the SQL - * - * @return - * TRUE on success otherwise FALSE - * - * @warning - * If a SQL warning occurs: - * - the function returns TRUE - * - the SQL warning triggers the global error handler with an OCI_Error having its OCI_ErrorGetType() - * attribute set to OCI_ERR_WARNING - * - If OCILIB is initialized with the OCI_ENV_CONTEXT mode, OCI_GetLastError() will return the OCI_Error - * object corresponding to the warning - * - */ - -OCI_EXPORT boolean OCI_ExecuteStmtFmt -( - OCI_Statement *stmt, - const otext *sql, - ... -); - -/** - * @brief - * Parse a formatted SQL statement or PL/SQL block. - * - * @param stmt - Statement handle - * @param sql - SQL statement - * @param ... - List of program values to format the SQL - * - * @note - * This call sends the SQL or PL/SQL command to the server for parsing only. - * The command is not executed. - * This call is only useful to check is a command is valid or not. - * - * @note - * This call prepares the statement (internal call to OCI_Prepare()) and ask - * the Oracle server to parse its SQL or PL/SQL command. - * OCI_Execute() can be call after OCI_ParseFmt() in order to execute the - * statement, which means that the server will re-parse again the command. - * - * @warning - * Do not use OCI_ParseFmt() unless you're only interested in the parsing result - * because the statement will be parsed again when executed and thus leading to - * unnecessary server round-trips and less performance - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_ParseFmt -( - OCI_Statement *stmt, - const otext *sql, - ... -); - -/** - * @brief - * Describe the select list of a formatted SQL select statement. - * - * @param stmt - Statement handle - * @param sql - SQL statement - * @param ... - List of program values to format the SQL - * - * @note - * This call sends the SELECT SQL order to the server for retrieving the - * description of the select order only. - * The command is not executed. - * This call is only useful to retrieve information on the associated resultset - * Call OCI_GetResultset() after OCI_Describe() to access to SELECT list - * information - * - * @note - * This call prepares the statement (internal call to OCI_Prepare()) and ask - * the Oracle server to describe the output SELECT list. - * OCI_Execute() can be call after OCI_Describe() in order to execute the - * statement, which means that the server will parse, and describe again the SQL - * order. - * - * @warning - * Do not use OCI_Describe() unless you're only interested in the resultset - * information because the statement will be parsed again when executed and thus - * leading to unnecessary server round-trips and less performance - * - * @return - * TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_DescribeFmt -( - OCI_Statement *stmt, - const otext *sql, - ... -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiHashTables Hash tables - * @{ - * - * OCILIB uses hash tables internally for index/name columns mapping. - * - * OCILIB makes public its hash table’s implementation public for general purpose - * uses. - * - * OCI_HashTable objects manage string keys / values that can be : - * - * - integers - * - strings - * - pointers - * - * This hash table implementation : - * - * - handle collisions - * - allows multiple values per key - * - * @par Internal conception - * - * - The hash table is composed of an array of slots. - * - Each slot can hold a linked list of entries (one per key) - * - Each entry can hold a linked list of values - * - * @note - * - The internal hash function computes the index in the array where the entry - * has to be inserted/looked up. - * - * - * @note - * Collisions are handled by chaining method. - * - * @include hash.c - * - */ - -/** - * @brief - * Create a hash table - * - * @param size - size of the hash table - * @param type - type of the hash table - * - * @note - * Parameter can be one of the following values : - * - * - OCI_HASH_STRING : string values - * - OCI_HASH_INTEGER : integer values - * - OCI_HASH_POINTER : pointer values - * - * @return - * Hash handle on success or NULL on failure - * - */ - -OCI_EXPORT OCI_HashTable * OCI_API OCI_HashCreate -( - unsigned int size, - unsigned int type -); - -/** - * @brief - * Destroy a hash table - * - * @param table - Table handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_HashFree -( - OCI_HashTable *table -); - -/** - * @brief - * Return the size of the hash table - * - * @param table - Table handle - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_HashGetSize -( - OCI_HashTable *table -); - -/** - * @brief - * Return the type of the hash table - * - * @param table - Table handle - * - * @note - * the return value can be one of the following values : - * - * - OCI_HASH_STRING : string values - * - OCI_HASH_INTEGER : integer values - * - OCI_HASH_POINTER : pointer values - * - * @return - * Hash table data type or OCI_UNKNOWN the input handle is NULL - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_HashGetType -( - OCI_HashTable *table -); - -/** - * @brief - * Add a pair string key / string value to the hash table - * - * @param table - Table handle - * @param key - String key - * @param value - string value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_HashAddString -( - OCI_HashTable *table, - const otext *key, - const otext *value -); - -/** - * @brief - * Return the string value associated to the given key - * - * @param table - Table handle - * @param key - String key - * - * @return - * Stored string associated with the key otherwise NULL - * - */ - -OCI_EXPORT const otext * OCI_API OCI_HashGetString -( - OCI_HashTable *table, - const otext *key -); - -/** - * @brief - * Adds a pair string key / integer value to the hash table - * - * @param table - Table handle - * @param key - String key - * @param value - Integer value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_HashAddInt -( - OCI_HashTable *table, - const otext *key, - int value -); - -/** - * @brief - * Return the integer value associated to the given key - * - * @param table - Table handle - * @param key - String key - * - * @return - * Stored integer associated with the key otherwise 0 - * - */ - -OCI_EXPORT int OCI_API OCI_HashGetInt -( - OCI_HashTable *table, - const otext *key -); - -/** - * @brief - * Adds a pair string key / pointer value to the hash table - * - * @param table - Table handle - * @param key - String key - * @param value - Pointer value - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_HashAddPointer -( - OCI_HashTable *table, - const otext *key, - void *value -); - -/** - * @brief - * Return a pointer associated with the given key - * - * @param table - Table handle - * @param key - String key - * - * @return - * Stored pointer associated with the key otherwise NULL - * - */ - -OCI_EXPORT void * OCI_API OCI_HashGetPointer -( - OCI_HashTable *table, - const otext *key -); - -/** - * @brief - * Lookup for an entry matching the key in the table - * - * @param table - Table handle - * @param key - String key - * @param create - Do create the entry if not exists - * - * @return - * Entry handle if key found/added otherwise NULL - * - */ - -OCI_EXPORT OCI_HashEntry * OCI_API OCI_HashLookup -( - OCI_HashTable *table, - const otext *key, - boolean create -); - -/** - * @brief - * Return the first hash slot that matches the key - * - * @param table - Table handle - * @param key - String key - * - * @return - * Slot handle if key found otherwise NULL - * - */ - -OCI_EXPORT OCI_HashValue * OCI_API OCI_HashGetValue -( - OCI_HashTable *table, - const otext *key -); - -/** - * @brief - * Return the entry slot of the hash table internal list at the given position - * - * @param table - Table handle - * @param index - index - * - * @warning - * Index start at at - * - * @return - * Slot handle otherwise NULL - * - */ - -OCI_EXPORT OCI_HashEntry * OCI_API OCI_HashGetEntry -( - OCI_HashTable *table, - unsigned int index -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiThreading Threads and mutexes - * @{ - * - * Oracle proposes a portable implementation of Mutex and Thread objects - * - * OCILIB implements these OCI features for portable multi-threading support. - * - * Mutexes are designed for mutual exclusion between thread in order to lock resources temporarily - * - * Thread keys can be seen as process-wide variables that have a thread-specific - * values. It allows to create a unique key identified by a name (string) that - * can store values specific to each thread. - * - * OCILIB exposes the types OCI_Mutex, OCI_Thread - * - * @warning - * OCILIB MUST be initialized with OCI_ENV_THREADED to enable threads support - * - * @warning - * OCI_Thread relies on Oracle API which uses natives threading capabilities of - * the supported platform - * - * @warning - * Using OCI_Mutex : - * - On Microsoft Windows, a thread can call OCI_MutexAcquire() more than once - * without any blocking. Just be sure that there is an OCI_MutexRelease() for - * every OCI_MutexAcquire() call - * - On Unix systems, a thread MUST call OCI_MutexRelease() after every call to - * OCI_MutexAcquire() in order to be able to call OCI_MutexAcquire() again. If - * not, it will be blocked... - * - * @par Example - * @include thread.c - * - */ - -/** - * @brief - * Create a Mutex object - * - * @return - * Mutex handle on success or NULL on failure - * - */ - -OCI_EXPORT OCI_Mutex * OCI_API OCI_MutexCreate -( - void -); - -/** - * @brief - * Destroy a mutex object - * - * @param mutex - Mutex handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MutexFree -( - OCI_Mutex *mutex -); - -/** - * @brief - * Acquire a mutex lock - * - * @param mutex - Mutex handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MutexAcquire -( - OCI_Mutex *mutex -); - -/** - * @brief - * Release a mutex lock - * - * @param mutex - Mutex handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MutexRelease -( - OCI_Mutex *mutex -); - -/** - * @brief - * Create a Thread object - * - * @return - * Thread handle on success or NULL on failure - * - */ - -OCI_EXPORT OCI_Thread * OCI_API OCI_ThreadCreate -( - void -); - -/** - * @brief - * Destroy a thread object - * - * @param thread - Thread handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ThreadFree -( - OCI_Thread *thread -); - -/** - * @brief - * Execute the given routine within the given thread object - * - * @param thread - Thread handle - * @param proc - routine to execute - * @param arg - parameter to pass to the routine - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ThreadRun -( - OCI_Thread *thread, - POCI_THREAD proc, - void *arg -); - -/** - * @brief - * Join the given thread - * - * @param thread - Thread handle - * - * @note - * This function waits for the given thread to finish - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ThreadJoin -( - OCI_Thread *thread -); - -/** - * @brief - * Create a thread key object - * - * @param name - Thread key name - * @param destfunc - Thread key value destructor function - * - * @note - * Parameter proc is optional. It's called when the thread terminates to allow - * the program to deal with the thread specific value of the key - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ThreadKeyCreate -( - const otext *name, - POCI_THREADKEYDEST destfunc -); - -/** - * @brief - * Set a thread key value - * - * @param name - Thread key name - * @param value - user value to set - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_ThreadKeySetValue -( - const otext *name, - void *value -); - -/** - * @brief - * Get a thread key value - * - * @param name - Thread key name - * - * @return - * Thread key value on success otherwise FALSE - * - */ - -OCI_EXPORT void * OCI_API OCI_ThreadKeyGetValue -( - const otext *name -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiDirectPath Direct Path loading - * @{ - * - * OCILIB (from version 3.2.0) support the OCI direct Path API. - * - * Actual implementation of direct path API does not support the following - * elements : - * - Objects data types (User Defined Types and Object References) - * - Object tables - * - Nested tables - * - SQL String functions - * - * All scalar data types (numerics, characters and date/time), including LOBs - * and LONG types are supported - * - * @par Oracle direct API features (from Oracle Documentation) - * - * The direct path load interface allows an application to access the direct path - * load engine of the Oracle database server to perform the functions of the - * Oracle SQL*Loader utility. - * This functionality provides the ability to load data from external files - * into Oracle database objects, either a table or a partition of a partitioned - * table. - * The OCI direct path load interface has the ability to load multiple rows by - * loading a direct path stream which contains data for multiple rows. - * - * @par Oracle direct API limitation (from Oracle Documentation) - * The direct path load interface has the following limitations which are the - * same as SQL*Loader: - * - triggers are not supported - * - check constraints are not supported - * - referential integrity constraints are not supported - * - clustered tables are not supported - * - loading of remote objects is not supported - * - user-defined types are not supported - * - LOBs must be specified after all scalar columns - * - LONGs must be specified last - * - * @warning - * - * Its recommended to use direct path interface with an Oracle client that is - * the same version than the database. With version < 10g, it is mandatory - * regarding that it causes segmentation faults and it's known from Oracle that - * advices to use the same version for client and server (see metalink KB) - * - * @par How to use direct path - * - * - 1 : Create a direct path handle with OCI_DirPathCreate() - * - 2 : Set (optional) some direct path load attributes - * - 3 : Describe the columns to load with OCI_DirPathSetColumn() - * - 4 : Populate data with OCI_DirPathSetEntry() - * - 5 : Convert the data with OCI_DirPathConvert() - * - 6 : Load the data into the database with OCI_DirPathLoad() - * - 7 : Repeat step 4,5,6 + reset the stream with OCI_DirPathReset() until all - * rows has been loaded - * - 8 : Commit the load with OCI_DirPathFinish() - * - 9 : Free the direct path handle with OCI_DirPathFree() - * - * @par Example - * @include dirpath.c - * - */ - -/** - * @brief - * Create a direct path object - * - * @param typinf - Table type info handle - * @param partition - Partition name - * @param nb_cols - Number of columns to load - * @param nb_rows - Maximum of rows to handle per load operation - * - * @note - * Retrieve the table type info handle with OCI_TypeInfoGet(). - * The partition name is not mandatory - * - * @note - * Parameter 'nb_rows' is ignored for Oracle 8i. Prior to Oracle 9i, it's the - * OCI client that decides of the number of rows to process per convert/load calls. - * From Oracle 9i, OCI allows application to specify this value. Note that, the - * OCI client might not accept the input value. After OCI_DirPathPrepare() has - * been successfully called, OCI_DirPathGetMaxRows() returns the final number - * of rows used for the given direct path operation. - * - * @return - * Return the direct path handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_DirPath * OCI_API OCI_DirPathCreate -( - OCI_TypeInfo *typinf, - const otext *partition, - unsigned int nb_cols, - unsigned int nb_rows -); - -/** - * @brief - * Free an OCI_DirPath handle - * - * @param dp - Direct path Handle - * - * @return - * TRUE on success otherwise FALSE - * - */ -OCI_EXPORT boolean OCI_API OCI_DirPathFree -( - OCI_DirPath *dp -); - -/** - * @brief - * Describe a column to load into the given table - * - * @param dp - Direct path Handle - * @param index - Column index - * @param name - Column name - * @param maxsize - Maximum input value size for a column entry - * @param format - Date or numeric format to use - * - * @note - * An error is thrown if : - * - If the column specified by the 'name' parameter is not found in the table - * referenced by the type info handle passed to OCI_DirPathCreate() - * - the index is out of bounds (= 0 or >= number of columns) - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetColumn -( - OCI_DirPath *dp, - unsigned int index, - const otext *name, - unsigned int maxsize, - const otext *format -); - -/** - * @brief - * Prepares the OCI direct path load interface before any rows can be converted - * or loaded - * - * @param dp - Direct path Handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathPrepare -( - OCI_DirPath *dp -); - -/** - * @brief - * Set the value of the given row/column array entry - * - * @param dp - Direct path Handle - * @param row - Row index - * @param index - Column index - * @param value - Value to set - * @param size - Size of the input value - * @param complete - Is the entry content fully provided ? - * - * @note - * Rows and columns indexes start at 1. - * - * @note - * The 'size' parameter is expressed in number of : - * - bytes for binary columns - * - characters for other columns - * - * @note - * Direct path support piece loading for LONGs and LOBs columns. When filling - * these columns, it's possible to provide input buffer piece by piece. In order - * to do so : - * - set the 'complete' parameter to FALSE - * - set the 'size' parameter to the piece size - * - Repeat calls to OCI_DirPathSetEntry() until the data is totally provided - * - The last call that set the last piece or an entry must specify the value - * TRUE for the 'complete' parameter - * - * @warning - * Current Direct Path OCILIB implementation DOES NOT support setting entry - * content piece by piece as mentioned above. It was planned in the original design - * but not supported yet. So, always set the complete parameter to TRUE. - * Setting entries content piece by piece may be supported in future releases - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetEntry -( - OCI_DirPath *dp, - unsigned int row, - unsigned int index, - void *value, - unsigned size, - boolean complete -); - -/** - * @brief - * Convert provided user data to the direct path stream format - * - * @param dp - Direct path Handle - * - * @return - * Possible return values : - * - OCI_DPR_COMPLETE : load has been successful - * - OCI_DPR_ERROR : an error happened while loading data - * - OCI_DPR_FULL : the internal stream is full - * - OCI_DPR_PARTIAL : a column has not been fully filled yet - * - OCI_DPR_EMPTY : no data was found to convert - * - * @note - * - When using conversion mode OCI_DCM_DEFAULT, OCI_DirPathConvert() stops when - * any error is encountered and returns OCI_DPR_ERROR - * - When using conversion mode OCI_DCM_FORCE, OCI_DirPathConvert() does not stop - * on errors. Instead it discards any erred rows and returns OCI_DPR_COMPLETE once - * all rows are processed. - * - * @note - * List of faulted rows and columns can be retrieved using OCI_DirPathGetErrorRow() and - * OCI_DirPathGetErrorColumn() - * - * @note - * OCI_DirPathGetAffectedRows() returns the number of rows converted in the last call. - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathConvert -( - OCI_DirPath *dp -); - -/** - * @brief - * Loads the data converted to direct path stream format - * - * @param dp - Direct path Handle - * - * @return - * Possible return values : - * - OCI_DPR_COMPLETE : conversion has been successful - * - OCI_DPR_ERROR : an error happened while converting data - * - OCI_DPR_FULL : the internal stream is full - * - OCI_DPR_PARTIAL : a column has not been fully filled yet - * - OCI_DPR_EMPTY : no data was found to load - * - * @note - * List of faulted rows can be retrieved using OCI_DirPathGetErrorRow() - * - * @note - * OCI_DirPathGetAffectedRows() returns the number of rows successfully loaded in the last call. - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathLoad -( - OCI_DirPath *dp -); - -/** - * @brief - * Reset internal arrays and streams to prepare another load - * - * @param dp - Direct path Handle - * - * @note - * Once some data have been converted or loaded, OCI_DirPathReset() resets - * internal OCI structures in order to prepare another load operation - * (set entries, convert and load) - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathReset -( - OCI_DirPath *dp -); - -/** - * @brief - * Terminate a direct path operation and commit changes into the database - * - * @param dp - Direct path Handle - * - * @warning - * The direct path handle cannot be used anymore after this call for any more - * loading operations and must be freed with OCI_DirPathFree(). - * - * @note - * Some properties functions of the direct path handle, such as - * OCI_DirPathGetRowCount() can be called on a terminated direct path handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathFinish -( - OCI_DirPath *dp -); - -/** - * @brief - * Terminate a direct path operation without committing changes - * - * @param dp - Direct path Handle - * - * @note - * Any pending loaded data are canceled. - * Any load completion operations, such as index maintenance operations, are not performed. - * - * @warning - * The direct path handle cannot be used anymore after this call for any more - * loading operations and must be freed with OCI_DirPathFree(). - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathAbort -( - OCI_DirPath *dp -); - -/** - * @brief - * Execute a data save-point (server side) - * - * @param dp - Direct path Handle - * - * @note - * Executing a data save-point is not allowed for LOBs - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSave -( - OCI_DirPath *dp -); - -/** - * @brief - * Flushes a partially loaded row from server - * - * @param dp - Direct path Handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathFlushRow -( - OCI_DirPath *dp -); - -/** - * @brief - * Set the current number of rows to convert and load - * - * @param dp - Direct path Handle - * @param nb_rows - Number of row to process - * - * @warning - * An OCILIB error will be thrown if the value exceeds the maximum number of - * rows in the internals arrays - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetCurrentRows -( - OCI_DirPath *dp, - unsigned int nb_rows -); - -/** - * @brief - * Return the current number of rows used in the OCILIB internal - * arrays of rows - * - * @param dp - Direct path Handle - * - * @return - * Internal current array size on SUCCESS otherwise 0 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathGetCurrentRows -( - OCI_DirPath *dp -); - -/** - * @brief - * Return the maximum number of rows allocated in the OCI and OCILIB - * internal arrays of rows - * - * @param dp - Direct path Handle - * - * @return - * Internal maximum array size on SUCCESS otherwise 0 - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathGetMaxRows -( - OCI_DirPath *dp -); - -/** - * @brief - * Set the default date format string for input conversion - * - * @param dp - Direct path Handle - * @param format - date format - * - * @note - * For string to date conversion, Oracle uses : - * - Column date format - * - Default date format (modified by this call) - * - Default global support environment setting - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetDateFormat -( - OCI_DirPath *dp, - const otext *format -); - -/** - * @brief - * Set the parallel loading mode - * - * @param dp - Direct path Handle - * @param value - enable/disable parallel mode - * - * @note - * Default value is FALSE. - * - * @note - * Setting the value to TRUE allows multiple load sessions to load the same - * segment concurrently - * - * @par Parallel loading mode (From Oracle documentation) - * - * A direct load operation requires that the object being loaded is locked to - * prevent DML on the object. - * Note that queries are lock-free and are allowed while the object is being loaded. - * - For a table load, if the option is set to: - * - FALSE, then the table DML X-Lock is acquired. - * - TRUE, then the table DML S-Lock is acquired. - * - For a partition load, if the option is set to: - * - FALSE, then the table DML SX-Lock and partition DML X-Lock is acquired. - * - TRUE, then the table DML SS-Lock and partition DML S-Lock is acquired. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetParallel -( - OCI_DirPath *dp, - boolean value -); - -/** - * @brief - * Set the logging mode for the loading operation - * - * @param dp - Direct path Handle - * @param value - enable/disable logging - * - * @par Logging mode (from Oracle Documentation) - * - * The NOLOG attribute of each segment determines whether image redo or - * invalidation redo is generated: - * - FALSE : Use the attribute of the segment being loaded. - * - TRUE : No logging. Overrides DDL statement, if necessary. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetNoLog -( - OCI_DirPath *dp, - boolean value -); - -/** - * @brief - * Set number of elements in the date cache - * - * @param dp - Direct path Handle - * @param size - Buffer size - * - * @note - * Default value is 0. - * - * @note - * Setting the value to 0 disables the cache - * - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetCacheSize -( - OCI_DirPath *dp, - unsigned int size -); - -/** - * @brief - * Set the size of the internal stream transfer buffer - * - * @param dp - Direct path Handle - * @param size - Buffer size - * - * @note - * Default value is 64KB. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetBufferSize -( - OCI_DirPath *dp, - unsigned int size -); - -/** - * @brief - * Set the direct path conversion mode - * - * @param dp - Direct path Handle - * @param mode - Conversion mode - * - * @note - * Possible values for parameter 'mode' : - * - OCI_DCM_DEFAULT : conversion fails on error - * - OCI_DCM_FORCE : conversion does not fail on error - * - * @note - * See OCI_DirPathConvert() for conversion mode details - * - * @note - * Default value is OCI_DCM_DEFAULT - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DirPathSetConvertMode -( - OCI_DirPath *dp, - unsigned int mode -); - -/** - * @brief - * Return the number of rows successfully loaded into the database so far - * - * @param dp - Direct path Handle - * - * @note - * Insertions are committed with OCI_DirPathFinish() - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathGetRowCount -( - OCI_DirPath *dp -); - -/** - * @brief - * return the number of rows successfully processed during in the last - * conversion or loading call - * - * @param dp - Direct path Handle - * - * @note - * This function called after : - * - * - OCI_DirPathConvert(), returns the number of converted rows - * - OCI_DirPathLoad(), returns the number of loaded rows - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathGetAffectedRows -( - OCI_DirPath *dp -); - -/** - * @brief - * Return the index of a column which caused an error during data conversion - * - * @param dp - Direct path Handle - * - * @warning - * Direct path column indexes start at 1. - * - * @note - * Errors may happen while data is converted to direct path stream format - * using OCI_DirPathConvert(). - * When using conversion mode OCI_DCM_DEFAULT, OCI_DirPathConvert() returns - * OCI_DPR_ERROR on error. OCI_DirPathGetErrorColumn() returns the column index - * that caused the error - * When using conversion mode OCI_DCM_FORCE, OCI_DirPathConvert() returns - * OCI_DPR_COMPLETE even on errors. In order to retrieve the list of all column - * indexes that have erred, the application can call OCI_DirPathGetErrorColumn() - * repeatedly until it returns 0. - * - * @note - * The internal value is reset to 0 when calling OCI_DirPathConvert() - * - * @return - * 0 is no error occurs otherwise the index of the given column which caused an - * error - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorColumn -( - OCI_DirPath *dp -); - -/** - * @brief - * Return the index of a row which caused an error during data conversion - * - * @param dp - Direct path Handle - * - * @warning - * Direct path row indexes start at 1. - * - * @note - * Errors may happen : - * - while data is converted to direct path stream format using OCI_DirPathConvert() - * - while data is loaded to database using OCI_DirPathLoad() - * - * @note - * When using conversion mode OCI_DCM_DEFAULT, OCI_DirPathConvert() returns - * OCI_DPR_ERROR on error. OCI_DirPathGetErrorRow() returns the row index that - * caused the error. - * When using conversion mode OCI_DCM_FORCE, OCI_DirPathConvert() returns - * OCI_DPR_COMPLETE even on errors. In order to retrieve the list of all row - * indexes that have erred, the application can call OCI_DirPathGetErrorRow() - * repeatedly until it returns 0. - * - * @note - * After a call to OCI_DirPathLoad(), in order to retrieve the list of all faulted rows - * indexes, the application can call OCI_DirPathGetErrorRow() repeatedly until it returns 0. - * - * @note - * The internal value is reset to 0 when calling OCI_DirPathConvert(), - * OCI_DirPathReset() or OCI_DirPathLoad() - * - * @return - * 0 is no error occurs otherwise the index of the given row which caused an - * error - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorRow -( - OCI_DirPath *dp -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiAdvancedQueuing Oracle Advanced Queuing (A/Q) - * @{ - * - * OCILIB supports Oracle Advanced Queues features - * - * Let's Oracle talk about this features ! - * - * @par Oracle Queues (from Oracle Streams - Advanced Queuing User's Guide) - * - * Oracle Streams AQ provides database-integrated message queuing functionality. - * It is built on top of Oracle Streams and leverages the functions of Oracle - * Database so that messages can be stored persistently, propagated between - * queues on different computers and databases, and transmitted using Oracle - * Net Services and HTTP(S). - * Because Oracle Streams AQ is implemented in database tables, all operational - * benefits of high availability, scalability, and reliability are also - * applicable to queue data. Standard database features such as recovery, - * restart, and security are supported by Oracle Streams AQ. You can use - * database development and management tools such as Oracle Enterprise Manager - * to monitor queues. Like other database tables, queue tables can be imported - * and exported. - * - * @par OCILIB implementation - * - * OCILIB provides a (nearly) full C implementation of Advanced Queues available in - * Oracle OCI and proposes the following data types : - * - OCI_Msg : Implementation of message to enqueue/dequeue from/to queues - * - OCI_Enqueue : Implementation of enqueuing process - * - OCI_Dequeue : Implementation of dequeuing process - * - OCI_Agent : Implementation of Advanced queues Agents - * - * OCILIB support AQ messages notification with Oracle Client 10gR2 or above - * - * Note that the only AQ features not supported yet by OCILIB are : - * - Payloads of type AnyData - * - Enqueuing/dequeuing arrays of messages - * - Optional delivery mode introduced in 10gR2 - * - * OCILIB provides as well a C API to administrate queues and queue tables initially - * reserved to PL/SQL and Java (wrappers around PL/SQL calls). - * This API, based on internal PL/SQL calls wrapping the DBMS_AQADM packages procedures, allow the - * following actions : - * - create, alter, drop and purge queue tables (OCI_QueueTableXXX calls) - * - create, alter, drop, start, stop queues (OCI_QueueXXX calls) - * - * Note that the user connected to the database needs particular privileges to manipulate or - * administrate queues (See Oracle Streams - Advanced Queuing User's Guide for more information - * on these privileges) - * - * @par Example - * @include queue.c - * - */ - -/** - * @brief - * Create a message object based on the given payload type - * - * @param typinf - Type info handle - * - * @note - * OCILIB supports 2 type of message payload : - * - Oracle types (UDT) - * - RAW data - * - * @note - * Oracle Type AnyData is not supported in the current version of OCILIB - * - * @note - * the parameter 'typinf' indicates the type of payload : - * - For object payload, retrieve the object type information handle with - * OCI_TypeInfoGet() using the object type name - * - For RAW payload, you MUST pass the object type information retrieved with - * OCI_TypeInfoGet() using "SYS.RAW" as object type name - * - * @warning - * Newly created Message handles have NULL payloads. - * For Message handling Objects payloads, OCI_MsgGetObject() returns NULL until an object handle is - * assigned to the message. - * - * @note - * When a local OCI_Msg handle is enqueued, it keeps its attributes. If it's enqueued again, another - * identical message is posted into the queue. - * To reset a message and empty all its properties, call OCI_MsgReset() - * Note that OCI_MsgReset() clears the message payload. - * - * @return - * Return the message handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Msg * OCI_API OCI_MsgCreate -( - OCI_TypeInfo *typinf -); - -/** - * @brief - * Free a message object - * - * @param msg - Message handle - * - * @warning - * Only message handles created with OCI_MsgCreate() should be freed by OCI_MsgFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgFree -( - OCI_Msg *msg -); - -/** - * @brief - * Reset all attributes of a message object - * - * @param msg - Message handle - * - * @note - * This function calls OCI_MsgSetxxx() with default or NULL attributes - * - * @warning - * OCI_MsgReset() clears the message payload and set it to NULL - * For messages handling objects payloads, OCI_MsgSetObject() must be called again to assign a - * payload. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgReset -( - OCI_Msg *msg -); - -/** - * @brief - * Get the object payload of the given message - * - * @param msg - Message handle - * - * @return - * Return the object handle on success otherwise NULL on failure or if payload is NULL - * - */ - -OCI_EXPORT OCI_Object * OCI_API OCI_MsgGetObject -( - OCI_Msg *msg -); - -/** - * @brief - * Set the object payload of the given message - * - * @param msg - Message handle - * @param obj - Object handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetObject -( - OCI_Msg *msg, - OCI_Object *obj -); - -/** - * @brief - * Get the RAW payload of the given message - * - * @param msg - Message handle - * @param raw - Input buffer - * @param size - Input buffer maximum size - * - * @note - * On output, parameter 'size' holds the number of bytes copied into the given buffer - * - * @return - * TRUE on success otherwise FALSE on failure or if payload is object based. - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgGetRaw -( - OCI_Msg *msg, - void *raw, - unsigned int *size -); - -/** - * @brief - * Set the RAW payload of the given message - * - * @param msg - Message handle - * @param raw - Raw data - * @param size - Raw data size - * - * @return - * TRUE on success otherwise FALSE on failure or if payload is object based. - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetRaw -( - OCI_Msg *msg, - const void *raw, - unsigned int size -); - -/** - * @brief - * Return the number of attempts that have been made to dequeue the message - * - * @param msg - Message handle - * - */ - -OCI_EXPORT int OCI_API OCI_MsgGetAttemptCount -( - OCI_Msg *msg -); - -/** - * @brief - * Return the number of seconds that a message is delayed for dequeuing - * - * @param msg - Message handle - * - * @note - * see OCI_MsgSetEnqueueDelay() for more details - * - */ - -OCI_EXPORT int OCI_API OCI_MsgGetEnqueueDelay -( - OCI_Msg *msg -); - -/** - * @brief - * set the number of seconds to delay the enqueued message - * - * @param msg - Message handle - * @param value - Delay in seconds - * - * @note - * The delay represents the number of seconds after which a message is available for dequeuing. - * When the message is enqueued, its state is set to OCI_AMS_WAITING. - * When the delay expires, its state is set to OCI_AMS_READY. - * - * @note - * If parameter 'value' is set to zero (default value), the message will be immediately available - * for dequeuing - * - * @warning - * Dequeuing by Message ID overrides the delay specification. - * - * @warning - * Delaying processing requires the queue monitor to be started. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetEnqueueDelay -( - OCI_Msg *msg, - int value -); - -/** - * @brief - * return the time the message was enqueued - * - * @param msg - Message handle - * - * @note - * Only use this function for message dequeued from queues - * - */ - -OCI_EXPORT OCI_Date * OCI_API OCI_MsgGetEnqueueTime -( - OCI_Msg *msg -); - -/** - * @brief - * Return the duration that the message is available for dequeuing - * - * @param msg - Message handle - * - * @note - * see OCI_MsgSetExpiration() for more details - * - */ - -OCI_EXPORT int OCI_API OCI_MsgGetExpiration -( - OCI_Msg *msg -); - -/** - * @brief - * set the duration that the message is available for dequeuing - * - * @param msg - Message handle - * @param value - duration in seconds - * - * @note - * This parameter is an offset from the delay (see OCI_MsgSetEnqueueDelay()) - * While waiting for expiration, the message state is set to OCI_AMS_READY. - * If the message is not dequeued before it expires, it will be moved to the exception queue - * with the state OCI_AMS_EXPIRED. - * - * @note - * If parameter 'value' is set to -1 (default value), the message will not expire - * - * @warning - * Expiration processing requires the queue monitor to be started. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetExpiration -( - OCI_Msg *msg, - int value -); - -/** - * @brief - * Return the state of the message at the time of the dequeue - * - * @param msg - Message handle - * - * @return - * - OCI_UNKNOWN : the function has failed to get the message state - * - OCI_AMS_READY : the message is ready to be processed - * - OCI_AMS_WAITING : the message delay has not yet completed - * - OCI_AMS_PROCESSED : the message has been processed - * - OCI_AMS_EXPIRED : the message has moved to exception queue - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_MsgGetState -( - OCI_Msg *msg -); - -/** - * @brief - * Return the priority of the message - * - * @param msg - Message handle - * - * @note - * see OCI_MsgSetPriority() for more details - * - */ - -OCI_EXPORT int OCI_API OCI_MsgGetPriority -( - OCI_Msg *msg -); - -/** - * @brief - * Set the priority of the message - * - * @param msg - Message handle - * @param value - Message priority - * - * @note - * - The priority can be any number, including negative numbers. - * - A smaller number indicates higher priority. - * - Default value is zero. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetPriority -( - OCI_Msg *msg, - int value -); - -/** - * @brief - * Return the ID of the message - * - * @param msg - Message handle - * @param id - Input buffer - * @param len - Input buffer maximum size - * - * @note - * The message ID is : - * - generated when the message is enqueued in the queue - * - retrieved when the message is dequeued from the queue - * - * @note - * On output, parameter 'len' holds the number of bytes copied into the given buffer - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgGetID -( - OCI_Msg *msg, - void *id, - unsigned int *len -); - -/** - * @brief - * Return the original ID of the message in the last queue that generated this message - * - * @param msg - Message handle - * @param id - Input buffer - * @param len - Input buffer maximum size - * - * @warning - * When a message is propagated from/to different queues, this ID is the one generated for the - * message in the previous queue. - * - * @note - * On output, parameter 'len' holds the number of bytes copied into the given buffer - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgGetOriginalID -( - OCI_Msg *msg, - void *id, - unsigned int *len -); - -/** - * @brief - * Set the original ID of the message in the last queue that generated this message - * - * @param msg - Message handle - * @param id - Message ID - * @param len - Message ID size - * - * @warning - * When a message is propagated from/to different queues, this ID is the one generated for the - * message in the previous queue. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetOriginalID -( - OCI_Msg *msg, - const void *id, - unsigned int len -); - -/** - * @brief - * Return the original sender of a message - * - * @param msg - Message handle - * - * @return - * Sender Handle (OCI_Agent *) on success (if set at enqueue time) otherwise NULL - * - */ - -OCI_EXPORT OCI_Agent * OCI_API OCI_MsgGetSender -( - OCI_Msg *msg -); - -/** - * @brief - * Set the original sender of a message - * - * @param msg - Message handle - * @param sender - Message sender - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetSender -( - OCI_Msg *msg, - OCI_Agent *sender -); - -/** - * @brief - * Set the recipient list of a message to enqueue - * - * @param msg - Message handle - * @param consumers - Recipients list (array of agent handles) - * @param count - Number of recipients - * - * @warning - * This function should only be used for queues which allow multiple consumers. - * The default recipients are the queue subscribers. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetConsumers -( - OCI_Msg *msg, - OCI_Agent **consumers, - unsigned int count -); - -/** - * @brief - * Get the correlation identifier of the message - * - * @param msg - Message handle - * - * @note - * see OCI_MsgSetCorrelation() for more details - * - */ - -OCI_EXPORT const otext * OCI_API OCI_MsgGetCorrelation -( - OCI_Msg *msg -); - -/** - * @brief - * set the correlation identifier of the message - * - * @param msg - Message handle - * @param correlation - Message correlation text - * - * @note - * see OCI_DequeueSetCorrelation() for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetCorrelation -( - OCI_Msg *msg, - const otext *correlation -); - -/** - * @brief - * Get the Exception queue name of the message - * - * @param msg - Message handle - * - * @warning - * When calling this function on a message retrieved with OCI_DequeueGet(), the returned value is - * NULL if the default exception queue associated with the current queue is used (e.g. no user - * defined specified at enqueue time for the message) - * - * @note - * see OCI_MsgSetExceptionQueue() for more details - * - */ -OCI_EXPORT const otext * OCI_API OCI_MsgGetExceptionQueue -( - OCI_Msg *msg -); - -/** - * @brief - * Set the name of the queue to which the message is moved to if it cannot be - * processed successfully - * - * @param msg - Message handle - * @param queue - Exception queue name - * - * @warning - * From Oracle Documentation : - * - * "Messages are moved into exception queues in two cases : - * - If the number of unsuccessful dequeue attempts has exceeded the attribute 'max_retries' of - * given queue - * - if the message has expired. - * - * All messages in the exception queue are in the EXPIRED state. - * - * The default is the exception queue associated with the queue table. - * - * If the exception queue specified does not exist at the time of the move the message will be - * moved to the default exception queue associated with the queue table and a warning will be - * logged in the alert file. - * - * This attribute must refer to a valid queue name." - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_MsgSetExceptionQueue -( - OCI_Msg *msg, - const otext *queue -); - -/** - * @brief - * Create a Enqueue object for the given queue - * - * @param typinf - Type info handle - * @param name - Queue name - * - * @note - * OCILIB supports 2 type of message payload : - * - Oracle types (UDT) - * - RAW data - * - * @note - * Oracle Type AnyData is not supported in the current version of OCILIB - * - * @note - * the parameter 'typinf' indicates the type of payload to enqueue to the given queue : - * - For object payload, retrieve the object type information handle with - * OCI_TypeInfoGet() using the object type name - * - For RAW payload, you MUST pass the object type information retrieved with - * OCI_TypeInfoGet() using "SYS.RAW" as object type name - * - * @return - * Return the Enqueue handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Enqueue * OCI_API OCI_EnqueueCreate -( - OCI_TypeInfo *typinf, - const otext *name -); - -/** - * @brief - * Free a Enqueue object - * - * @param enqueue - Enqueue handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_EnqueueFree -( - OCI_Enqueue *enqueue -); - -/** - * @brief - * Enqueue a message on the queue associated to the Enqueue object - * - * @param enqueue - Enqueue handle - * @param msg - Message handle to enqueue - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_EnqueuePut -( - OCI_Enqueue *enqueue, - OCI_Msg *msg -); - -/** -* @brief -* Set the enqueuing sequence of messages to put in the queue -* -* @param enqueue - Enqueue handle -* @param sequence - enqueuing sequence -* -* @note -* Possible values for parameter 'sequence' : -* - OCI_ASD_BEFORE : enqueue message before another message -* - OCI_ASD_TOP : enqueue message before all messages -* -* @note -* Default value is OCI_ASD_TOP -* -* @note -* if the parameter 'sequence' is set to OCI_ASD_BEFORE, the application must -* call OCI_EnqueueSetRelativeMsgID() before enqueuing the next message in the queue. -* -* @note -* In order to stop enqueuing message using a sequence deviation, call -* OCI_EnqueueSetSequenceDeviation() with the value OCI_ASD_TOP -* -* @return -* TRUE on success otherwise FALSE -* -*/ - -OCI_EXPORT boolean OCI_API OCI_EnqueueSetSequenceDeviation -( - OCI_Enqueue *enqueue, - unsigned int sequence -); - -/** - * @brief - * Return the sequence deviation of messages to enqueue to the queue - * - * @param enqueue - Enqueue handle - * - * @note - * see OCI_EnqueueSetSequenceDeviation() for more details - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_EnqueueGetSequenceDeviation -( - OCI_Enqueue *enqueue -); - -/** - * @brief - * Set whether the new message is enqueued as part of the current transaction - * - * @param enqueue - Enqueue handle - * @param visibility - Enqueuing visibility - * - * @note - * Possible values for parameter 'visibility' : - * - OCI_AMV_IMMEDIATE : enqueue is an independent transaction - * - OCI_AMV_ON_COMMIT : enqueue is part of current transaction - * - * @note - * Default value is OCI_AMV_ON_COMMIT - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_EnqueueSetVisibility -( - OCI_Enqueue *enqueue, - unsigned int visibility -); - -/** - * @brief - * Get the enqueuing/locking behavior - * - * @param enqueue - Enqueue handle - * - * @note - * see OCI_EnqueueSetVisibility() for more details - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_EnqueueGetVisibility -( - OCI_Enqueue *enqueue -); - -/** - * @brief - * Set a message identifier to use for enqueuing messages using a sequence deviation - * - * @param enqueue - Enqueue handle - * @param id - message identifier - * @param len - pointer to message identifier length - * - * @note - * This call is only valid if OCI_EnqueueSetSequenceDeviation() has been called - * with the value OCI_ASD_BEFORE - * - * @warning - * if the function cannot assign the message id, the content of the parameter 'len' is set to zero. - * - * @note - * see OCI_EnqueueSetSequenceDeviation() for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_EnqueueSetRelativeMsgID -( - OCI_Enqueue *enqueue, - const void *id, - unsigned int len -); - -/** - * @brief - * Get the current associated message identifier used for enqueuing messages - * using a sequence deviation - * - * @param enqueue - Enqueue handle - * @param id - buffer to receive the message identifier - * @param len - pointer to buffer max length - * - * @warning - * When the function returns, parameter 'len' hold the number of bytes assigned to parameter 'id' - * - * @note - * see OCI_EnqueueGetRelativeMsgID() for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_EnqueueGetRelativeMsgID -( - OCI_Enqueue *enqueue, - void *id, - unsigned int *len -); - -/** - * @brief - * Create a Dequeue object for the given queue - * - * @param typinf - Type info handle - * @param name - Queue name - * - * @note - * OCILIB supports 2 type of message payload : - * - Oracle types (UDT) - * - RAW data - * - * @note - * Oracle Type AnyData is not supported in the current version of OCILIB - * - * @note - * the parameter 'typinf' indicates the type of payload to dequeue from the given queue : - * - For object payload, retrieve the object type information handle with - * OCI_TypeInfoGet() using the object type name - * - For RAW payload, you MUST pass the object type information retrieved with - * OCI_TypeInfoGet() using "SYS.RAW" as object type name - * - * @return - * Return the Dequeue handle on success otherwise NULL on failure - * - */ - -OCI_EXPORT OCI_Dequeue * OCI_API OCI_DequeueCreate -( - OCI_TypeInfo *typinf, - const otext *name -); - -/** - * @brief - * Free a Dequeue object - * - * @param dequeue - Dequeue handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueFree -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Dequeue messages from the given queue - * - * @param dequeue - Dequeue handle - * - * @warning - * The returned message is handled by the dequeue object. - * Do not release it with OCI_MsgFree() - * - * @warning - * When dequeuing from a multiple consumer queue, you need - * to set the navigation mode to OCI_ADN_FIRST_MSG using - * OCI_DequeueSetNavigation() - * - * @return - * Message handle on success otherwise NULL on failure or on timeout - * - */ - -OCI_EXPORT OCI_Msg * OCI_API OCI_DequeueGet -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Subscribe for asynchronous messages notifications - * - * @param dequeue - Dequeue handle - * @param port - Port to use for notifications - * @param timeout - notification timeout - * @param callback - User handler callback fired when messages are ready to be dequeued - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * asynchronous messages notifications - * - * @note - * Requires Oracle Client 10gR2 or above - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSubscribe -( - OCI_Dequeue *dequeue, - unsigned int port, - unsigned int timeout, - POCI_NOTIFY_AQ callback -); - -/** - * @brief - * Unsubscribe for asynchronous messages notifications - * - * @param dequeue - Dequeue handle - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueUnsubscribe -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Set the current consumer name to retrieve message for. - * - * @param dequeue - Dequeue handle - * @param consumer - consumer name - * - * @warning - * If a queue is not set up for multiple consumers, OCI_DequeueSetConsumer() - * should not be called or called with parameter 'consumer' set to NULL - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetConsumer -( - OCI_Dequeue *dequeue, - const otext *consumer -); - -/** - * @brief - * Get the current consumer name associated with the dequeuing process. - * - * @param dequeue - Dequeue handle - * - * @note - * see OCI_DequeueSetConsumer() for more details - * - */ - -OCI_EXPORT const otext * OCI_API OCI_DequeueGetConsumer -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * set the correlation identifier of the message to be dequeued - * - * @param dequeue - Dequeue handle - * @param pattern - correlation identifier - * - * @note - * Special pattern matching characters, such as "%" or "_" can be used. - * If more than one message satisfies the pattern, the order of dequeuing is undetermined. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetCorrelation -( - OCI_Dequeue *dequeue, - const otext *pattern -); - -/** - * @brief - * Get the correlation identifier of the message to be dequeued - * - * @param dequeue - Dequeue handle - * - * @note - * see OCI_DequeueSetCorrelation() for more details - * - */ - -OCI_EXPORT const otext * OCI_API OCI_DequeueGetCorrelation -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Set the message identifier of the message to be dequeued - * - * @param dequeue - Dequeue handle - * @param id - message identifier - * @param len - size of the message identifier - * - * @warning - * if the function cannot assign the message id, the content of the parameter 'len' is set to zero. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetRelativeMsgID -( - OCI_Dequeue *dequeue, - const void *id, - unsigned int len -); - -/** - * @brief - * Get the message identifier of the message to be dequeued - * - * @param dequeue - Dequeue handle - * @param id - message identifier - * @param len - size of the message identifier - * - * @warning - * When the function returns, parameter 'len' hold the number of bytes assigned to parameter 'id' - * - * @note - * see OCI_DequeueSetRelativeMsgID() for more details - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueGetRelativeMsgID -( - OCI_Dequeue *dequeue, - void *id, - unsigned int *len -); - -/** - * @brief - * Set whether the new message is dequeued as part of the current transaction - * - * @param dequeue - Dequeue handle - * @param visibility - dequeuing mode - * - * @warning - * The visibility parameter is ignored when using the OCI_ADM_BROWSE dequeuing - * mode (see OCI_DequeueSetMode()) - * - * @note - * Possible values for parameter 'mode' : - * - OCI_AMV_IMMEDIATE : dequeue is an independent transaction - * - OCI_AMV_ON_COMMIT : dequeue is part of current transaction - * - * @note - * Default value is OCI_AMV_ON_COMMIT - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetVisibility -( - OCI_Dequeue *dequeue, - unsigned int visibility -); - -/** - * @brief - * Get the dequeuing/locking behavior - * - * @param dequeue - Dequeue handle - * - * @note - * see OCI_DequeueSetVisibility() for more details - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DequeueGetVisibility -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Set the dequeuing/locking behavior - * - * @param dequeue - Dequeue handle - * @param mode - dequeuing mode - * - * @note - * Possible values for parameter 'mode' : - * - OCI_ADM_BROWSE : read message without acquiring a lock - * - OCI_ADM_LOCKED : read and obtain write lock on message - * - OCI_ADM_REMOVE : read the message and delete it - * - OCI_ADM_REMOVE_NODATA : confirm receipt of the message, but do not - * deliver the actual message content - * - * @note - * Default value is OCI_ADM_REMOVE - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetMode -( - OCI_Dequeue *dequeue, - unsigned int mode -); - -/** - * @brief - * Get the dequeuing/locking behavior - * - * @param dequeue - Dequeue handle - * - * @note - * see OCI_DequeueSetMode() for more details - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DequeueGetMode -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Set the position of messages to be retrieved. - * - * @param dequeue - Dequeue handle - * @param position - navigation position - * - * @note - * The dequeuing uses the following sequence : - * - find messages using the navigation position - * - apply search criteria (message correlation) - * - get message - * - * @note - * Possible values for parameter 'position' : - * - OCI_ADN_FIRST_MSG : retrieves the first message which is available - * - OCI_ADN_NEXT_MSG : retrieves the next message which is available - * - OCI_ADN_NEXT_TRANSACTION : skips the remainder of the current transaction - * group (if any) and retrieves the first message - * of the next transaction group. - * - * @note - * Default value is OCI_ADN_NEXT_MSG - * - * @warning - * OCI_ADN_NEXT_TRANSACTION can only be used if message grouping is enabled for the given queue. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetNavigation -( - OCI_Dequeue *dequeue, - unsigned int position -); - -/** - * @brief - * Return the navigation position of messages to retrieve from the queue - * - * @param dequeue - Dequeue handle - * - * @note - * see OCI_DequeueSetNavigation() for more details - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_DequeueGetNavigation -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * set the time that OCIDequeueGet() waits for messages if no messages are - * currently available - * - * @param dequeue - Dequeue handle - * @param timeout - timeout in seconds - * - * @note - * - Any positive values in seconds are valid. - * - The value 0 is accepted and means OCIDequeueGet() does not wait for - * messages and returns immediately if no messages are available - * - The value -1 is accepted and means OCIDequeueGet() waits for ever (until - * a message is available in the queue) - * - * @note - * Default value is -1 (wait for ever) - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetWaitTime -( - OCI_Dequeue *dequeue, - int timeout -); - -/** - * @brief - * Return the time that OCIDequeueGet() waits for messages if no messages are currently available - * - * @param dequeue - Dequeue handle - * - * @note - * see OCI_DequeueSetWaitTime() for more details - * - */ - -OCI_EXPORT int OCI_API OCI_DequeueGetWaitTime -( - OCI_Dequeue *dequeue -); - -/** - * @brief - * Set the Agent list to listen to message for - * - * @param dequeue - Dequeue handle - * @param consumers - Agent handle array - * @param count - Number of agents the array - * - * @return - * return TRUE on success otherwise FALSE - */ - -OCI_EXPORT boolean OCI_API OCI_DequeueSetAgentList -( - OCI_Dequeue *dequeue, - OCI_Agent **consumers, - unsigned int count -); - -/** - * @brief - * Listen for messages that match any recipient of the associated Agent list - * - * @param dequeue - Dequeue handle - * @param timeout - Timeout in second - * - * @note - * If an Agent handle is returned, messages are available for this agent. - * In order to retrieve its messages : - * - call OCI_DequeueSetConsumer() with the name of agent using OCI_AgentGetName() - * - call OCI_DequeueGet() to dequeue it's pending messages - * - * @warning - * The return value is valid only until: - * - OCIDequeueListen() is called again - * - OCI_DequeueFree(à is called to free the Dequeue object - * So Do not store the handle value across calls to OCIDequeueListen() - * - * @return - * An Agent handle for who messages are available on success otherwise NULL - */ - -OCI_EXPORT OCI_Agent * OCI_API OCI_DequeueListen -( - OCI_Dequeue *dequeue, - int timeout -); - -/** - * @brief - * Create an AQ agent object - * - * @param con - Connection handle - * @param name - Agent name - * @param address - Agent address - * - * @note - * An AQ agent object is : - * - used as recipient information when enqueuing a message - * - used as sender information when dequeuing a message - * - used for listening message only from identified senders - * - * @note - * the AQ agent address can be any Oracle identifier, up to 128 bytes. - * the AQ agent name can be any Oracle identifier, up to 30 bytes. - * - * @return - * AQ agent handle on success otherwise NULL - * - */ - -OCI_EXPORT OCI_Agent * OCI_API OCI_AgentCreate -( - OCI_Connection *con, - const otext *name, - const otext *address -); - -/** - * @brief - * Free an AQ agent object - * - * @param agent - AQ agent handle - * - * @warning - * Only AQ agent handle created with OCI_AgentCreate() should be freed by OCI_AgentFree() - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_AgentFree -( - OCI_Agent *agent -); - -/** - * @brief - * Set the given AQ agent name - * - * @param agent - AQ agent handle - * @param name - AQ agent name - * - * @note - * the AQ agent name is used to identified an message send or recipient when enqueuing/dequeuing - * a message - * - * @note - * the AQ agent name can be any Oracle identifier, up to 30 bytes. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_AgentSetName -( - OCI_Agent *agent, - const otext *name -); - -/** - * @brief - * Get the given AQ agent name - * - * @param agent - AQ agent handle - * - * @return - * AQ agent name on success otherwise NULL on failure - * - */ - -OCI_EXPORT const otext * OCI_API OCI_AgentGetName -( - OCI_Agent *agent -); - -/** - * @brief - * Set the given AQ agent address - * - * @param agent - AQ agent handle - * @param address - AQ agent address - * - * @note - * the parameter 'address' must be of the form : [schema.]queue_name[\@dblink] - * - * @note - * the AQ agent address can be any Oracle identifier, up to 128 bytes. - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_AgentSetAddress -( - OCI_Agent *agent, - const otext *address -); - -/** - * @brief - * Get the given AQ agent address - * - * @param agent - AQ agent handle - * - * @note - * See OCI_AgentSetAddress() - * - * @return - * AQ agent address on success otherwise NULL on failure - * - */ - -OCI_EXPORT const otext * OCI_API OCI_AgentGetAddress -( - OCI_Agent *agent -); - -/** - * @brief - * Create a queue - * - * @param con - Connection handle - * @param queue_name - Queue name - * @param queue_table - Queue table name - * @param queue_type - Queue type - * @param max_retries - Maximum number of attempts to dequeue a message - * @param retry_delay - Number of seconds between attempts to dequeue a message - * @param retention_time - number of seconds a message is retained in the queue table after - * being dequeued from the queue - * @param dependency_tracking - Parameter reserved for future use by Oracle (MUST be set to FALSE) - * @param comment - Description of the queue - * - * @note - * Parameter 'queue_name' can specify the schema where to create to queue ([schema.]queue_name) - * Queue names cannot be longer than 24 characters (Oracle limit for user queues) - * - * @note - * Possible values for parameter 'queue_type' : - * - OCI_AQT_NORMAL : Normal queue - * - OCI_AQT_EXCEPTION : Exception queue - * - OCI_AQT_NON_PERSISTENT : Non persistent queue - * - * To set default values, pass : - * - queue_type : OCI_AQT_NORMAL - * - max_retries : 0 - * - retry_delay : 0 - * - retention_time : 0 - * - comment : NULL - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueCreate -( - OCI_Connection *con, - const otext *queue_name, - const otext *queue_table, - unsigned int queue_type, - unsigned int max_retries, - unsigned int retry_delay, - unsigned int retention_time, - boolean dependency_tracking, - const otext *comment -); - -/** - * @brief - * Alter the given queue - * - * @param con - Connection handle - * @param queue_name - Queue name - * @param max_retries - Maximum number of attempts to dequeue a message - * @param retry_delay - Number of seconds between attempts to dequeue a message - * @param retention_time - number of seconds a message is retained in the queue table after - * being dequeued from the queue - * @param comment - Description of the queue - * - * @note - * See OCI_QueueCreate() for more details - * - * @warning - * This function updates all attributes handled in the parameter list ! - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueAlter -( - OCI_Connection *con, - const otext *queue_name, - unsigned int max_retries, - unsigned int retry_delay, - unsigned int retention_time, - const otext *comment -); - -/** - * @brief - * Drop the given queue - * - * @param con - Connection handle - * @param queue_name - Queue name - * - * @warning - * A queue can be dropped only if it has been stopped before. - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueDrop -( - OCI_Connection *con, - const otext *queue_name -); - -/** - * @brief - * Start the given queue - * - * @param con - Connection handle - * @param queue_name - Queue name - * @param enqueue - Enable enqueue - * @param dequeue - Enable dequeue - * - * @warning - * For exception queues, only enqueuing is allowed - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.START_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueStart -( - OCI_Connection *con, - const otext *queue_name, - boolean enqueue, - boolean dequeue -); - -/** - * @brief - * Stop enqueuing or dequeuing or both on the given queue - * - * @param con - Connection handle - * @param queue_name - Queue name - * @param enqueue - Disable enqueue - * @param dequeue - Disable dequeue - * @param wait - Wait for current pending enqueues/dequeues - * - * @warning - * A queue cannot be stopped if there are pending transactions against the queue. - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.STOP_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueStop -( - OCI_Connection *con, - const otext *queue_name, - boolean enqueue, - boolean dequeue, - boolean wait -); - -/** - * @brief - * Create a queue table for messages of the given type - * - * @param con - Connection handle - * @param queue_table - Queue table name - * @param queue_payload_type - Message type name - * @param storage_clause - Additional clauses for the table storage - * @param sort_list - Additional columns name to use for sorting - * @param multiple_consumers - Enable multiple consumers for each messages - * @param message_grouping - Specifies if messages are grouped within a transaction - * @param comment - Description of the queue table - * @param primary_instance - primary owner (instance) of the queue table - * @param secondary_instance - Owner of the queue table if the primary instance is not available - * @param compatible - lowest database version with which the queue table is compatible - * - * @note - * Parameter 'queue_table' can specify the schema where to create to queue table ([schema.]queue_table) - * Queue table names cannot be longer than 24 characters (Oracle limit for user queue tables) - * - * @note - * Possible values for parameter 'queue_payload_type' : - * - For Oracle types (UDT) : use the type name ([schema.].type_name) - * - For RAW data : use "SYS.RAW" or "RAW" - * - * @note - * Possible values for parameter 'message_grouping' : - * - OCI_AGM_NONE : each message is treated individually - * - OCI_AGM_TRANSACTIONNAL : all messages enqueued in one transaction are considered part of - * the same group and can be dequeued as a group of related messages. - * - * @note - * Possible values for parameter 'compatible' : - * - "8.0", "8.1", "10.0" - * - * To set default values, pass : - * - storage_clause : NULL - * - sort_list : NULL - * - message_grouping : OCI_AGM_NONE - * - comment : NULL - * - primary_instance : 0 - * - primary_instance : 0 - * - compatible : NULL - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueTableCreate -( - OCI_Connection *con, - const otext *queue_table, - const otext *queue_payload_type, - const otext *storage_clause, - const otext *sort_list, - boolean multiple_consumers, - unsigned int message_grouping, - const otext *comment, - unsigned int primary_instance, - unsigned int secondary_instance, - const otext *compatible -); - -/** - * @brief - * Alter the given queue table - * - * @param con - Connection handle - * @param queue_table - Queue table name - * @param comment - Description of the queue table - * @param primary_instance - primary owner (instance) of the queue table - * @param secondary_instance - Owner of the queue table if the primary instance is not available - * - * @note - * See OCI_QueueTableCreate() from more details - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueTableAlter -( - OCI_Connection *con, - const otext *queue_table, - const otext *comment, - unsigned int primary_instance, - unsigned int secondary_instance -); - -/** - * @brief - * Drop the given queue table - * - * @param con - Connection handle - * @param queue_table - Queue table name - * @param force - Force the deletion of objects related to the queue table - * - * @note - * Possible values for 'force' : - * - TRUE : all queues using the queue table and their associated propagation schedules are - * dropped automatically - * - FALSE : All the queues using the given queue table must be stopped and dropped before the - * queue table can be dropped. - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueTableDrop -( - OCI_Connection *con, - const otext *queue_table, - boolean force -); - -/** - * @brief - * Purge messages from the given queue table - * - * @param con - Connection handle - * @param queue_table - Queue table name - * @param purge_condition - Optional SQL based conditions (see notes) - * @param block - Lock all queues using the queue table while doing the purge - * @param delivery_mode - Type of message to purge - * - * @note - * Possible values for parameter 'delivery_mode' : - * - OCI_APM_BUFFERED : purge only buffered messages - * - OCI_APM_PERSISTENT : purge only persistent messages - * - OCI_APM_ALL : purge all messages - * - * @note - * For more information about the SQL purge conditions, refer to - * Oracle Streams - Advanced Queuing User's Guide for more details - * - * @warning - * This feature is only available from Oracle 10gR2. - * This function does nothing and returns TRUE is the server version is < Oracle 10gR2 - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.PURGE_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueTablePurge -( - OCI_Connection *con, - const otext *queue_table, - const otext *purge_condition, - boolean block, - unsigned int delivery_mode -); - -/** - * @brief - * Migrate a queue table from one version to another - * - * @param con - Connection handle - * @param queue_table - Queue table name - * @param compatible - Database version with witch the queue table has to migrate - * - * @note - * Possible values for parameter 'compatible' : - * - "8.0", "8.1", "10.0" - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.MIGRATE_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_QueueTableMigrate -( - OCI_Connection *con, - const otext *queue_table, - const otext *compatible -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiSubscriptions Database Change notifications (DCN or CQN) - * @{ - * - * OCILIB supports Oracle 10gR2 feature Database Change Notifications (DCN) - * also named Continuous Query Notifications (CQN) - * - * This features allows a client application to register notifications - * when some changes are made in a database : - * - Database status changes : startup and shutdown - * - Database objects changes : - * - DDL changes : alter or drop actions - * - DML changes : insert, delete, update actions - * - * This feature can be really useful in applications that hold - * a cache of data. Instead of refreshing data periodically by - * connecting to the server, the application could only refresh - * modified data when necessary or perform specific tasks depending on - * the events. It saves application time, network traffic and can help - * the design of the application logic. - * - * The database status change notification is also interesting to be - * informed of instance startup / shutdown - * - * Check Oracle documentation for more details about this feature - * - * @note - * No active database connection is required to receive the - * notifications as they are handled by the Oracle client using a - * dedicated socket connection to the server - * - * @par Database changes - * - * The client application can be notified of any database status - * change (single DB or multiple DB in a RAC environment). - * - * @par Object changes - * - * The notifications of object changes are based on the registration - * of a query ('select' SQL statement). - * - * Oracle server will notify of any changes of any object that is - * part of the statement result set. - * - * Registering a statement will notify about any changes on its - * result set rows performed after the registration of the query. - * - * The query can be a simple 'select * from table' or a complex - * query involving many tables and/or criteria in the where clause. - * - * For Object changes, the notification can be at : - * - At Object level : only the object name (schema + object) is given - * - At row level : same that object level + RowID of the altered row - * - * @warning - * Trying to use this features with a client/server version < 10gR2 will raise an error - * - * @par Example - * @include notification.c - * - */ - -/** - * @brief - * Register a notification against the given database - * - * @param con - Connection handle - * @param name - Notification name - * @param type - Subscription type - * @param handler - User handler callback - * @param port - Port to use for notifications - * @param timeout - notification timeout - * - * @note - * Parameter 'type' can be one of the following values : - * - * - OCI_CNT_OBJECTS : request for changes at objects (e.g. tables) level (DDL / DML) - * - OCI_CNT_ROWS : request for changes at rows level (DML) - * - OCI_CNT_DATABASES : request for changes at database level (startup, shutdown) - * - OCI_CNT_ALL : request for all changes - * - * @note - * Parameter 'port' and 'timeout' are optional (use value 0 a optional value) - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - * @ @warning Port usage - * All notifications are using the same port. - * Port number can be either: - * - determined automatically by Oracle client once the first subscription had been created and can be retrieved using OCI_SubscriptionGetPort() - * - Set by the parameter 'port' during the first call to OCI_SubscriptionRegister(). In this case later calls can provide same port number or 0 - * - * @note - * Requires Oracle Client 10gR2 or above - * - * @note - * Subscription handles are automatically managed by the library - * - * @return - * Subscription handle on success or NULL on failure - * - */ - -OCI_EXPORT OCI_Subscription * OCI_API OCI_SubscriptionRegister -( - OCI_Connection *con, - const otext *name, - unsigned int type, - POCI_NOTIFY handler, - unsigned int port, - unsigned int timeout -); - -/** - * @brief - * Unregister a previously registered notification - * - * @param sub - Subscription handle - * - * @note - * OCI_Cleanup() will automatically unregister any registered subscriptions - * - * @note - * If the database connection passed to OCI_SubscriptionRegister() - * has been closed by the time that the application calls - * OCI_SubscriptionUnregister, the library internally reconnects - * to the given database, performs the unregistration and then disconnects - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SubscriptionUnregister -( - OCI_Subscription *sub -); - -/** - * @brief - * Add a statement to the notification to monitor - * - * @param sub - Subscription handle - * @param stmt - Statement handle - * - * @note - * The given statement must be prepared but not executed before being passed to this function. - * OCI_SubscriptionAddStatement() executes the statement and register it for notifications - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - * @note - * The given statement must hold a 'SELECT' SQL statement - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_SubscriptionAddStatement -( - OCI_Subscription *sub, - OCI_Statement *stmt -); - -/** - * @brief - * Return the name of the given registered subscription - * - * @param sub - Subscription handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT const otext * OCI_API OCI_SubscriptionGetName -( - OCI_Subscription *sub -); - -/** - * @brief - * Return the port used by the notification - * - * @param sub - Subscription handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_SubscriptionGetPort -( - OCI_Subscription *sub -); - -/** - * @brief - * Return the timeout of the given registered subscription - * - * @param sub - Subscription handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_SubscriptionGetTimeout -( - OCI_Subscription *sub -); - -/** - * @brief - * Return the connection handle associated with a subscription handle - * - * @param sub - Subscription handle - * - * @note - * It may return a NULL handle if the connection used in OCI_SubscriptionRegister has been closed. - * - */ - -OCI_EXPORT OCI_Connection * OCI_API OCI_SubscriptionGetConnection -( -OCI_Subscription *sub -); - -/** - * @brief - * Return the type of event reported by a notification - * - * @param event - Event handle - * - * @note - * The returned value can be one of the following values : - * - * - OCI_ENT_STARTUP : a database has been started up - * - OCI_ENT_SHUTDOWN : a database has been shut down - * - OCI_ENT_SHUTDOWN_ANY : a database has been shut down (RAC) - * - OCI_ENT_DROP_DATABASE : a database has been dropped - * - OCI_ENT_DEREGISTER : the notification is timed out - * - OCI_ENT_OBJECT_CHANGED : a database object has been modified - * - * @note - * OCI_EventGetDatabase() returns the affected database - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - * @note - * OCI_EventGetObject() returns the affected object - * ('schema_name'.'object_name') - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_EventGetType -( - OCI_Event *event -); - -/** - * @brief - * Return the type of operation reported by a notification - * - * @param event - Event handle - * - * @note - * This call is only valid when OCI_EventGetType() reports the - * event type OCI_ENT_OBJECT_CHANGED - * - * @note - * The returned value can be one of the following values : - * - * - OCI_ONT_INSERT : an insert has been performed - * - OCI_ONT_UPDATE : an update has been performed - * - OCI_ONT_DELETE : a delete has been performed - * - OCI_ONT_ALTER : an alter has been performed - * - OCI_ONT_DROP : a drop has been performed - * - OCI_ONT_GENERIC : generic undefined action - * - * @note - * OCI_EventGetDatabase() returns the affected database - * - * @note - * OCI_EventGetObject() returns the affected object ('schema_name'.'object_name') - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - * @note - * if OCI_CNT_ROWS is passed to OCI_SubscriptionRegister(), - * the rowid of the altered row can be retrieved with OCI_EventGetRowid() - * - */ - -OCI_EXPORT unsigned int OCI_API OCI_EventGetOperation -( - OCI_Event *event -); - -/** - * @brief - * Return the name of the database that generated the event - * - * @param event - Event handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT const otext * OCI_API OCI_EventGetDatabase -( - OCI_Event *event -); - -/** - * @brief - * Return the name of the object that generated the event - * - * @param event - Event handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT const otext * OCI_API OCI_EventGetObject -( - OCI_Event *event -); - -/** - * @brief - * Return the rowid of the altered database object row - * - * @param event - Event handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT const otext * OCI_API OCI_EventGetRowid -( - OCI_Event *event -); - -/** - * @brief - * Return the subscription handle that generated this event - * - * @param event - Event handle - * - * @note - * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use - * subscriptions - * - */ - -OCI_EXPORT OCI_Subscription * OCI_API OCI_EventGetSubscription -( - OCI_Event *event -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiInstancesManagement Remote Instance startup/shutdown - * @{ - * - * OCILIB supports Oracle 11g client features for manipulating remote Oracle instances. - * - * Oracle instances (on the same computer or on a remote server) can be : - * - * - started with OCI_DatabaseStartup() - * - shutdown with OCI_DatabaseShutdown() - * - * Several options are handled for this actions - * - * @par Example - * @include instance.c - * - */ - -/** - * @brief - * Start a database instance - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param sess_mode - Session mode - * @param start_mode - Start mode - * @param start_flag - Start flags - * @param spfile - Client-side spfile to start up the database (optional) - * - * Possible values for parameter session mode : - * - OCI_SESSION_SYSDBA - * - OCI_SESSION_SYSOPER - * - * @note - * External credentials are supported by supplying a null value for the 'user' and 'pwd' parameters - * If the param 'db' is NULL then a connection to the default local DB is done - * - * Possible (combined) values for parameter start_mode : - * - OCI_DB_SPM_START : start the instance - * - OCI_DB_SPM_MOUNT : mount the instance - * - OCI_DB_SPM_OPEN : open the instance - * - OCI_DB_SPM_FULL : start, mount and open the instance - * - * Possible (combined) values for parameter start_flag : - * - OCI_DB_SPF_DEFAULT : default startup - * - OCI_DB_SPF_FORCE : shuts down a running instance (if needed) using - * ABORT command and starts a new instance - * - OCI_DB_SPF_RESTRICT : allows database access only to users with both - * CREATE SESSION and RESTRICTED SESSION privileges - * - * @note - * If the client side spfile is not provided, the database is started with its server-side spfile - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DatabaseStartup -( - const otext *db, - const otext *user, - const otext *pwd, - unsigned int sess_mode, - unsigned int start_mode, - unsigned int start_flag, - const otext *spfile -); - -/** - * @brief - * Shutdown a database instance - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param sess_mode - Session mode - * @param shut_mode - Shutdown mode - * @param shut_flag - Shutdown flag - * - * - * @warning - * Possible values for parameter session mode : - * - OCI_SESSION_SYSDBA - * - OCI_SESSION_SYSOPER - * - * @note - * External credentials are supported by supplying a null value for the 'user' and 'pwd' parameters - * If the param 'db' is NULL then a connection to the default local DB is done - * - * Possible (combined) values for parameter shut_mode : - * - OCI_DB_SDM_SHUTDOWN : shutdown the instance - * - OCI_DB_SDM_CLOSE : close the instance - * - OCI_DB_SDM_DISMOUNT : dismount the instance - * - OCI_DB_SDM_FULL : shutdown, close and dismount the instance - * - * Possible (exclusive) value for parameter shut_flag (from Oracle documentation) : - * - OCI_DB_SDF_DEFAULT : - * - Further connects are prohibited. - * - Waits for users to disconnect from the database - * - OCI_DB_SDF_TRANS : - * - Further connects are prohibited - * - No new transactions are allowed. - * - Waits for active transactions to complete - * - OCI_DB_SDF_TRANS_LOCAL : - * - Further connects are prohibited - * - No new transactions are allowed. - * - Waits only for local transactions to complete - * - OCI_DB_SDF_IMMEDIATE : - * - Does not wait for current calls to complete or users to disconnect from the database. - * - All uncommitted transactions are terminated and rolled back - * - OCI_DB_SDF_ABORT : - * - Does not wait for current calls to complete or users to disconnect from the database. - * - All uncommitted transactions are terminated and are not rolled back. - * - This is the fastest possible way to shut down the database, but the next - * database startup may require instance recovery. - * - Therefore, this option should be used only in unusual circumstances - * - * @return - * TRUE on success otherwise FALSE - * - */ - -OCI_EXPORT boolean OCI_API OCI_DatabaseShutdown -( - const otext *db, - const otext *user, - const otext *pwd, - unsigned int sess_mode, - unsigned int shut_mode, - unsigned int shut_flag -); - -/** - * @} - */ - -/** - * @defgroup OcilibCApiRawHandles Using OCI Handles directly - * @{ - * - * OCILIB conception was focused on a full but closed encapsulation of OCI. - * - * All OCI headers, data types, prototypes are imported internally - * (linkage or runtime import). - * - * OCILIB public interface exposes only ISO C scalar types and OCILIB objects - * - * OCI is a wide and rich API that can deals with hundreds of options ! - * - * OCILIB tries to implements most of it. But, sometimes in really specific - * contexts, it might be necessary to directly call OCI APIs in order to use - * uncovered OCI functionalities or options - * - * OCILIB proposes now a set of functions to retrieve its internal OCI handles - * - * @warning - * - * The OCILIB author strongly advises against the use of internal handles, - * unless there is no other way to accomplish the task - * - * @warning - * - * Using these handles for direct application calls to OCI might lead - * to OCILIB instability or crash if handles are incorrectly used ! - * - */ - -/** - * @brief - * Return the OCI Environment Handle (OCIEnv *) of OCILIB library - * - * @return - * OCI Environment handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetEnvironment -( - void -); - -/** - * @brief - * Return the OCI Context Handle (OCISvcCtx *) of an OCILIB OCI_Connection object - * - * @param con - Connection handle - * - * @return - * OCI Context handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetContext -( - OCI_Connection *con -); - -/** - * @brief - * Return the OCI Server Handle (OCIServer *) of an OCILIB OCI_Connection object - * - * @param con - Connection handle - * - * @return - * OCI Server handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetServer -( - OCI_Connection *con -); - -/** - * @brief - * Return the OCI Error Handle (OCIError *) of an OCILIB OCI_Connection object - * - * @param con - Connection handle - * - * @return - * OCI Error handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetError -( - OCI_Connection *con -); - -/** - * @brief - * Return the OCI Session Handle (OCISession *) of an OCILIB OCI_Connection object - * - * @param con - Connection handle - * - * @return - * OCI Session handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetSession -( - OCI_Connection *con -); - -/** - * @brief - * Return the OCI Transaction Handle (OCITrans *) of an OCILIB OCI_Transaction object - * - * @param trans - Transaction handle - * - * @return - * OCI Transaction handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetTransaction -( - OCI_Transaction *trans -); - -/** - * @brief - * Return the OCI Statement Handle (OCIStmt *) of an OCILIB OCI_Statement object - * - * @param stmt - Statement handle - * - * @return - * OCI Statement handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetStatement -( - OCI_Statement *stmt -); - -/** - * @brief - * Return the OCI LobLocator Handle (OCILobLocator *) of an OCILIB OCI_Lob object - * - * @param lob - Lob handle - * - * @return - * OCI LobLocator handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetLob -( - OCI_Lob *lob -); - -/** - * @brief - * Return the OCI LobLocator Handle (OCILobLocator *) of an OCILIB OCI_File object - * - * @param file - File handle - * - * @return - * OCI LobLocator handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetFile -( - OCI_File *file -); - -/** - * @brief - * Return the OCI Date Handle (OCIDate *) of an OCILIB OCI_Date object - * - * @param date - Date handle - * - * @return - * OCI Date handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetDate -( - OCI_Date *date -); - -/** - * @brief - * Return the OCI Date time Handle (OCIDatetime *) of an OCILIB OCI_Timestamp object - * - * @param tmsp - Timestamp handle - * - * @return - * OCI Date time handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetTimestamp -( - OCI_Timestamp *tmsp -); - -/** - * @brief - * Return OCI Interval Handle (OCIInterval *) of an OCILIB OCI_Interval object - * - * @param itv - Interval handle - * - * @return - * OCI Interval handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetInterval -( - OCI_Interval *itv -); - -/** - * @brief - * Return OCI Object Handle (void *) of an OCILIB OCI_Object object - * - * @param obj - Object handle - * - * @return - * OCI Object handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetObject -( - OCI_Object *obj -); - -/** - * @brief - * Return OCI Collection Handle (OCIColl *) of an OCILIB OCI_Coll object - * - * @param coll - Collection handle - * - * @return - * OCI Collection handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetColl -( - OCI_Coll *coll -); - -/** - * @brief - * Return OCI Ref Handle (OCIRef *) of an OCILIB OCI_Ref object - * - * @param ref - Ref handle - * - * @return - * OCI Ref handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetRef -( - OCI_Ref *ref -); - -/** - * @brief - * Return OCI Mutex handle (OCIThreadMutex *) of an OCILIB OCI_Mutex object - * - * @param mutex - Mutex handle - * - * @return - * OCI Mutex handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetMutex -( - OCI_Mutex *mutex -); - -/** - * @brief - * Return OCI Thread ID (OCIThreadId *) of an OCILIB OCI_Thread object - * - * @param thread - Thread handle - * - * @return - * OCI Thread ID otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetThreadID -( - OCI_Thread *thread -); - -/** - * @brief - * Return OCI Thread handle (OCIThreadHandle *) of an OCILIB OCI_Thread object - * - * @param thread - Thread handle - * - * @return - * OCI Thread handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetThread -( - OCI_Thread *thread -); - -/** - * @brief - * Return OCI DirectPath Context handle (OCIDirPathCtx *) of an OCILIB OCI_DirPath object - * - * @param dp - DirectPath handle - * - * @return - * OCI DirectPath Context handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetDirPathCtx -( - OCI_DirPath *dp -); - -/** - * @brief - * Return OCI DirectPath Column array handle (OCIDirPathColArray *) of an OCILIB OCI_DirPath object - * - * @param dp - DirectPath handle - * - * @return - * OCI DirectPath Column array handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetDirPathColArray -( - OCI_DirPath *dp -); - -/** - * @brief - * Return OCI DirectPath Stream handle (OCIDirPathStream *) of an OCILIB OCI_DirPath object - * - * @param dp - DirectPath handle - * - * @return - * OCI DirectPath Stream handle otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetDirPathStream -( - OCI_DirPath *dp -); - -/** - * @brief - * Return OCI Subscription handle (OCISubscription *) of an OCILIB OCI_Subscription object - * - * @param sub - Subscription handle - * - * @return - * OCI Subscription otherwise NULL - * - */ - -OCI_EXPORT const void * OCI_API OCI_HandleGetSubscription -( - OCI_Subscription *sub -); - -/** - * @} - */ +#include "ocilib_config.h" +#include "ocilib_types.h" +#include "ocilib_api.h" +#include "ocilib_compat.h" #ifdef __cplusplus } #endif -/** -* @defgroup OcilibCApiEnvironmentVariables Environment Variables -* @{ -* -* Some environment variables can be defined in order to activate specific features -* They must have one of the following values (case insensitive) for being enabled : "TRUE", "1" -* -* - "OCILIB_WORKAROUND_UTF16_COLUMN_NAME": This variable enables an experimental workaround for the Oracle bug 9838993: -* - When calling OCI_GetResultset(), OCILIB queries column names against the Oracle Client -* - Unicode builds of OCILIB initialize Oracle client into UTF16 mode -* - In such environments, a memory leak occurs when statements are re-executed multiple times followed by OCI_GetResultset() -* - This workaround retrieves column names using direct access to undocumented Oracle structures instead of using buggy Oracle calls -* - As Oracle undocumented structures may change upon versions, this workaround is provided as-is in case the Oracle bug represents an real issue for applications -* - This workaround has been tested with 32bit and 64bit Oracle 12g clients and Unicode OCILIB builds -*/ - -#define VAR_OCILIB_WORKAROUND_UTF16_COLUMN_NAME "OCILIB_WORKAROUND_UTF16_COLUMN_NAME" - -/** -* @} -*/ - -/** - * @defgroup OcilibCApiDemoApplication OCILIB main demo application code - * @{ - * - * Portable Main demo application header - * @include ocilib_demo.h - * - * Portable Main demo application source - * @include ocilib_demo.c - * - * @} - */ - -/* Compatibility with sources built with older versions of OCILIB */ - -/* macros added in version 2.3.0 */ - -#define OCI_CreateConnection OCI_ConnectionCreate -#define OCI_FreeConnection OCI_ConnectionFree -#define OCI_CreateStatement OCI_StatementCreate -#define OCI_FreeStatement OCI_StatementFree - -/* macros added in version 2.4.0 */ - -#define OCI_CreateTransaction OCI_TransactionCreate -#define OCI_FreeTransaction OCI_TransactionFree -#define OCI_CreateHashTable OCI_HashCreate -#define OCI_FreeHashTable OCI_HashFree - -/* macros added in version 3.0.0 */ - -#define OCI_GetColumnName OCI_ColumnGetName -#define OCI_GetColumnType OCI_ColumnGetType -#define OCI_GetColumnCharsetForm OCI_ColumnGetCharsetForm -#define OCI_GetColumnSQLType OCI_ColumnGetSQLType -#define OCI_GetColumnFullSQLType OCI_ColumnGetFullSQLType -#define OCI_GetColumnSize OCI_ColumnGetSize -#define OCI_GetColumnScale OCI_ColumnGetScale -#define OCI_GetColumnPrecision OCI_ColumnGetPrecision -#define OCI_GetColumnFractionnalPrecision OCI_ColumnGetFractionnalPrecision -#define OCI_GetColumnLeadingPrecision OCI_ColumnGetLeadingPrecision -#define OCI_GetColumnNullable OCI_ColumnGetNullable -#define OCI_GetColumnCharUsed OCI_ColumnGetCharUsed - -#define OCI_GetFormatDate(s) OCI_GetDefaultFormatDate(OCI_StatementGetConnection(s)) -#define OCI_SetFormatDate(s, f) OCI_SetDefaultFormatDate(OCI_StatementGetConnection(s), f) - -#define OCI_ERR_API OCI_ERR_ORACLE - -/* macros added in version 3.2.0 */ - -#define OCI_ERR_NOT_SUPPORTED OCI_ERR_DATATYPE_NOT_SUPPORTED -#define OCI_SCHEMA_TABLE OCI_TIF_TABLE -#define OCI_SCHEMA_VIEW OCI_TIF_VIEW -#define OCI_SCHEMA_TYPE OCI_TIF_TYPE - -#define OCI_Schema OCI_TypeInfo - -#define OCI_SchemaGet OCI_TypeInfoGet -#define OCI_SchemaFree OCI_TypeInfoFree -#define OCI_SchemaGetColumnCount OCI_TypeInfoGetColumnCount -#define OCI_SchemaGetColumn OCI_TypeInfoGetColumn -#define OCI_SchemaGetName OCI_TypeInfoGetName - -#define OCI_ColumnGetFractionnalPrecision OCI_ColumnGetFractionalPrecision - -/* macro added in version 3.3.0 */ - -#define OCI_SetNull(stmt, index) \ - OCI_BindSetNull(OCI_GetBind(stmt, index)) - -#define OCI_SetNull2(stmt, name) \ - OCI_BindSetNull(OCI_GetBind2(stmt, name)) - -#define OCI_SetNullAtPos(stmt, index, position) \ - OCI_BindSetNullAtPos(OCI_GetBind(stmt, index), position) - -#define OCI_SetNullAtPos2(stmt, name, position) \ - OCI_BindSetNullAtPos(OCI_GetBind2(stmt, name), position) - -/* macro added in version 3.4.0 */ - -#define OCI_8 OCI_8_1 -#define OCI_9 OCI_9_0 -#define OCI_10 OCI_10_1 -#define OCI_11 OCI_11_1 - -/* macro added in version 3.6.0 */ - -#define OCI_CHAR_UNICODE OCI_CHAR_WIDE -#define OCI_CSF_CHARSET OCI_CSF_DEFAULT - -/* macro added in version 3.7.0 */ - -#define OCI_ConnPool OCI_Pool - -#define OCI_ConnPoolCreate(db, us, pw, mo, mi, ma, in) \ - OCI_PoolCreate(db, us, pw, OCI_POOL_CONNECTION, mo, mi, ma, in) - -#define OCI_ConnPoolGetConnection(p) \ - OCI_PoolGetConnection(p, NULL) - -#define OCI_ConnPoolFree OCI_PoolFree -#define OCI_ConnPoolGetTimeout OCI_PoolGetConnection -#define OCI_ConnPoolSetTimeout OCI_PoolSetTimeout -#define OCI_ConnPoolGetNoWait OCI_PoolGetNoWait -#define OCI_ConnPoolSetNoWait OCI_PoolSetNoWait -#define OCI_ConnPoolGetBusyCount OCI_PoolGetBusyCount -#define OCI_ConnPoolGetOpenedCount OCI_PoolGetOpenedCount -#define OCI_ConnPoolGetMin OCI_PoolGetMin -#define OCI_ConnPoolGetMax OCI_PoolGetMax -#define OCI_ConnPoolGetIncrement OCI_PoolGetIncrement - -/* macro added in version 3.8.0 */ - -#define OCI_ObjectGetTimeStamp OCI_ObjectGetTimestamp -#define OCI_ElemGetTimeStamp OCI_ElemGetTimestamp -#define OCI_TimestampSysTimeStamp OCI_TimestampSysTimestamp - -/* macro added in version 4.0.0 */ - -#define OCI_CollSetAt OCI_CollSetElem -#define OCI_CollGetAt OCI_CollGetElem -#define OCI_CollGetAt2 OCI_CollGetElem2 - -#define OCI_GetCharsetMetaData OCI_GetCharset -#define OCI_GetCharsetUserData OCI_GetCharset -#define OCI_SIZE_TRACE_INF0 OCI_SIZE_TRACE_INFO - -#define MT(x) OTEXT(x) -#define mtext otext -#define DT(x) OTEXT(x) -#define dtext otext - -#define mtsdup ostrdup -#define mtscpy ostrcpy -#define mtsncpy ostrncpy -#define mtscat ostrcat -#define mtsncat ostrncat -#define mtslen ostrlen -#define mtscmp ostrcmp -#define mtscasecmp ostrcasecmp -#define mtsprintf osprintf -#define mtstol ostrtol -#define mtsscanf osscanf - -#define dtsdup ostrdup -#define dtscpy ostrcpy -#define dtsncpy ostrncpy -#define dtscat ostrcat -#define dtsncat ostrncat -#define dtslen ostrlen -#define dtscmp ostrcmp -#define dtscasecmp ostrcasecmp -#define dtsprintf osprintf -#define dtstol ostrtol -#define dtsscanf osscanf - -/* macro added in version 4.1.0 */ - -#define OCI_SetDefaultFormatDate(con, fmt) OCI_SetFormat(con, OCI_FMT_DATE, fmt) -#define OCI_SetDefaultFormatNumeric(con, fmt) OCI_SetFormat(con, OCI_FMT_NUMERIC, fmt) - -#define OCI_GetDefaultFormatDate(con) OCI_GetFormat(con, OCI_FMT_DATE) -#define OCI_GetDefaultFormatNumeric(con) OCI_GetFormat(con, OCI_FMT_NUMERIC) - -#define OCI_STRING_FORMAT_NUM_BIN OCI_STRING_FORMAT_NUM_BDOUBLE - -/** - * @} - */ - -#endif /* OCILIB_H_INCLUDED */ - +#endif /* OCILIB_H_INCLUDED */ diff --git a/include/ocilib_api.h b/include/ocilib_api.h new file mode 100644 index 00000000..f35f50ab --- /dev/null +++ b/include/ocilib_api.h @@ -0,0 +1,17419 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* IMPORTANT NOTICE + * + * This file contains explanations about Oracle and OCI technologies. + * OCILIB is a wrapper around OCI and thus exposes OCI features. + * The OCILIB documentation intends to explain Oracle / OCI concepts + * and is naturally based on the official Oracle OCI documentation. + * + * Some parts of OCILIB documentation may include some information + * taken and adapted from the following Oracle documentations : + * - Oracle Call Interface Programmer's Guide + * - Oracle Streams - Advanced Queuing User's Guide + */ + +#ifndef OCILIB_API_H_INCLUDED +#define OCILIB_API_H_INCLUDED + +#include "ocilib_types.h" + +/** + * @defgroup OcilibCApiInitialization Initializing the library + * @{ + * + * To use OCILIB, it first needs to be initialized through a call to OCI_Initialize(). + * + * Then, the application connects to server, executes queries... + * + * Finally, OCILIB resources must be released by OCI_Cleanup() + * + * @note + * + * The following objects are automatically freed by the library: + * - Connections + * - pools + * - Statements + * - Type info objects + * - Thread keys + * + * @warning + * + * All other standalone object instances (mutexes, threads, dates, lobs, ...) ARE NOT freed. + * + */ + +/** + * @brief + * Initialize the library + * + * @param err_handler - Pointer to error handler procedure (optional) + * @param lib_path - Oracle shared library path (optional) + * @param mode - Environment mode + * + * Possible values for parameter mode: + * - OCI_ENV_DEFAULT : default mode + * - OCI_ENV_THREADED : multi-threading support + * - OCI_ENV_CONTEXT : thread contextual error handling + * - OCI_ENV_EVENTS : enables events for subscription, HA Events, AQ notifications + * + * @note + * This function must be called before any OCILIB library function. + * + * @warning + * - The parameter 'libpath' is only used if OCILIB has been built with the option OCI_IMPORT_RUNTIME + * - If the parameter 'lib_path' is NULL, the Oracle library is loaded from system environment variables + * + * @warning + * OCI_Initialize() should be called ONCE per application + * + * @return + * TRUE on success otherwise FALSE. + * Possible reasons for failures: + * - when OCI_ErrorGetType() return OCI_ERR_ORACLE, OCI_ErrorGetOCICode() returns: + * - any ORA-XXXXXX error code. Refer to Oracle documentation + * - when OCI_ErrorGetType() return OCI_ERR_OCILIB, possible error code returned by OCI_ErrorGetInternalCode() + * - OCI_ERR_LOADING_SHARED_LIB : OCILIB could not load oracle shared libraries at runtime (32/64bits mismatch, wrong \p lib_path, missing MSVC runtime required by oci.dll (MS Windows) + * - OCI_ERR_LOADING_SYMBOLS : the loaded shared library does not contain OCI symbols + * - OCI_ERR_NOT_AVAILABLE : OCILIb was built with OCI_CHARSET_WIDE and the oracle shared library dos not supports UTF16 (Oracle 8i) + * - OCI_ERR_CREATE_OCI_ENVIRONMENT: Oracle OCI environment initialization failed (in such cases, it is impossible to get the reason) + * + */ + +OCI_EXPORT boolean OCI_API OCI_Initialize +( + POCI_ERROR err_handler, + const otext *lib_path, + unsigned int mode +); + +/** + * @brief + * Clean up all resources allocated by the library + * + * @note + * * This function must be the last OCILIB library function call. + * - It deallocates objects not explicitly freed by the program (connections, statements, ...) + * - It unloads the Oracle shared library if it has been dynamically loaded + * + * @warning + * OCI_Cleanup() should be called ONCE per application + * + * @return TRUE + */ + +OCI_EXPORT boolean OCI_API OCI_Cleanup +( + void +); + +/** + * @brief + * Return the version of OCI used for compilation + * + * @note + * - with linkage build option, the version is determined from the oci.h header through different ways + * - with runtime loading build option, the version is set to the highest version + * of OCI needed by OCILIB, not necessarily the real OCI version + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetOCICompileVersion +( + void +); + +/** + * @brief + * Return the version of OCI used at runtime + * + * @note + * - with linkage build option, the version is determined from the oci.h header + * through different ways + * - with runtime loading build option, the version determined from the symbols + * dynamically loaded. + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetOCIRuntimeVersion +( + void +); + +/** + * @brief + * Return the Oracle shared library import mode + * + * @note + * Possible values are: + * - OCI_IMPORT_MODE_LINKAGE + * - OCI_IMPORT_MODE_RUNTIME + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetImportMode +( + void +); + +/** + * @brief + * Return the OCILIB charset type + * + * @note + * Possible values are: + * - OCI_CHAR_ANSI + * - OCI_CHAR_WIDE + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetCharset +( + void +); + +/** +* @brief +* Return the current number of bytes allocated internally in the library +* +* @param mem_type : type of memory to request +* +* @note +* Possible values are: +* - OCI_MEM_ORACLE : bytes allocated by Oracle client library +* - OCI_MEM_OCILIB : bytes allocated by OCILIB library +* - OCI_MEM_ORACLE : bytes allocated by all libraries +* +*/ + +OCI_EXPORT big_uint OCI_API OCI_GetAllocatedBytes +( + unsigned int mem_type +); + +/** + * @brief + * Enable or disable Oracle warning notifications + * + * @param value - enable/disable warnings + * + * @note + * Default value is FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_EnableWarnings +( + boolean value +); + +/** + * @brief + * Set the global error user handler + * + * @param handler - Pointer to error handler procedure + * + * @note + * Use this call to change or remove the user callback error handler installed by OCI_Initialize() + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetErrorHandler +( + POCI_ERROR handler +); + +/** + * @brief + * Set the High availability (HA) user handler + * + * @param handler - Pointer to HA handler procedure + * + * @note + * See POCI_HA_HANDLER documentation for more details + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * HA events + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns FALSE without throwing any exception. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetHAHandler +( + POCI_HA_HANDLER handler +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiErrorHandling Error handling + * @{ + * + * OCILIB provides two mechanisms for error handling: + * + * - Global error handling through callbacks. + * - Contextual thread error handling + * + * Exceptions are raised: + * + * - On Oracle OCI API call error + * - On Oracle SQL statement error + * - On Internal OCILIB error (type checking, memory allocations ...) + * - On Oracle warnings (OCI API or SQL) + * + * If an error handler was provided to OCI_Initialize(), when an error occurs, the + * library generates an OCI_Error handle and pass it to the error handler. + * + * In order to use the thread contextual error handling, you must call + * OCI_Initialize() with the flag OCI_ENV_CONTEXT for the mode parameter. When + * activated, error handles are stored per thread and the last error within a + * thread can be retrieved with OCI_GetLastError() + * + * Exception properties are accessible through a set of functions + * + * @note + * The two ways to handle errors are not exclusive and can be mixed. + * + * @note + * Thread contextual error is also available for single thread based applications + * + * @par Oracle Warnings + * + * Oracle warnings are raised through OCI_Error API. + * Such error handles have their error type property (OCI_ErrorGetType()) set to OCI_ERR_WARNING. + * Warning handing is disabled by default. To activate/deactivate it, use OCI_EnableWarnings() + * + * @par Example with callbacks + * @include err.c + * + * @par Example with thread context + * @include err_ctx.c + * + * @par Example of warning handling + * @include err_warning.c + * + */ + +/** + * @brief + * Retrieve the last error or warning occurred within the last OCILIB call + * + * @note + * OCI_GetLastError() is based on thread context and thus OCILIB must be + * initialized with the flag OCI_ENV_CONTEXT + * + * @warning + * OCILIB functions that returns a boolean value to indicate their success : + * - return TRUE if no error occurred OR if a warning occurred + * - return FALSE if an error occurred + * + */ + +OCI_EXPORT OCI_Error * OCI_API OCI_GetLastError +( + void +); + +/** + * @brief + * Retrieve error message from error handle + * + * @param err - Error handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ErrorGetString +( + OCI_Error *err +); + +/** + * @brief + * Retrieve the type of error from error handle + * + * @param err - Error handle + * + * @note + * Returns one of the following values: + * + * - OCI_ERR_ORACLE + * - OCI_ERR_OCILIB + * - OCI_ERR_WARNING + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ErrorGetType +( + OCI_Error *err +); + +/** + * @brief + * Retrieve Oracle Error code from error handle + * + * @param err - Error handle + * + */ + +OCI_EXPORT int OCI_API OCI_ErrorGetOCICode +( + OCI_Error *err +); + +/** + * @brief + * Retrieve Internal Error code from error handle + * + * @param err - Error handle + * + */ + +OCI_EXPORT int OCI_API OCI_ErrorGetInternalCode +( + OCI_Error *err +); + +/** + * @brief + * Retrieve connection handle within the error occurred + * + * @param err - Error handle + * + */ + +OCI_EXPORT OCI_Connection * OCI_API OCI_ErrorGetConnection +( + OCI_Error *err +); + +/** + * @brief + * Retrieve statement handle within the error occurred + * + * @param err - Error handle + * + * @note + * If the error occurred outside of a statement context, it returns NULL + * + */ + +OCI_EXPORT OCI_Statement * OCI_API OCI_ErrorGetStatement +( + OCI_Error *err +); + +/** + * @brief + * Return the row index which caused an error during statement execution + * + * @param err - Error handle + * + * @warning + * Row index start at 1. + * + * @return + * 0 is the error is not related to array DML otherwise the index of the given + * row which caused the error + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ErrorGetRow +( + OCI_Error *err +); + +/** + * @brief + * Return the location where the error occured + * + * @param err - Error handle + * + * @return + * The method name that has generated the error + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ErrorGetLocation +( + OCI_Error* err +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiConnections Connecting to Database + * @{ + * + * Connecting to a database server is done with one call to OCI_ConnectionCreate(). + * + * OCI_ConnectionFree() closes the established connection. + * + * Connection properties are accessible through a set of functions + * + * @par Example + * @include conn.c + * + */ + +/** + * @brief + * Create a physical connection to an Oracle database server + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param mode - Session mode + * + * Possible values for parameter mode : + * - OCI_SESSION_DEFAULT + * - OCI_SESSION_SYSDBA + * - OCI_SESSION_SYSOPER + * - OCI_SESSION_XA + * + * @note + * External credentials are supported by supplying a null value for the + * 'user' and 'pwd' parameters. + * If the param 'db' is NULL then a connection to the default local DB is done + * + * @note + * For parameter 'mode', the possible values are exclusive and cannot be combined + * + * @par Oracle XA support + * + * OCILIB supports Oracle XA connectivity. In order to get a connection using + * the XA interface : + * - For parameter 'db' : pass the value of the 'DB' parameter of the given + * XA connection string passed to the Transaction Processing Monitor (TPM) + * - Pass NULL to the 'user' and 'pwd' parameters + * - Pass the value OCI_SESSION_XA to parameter 'mode' + * + * @par Oracle XA Connection String + * + * The XA connection string used in a transaction monitor to connect to Oracle must + * be compatible with OCILIB : + * + * - the XA parameter 'Objects' MUST be set to 'true' + * - If OCI_ENV_THREADED is passed to OCI_Initialize(), the XA parameter 'Threads' must + * be set to 'true', otherwise to 'false' + * - If OCI_ENV_EVENTS is passed to OCI_Initialize(), the XA parameter 'Events' must + * be set to 'true', otherwise to 'false' + * - As Oracle does not support Unicode UTF16 character set through the XA interface, + * Only OCI_CHARSET_ANSI builds of OCILIB can be used + * - You still can use UTF8 if the NLS_LANG environment variable is set with a valid + * UTF8 NLS value + * - DO NOT USE OCI_CHARSET_WIDE OCILIB builds with XA connections + * + * @note + * On success, a local transaction is automatically created and started ONLY for regular + * standalone connections and connections retrieved from connection pools. + * No transaction is created for a XA connection or q connection retrieved from session pools. + * + * @return + * Connection handle on success or NULL on failure + * + */ + +OCI_EXPORT OCI_Connection * OCI_API OCI_ConnectionCreate +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int mode +); + +/** + * @brief + * Close a physical connection to an Oracle database server + * + * @param con - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ConnectionFree +( + OCI_Connection *con +); + +/** + * @brief + * Returns TRUE is the given connection is still connected otherwise FALSE + * + * @param con - Connection handle + * + */ + +OCI_EXPORT boolean OCI_API OCI_IsConnected +( + OCI_Connection *con +); + +/** + * @brief + * Return the pointer to user data previously associated with the connection + * + * @param con - Connection handle + * + * @note + * Value NULL for parameter \p con is a valid value. + * It returns then previously stored data with global scope (program wide) + * + */ + +OCI_EXPORT void * OCI_API OCI_GetUserData +( + OCI_Connection *con +); + +/** + * @brief + * Associate a pointer to user data to the given connection + * + * @param con - Connection handle + * @param data - User data pointer + * + * @note + * Value NULL for parameter \p con is a valid value. + * It allows users to associate a pointer to user data with global scope (program wide) + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetUserData +( + OCI_Connection *con, + void * data +); + +/** + * @brief + * Associate a tag to the given connection/session + * + * @param con - Connection handle + * @param tag - user tag string + * + * @note + * Use this call only for connections retrieved from a session pool + * See OCI_PoolGetConnection() for more details + * + * @note + * To untag a session, call OCI_SetSessionTag() with 'tag' parameter set to NULL + * + * @warning + * No error is raised if the connection is a standalone connection or retrieved from a connection + * pool + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetSessionTag +( + OCI_Connection *con, + const otext * tag +); + +/** + * @brief + * Return the tag associated the given connection + * + * @param con - Connection handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetSessionTag +( + OCI_Connection *con +); + +/** + * @brief + * Return the name of the connected database/service name + * + * @param con - Connection handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetDatabase +( + OCI_Connection *con +); + +/** + * @brief + * Return the current logged user name + * + * @param con - Connection handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetUserName +( + OCI_Connection *con +); + +/** + * @brief + * Return the current logged user password + * + * @param con - Connection handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetPassword +( + OCI_Connection *con +); + +/** + * @brief + * Change the password of the logged user + * + * @param con - Connection handle + * @param password - New password + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetPassword +( + OCI_Connection *con, + const otext * password +); + +/** + * @brief + * Change the password of the given user on the given database + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param new_pwd - Oracle User New password + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetUserPassword +( + const otext *db, + const otext *user, + const otext *pwd, + const otext *new_pwd +); + +/** + * @brief + * Return the current session mode + * + * @param con - Connection handle + * + * @note + * See OCI_ConnectionCreate() for possible values + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetSessionMode +( + OCI_Connection *con +); + +/** + * @brief + * Return the connected database server version + * + * @param con - Connection handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetVersionServer +( + OCI_Connection *con +); + +/** + * @brief + * Return the major version number of the connected database server + * + * @param con - Connection handle + * + * @return + * Version number or 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetServerMajorVersion +( + OCI_Connection *con +); + +/** + * @brief + * Return the minor version number of the connected database server + * + * @param con - Connection handle + * + * @return + * Version number or 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetServerMinorVersion +( + OCI_Connection *con +); + +/** + * @brief + * Return the revision version number of the connected database server + * + * @param con - Connection handle + * + * @return + * Version number or 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetServerRevisionVersion +( + OCI_Connection *con +); + +/** + * @brief + * Set the format string for implicit string conversions of the given type + * + * @param con - Connection handle (optional) + * @param type - Type of format + * @param format - Format string + * + * Formats can set at 2 levels: + * - Library level: by passing a NULL Connection handle + * - Connection level: by passing a valid Connection handle + * + * When the library needs to perform a string conversion, it search for a valid format using the + * following order: + * - Connection format + * - Library format + * - Default format + * + * @note + * Possible values of parameter 'type' : + * + * - OCI_FMT_DATE : format used to convert DATE to string + * - OCI_FMT_TIMESTAMP : format used to convert TIMESTAMP and TIMESTAMP WITH LOCAL TIMEZONE to string + * - OCI_FMT_TIMESTAMP_TZ : format used to convert TIMESTAMP WITH TIME ZONE to string + * - OCI_FMT_NUMERIC : format used to convert numeric types to string + * - OCI_FMT_BINARY_DOUBLE : format used to convert BINARY_DOUBLE to string + * - OCI_FMT_BINARY FLOAT : format used to convert BINARY_FLOAT to string + * + * @note + * Default format values are : + * - OCI_FMT_DATE : constant OCI_STRING_FORMAT_DATE + * - OCI_FMT_TIMESTAMP : constant OCI_STRING_FORMAT_TIMESTAMP + * - OCI_FMT_TIMESTAMP_TZ : constant OCI_STRING_FORMAT_TIMESTAMP_TZ + * - OCI_FMT_NUMERIC : constant OCI_STRING_FORMAT_NUMERIC + * - OCI_FMT_BINARY_DOUBLE : constant OCI_STRING_FORMAT_BINARY_DOUBLE + * - OCI_FMT_BINARY FLOAT : constant OCI_STRING_FORMAT_BINARY_FLOAT + * + * @note + * Conversions are performed by Oracle built-in functions whenever possible. + * For DATE, TIMESTAMP and numeric types, see documentation of Oracle SQL to_char() function for more details + * For BINARY_DOUBLE and BINARY_FLOAT, refer to the C Standard Library printf() family documentation + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetFormat +( + OCI_Connection *con, + unsigned int type, + const otext * format +); + +/** + * @brief + * Return the format string for implicit string conversions of the given type + * + * @param con - Connection handle + * @param type - Type of format + * + * @note + * See OCI_SetFormat() for possible values + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetFormat +( + OCI_Connection *con, + unsigned int type +); + +/** + * @brief + * Return the current transaction of the connection + * + * @param con - Connection handle + * + * @note + * From v3.9.4, no more default transaction object is created for a new connection + * + */ + +OCI_EXPORT OCI_Transaction * OCI_API OCI_GetTransaction +( + OCI_Connection *con +); + +/** + * @brief + * Set a transaction to a connection + * + * @param con - Connection handle + * @param trans - Transaction handle to assign + * + * @note + * The current transaction (if any) is automatically stopped but the newly assigned is not + * started or resumed + * + * @warning + * Do not set transaction object to XA connection or connection retrieved from a session pool + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetTransaction +( + OCI_Connection * con, + OCI_Transaction *trans +); + +/** + * @brief + * Return the highest Oracle version is supported by the connection + * + * @param con - connection handle + * + * @note + * The highest supported version is the lower version between client and server: + * + * @note + * Returns one of the following values: + * + * - OCI_UNKNOWN + * - OCI_8_0 + * - OCI_8_1 + * - OCI_9_0 + * - OCI_9_2 + * - OCI_10_1 + * - OCI_10_2 + * - OCI_11_1 + * - OCI_11_2 + * - OCI_12_1 + * - OCI_18_3 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetVersionConnection +( + OCI_Connection *con +); + +/** + * @brief + * Set tracing information to the session of the given connection + * + * @param con - connection handle + * @param trace - trace type + * @param value - trace content + * + * Store current trace information to the given connection handle. + * These information: + * + * - is stored in system view V$SESSION and/or V$SQL_MONITOR + * - can be retrieved from the connection property of an OCI_Error handle + * + * @note + * Possible values of parameter 'trace' : + * + * - OCI_TRC_IDENTITY : Specifies the user defined identifier in the session. + * It's recorded in the column CLIENT_IDENTIFIER of the + * system view V$SESSION + * - OCI_TRC_MODULE : name of the current module in the client application. + * It's recorded in the column MODULE of the + * system view V$SESSION + * - OCI_TRC_ACTION : name of the current action within the current module. + * It's recorded in the column ACTION of the + * system view V$SESSION + * - OCI_TRC_DETAIL : Client application additional information. + * It's recorded in the column CLIENT_INFO of the + * system view V$SESSION + * - OCI_TRC_OPERATION: Client application database operation. + * It's recorded in the column DBOP_NAME of the + * system view V$SQL_MONITOR + * @warning + * The system view V$SESSION is updated on Oracle versions >= 10gR1 + * The system view V$SQL_MONITOR is updated on Oracle versions >= 12cR1 + * + * @warning + * Oracle limits the size of these traces content: + * + * - OCI_TRC_IDENTITY : 64 bytes + * - OCI_TRC_MODULE : 48 bytes + * - OCI_TRC_ACTION : 32 bytes + * - OCI_TRC_DETAIL : 64 bytes + * - OCI_TRC_OPERATION: 32 bytes + * + * OCILIB truncates input values to match theses limits + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetTrace +( + OCI_Connection *con, + unsigned int trace, + const otext * value +); + +/** + * @brief + * Get the current trace for the trace type from the given connection. + * + * @param con - connection handle + * @param trace - trace type + * + * @note + * See OCI_SetTrace() for more details. + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetTrace +( + OCI_Connection *con, + unsigned int trace +); + +/** + * @brief + * Makes a round trip call to the server to confirm that the connection and the server are active. + * + * @param con - Connection handle + * + * @note + * Returns TRUE is the connection is still alive otherwise FALSE + * + * @warning + * This call is supported from Oracle 10g. + * For previous versions, it returns FALSE without throwing any exception. + * + */ + +OCI_EXPORT boolean OCI_API OCI_Ping +( + OCI_Connection *con +); + +/** + * @brief + * Set a given timeout for OCI calls that require server round-trips to the given database + * + * @param con - Connection handle + * @param type - Type of timeout to set + * @param value - Timeout in milliseconds + * + * Possible values for parameter 'type': + * - OCI_NTO_SEND + * - Time to wait for send operations completion to the database server + * - Requires Oracle 12cR1 client + * - OCI_NTO_RECEIVE + * - Time to wait for read operations completion from the database server + * - Requires Oracle 12cR1 client + * - OCI_NTO_CALL + * - Time to wait for a database round-trip to complete ( Client processing is not taken into account) + * - Requires Oracle 18c client + * + * OCI client raises an timeout type related error when a given timeout is reached. + * + * @note + * To disable a given timeout, pass the value 0 + * + * @warning + * OCI client is using the following precedence rules when applying timeouts: + * - 1 - Timeout set using OCI_NTO_CALL (all other timeouts are discarded) + * - 2 - Timeouts set using OCI_NTO_SEND and/or OCI_NTO_RECEIVE + * - 3 - Timeouts set in sqlnet.ora file + * + * Here is a summary: + * + * FLAG | Min. Version | OCI Error raised | OCI Error description | sqlnet.ora equivalent | + * --------------- | ------------ | ---------------- | ------------------------------ | --------------------- | + * OCI_NTO_SEND | OCI_12_1 | ORA-12608 | TNS: Send timeout occurred | SQLNET.SEND_TIMEOUT | + * OCI_NTO_RECEIVE | OCI_12_1 | ORA-12609 | TNS: Receive timeout occurred | SQLNET.RECV_TIMEOUT | + * OCI_NTO_CALL | OCI_18_1 | ORA-03136 | inbound connection timed out | --- | + * + * @warning + * Returns FALSE without throwing any exception if the Oracle client does not support the given flag + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetTimeout +( + OCI_Connection *con, + unsigned int type, + unsigned int value +); + +/** + * @brief + * Returns the requested timeout value for OCI calls that require server round-trips to the given database + * + * @param con - Connection handle + * @param type - Type of timeout + * + * @note: + * See OCI_SetTimeout() for more information + * + * @return + * The given timeout value if supported, otherwise 0 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetTimeout +( + OCI_Connection *con, + unsigned int type +); + +/** + * @brief + * Return the Oracle server database name of the connected database/service name + * + * @param con - Connection handle + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns NULL without throwing any exception. + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetDBName +( + OCI_Connection *con +); + +/** + * @brief + * Return the Oracle server Instance name of the connected database/service name + * + * @param con - Connection handle + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns NULL without throwing any exception. + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetInstanceName +( + OCI_Connection *con +); + +/** + * @brief + * Return the Oracle server service name of the connected database/service name + * + * @param con - Connection handle + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns NULL without throwing any exception. + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetServiceName +( + OCI_Connection *con +); + +/** + * @brief + * Return the Oracle server machine name of the connected database/service name + * + * @param con - Connection handle + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns NULL without throwing any exception. + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetServerName +( + OCI_Connection *con +); + +/** + * @brief + * Return the Oracle server domain name of the connected database/service name + * + * @param con - Connection handle + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns NULL without throwing any exception. + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetDomainName +( + OCI_Connection *con +); + +/** + * @brief + * Return the date and time (Timestamp) server instance start of the + * connected database/service name + * + * @param con - Connection handle + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns NULL without throwing any exception. + * + */ + +OCI_EXPORT OCI_Timestamp * OCI_API OCI_GetInstanceStartTime +( + OCI_Connection *con +); + +/** + * @brief + * Verify if the given connection support TAF events + * + * @param con - Connection handle + * + * @note + * Returns TRUE is the connection supports TAF event otherwise FALSE + * + * @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns FALSE without throwing any exception. + * + */ + +OCI_EXPORT boolean OCI_API OCI_IsTAFCapable +( + OCI_Connection *con +); + +/** + * @brief + * Set the Transparent Application Failover (TAF) user handler + * + * @param con - Connection handle + * @param handler - Pointer to TAF handler procedure + * + * @note + * See POCI_TAF_HANDLER documentation for more details + * +* @warning + * This call is supported from Oracle 10gR2. + * For previous versions, it returns FALSE without throwing any exception. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetTAFHandler +( + OCI_Connection * con, + POCI_TAF_HANDLER handler +); + +/** + * @brief + * Return the maximum number of statements to keep in the statement cache + * + * @param con - Connection handle + * + * @note + * Default value is 20 (value from Oracle Documentation) + * + * @warning + * Requires Oracle Client 9.2 or above + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetStatementCacheSize +( + OCI_Connection *con +); + +/** + * @brief + * Set the maximum number of statements to keep in the statement cache + * + * @param con - Connection handle + * @param value - maximum number of statements in the cache + * + * @warning + * Requires Oracle Client 9.2 or above + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetStatementCacheSize +( + OCI_Connection *con, + unsigned int value +); + +/** + * @brief + * Return the default LOB prefetch buffer size for the connection + * + * @param con - Connection handle + * + * @warning + * Requires Oracle Client AND Server 11gR1 or above + * + * @note + * Prefetch size is: + * - number of bytes for BLOBs and BFILEs + * - number of characters for CLOBs. + * + * @note + * Default is 0 (prefetching disabled) + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetDefaultLobPrefetchSize +( + OCI_Connection *con +); + +/** + * @brief + * Enable or disable prefetching for all LOBs fetched in the connection + * + * @param con - Connection handle + * @param value - default prefetch buffer size + * + * @note + * If parameter 'value': + * - is == 0, it disables prefetching for all LOBs fetched in the connection. + * - is > 0, it enables prefetching for all LOBs fetched in the connection + * and the given buffer size is used for prefetching LOBs + * + * @note + * LOBs prefetching is disabled by default + * + * @warning + * Requires Oracle Client AND Server 11gR1 or above. + * + * @note + * Prefetch size is: + * - number of bytes for BLOBs and BFILEs + * - number of characters for CLOBs. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetDefaultLobPrefetchSize +( + OCI_Connection *con, + unsigned int value +); + +/** +* @brief +* Return the maximum number of SQL statements that can be opened in one session +* +* @param con - Connection handle +* +* @warning +* Requires Oracle Client AND Server 12cR1 or above +* +* @note +* the returned value is the same as the db parameter 'open_cursors' from server's parameter file +* +* @note +* Return 0 if the client and server version are < 12cR1 +* +*/ + +OCI_EXPORT unsigned int OCI_API OCI_GetMaxCursors +( + OCI_Connection *con +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiPools Oracle Pools + * @{ + * + * OCILIB support the connections and sessions pooling features introduced + * in Oracle 9i. + * + * Let's Oracle talk about this features ! + * + * @par Connection pools (from Oracle Call Interface Programmer's Guide) + * + * Connection pooling is the use of a group (the pool) of reusable physical connections + * by several sessions, in order to balance loads. The management of the pool is done + * by OCI, not the application. Applications that can use connection pooling include + * middle-tier applications for Web application servers and e-mail servers. + * + * @par Session Pools (from Oracle Call Interface Programmer's Guide) + * + * Session pooling means that the application will create and maintain a group of stateless + * sessions to the database. These sessions will be handed over to thin clients as requested. + * If no sessions are available, a new one may be created. When the client is done with + * the session, the client will release it to the pool. Thus, the number of sessions in + * the pool can increase dynamically. + * + * @note + * OCILIB implements homogeneous session pools only. + * + * @par When using Pools (from Oracle Call Interface Programmer's Guide) + * + * If database sessions are not reusable by mid-tier threads (that is, they are stateful) + * and the number of back-end server processes may cause scaling problems on the database, + * use OCI connection pooling. + * + * If database sessions are reusable by mid-tier threads (that is, they are stateless) + * and the number of back-end server processes may cause scaling problems on the database, + * use OCI session pooling. + * + * If database sessions are not reusable by mid-tier threads (that is, they are stateful) + * and the number of back-end server processes will never be large enough to potentially + * cause any scaling issue on the database, there is no need to use any pooling mechanism. + * + * @par Example + * @include pool.c + * + */ + +/** + * @brief + * Create an Oracle pool of connections or sessions + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param type - Type of pool + * @param mode - Session mode + * @param min_con - minimum number of connections/sessions that can be opened. + * @param max_con - maximum number of connections/sessions that can be opened. + * @param incr_con - next increment for connections/sessions to be opened + * + * Possible values for parameter 'type': + * - OCI_POOL_CONNECTION + * - OCI_POOL_SESSION + * + * Possible values for parameter 'mode': + * - OCI_SESSION_DEFAULT + * - OCI_SESSION_SYSDBA (session pools only) + * + * @note + * External credentials are supported by supplying a null value for the 'user' + * and 'pwd' parameters + * If the param 'db' is NULL then a connection to the default local DB is done + * + * @return + * Connection or session pool handle on success or NULL on failure + * + */ + +OCI_EXPORT OCI_Pool * OCI_API OCI_PoolCreate +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int type, + unsigned int mode, + unsigned int min_con, + unsigned int max_con, + unsigned int incr_con +); + +/** + * @brief + * Destroy a pool object + * + * @param pool - Pool handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_PoolFree +( + OCI_Pool *pool +); + +/** + * @brief + * Get a connection from the pool + * + * @param pool - Pool handle + * @param tag - user tag string + * + * @par Session tagging + * + * Session pools have a nice feature that is 'session tagging' + * It's possible to tag a session with a string identifier + * when the session is returned to the pool, it keeps its tags. + * When requesting a connection from the session pool, it's + * possible to request a session that has the given 'tag' parameter + * If one exists, it is returned. If not and if an untagged session + * is available, it is then returned. So check the connection tag + * property with OCI_GetSessionTag() to find out if the returned + * connection is tagged or not. + * + * This features is described in the OCI developer guide as the following : + * + * "The tags provide a way for users to customize sessions in the pool. + * A client may get a default or untagged session from a pool, set certain + * attributes on the session (such as NLS settings), and return the session + * to the pool, labeling it with an appropriate tag. + * The user may request a session with the same tags in order to have a + * session with the same attributes" + * + * @return + * Connection handle otherwise NULL on failure + */ + +OCI_EXPORT OCI_Connection * OCI_API OCI_PoolGetConnection +( + OCI_Pool * pool, + const otext *tag +); + +/** + * @brief + * Get the idle timeout for connections/sessions in the pool + * + * @param pool - Pool handle + * + * @note + * Connections/sessions idle for more than this time value (in seconds) is terminated + * + * @note + * Timeout is not available for internal pooling implementation (client < 9i) + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetTimeout +( + OCI_Pool *pool +); + +/** + * @brief + * Set the connections/sessions idle timeout + * + * @param pool - Pool handle + * @param value - Timeout value + * + * @note + * connections/sessions idle for more than this time value (in seconds) is terminated + * + * @note + * This call has no effect if pooling is internally implemented (client < 9i) + * + */ + +OCI_EXPORT boolean OCI_API OCI_PoolSetTimeout +( + OCI_Pool * pool, + unsigned int value +); + +/** + * @brief + * Get the waiting mode used when no more connections/sessions are available + * from the pool + * + * @param pool - Pool handle + * + * @return + * - FALSE to wait for an available object if the pool is saturated + * - TRUE to not wait for an available object + * + */ + +OCI_EXPORT boolean OCI_API OCI_PoolGetNoWait +( + OCI_Pool *pool +); + +/** + * @brief + * Set the waiting mode used when no more connections/sessions are available + * from the pool + * + * @param pool - Pool handle + * @param value - wait for object + * + * @note + * Pass : + * - FALSE to wait for an available object if the pool is saturated + * - TRUE to not wait for an available object + * + */ + +OCI_EXPORT boolean OCI_API OCI_PoolSetNoWait +( + OCI_Pool *pool, + boolean value +); + +/** + * @brief + * Return the current number of busy connections/sessions + * + * @param pool - Pool handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetBusyCount +( + OCI_Pool *pool +); + +/** + * @brief + * Return the current number of opened connections/sessions + * + * @param pool - Pool handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetOpenedCount +( + OCI_Pool *pool +); + +/** + * @brief + * Return the minimum number of connections/sessions that can be opened to the database + * + * @param pool - Pool handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetMin +( + OCI_Pool *pool +); + +/** + * @brief + * Return the maximum number of connections/sessions that can be opened to the database + * + * @param pool - Pool handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetMax +( + OCI_Pool *pool +); + +/** + * @brief + * Return the increment for connections/sessions to be opened to the database when the pool is + * not full + * + * @param pool - Pool handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetIncrement +( + OCI_Pool *pool +); + +/** + * @brief + * Return the maximum number of statements to keep in the pool statement cache + * + * @param pool - Pool handle + * + * @note + * Default value is 20 (value from Oracle Documentation) + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_PoolGetStatementCacheSize +( + OCI_Pool *pool +); + +/** + * @brief + * Set the maximum number of statements to keep in the pool statement cache + * + * @param pool - Pool handle + * @param value - maximum number of statements in the cache + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_PoolSetStatementCacheSize +( + OCI_Pool * pool, + unsigned int value +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiTransactions Managing transactions + * @{ + * + * OCILIB supports local and global transactions. + * + * Local transactions are implicit within connection objects and there is no + * specific call or programming step for using it. + * + * In order to control changes made in the database: + * + * - OCI_Commit() validates current pending modifications + * - OCI_Rollback() discards current pending modifications + * + * OCILIB supports a feature called 'Auto Commit' that performs an implicit and + * automatic commit call after every execute call + * + * @note + * Those actions are executed within a connection context and not directly to a transaction. + * + * @warning + * Global transactions are optional and are designed for distributed or global + * transaction environments. + * + * OCILIB supports them by : + * + * - Creating/Destroying explicitly a transaction object + * - Starting/Stopping/Resuming explicitly the transaction + * - Preparing the transaction for specific calls + * + */ + +/** + * @brief + * Commit current pending changes + * + * @param con - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_Commit +( + OCI_Connection *con +); + +/** + * @brief + * Cancel current pending changes + * + * @param con - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_Rollback +( + OCI_Connection *con +); + +/** + * @brief + * Enable / disable auto commit mode + * + * The auto commit mode allows commit changes after every executed SQL order + * + * @param con - Connection handle + * @param enable - Enable (TRUE) or disable (FALSE) + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetAutoCommit +( + OCI_Connection *con, + boolean enable +); + +/** + * @brief + * Get current auto commit mode status + * + * @param con - Connection handle + * + * @return + * TRUE if auto commit mode is activated otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_GetAutoCommit +( + OCI_Connection *con +); + +/** + * @brief + * Create a new global transaction or a serializable/read-only local transaction + * + * @param con - Connection handle + * @param timeout - Time that a transaction stays inactive after being stopped + * @param mode - Transaction mode + * @param pxid - pointer to a global transaction identifier structure + * + * + * @note + * The parameter 'mode' can be one of the following values : + * + * - Global transactions: + * - OCI_TRS_NEW : By default starts a new, tightly coupled and + * migratable branch. + * - OCI_TRS_TIGHT : explicitly specifies a tightly coupled branch + * - OCI_TRS_LOOSE : specifies a loosely coupled branch + * + * - Global and local transactions : + * - OCI_TRS_READONLY - start a read-only transaction + * - OCI_TRS_READWRITE - start a read-write transaction + * - OCI_TRS_SERIALIZABLE : start a serializable transaction + * + * @note + * For local transaction: + * - pass a NULL value for pxid + * + */ + +OCI_EXPORT OCI_Transaction * OCI_API OCI_TransactionCreate +( + OCI_Connection *con, + unsigned int timeout, + unsigned int mode, + OCI_XID * pxid +); + +/** + * @brief + * Free current transaction + * + * @param trans - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TransactionFree +( + OCI_Transaction *trans +); + +/** + * @brief + * Start global transaction + * + * @param trans - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TransactionStart +( + OCI_Transaction *trans +); + +/** + * @brief + * Stop current global transaction + * + * @param trans - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TransactionStop +( + OCI_Transaction *trans +); + +/** + * @brief + * Resume a stopped global transaction + * + * @param trans - Global transaction handle + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_TransactionResume +( + OCI_Transaction *trans +); + +/** + * @brief + * Prepare a global transaction validation + * + * @param trans - Global transaction handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TransactionPrepare +( + OCI_Transaction *trans +); + +/** + * @brief + * Cancel the prepared global transaction validation + * + * @param trans - Global transaction handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TransactionForget +( + OCI_Transaction *trans +); + +/** + * @brief + * Return global transaction mode. + * + * @note: + * see OCI_TransactionCreate() for possible values + * + * @param trans - Global transaction handle + * + * @return + * Transaction mode or OCI_UNKNOW if trans is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_TransactionGetMode +( + OCI_Transaction *trans +); + +/** + * @brief + * Return global transaction Timeout + * + * @param trans - Global transaction handle + * + * @return + * Transaction timeout or 0 if trans is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_TransactionGetTimeout +( + OCI_Transaction *trans +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiStatements Executing statements + * @{ + * + * Executing SQL statements or PL/SQL blocks is really simple with OCILIB. + * + * First, call OCI_StatementCreate() to allocate a statement handle. Then : + * + * - Prepare the SQL with OCI_Prepare() + * - Parse and execute it with OCI_Execute() + * + * These two steps can be done together by calling OCI_ExecuteStmt() that + * prepares and executes in one go. + * + * To find out if the statement has affected any rows, call OCI_GetAffectedRows() + * + * Finally, release the statement and its resources with OCI_StatementFree() + * + * @note + * A statement can be prepared once and executed as many times as needed (see + * Binding variables section) + * + * @note + * An OCI_Statement can be used to prepare and/or execute different SQL and PL/SQL + * statements as many times as needed. + * For example, if the SQL processing of an application is sequential, only + * one statement handle is required + * + * @note + * OCILIB supports nested levels of SQL statement processing. + * An application can loop through the resultset of the statement handle A, + * executing statement B and fetching statement C at every loop, and so on ... + * + * @par Example + * @include exec.c + * + */ + +/** + * @brief + * Create a statement object and return its handle + * + * @param con - Connection handle + * + * @return + * A statement handle on success otherwise NULL + * + */ + +OCI_EXPORT OCI_Statement * OCI_API OCI_StatementCreate +( + OCI_Connection *con +); + +/** + * @brief + * Free a statement and all resources associated to it (resultsets ...) + * + * @param stmt - Connection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_StatementFree +( + OCI_Statement *stmt +); + +/** + * @brief + * Prepare a SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * @param sql - SQL order or PL/SQL block + * + * @note + * Do not call this function for fetched statements (REF cursors) + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_Prepare +( + OCI_Statement *stmt, + const otext * sql +); + +/** + * @brief + * Execute a prepared SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * + * @return + * TRUE on success otherwise FALSE + * + * @warning + * If a SQL warning occurs: + * - the function returns TRUE + * - the SQL warning triggers the global error handler with an OCI_Error having its OCI_ErrorGetType() + * attribute set to OCI_ERR_WARNING + * - If OCILIB is initialized with the OCI_ENV_CONTEXT mode, OCI_GetLastError() will return the OCI_Error + * object corresponding to the warning + * + */ + +OCI_EXPORT boolean OCI_API OCI_Execute +( + OCI_Statement *stmt +); + +/** + * @brief + * Prepare and Execute a SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * @param sql - SQL order - PL/SQL block + * + * @return + * TRUE on success otherwise FALSE + * + * @warning + * If a SQL warning occurs: + * - the function returns TRUE + * - the SQL warning triggers the global error handler with an OCI_Error having its OCI_ErrorGetType() + * attribute set to OCI_ERR_WARNING + * - If OCILIB is initialized with the OCI_ENV_CONTEXT mode, OCI_GetLastError() will return the OCI_Error + * object corresponding to the warning + * + */ + +OCI_EXPORT boolean OCI_API OCI_ExecuteStmt +( + OCI_Statement *stmt, + const otext * sql +); + +/** + * @brief + * Parse a SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * @param sql - SQL order - PL/SQL block + * + * @note + * This call sends the SQL or PL/SQL command to the server for parsing only. + * The command is not executed. + * This call is only useful to check is a command is valid or not. + * + * @note + * This call prepares the statement (internal call to OCI_Prepare()) and ask + * the Oracle server to parse its SQL or PL/SQL command. + * OCI_Execute() can be call after OCI_Parse() in order to execute the + * statement, which means that the server will re-parse again the command. + * + * @warning + * Do not use OCI_Parse() unless you're only interested in the parsing result + * because the statement will be parsed again when executed and thus leading to + * unnecessary server round-trips and less performance + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_Parse +( + OCI_Statement *stmt, + const otext * sql +); + +/** + * @brief + * Describe the select list of a SQL select statement. + * + * @param stmt - Statement handle + * @param sql - SELECT sql statement + * + * @note + * This call sends the SELECT SQL order to the server for retrieving the + * description of the select order only. + * The command is not executed. + * This call is only useful to retrieve information on the associated resultset + * Call OCI_GetResultet() after OCI_Describe() to access to SELECT list + * information + * + * @note + * This call prepares the statement (internal call to OCI_Prepare()) and ask + * the Oracle server to describe the output SELECT list. + * OCI_Execute() can be called after OCI_Describe() in order to execute the + * statement, which means that the server will parse, and describe again the SQL + * order. + * + * @warning + * Do not use OCI_Describe() unless you're only interested in the resultset + * information because the statement will be parsed again when executed and thus + * leading to unnecessary server round-trips and less performance + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_Describe +( + OCI_Statement *stmt, + const otext * sql +); + +/** + * @brief + * Return the last SQL or PL/SQL statement prepared or executed by the statement + * + * @param stmt - Statement handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetSql +( + OCI_Statement *stmt +); + +/** +* @brief +* Returns the statement SQL_ID from the server +* +* @param stmt - Statement handle +* +* @note +* The statement must be executed first +* +* @warning +* Requires Oracle 12cR2 (both client and server side), otherwise it returns NULL +* +*/ + +OCI_EXPORT const otext * OCI_API OCI_GetSqlIdentifier +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the error position (in terms of characters) in the SQL statement + * where the error occurred in case of SQL parsing error + * + * @param stmt - Statement handle + * + * @note + * Positions start at 1. + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetSqlErrorPos +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the number of rows affected by the SQL statement + * + * @param stmt - Statement handle + * + * The returned value is : + * - For UPDATEs : number of rows updated + * - For INSERTs : number of rows inserted + * - For DELETEs : number of rows deleted + * + * @note + * For SELECTs statements, use OCI_GetRowCount() instead + * + * @note + * For PL/SQL blocks performing "select into :": + * - it returns the number of rows selected from PL/SQL + * - Up to version 4.3.0, OCI_Execute() returned FALSE and generated an error ORA-01403 - "No Data Found" + * - From version 4.3.1, OCI_Execute() returns 0 if no data found, otherwise the number of selected rows + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetAffectedRows +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the Oracle SQL code the command held by the statement handle + * + * @param stmt - Statement handle + * + * @warning + * OCI_GetSQLCommand() must be called after the statement has be executed + * because that's the server engine that computes the SQL command code + * + * @return + * The SQL command code of the statement otherwise OCI_UNKOWN + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetSQLCommand +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the verb of the SQL command held by the statement handle + * + * @param stmt - Statement handle + * + * @warning + * OCI_GetSQLVerb() must be called after the statement has been executed + * because that's the server engine that computes the SQL verb + * + * @note + * The SQL verb list is available in Oracle documentations and guides + * + * @return + * The SQL command verb of the statement otherwise NULL + */ + +OCI_EXPORT const otext * OCI_API OCI_GetSQLVerb +( + OCI_Statement *stmt +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiBinding Binding variables and arrays + * @{ + * + * OCILIB supports OCI data binding APIs + * + * Programs variables can be binded to an Oracle SQL PL/SQL statement in order to : + * + * - Provide input data for SQL statement + * - Provide input/output data for PL/SQL blocks + * + * OCILIB provides a set of binding functions to use with: + * + * - Basic data types: string (char/wchar_t *), int, float, double, raw + * - Object data types: lobs, files,longs, dates, cursors, statements, + * timestamps, intervals, objects + * + * To use binding: + * + * - Prepare a statement with OCI_Prepare() (see Executing statements) + * - Bind variables by calling one if the OCI_Bindxxxxx() function for every + * input variable referenced by the SQL statement + * - Setup up values of the program variables + * - Call OCI_Execute() as many times as needed + * - Each OCI_Execute() call may be preceded by an update of the program + * variables (for INSERTs for example) + * + * Bindings can be: + * - IN (host variable are not used anymore after statement execution) + * - OUT (host variable are set during statement execution) + * - IN/OUT (default) + * Use OCI_BindSetDirectionTo() to change a host variable bind direction mode after the binding call but before statement execution. + * Note that each direction mode may have a little overhead depending on the SQL type as OCILIB may have to do checks/conversions/mappings between host variable and buffers. + * Thus, to maximize performances: + * - set direction mode to OCI_BDM_IN if host variable is not updated by statement execution + * - set direction mode to OCI_BDM_OUT if host variable value does not matter prior to statement execution + * - set direction mode to OCI_BDM_IN_OUT when host variable value is used for execution and updated by statement execution + * + * OCILIB supports the OCI array Interface by binding arrays of C scalar types + * and OCILIB object types. + * + * - all types supported the library can be used for array binding except + * OCI_Statement and OCI_Long + * - Array binding is really fast for massive DML operations + * - For string/RAW arrays, the input array MUST BE a contiguous block of data + * and not an array of pointers. So to bind an array of 10 elements for a + * varchar2(30) column, binded variable must be a like array[10][31] + * + * OCILIB does not pre-parse statements (like other frameworks such as JDBC, ...) + * and lets Oracle recognize input variables embedded within the SQL statements. + * + * Bind variables must be preceded in the SQL code by the character ':'. + * + * Oracle and OCILIB supports two ways of binding: + * + * - by name (default mode in OCILIB): Oracle looks for variables in the SQL + * statement by searching their names provided to the binding function. + * So a variable can be binded once and used many times in the statement + * - by position: Oracle binds variables by position, so every variable is + * binded with a position number + * + * OCILIB Default binding mode is OCI_BIND_BY_NAME. + * + * When using binding by position, provide the position to OCI_BindXXXX() call + * through the name parameter. Within this mode the bind name must be the + * position preceded by a semicolon like ':1', ':2', .... + * + * @par Internal Bind allocation mode + * + * Bind variables or arrays can be internally allocated by OCILIB. + * That means that instead of allocating variables or arrays on the stack/heap + * in the user program, bind contents can be allocated internally and thus : + * - minimize the amount of program variables + * - optimize internal memory management for arrays + * + * To do so : + * - Call OCI_SetBindAllocation() with the mode OCI_BAM_INTERNAL + * - pass a NULL variable or array to OCI_BindXXX() calls + * - Retrieve the bind content allocated by OCILIB with OCI_BindGetData() + * + * Internal Bind allocation mode IS compatible with ALL array binding OCI_BindArrayOfxxx() methods. + * + * Internal Bind allocation mode IS NOT compatible with some single variable bind calls : + * - OCI_BindTimestamp() + * - OCI_BindInterval() + * - OCI_BindLob() + * - OCI_BindFile() + * - OCI_BindObject() + * - OCI_BindColl() + * - OCI_BindRef() + * - OCI_BindStatement() + * - OCI_BindLong() + * + * These methods need to know the data sub type (like OCI_CLOB/OCI_BLOB for lobs) in order + * to internally create variables. As these methods prototypes are not passing the sub type, + * calling them with the statement bind mode set to OCI_BAM_INTERNAL will raise + * an OCILIB error of type OCI_ERR_NULL_POINTER + * + * @note + * Rebinding is disabled by default (see OCI_AllowRebinding()) + * When using rebinding feature, host variable re-binded to a previously allocated + * bind MUST be of the SAME data type ! + * + * @par Basic input bind Example + * @include bind.c + * + * @par Array interface Example + * @include array.c + * + * @par Internal Array interface Example + * @include array_internal.c + * + * */ + +/** + * @brief + * Set the input array size for bulk operations + * + * @param stmt - Statement handle + * @param size - Array size + * + * @warning + * Do not use OCI_BindArraySetSize() for PL/SQL tables binding + * + * @note + * OCI_BindArraySetSize() is used to set the size of input bind array when using + * arrays for DML statements. + * OCI_BindArraySetSize() MUST be called to set the maximum size of the arrays + * to bind to the statement before any of its execution. This initial call must + * be bone AFTER OCI_Prepare() and BEFORE any OCI_BindArrayOfxxx() call. + * + * @note + * OCI_BindArraySetSize() can optionally be called before any later OCI_Execute() + * call in order to notify the statement of the exact number of elements + * populating the input arrays for the next execution. The array size passed to + * later OCI_BindArraySetSize() calls cannot be greater than the initial size + * otherwise an exception will be thrown. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindArraySetSize +( + OCI_Statement *stmt, + unsigned int size +); + +/** + * @brief + * Return the current input array size for bulk operations + * + * @param stmt - Statement handle + * + * @return + * Array size value or 0 if OCI_BindArraySetSize() has not been called + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindArrayGetSize +( + OCI_Statement *stmt +); + +/** + * @brief + * Allow different host variables to be binded using the same bind name or + * position between executions of a prepared statement + * + * @param stmt - Statement handle + * @param value - Rebinding mode allowed + * + * @note + * Default value is FALSE + * + * @warning + * When using rebinding feature, host variable re-binded to a previously allocated + * bind MUST be of the same data type ! + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_AllowRebinding +( + OCI_Statement *stmt, + boolean value +); + +/** + * @brief + * Indicate if rebinding is allowed on the given statement + * + * @param stmt - Statement handle + * + * @note + * See OCI_AllowRebinding() for more details + * + * @return + * TRUE if allowed otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_IsRebindingAllowed +( + OCI_Statement *stmt +); + +/** +* @brief +* Bind a boolean variable (PL/SQL ONLY) +* +* @param stmt - Statement handle +* @param name - Variable name +* @param data - Pointer to boolean variable +* +* @note +* parameter 'data' can NULL if the statement bind allocation mode +* has been set to OCI_BAM_INTERNAL +* +* @warning +* - OCI_BindBoolean() CAN ONLY BE USED for PL/SQL boolean type when calling PL/SQL procedures/function +* - ONLY supported by Oracle 12c and above ! +* +* @return +* TRUE on success otherwise FALSE +*/ +OCI_EXPORT boolean OCI_API OCI_BindBoolean +( + OCI_Statement *stmt, + const otext * name, + boolean * data +); + +/** +* @brief +* Bind an Number variable +* +* @param stmt - Statement handle +* @param name - Variable name +* @param data - Pointer to short variable +* +* @note +* parameter 'data' can NULL if the statement bind allocation mode +* has been set to OCI_BAM_INTERNAL +* +* @return +* TRUE on success otherwise FALSE +*/ + +OCI_EXPORT boolean OCI_API OCI_BindNumber +( + OCI_Statement *stmt, + const otext * name, + OCI_Number * data +); + +/** +* @brief +* Bind an array of Number +* +* @param stmt - Statement handle +* @param name - Variable name +* @param data - Array of numbers +* @param nbelem - Number of element in the array (PL/SQL table only) +* +* @warning +* Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. +* For regular DML array operations, pass the value 0. +* +* @note +* parameter 'data' can NULL if the statement bind allocation mode +* has been set to OCI_BAM_INTERNAL +* +* @return +* TRUE on success otherwise FALSE +*/ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfNumbers +( + OCI_Statement *stmt, + const otext * name, + OCI_Number ** data, + unsigned int nbelem +); + +/** + * @brief + * Bind an short variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to short variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindShort +( + OCI_Statement *stmt, + const otext * name, + short * data +); + +/** + * @brief + * Bind an array of shorts + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of shorts + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfShorts +( + OCI_Statement *stmt, + const otext * name, + short * data, + unsigned int nbelem +); + +/** + * @brief + * Bind an unsigned short variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to unsigned short variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindUnsignedShort +( + OCI_Statement * stmt, + const otext * name, + unsigned short *data +); + +/** + * @brief + * Bind an array of unsigned shorts + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of unsigned shorts + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedShorts +( + OCI_Statement * stmt, + const otext * name, + unsigned short *data, + unsigned int nbelem +); + +/** + * @brief + * Bind an integer variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to int variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindInt +( + OCI_Statement *stmt, + const otext * name, + int * data +); + +/** + * @brief + * Bind an array of integers + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of int + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfInts +( + OCI_Statement *stmt, + const otext * name, + int * data, + unsigned int nbelem +); + +/** + * @brief + * Bind an unsigned integer variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to unsigned int variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindUnsignedInt +( + OCI_Statement *stmt, + const otext * name, + unsigned int * data +); + +/** + * @brief + * Bind an array of unsigned integers + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of unsigned int + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedInts +( + OCI_Statement *stmt, + const otext * name, + unsigned int * data, + unsigned int nbelem +); + +/** + * @brief + * Bind a big integer variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to big int variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindBigInt +( + OCI_Statement *stmt, + const otext * name, + big_int * data +); + +/** + * @brief + * Bind an array of big integers + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of big int + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfBigInts +( + OCI_Statement *stmt, + const otext * name, + big_int * data, + unsigned int nbelem +); + +/** + * @brief + * Bind an unsigned big integer variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to unsigned big int variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindUnsignedBigInt +( + OCI_Statement *stmt, + const otext * name, + big_uint * data +); + +/** + * @brief + * Bind an array of unsigned big integers + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of unsigned big int + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedBigInts +( + OCI_Statement *stmt, + const otext * name, + big_uint * data, + unsigned int nbelem +); + +/** + * @brief + * Bind a string variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - String to bind + * @param len - Max length of the string (in character without + * the zero null terminal character) + * + * @note + * if len == 0, len is set to the string size + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindString +( + OCI_Statement *stmt, + const otext * name, + otext * data, + unsigned int len +); + +/** + * @brief + * Bind an array of strings + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of string + * @param len - Max length of a single string element (in character without + * the zero null terminal character) + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @warning + * if len <= 0, it returns FALSE + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfStrings +( + OCI_Statement *stmt, + const otext * name, + otext * data, + unsigned int len, + unsigned int nbelem +); + +/** + * @brief + * Bind a raw buffer + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - buffer to bind + * @param len - Max length of the buffer + * + * @note + * if len <= 0, it returns false + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindRaw +( + OCI_Statement *stmt, + const otext * name, + void * data, + unsigned int len +); + +/** + * @brief + * Bind an array of raw buffers + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of buffers + * @param len - Size in bytes on a single RAW array element + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * The buffer must be a contiguous block of data elements + * + * @note + * If len <= 0, it returns FALSE + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfRaws +( + OCI_Statement *stmt, + const otext * name, + void * data, + unsigned int len, + unsigned int nbelem +); + +/** + * @brief + * Bind a double variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to double variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindDouble +( + OCI_Statement *stmt, + const otext * name, + double * data +); + +/** + * @brief + * Bind an array of doubles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of double + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfDoubles +( + OCI_Statement *stmt, + const otext * name, + double * data, + unsigned int nbelem +); + +/** + * @brief + * Bind a float variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Pointer to float variable + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindFloat +( + OCI_Statement *stmt, + const otext * name, + float * data +); + +/** + * @brief + * Bind an array of floats + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of float + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfFloats +( + OCI_Statement *stmt, + const otext * name, + float * data, + unsigned int nbelem +); + +/** + * @brief + * Bind a date variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Date handle + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindDate +( + OCI_Statement *stmt, + const otext * name, + OCI_Date * data +); + +/** + * @brief + * Bind an array of dates + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of date handle + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfDates +( + OCI_Statement *stmt, + const otext * name, + OCI_Date ** data, + unsigned int nbelem +); + +/** + * @brief + * Bind a timestamp variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Timestamp handle + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindTimestamp +( + OCI_Statement *stmt, + const otext * name, + OCI_Timestamp *data +); + +/** + * @brief + * Bind an array of timestamp handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of Timestamp handle + * @param type - Timestamp type + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * See OCI_TimestampCreate() for possible values of parameter 'type' + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfTimestamps +( + OCI_Statement * stmt, + const otext * name, + OCI_Timestamp **data, + unsigned int type, + unsigned int nbelem +); + +/** + * @brief + * Bind an interval variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Interval handle + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindInterval +( + OCI_Statement *stmt, + const otext * name, + OCI_Interval * data +); + +/** + * @brief + * Bind an array of interval handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of Interval handle + * @param type - Interval type + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * See OCI_IntervalCreate() for possible values of parameter 'type' + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfIntervals +( + OCI_Statement *stmt, + const otext * name, + OCI_Interval **data, + unsigned int type, + unsigned int nbelem +); + +/** + * @brief + * Bind a Lob variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Lob handle + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindLob +( + OCI_Statement *stmt, + const otext * name, + OCI_Lob * data +); + +/** + * @brief + * Bind an array of Lob handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of Lob handle + * @param type - Lob type + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * See OCI_LobCreate() for possible values of parameter 'type' + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfLobs +( + OCI_Statement *stmt, + const otext * name, + OCI_Lob ** data, + unsigned int type, + unsigned int nbelem +); + +/** + * @brief + * Bind a File variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - File handle + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindFile +( + OCI_Statement *stmt, + const otext * name, + OCI_File * data +); + +/** + * @brief + * Bind an array of File handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of File handle + * @param type - File type + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * See OCI_FileCreate() for possible values of parameter 'type' + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfFiles +( + OCI_Statement *stmt, + const otext * name, + OCI_File ** data, + unsigned int type, + unsigned int nbelem +); + +/** + * @brief + * Bind an object (named type) variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Object handle + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindObject +( + OCI_Statement *stmt, + const otext * name, + OCI_Object * data +); + +/** + * @brief + * Bind an array of object handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of object handle + * @param typinf - type info handle + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfObjects +( + OCI_Statement *stmt, + const otext * name, + OCI_Object ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +/** + * @brief + * Bind a Collection variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Collection handle to bind + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindColl +( + OCI_Statement *stmt, + const otext * name, + OCI_Coll * data +); + +/** + * @brief + * Bind an array of Collection handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of Collection handle + * @param typinf - Type info handle + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * See OCI_CollCreate() for possible values of parameter 'type' + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfColls +( + OCI_Statement *stmt, + const otext * name, + OCI_Coll ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +/** + * @brief + * Bind a Ref variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Ref handle to bind + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindRef +( + OCI_Statement *stmt, + const otext * name, + OCI_Ref * data +); + +/** + * @brief + * Bind an array of Ref handles + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Array of Ref handle + * @param typinf - type info handle + * @param nbelem - Number of element in the array (PL/SQL table only) + * + * @warning + * Parameter 'nbelem' SHOULD ONLY be USED for PL/SQL tables. + * For regular DML array operations, pass the value 0. + * + * @note + * parameter 'data' can NULL if the statement bind allocation mode + * has been set to OCI_BAM_INTERNAL + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindArrayOfRefs +( + OCI_Statement *stmt, + const otext * name, + OCI_Ref ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +/** + * @brief + * Bind a Statement variable (PL/SQL Ref Cursor) + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Statement handle to bind + * + * @note + * parameter 'data' CANNOT be NULL resulting OCI_BAM_INTERNAL bind allocation mode being NOT supported + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindStatement +( + OCI_Statement *stmt, + const otext * name, + OCI_Statement *data +); + +/** + * @brief + * Bind a Long variable + * + * @param stmt - Statement handle + * @param name - Variable name + * @param data - Long handle + * @param size - Size of the long buffer in bytes or characters + * + * @note + * Size is expressed in: + * - Bytes for BLONGs + * - Characters for CLONGs + * + * @note + * parameter 'data' CANNOT be NULL whatever the statement bind allocation mode + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindLong +( + OCI_Statement *stmt, + const otext * name, + OCI_Long * data, + unsigned int size +); + +/** + * @brief + * Returns the first or next error that occurred within a DML array statement execution + * + * @param stmt - Statement handle + * + * @return + * The first or next error handle otherwise NULL + */ + +OCI_EXPORT OCI_Error * OCI_API OCI_GetBatchError +( + OCI_Statement *stmt +); + +/** + * @brief + * Returns the number of errors that occurred within the last DML array statement + * + * @param stmt - Statement handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetBatchErrorCount +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the number of binds currently associated to a statement + * + * @param stmt - Statement handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetBindCount +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the bind handle at the given index in the internal array of bind + * handle + * + * @param stmt - Statement handle + * @param index - Bind position + * + * @note + * Index starts at 1. + * + * @note + * Bind handle are created sequentially. For example, the third call to a + * OCI_BindXXX() generates a bind handle of index 3. + * + * @return + * The bind handle or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Bind * OCI_API OCI_GetBind +( + OCI_Statement *stmt, + unsigned int index +); + +/** + * @brief + * Return a bind handle from its name + * + * @param stmt - Statement handle + * @param name - Bind variable name + * + * @note + * Bind names must include a semicolon at the beginning. + * + * @return + * The bind handle or NULL if not found + * + */ + +OCI_EXPORT OCI_Bind * OCI_API OCI_GetBind2 +( + OCI_Statement *stmt, + const otext * name +); + +/** +* @brief +* Return the index of the bind from its name belonging to the given statement +* +* @param stmt - Statement handle +* @param name - Bind variable name +* +* @warning +* The bind name is case insensitive +* +* @note +* Bind indexes start with 1 in OCILIB +* +* @return +* Bind index on success or zero if the bind does not exists or if statement is NULL +* +*/ + +OCI_EXPORT unsigned int OCI_API OCI_GetBindIndex +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Return the name of the given bind + * + * @param bnd - Bind handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_BindGetName +( + OCI_Bind *bnd +); + +/** + * @brief + * Set the direction mode of a bind handle + * + * @param bnd - Bind handle + * @param direction - direction mode + * + * @note + * Possible values for parameter 'direction' : + * - OCI_BDM_IN : input values (not modified by the server) + * - OCI_BDM_OUT : output values (modified by the server) + * - OCI_BDM_IN_OUT : input and output values + * + * @note + * Default value is OCI_BDM_IN_OUT + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetDirection +( + OCI_Bind * bnd, + unsigned int direction +); + +/** + * @brief + * Get the direction mode of a bind handle + * + * @param bnd - Bind handle + * + * @note + * see OCI_BindSetDirection() for more details + * + * return the bind direction mode on success otherwise OCI_UNKNWON + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetDirection +( + OCI_Bind *bnd +); + +/** + * @brief + * Return the OCILIB type of the given bind + * + * @param bnd - Bind handle + * + * @note + * Possible values are : + * + * - OCI_CDT_NUMERIC : short, int, long long, float, double + * - OCI_CDT_DATETIME : OCI_Date * + * - OCI_CDT_TEXT : otext * + * - OCI_CDT_LONG : OCI_Long * + * - OCI_CDT_CURSOR : OCI_Statement * + * - OCI_CDT_LOB : OCI_Lob * + * - OCI_CDT_FILE : OCI_File * + * - OCI_CDT_TIMESTAMP : OCI_Timestamp * + * - OCI_CDT_INTERVAL : OCI_Interval * + * - OCI_CDT_RAW : void * + * - OCI_CDT_OBJECT : OCI_Object * + * - OCI_CDT_COLLECTION : OCI_Coll * + * - OCI_CDT_REF : OCI_Ref * + * - OCI_CDT_BOOLEAN : boolean + * + * @return + * The column type or OCI_CDT_UNKNOWN on error + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetType +( + OCI_Bind *bnd +); + +/** + * @brief + * Return the OCILIB object subtype of the given bind + * + * @param bnd - Bind handle + * + * @note + * * This call is valid for the following OCILIB types: + * - OCI_CDT_NUMERIC + * - OCI_CDT_LONG + * - OCI_CDT_LOB + * - OCI_CDT_FILE + * - OCI_CDT_TIMESTAMP + * - OCI_CDT_INTERVAL + * + * For numeric binds the possible values are: + * - OCI_NUM_SHORT + * - OCI_NUM_INT + * - OCI_NUM_BIGINT + * - OCI_NUM_USHORT + * - OCI_NUM_UINT + * - OCI_NUM_BIGUINT + * - OCI_NUM_DOUBLE + * - OCI_NUM_FLOAT + * - OCI_NUM_NUMBER + * + * For OCI_Long type the possible values are: + * - OCI_BLONG + * - OCI_CLONG + * + * For OCI_Lob type the possible values are: + * - OCI_BLOB + * - OCI_CLOB + * - OCI_NCLOB + * + * For OCI_File type the possible values are: + * - OCI_BFILE + * - OCI_CFILE + * + * For OCI_Timestamp type the possible values are: + * - OCI_TIMESTAMP + * - OCI_TIMESTAMP_TZ + * - OCI_TIMESTAMP_LTZ + * + * For OCI_Interval type the possible values are: + * - OCI_INTERVAL_YM + * - OCI_INTERVAL_DS + * + * @note + * For all other OCILIB types, it returns OCI_UNKNOWN + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetSubtype +( + OCI_Bind *bnd +); + +/** + * @brief + * Return the number of elements of the bind handle + * + * @param bnd - Bind handle + * + * @return + * - For single binds, it returns 1 + * - For array binds, it returns the number of element in the array + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetDataCount +( + OCI_Bind *bnd +); + +/** + * @brief + * Return the user defined data associated with a bind handle + * + * @param bnd - Bind handle + * + * @return + * - The pointer to variable/array passed to an OCI_BindXXX() or + * OCI_BindArrayOfXXX() call + * + */ + +OCI_EXPORT void * OCI_API OCI_BindGetData +( + OCI_Bind *bnd +); + +/** + * @brief + * Return the statement handle associated with a bind handle + * + * @param bnd - bind handle + * + */ + +OCI_EXPORT OCI_Statement * OCI_API OCI_BindGetStatement +( + OCI_Bind *bnd +); + +/** + * @brief + * Set the actual size of the element held by the given bind handle + * + * @param bnd - bind handle + * @param size - data size + * + * @note + * This call is not mandatory and should ONLY be called for RAWs binds to set + * the real size of the given data if different from the expected column or + * parameter size + * + * @note + * It works as well with string based PL/SQL tables (in or in/out but NOT out) + * even if it's not necessary. + * + * @warning + * For binds of type OCI_CDT_TEXT (strings), the parameter 'size' is expressed in + * number of characters. + * + * @return + * Data size if the bind type is listed above otherwise 0. + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetDataSize +( + OCI_Bind * bnd, + unsigned int size +); + +/** + * @brief + * Set the size of the element at the given position in + * the bind input array + * + * @param bnd - bind handle + * @param position - Position in the array + * @param size - data size + * + * @note + * See OCI_BindSetDataSize() for supported data types + * + * @warning + * Before execution, it returns the max default size for the bind and not the real + * data size, unless a custom size has been set with OCI_BindSetDataSizeXXX() + * After execution, it returns the real data size. + * + * @warning + * For binds of type OCI_CDT_TEXT (strings), the parameter 'size' is expressed in + * number of characters. + * + * @return + * Data size if the bind type is listed above otherwise 0. + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetDataSizeAtPos +( + OCI_Bind * bnd, + unsigned int position, + unsigned int size +); + +/** + * @brief + * Return the actual size of the element held by the given bind handle + * + * @param bnd - bind handle + * + * @note + * See OCI_BindSetDataSize() for supported data types + * + * @warning + * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in + * number of characters. + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSize +( + OCI_Bind *bnd +); + +/** + * @brief + * Return the actual size of the element at the given position in + * the bind input array + * + * @param bnd - bind handle + * @param position - Position in the array + * + * @note + * See OCI_BindSetDataSize() for supported data types + * + * @warning + * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in + * number of characters. + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSizeAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +/** + * @brief + * Set the bind variable to null + * + * @param bnd - Bind handle + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetNull +( + OCI_Bind *bnd +); + +/** + * @brief + * Set to null the entry in the bind variable input array + * + * @param bnd - Bind handle + * @param position - Position in the array + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @warning + * Position starts with 1 + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetNullAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +/** + * @brief + * Set the bind variable to NOT null + * + * @param bnd - Bind handle + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetNotNull +( + OCI_Bind *bnd +); + +/** + * @brief + * Set to NOT null the entry in the bind variable input array + * + * @param bnd - Bind handle + * @param position - Position in the array + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @warning + * Position starts with 1 + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_BindSetNotNullAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +/** + * @brief + * Check if the current value of the binded variable is marked as NULL + * + * @param bnd - Bind handle + * + * @return + * TRUE if it's null otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindIsNull +( + OCI_Bind *bnd +); + +/** + * @brief + * Check if the current entry value at the given index of the binded array + * is marked as NULL + * + * @param bnd - Bind handle + * @param position - Position in the array + * + * @warning + * Position starts with 1 + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_BindIsNullAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +/** + * @brief + * Set the charset form of the given character based bind variable + * + * @param bnd - Bind handle + * @param csfrm - charset form + * + * @note + * Possible values are : + * + * - OCI_CSF_DEFAULT : the column has default charset + * - OCI_CSF_NATIONAL: the column has national charset + * + * @note + * This call has to be made after OCI_Prepare() but before OCI_Execute() + * + * @warning + * This call does nothing : + * - if the csform is out of range + * - if the bind type is not OCI_CFT_TEXT or OCI_CDT_LONG + * + * @return + * TRUE on success otherwise FALSE + * + */ + +boolean OCI_API OCI_BindSetCharsetForm +( + OCI_Bind * bnd, + unsigned int csfrm +); + +/** + * @brief + * Get the allocation mode of a bind handle + * + * @param bnd - Bind handle + * + * @note + * Possible values are : + * - OCI_BAM_EXTERNAL : bind variable is allocated by user code + * - OCI_BAM_INTERNAL : bind variable is allocated internally + * + * return the allocation mode on success otherwise OCI_UNKNOWN + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_BindGetAllocationMode +( + OCI_Bind *bnd +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiFetching Fetching data + * @{ + * + * OCILIB offers a really easy and smart mechanism to fetch data from a SQL Statement. + * It looks like what's found in JDBC and other object oriented databases frameworks. + * + * ONLY the following statements can return resultsets that can be fetched by host programs: + * - Statements executing SQL SELECT + * - Statements executing SQL INSERT/UPDATE/DELETE using a RETURNING INTO clause + * - Statements binded to PL/SQL OPEN FOR argument + * - Statements binded to PL/SQL procedure OUT variables + * - Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using + * DBMS_SQL.RETURN_RESULT() + * + * These resultsets are encapsulated in OCILIB by OCI_Resultset objects. + * + * Thus, after any successful call to an OCI_Executexxx() function that executed + * a fetchable statement or filled output bind variables, the resultset can be + * retrieved by calling OCI_GetResultset() + * + * The creation of a OCI_Resultset object consists in : + * + * - Describing the output columns of the resultset + * - Allocating memory to hold the content data + * + * OCILIB supports multi-row fetching for increasing performances. Instead of + * fetching data row by row from the server (that induces lots of round-trips + * between the client and the server), the library prefetches data chunk by + * chunks (default is 20 rows). + * So, less network traffic and better performances. + * These mechanisms are completely hidden from the application which fetches the + * resultset row by row. + * + * Once the Resultset handle is retrieved : + * + * - It can be fetched by calling OCI_FetchNext() as long as it returns TRUE. + * - To retrieve the value of a column, call OCI_GetXXXX() where XXXX is the + * type of data you want to fetch. + * + * @note + * In case of a statement that has executed PL/SQL calls or blocks returning implicit resultsets: + * - OCI_GetResultset() return the first available resultset + * - OCI_GetNextResultset() return the next available resultset until no more resultset available + * + * @par Scrollable Resultsets + * + * Oracle 9i introduced scrollable cursors (resultsets in OCILIB) that can be + * fetched: + * + * - Sequentially in both directions: OCI_FetchPrev() and OCI_FetchNext() + * - To a relative position in the resultset: OCI_FetchSeek() with OCI_SFD_RELATIVE + * - To an absolute position in the resultset: OCI_FetchSeek() with OCI_SFD_ABOSLUTE + * - To the first or last row in the resultset: OCI_FetchFirst() and OCI_FetchLast() + * + * Scrollable statements uses more server and client resources and should only + * be used when necessary. + * + * Resultsets are 'forward only' by default. Call OCI_SetFetchMode() with + * OCI_SFM_SCROLLABLE to enable scrollable resultsets for a given statement. + * + * @warning + * Any use of scrollable fetching functions with a resultset that depends on a + * statement with fetch mode set to OCI_SFM_DEFAULT will fail ! + * + * @warning + * If you intend to use OCI_FetchSeek() on a scrollable statement and if any of the + * selected columns is a ref cursor or a nested table, OCILIB will internally set the + * resultset internal array size to 1 and thus ignore any values set using OCI_SetFetchSize() + * This is performed due to an Oracle bug. + * + * @note + * If the column internal data does not match the requested type, OCILIB tries + * to convert the data when it's possible and throws an error if not. + * + * The properties (columns names, types ...) of the resultset are accessible + * through a set of APIs. + * + * @par Implicit conversion to string types + * + * OCI_GetString() performs an implicit conversion from ANY Oracle types: + * + * - Numerics (based on the current connection handle numeric format) + * - Binary doubles and floats (using the standard C Library functions) + * - OCI_Date : uses OCI_DateToText() with current connection date format + * - OCI_Timestamp : uses OCI_TimestampToText() with current connection date format + * - OCI_Interval : uses OCI_IntervalToText() with Oracle default format + * - OCI_Coll : uses OCI_CollToText() + * - OCI_Object : uses OCI_ObjectToText() + * - OCI_Ref : uses OCI_RefToText() + * - OCI_File : returns "$(folder)/$(filename)" - no content returned + * - OCI_Lob : see note above for binary types + * - OCI_Long : see note above for binary types + * - RAWs : see note above for binary types + * + * @note + * For RAWs and BLOBs attributes, their binary values are converted to hexadecimal strings + * For LONG and CLOBs/NCLOBSs attributes, the whole string content is returned + * + * @note + * The following OCILIB types are not supported for implicit conversion: + * - OCI_Statement + * + * @warning + * For Dates and numerics types, OCILIB uses OCI client calls to perform + * the conversion. + * For binary double and binary floats data types, OCI client functions cannot + * handle the full double range of values. Thus, OCILIB is using the + * standard C library to convert theses data types to string + * + * @par Fetching rows into user structures + * + * It is possible to fetch a complete row into a user defined structure. + * Each column of the resultset is mapped to a structure member. + * The mapping rules are : + * - LOBs (CLOB, NCLOB, BLOB) : OCI_Lob * + * - DATE : OCI_Date * + * - TIMESTAMPS : OCI_Timestamp * + * - INTERVALS : OCI_Interval * + * - LONG, LONG RAW : OCI_Long * + * - REFs : OCI_Ref * + * - CURSOR, RESULSET : OCI_Statement * + * - OBJECTS, UDT : OCI_Object * + * - Character columns (CHAR,VARCHAR, etc..) : otext * + * - All NUMERIC types : + * - default : big_int + * - user defined (see OCI_SetStructNumericType()) + * + * See OCI_GetStruct() and OCI_SetStructNumericType() for more details + * + * @par Fetch Example + * @include fetch.c + * + * @par Fetch Rows into user structures Example + * @include fetch_struct.c + * + * @par Meta data Example + * @include meta.c + * + * @par Ref cursor Example + * @include cursor.c + * + * @par Implicit resultset Example + * @include implicit_resultset.c + * + * @par Scrollable resultset Example + * @include scroll.c + * + */ + +/** + * @brief + * Retrieve the resultset handle from an executed statement + * + * @param stmt - Statement handle + * + * @note + * See @ref OcilibCApiFetching for more details about what statements can return resultsets + * + * @warning + * If the statement has not been prepared and executed, no resultset will be returned + * + * @return + * A resultset handle on success otherwise NULL + * + */ + +OCI_EXPORT OCI_Resultset * OCI_API OCI_GetResultset +( + OCI_Statement *stmt +); + +/** + * @brief + * Free the statement resultsets + * + * @param stmt - Statement handle + * + * @note + * This call is optional. Resultsets are automatically freed when the + * statement is destroyed or when it's reused. + * + * @note + * This function has been introduced for releasing big resultsets when the + * application wants to keep the statement alive and does not know when it + * will be destroyed. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ReleaseResultsets +( + OCI_Statement *stmt +); + +/** + * @brief + * Fetch the next row of the resultset + * + * @param rs - Resultset handle + * + * @note + * OCI_FetchNext() works for normal and scrollable resultsets + * + * @return + * TRUE on success otherwise FALSE if : + * - Empty resultset + * - Last row already fetched + * - An error occurred + * + */ + +OCI_EXPORT boolean OCI_API OCI_FetchNext +( + OCI_Resultset *rs +); + +/** + * @brief + * Fetch the previous row of the resultset + * + * @param rs - Resultset handle + * + * @note + * OCI_FetchPrev() works ONLY for scrollable resultsets + * + * @return + * TRUE on success otherwise FALSE if : + * - Empty resultset + * - First row already fetched + * - An error occurred + * + */ + +OCI_EXPORT boolean OCI_API OCI_FetchPrev +( + OCI_Resultset *rs +); + +/** + * @brief + * Fetch the first row of the resultset + * + * @param rs - Resultset handle + * + * @note + * OCI_FetchFirst() works ONLY for scrollable resultsets + * + * @return + * TRUE on success otherwise FALSE if : + * - Empty resultset + * - An error occurred + *f + */ + +OCI_EXPORT boolean OCI_API OCI_FetchFirst +( + OCI_Resultset *rs +); + +/** + * @brief + * Fetch the last row of the resultset + * + * @param rs - Resultset handle + * + * @note + * OCI_FetchLast() works ONLY for scrollable resultsets + * + * @return + * TRUE on success otherwise FALSE if: + * - Empty resultset + * - An error occurred + * + */ + +OCI_EXPORT boolean OCI_API OCI_FetchLast +( + OCI_Resultset *rs +); + +/** + * @brief + * Custom Fetch of the resultset + * + * @param rs - Resultset handle + * @param mode - Fetch direction + * @param offset - Fetch offset + * + * @note + * Possible values for 'direction' parameter are: + * - OCI_SFD_ABSOLUTE + * - OCI_SFD_RELATIVE + * + * @note + * OCI_FetchSeek() works ONLY for scrollable resultsets + * + * @warning + * If you intend to use OCI_FetchSeek() on a scrollable statement and if any of the + * selected columns is a ref cursor or a nested table, you must set the fetching size + * to 1 using OCI_SetFetchSize() before calling OCI_GetResultset() + * Otherwise OCI_FetchSeek() will fails with a OCI-10002 error + * + * @return + * TRUE on success otherwise FALSE if: + * - Empty resultset + * - An error occurred + * - OCI_SetFetchMode() has not been called with OCI_SFM_SCROLLABLE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FetchSeek +( + OCI_Resultset *rs, + unsigned int mode, + int offset +); + +/** + * @brief + * Retrieve the number of rows fetched so far + * + * @param rs - Resultset handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetRowCount +( + OCI_Resultset *rs +); + +/** + * @brief + * Retrieve the current row number + * + * @param rs - Resultset handle + * + * @note + * - OCI_GetCurrentRow() returns the current row number starting from 1 + * - If the resultset has not been fetched or if the resultset is empty, it returns 0 + * - If the resultset has been fully fetched, it returns the last fetched row number + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetCurrentRow +( + OCI_Resultset *rs +); + +/** + * @brief + * Return the number of columns in the resultset + * + * @param rs - Resultset handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetColumnCount +( + OCI_Resultset *rs +); + +/** + * @brief + * Return the column object handle at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @return + * - Column handle on success + * - NULL if index is out of bounds or on error + * + */ + +OCI_EXPORT OCI_Column * OCI_API OCI_GetColumn +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the column object handle from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * - Column handle on success or + * - NULL if no column found with the given name or on error + * + */ + +OCI_EXPORT OCI_Column * OCI_API OCI_GetColumn2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the index of the column in the result from its name + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @note + * Column indexes start with 1 in OCILIB + * + * @return + * Column index on success or zero on error + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetColumnIndex +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the name of the given column + * + * @param col - Column handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ColumnGetName +( + OCI_Column *col +); + +/** + * @brief + * Return the type of the given column + * + * @param col - Column handle + * + * @note + * Possible values are : + * + * - OCI_CDT_NUMERIC : short, int, long long, float, double + * - OCI_CDT_DATETIME : OCI_Date * + * - OCI_CDT_TEXT : otext * + * - OCI_CDT_LONG : OCI_Long * + * - OCI_CDT_CURSOR : OCI_Statement * + * - OCI_CDT_LOB : OCI_Lob * + * - OCI_CDT_FILE : OCI_File * + * - OCI_CDT_TIMESTAMP : OCI_Timestamp * + * - OCI_CDT_INTERVAL : OCI_Interval * + * - OCI_CDT_RAW : void * + * - OCI_CDT_OBJECT : OCI_Object * + * - OCI_CDT_COLLECTION : OCI_Coll * + * - OCI_CDT_REF : OCI_Ref * + * - OCI_CDT_BOOLEAN : boolean + * + * @return + * The column type or OCI_CDT_UNKNOWN if index is out of bounds + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetType +( + OCI_Column *col +); + +/** + * @brief + * Return the charset form of the given column + * + * @param col - Column handle + * + * @note + * Possible values are : + * - OCI_CSF_NONE : the column is not an character or lob column + * - OCI_CSF_DEFAULT : the column has server default charset + * - OCI_CSF_NATIONAL : the column has national server charset + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetCharsetForm +( + OCI_Column *col +); + +/** + * @brief + * Return the Oracle SQL type name of the column data type + * + * @param col - Column handle + * + * @note + * For possible values, consults Oracle Documentation + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ColumnGetSQLType +( + OCI_Column *col +); + +/** + * @brief + * Return the Oracle SQL Full name including precision and size of the + * column data type + * + * @param col - Column handle + * @param buffer - buffer to store the full column type name and size + * @param len - max size of the buffer in characters + * + * @note + * This function returns a description that matches the one given by SQL*Plus + * + * @note + * Return the number of characters written into the buffer + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetFullSQLType +( + OCI_Column * col, + otext * buffer, + unsigned int len +); + +/** + * @brief + * Return the size of the column + * + * @note + * For all types, the size is expressed is bytes, excepted for character + * based columns that were created with a character based size or of type NCHAR/NVARCHAR + * + * @param col - Column handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetSize +( + OCI_Column *col +); + +/** + * @brief + * Return the scale of the column for numeric columns + * + * @param col - Column handle + * + */ + +OCI_EXPORT int OCI_API OCI_ColumnGetScale +( + OCI_Column *col +); + +/** + * @brief + * Return the precision of the column for numeric columns + * + * @param col - Column handle + * + */ + +OCI_EXPORT int OCI_API OCI_ColumnGetPrecision +( + OCI_Column *col +); + +/** + * @brief + * Return the fractional precision of the column for timestamp and interval columns + * + * @param col - Column handle + * + */ + +OCI_EXPORT int OCI_API OCI_ColumnGetFractionalPrecision +( + OCI_Column *col +); + +/** + * @brief + * Return the leading precision of the column for interval columns + * + * @param col - Column handle + * + */ + +OCI_EXPORT int OCI_API OCI_ColumnGetLeadingPrecision +( + OCI_Column *col +); + +/** + * @brief + * Return the nullable attribute of the column + * + * @param col - Column handle + * + * @return + * Return TRUE if the column is nullable otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ColumnGetNullable +( + OCI_Column *col +); + +/** + * @brief + * Return TRUE if the length of the column is character-length or FALSE if + * it is byte-length + * + * @param col - Column handle + * + * @note + * This was introduced in Oracle 9i. So for version that are not supporting this + * property, it always return FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ColumnGetCharUsed +( + OCI_Column *col +); + +/** + * @brief + * Return the column property flags + * + * @param col - Column handle + * + * For flags are: + * - OCI_CPF_NONE : The column has no flags or the OCI client does not support this call + * - OCI_CPF_IS_IDENTITY: + * - If Set, the column is an IDENTITY column + * - Otherwise, it is not an IDENTITY column + * - OCI_CPF_IS_GEN_ALWAYS: + * - If set, means that the value is "ALWAYS GENERATED" + * - Otherwise means that the value is "GENERATED BY" + * - OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL: + * - If set, means that the value is generated by default on NULL + * - OCI_CPF_IS_LPART: + * - If set, Column is an implicitly generated logical partitioning column for container_map enabled object + * - OCI_CPF_IS_CONID: + * - If set, Column is a CON_ID column implicitly generated by CONTAINERS() or is an ORIGIN_CON_ID column implicitly generated for Extended Data Link + * + * @note + * This was introduced in Oracle 12cR1. + * For earlier versions, it always return OCI_CPF_NONE + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetPropertyFlags +( + OCI_Column *col +); + +/** +* @brief +* Return the column collation ID +* +* @param col - Column handle +* +* Possible values: +* - OCI_CCI_NONE +* - OCI_CCI_NLS_COMP +* - OCI_CCI_NLS_SORT +* - OCI_CCI_NLS_SORT_CI +* - OCI_CCI_NLS_SORT_AI +* - OCI_CCI_NLS_SORT_CS +* - OCI_CCI_NLS_SORT_VAR1 +* - OCI_CCI_NLS_SORT_VAR1_CI +* - OCI_CCI_NLS_SORT_VAR1_AI +* - OCI_CCI_NLS_SORT_VAR1_CS +* - OCI_CCI_BINARY +* - OCI_CCI_BINARY_CI +* - OCI_CCI_BINARY_AI +* +* @note +* This was introduced in Oracle 12cR2. +* For earlier versions, it always return OCI_CCI_NONE +* +*/ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetCollationID +( + OCI_Column *col +); + +/** + * @brief + * Return the type information object associated to the column + * + * @param col - Column handle + * + * @note + * This call is used only for Named Object typed and collection columns. + * It returns NULL if the column is not a Named Object or a collection. + * + */ + +OCI_EXPORT OCI_TypeInfo * OCI_API OCI_ColumnGetTypeInfo +( + OCI_Column *col +); + +/** + * @brief + * Return the OCILIB object subtype of a column + * + * @param col - Column handle + * + * @note + * This call is valid for the following OCILIB types: + * + * - OCI_CDT_LONG + * - OCI_CDT_LOB + * - OCI_CDT_FILE + * - OCI_CDT_TIMESTAMP + * - OCI_CDT_INTERVAL + * - OCI_CDT_NUMERIC + * + * For OCI_Long type the possible values are: + * - OCI_BLONG + * - OCI_CLONG + * + * For OCI_Lob type the possible values are: + * - OCI_BLOB + * - OCI_CLOB + * - OCI_NCLOB + * + * For OCI_File type the possible values are: + * - OCI_BFILE + * - OCI_CFILE + * + * For OCI_Timestamp type the possible values are: + * - OCI_TIMESTAMP + * - OCI_TIMESTAMP_TZ + * - OCI_TIMESTAMP_LTZ + * + * For OCI_Interval type the possible values are: + * - OCI_INTERVAL_YM + * - OCI_INTERVAL_DS + * + * For numeric columns the possible values are: + * - OCI_NUM_SHORT + * - OCI_NUM_INT + * - OCI_NUM_BIGINT + * - OCI_NUM_USHORT + * - OCI_NUM_UINT + * - OCI_NUM_BIGUINT + * - OCI_NUM_DOUBLE + * - OCI_NUM_FLOAT + * - OCI_NUM_NUMBER + * + * @warning + * For numeric columns, the value may be not accurate at all! + * OCI does not allow to find out the real SQL precise type of an numeric column (int, real, ...). + * OCI based libraries can only 'guess' some types in some situations : float, binary_float, binary_float, number. + * For example: + * - with the statement 'select 101 from dual', OCI would report numeric type NUMBER. + * - if a column is declared as "INT", OCI would report also NUMBER. + * + * + * @note + * For all other OCILIB types, it returns OCI_UNKNOWN + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ColumnGetSubType +( + OCI_Column *col +); + +/** + * @brief + * set the numeric data type of the given structure member (identified from position in the + * resultset) to retrieve when calling OCI_GetStruct() + * + * @param rs - Resultset handle + * @param index - Column position + * @param type - Numeric type + * + * @note + * Possible values for parameter 'type' : + * - OCI_NUM_SHORT + * - OCI_NUM_USHORT + * - OCI_NUM_INT + * - OCI_NUM_UINT + * - OCI_NUM_BIGINT + * - OCI_NUM_BIGUINT + * - OCI_NUM_DOUBLE + * - OCI_NUM_FLOAT + * - OCI_NUM_NUMBER + * + * @return + * Return TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetStructNumericType +( + OCI_Resultset *rs, + unsigned int index, + unsigned int type +); + +/** + * @brief + * set the numeric data type of the given structure member (identified from column name in the + * resultset) to retrieve when calling OCI_GetStruct() + * + * @param rs - Resultset handle + * @param name - Column name + * @param type - Numeric type + * + * @note + * Possible values for parameter 'type' : + * - OCI_NUM_SHORT + * - OCI_NUM_USHORT + * - OCI_NUM_INT + * - OCI_NUM_UINT + * - OCI_NUM_BIGINT + * - OCI_NUM_BIGUINT + * - OCI_NUM_DOUBLE + * - OCI_NUM_FLOAT + * - OCI_NUM_NUMBER + * + * @return + * Return TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetStructNumericType2 +( + OCI_Resultset *rs, + const otext * name, + unsigned int type +); + +/** + * @brief + * Return the row columns values into a single structure + * + * @param rs - Resultset handle + * @param row_struct - pointer to user row structure + * @param row_struct_ind - pointer to user indicator structure + * + * @note + * Structure members values are contextual to the current row. + * The returned values can get out of scope when the current row + * changes when calling any OCI_FecthXXX() calls + * + * @par User row structure + * + * The user structure must have the same members than the resultset. + * Each column in the resultset must have its equivalent in the structure. + * Fields must be in the same order. + * + * The mapping rules are : + * + * - LOBs (CLOB, NCLOB, BLOB) : OCI_Lob * + * - DATE : OCI_Date * + * - TIMESTAMPS : OCI_Timestamp * + * - INTERVALS : OCI_Interval * + * - LONG, LONG RAW : OCI_Long * + * - REFs : OCI_Ref * + * - CURSOR, RESULSET : OCI_Statement * + * - OBJECTS, UDT : OCI_Object * + * - Character columns (CHAR,VARCHAR, etc..) : otext * + * - All NUMERIC types : + * - default : big_int + * - user defined (see OCI_SetStructNumericType()) + * + * The user structure pointer is not mandatory + * + * @par User row indicator structure + + * This structure must have one boolean field per column in + * the resultset and respect in the same member order. + * + * If the value of the given member is TRUE, it means the value in + * the user row structure is NOT NULL, otherwise its NULL + * + * The user indicator structure pointer is mandatory + * + * @return + * Return TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_GetStruct +( + OCI_Resultset *rs, + void * row_struct, + void * row_struct_ind +); + +/** +* @brief +* Return the current Number value of the column at the given index in the resultset +* +* @param rs - Resultset handle +* @param index - Column position +* +* @note +* Column position starts at 1. +* +* @return +* The column current row value or 0 if index is out of bounds +* +*/ +OCI_EXPORT OCI_Number * OCI_API OCI_GetNumber +( + OCI_Resultset *rs, + unsigned int index +); + +/** +* @brief +* Return the current number value of the column from its name in the resultset +* +* @param rs - Resultset handle +* @param name - Column name +* +* @note +* The column name is case insensitive +* +* @return +* The column current row value or 0 if no column found with the given name +* +*/ + +OCI_EXPORT OCI_Number * OCI_API OCI_GetNumber2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current short value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0 if index is out of bounds + * + */ + +OCI_EXPORT short OCI_API OCI_GetShort +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current short value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0 if no column found with the given name + * + */ + +OCI_EXPORT short OCI_API OCI_GetShort2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current unsigned short value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0 if index is out of bounds + * + */ + +OCI_EXPORT unsigned short OCI_API OCI_GetUnsignedShort +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current unsigned short value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0 if no column found with the given name + * + */ + +OCI_EXPORT unsigned short OCI_API OCI_GetUnsignedShort2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current integer value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0 if index is out of bounds + * + */ + +OCI_EXPORT int OCI_API OCI_GetInt +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current integer value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0 if no column found with the given name + * + */ + +OCI_EXPORT int OCI_API OCI_GetInt2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current unsigned integer value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0 if index is out of bounds + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetUnsignedInt +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current unsigned integer value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0 if no column found with the given name + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetUnsignedInt2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current big integer value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0 if index is out of bounds + * + */ + +OCI_EXPORT big_int OCI_API OCI_GetBigInt +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current big integer value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0 if no column found with the given name + * + */ + +OCI_EXPORT big_int OCI_API OCI_GetBigInt2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current unsigned big integer value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0 if index is out of bounds + * + */ + +OCI_EXPORT big_uint OCI_API OCI_GetUnsignedBigInt +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current unsigned big integer value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0 if no column found with the given name + * + */ + +OCI_EXPORT big_uint OCI_API OCI_GetUnsignedBigInt2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current string value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @note + * OCI_GetString() performs an implicit conversion from the + * following data types: + * + * - Numerics (based on the current connection handle numeric format) + * - Binary doubles and floats (using the standard C Library functions) + * - OCI_Number (based on the current connection handle numeric format) + * - OCI_Date (based on the current connection handle date format) + * - OCI_Timestamp (based on the current connection handle date format) + * - OCI_Interval (based on Oracle default conversion) + * - OCI_Lob (for BLOBs, output is expressed in hexadecimal) + * - OCI_Long (for BLONGs, output is expressed in hexadecimal) + * - OCI_File ("[directory]/[name]" will be output) + * - OCI_Object (Textual SQL string representation) + * - OCI_Coll (Textual SQL string representation) + * - RAW buffer (expressed in hexadecimal) + * - OCI_Statement (SQL statement string or cursor name) + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetString +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current string value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT const otext * OCI_API OCI_GetString2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Copy the current raw value of the column at the given index into the specified buffer + * + * @param rs - Resultset handle + * @param index - Column position + * @param buffer - Buffer that receive the raw value + * @param len - Max size of the input buffer in bytes + * + * @note + * Column position starts at 1. + * + * @return + * Number of bytes copied into the buffer on SUCCESS otherwise 0 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetRaw +( + OCI_Resultset *rs, + unsigned int index, + void * buffer, + unsigned int len +); + +/** + * @brief + * Copy the current raw value of the column from its name into the specified buffer + * + * @param rs - Resultset handle + * @param name - Column name + * @param buffer - Buffer that receive the raw value + * @param len - Max size of the input buffer + * + * @note + * The column name is case insensitive + * + * @return + * Number of bytes copied into the buffer on SUCCESS otherwise 0 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetRaw2 +( + OCI_Resultset *rs, + const otext * name, + void * buffer, + unsigned int len +); + +/** + * @brief + * Return the current double value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0.O if index is out of bounds + * + */ + +OCI_EXPORT double OCI_API OCI_GetDouble +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current double value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0.0 if no column found with the given name + * + */ + +OCI_EXPORT double OCI_API OCI_GetDouble2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current float value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or 0.O if index is out of bounds + * + */ + +OCI_EXPORT float OCI_API OCI_GetFloat +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current float value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @note + * The column name is case insensitive + * + * @return + * The column current row value or 0.0 if no column found with the given name + * + */ + +OCI_EXPORT float OCI_API OCI_GetFloat2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current date value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Date * OCI_API OCI_GetDate +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current date value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Date * OCI_API OCI_GetDate2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current timestamp value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Timestamp * OCI_API OCI_GetTimestamp +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current timestamp value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Timestamp * OCI_API OCI_GetTimestamp2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current interval value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Interval * OCI_API OCI_GetInterval +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current interval value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Interval * OCI_API OCI_GetInterval2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current cursor value (Nested table) of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Statement * OCI_API OCI_GetStatement +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current cursor value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Statement * OCI_API OCI_GetStatement2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current lob value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Lob * OCI_API OCI_GetLob +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current lob value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Lob * OCI_API OCI_GetLob2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current File value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_File * OCI_API OCI_GetFile +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current File value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_File * OCI_API OCI_GetFile2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current Object value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_GetObject +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current Object value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_GetObject2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current Collection value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Coll * OCI_API OCI_GetColl +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current Collection value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Coll * OCI_API OCI_GetColl2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current Ref value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Ref * OCI_API OCI_GetRef +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current Ref value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Ref * OCI_API OCI_GetRef2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the current Long value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row value or NULL if index is out of bounds + * + */ + +OCI_EXPORT OCI_Long * OCI_API OCI_GetLong +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the current Long value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * The column current row value or NULL if no column found with the given name + * + */ + +OCI_EXPORT OCI_Long * OCI_API OCI_GetLong2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Check if the current row value is null for the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * TRUE if it's null otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IsNull +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the size of the value of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @warning + * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in + * number of characters. + * + * @return value size of 0 if the value is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetDataSize +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @brief + * Return the size of the value of the column from its name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @warning + * For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in + * number of characters. + * + * @return value size of 0 if the value is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetDataSize2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Check if the current row value is null for the column of the given name in the resultset + * + * @param rs - Resultset handle + * @param name - Column name + * + * @return + * TRUE if it's null otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IsNull2 +( + OCI_Resultset *rs, + const otext * name +); + +/** + * @brief + * Return the statement handle associated with a resultset handle + * + * @param rs - resultset handle + * + */ + +OCI_EXPORT OCI_Statement * OCI_API OCI_ResultsetGetStatement +( + OCI_Resultset *rs +); + +/** + * @brief + * Return the current row data length of the column at the given index in the resultset + * + * @param rs - Resultset handle + * @param index - Column position + * + * @note + * Column position starts at 1. + * + * @return + * The column current row data length or 0 if index is out of bounds + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetDataLength +( + OCI_Resultset *rs, + unsigned int index +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiPlSql PL/SQL Support + * @{ + * + * OCILIB has a strong PL/SQL support : + * + * - Blocks, procedures and function can be used with OCILIB statements. + * - Ref cursors + * - Nested tables + * - Tables (indexed by integer types) + * - Access to the server side output generated by the DBMS_OUTPUT package + * + * Stored procedures/functions calls, blocks declarations are done like regular + * SQL calls using OCI_Prepare(), OCI_Execute(), OCI_ExecuteStmt() and + * OCI_ExecuteStmtFmt() functions. + * + * All PL/SQL statements must: + * + * - start with a 'begin' or 'declare' keyword + * - end with a 'end;' keyword + * + * Binding Host arrays to PL/SQL tables is done with OCI_BindArrayXXX() calls + * + * @par Using a PL/SQL block with OCILIB + * @include plsql_block.c + * + * @par Binding host arrays to PL/SQL tables parameters of a stored procedure + * @include plsql_table.c + * + * @par Retrieve the output generated by the dbms_output package on the server + * @include output.c + * + */ + +/** + * @brief + * Enable the server output + * + * @param con - Connection handle + * @param bufsize - server buffer max size (server side) + * @param arrsize - number of lines to retrieve per server round-trip + * @param lnsize - maximum size of one line + * + * @note + * This call is equivalent to the command 'set serveroutput on' in SQL*PLUS + * + * @note + * 'bufsize' minimum value is 2000, maximum 1000000 with Oracle < 10.2g and can be unlimited above + * + * @note + * 'lnsize' maximum value is 255 with Oracle < 10g R2 and 32767 above + * + * @warning + * If OCI_ServerEnableOutput() is not called, OCI_ServerGetOutput() will return NULL + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ServerEnableOutput +( + OCI_Connection *con, + unsigned int bufsize, + unsigned int arrsize, + unsigned int lnsize +); + +/** + * @brief + * Disable the server output + * + * @param con - Connection handle + * + * @note + * After this call, OCI_ServerGetOutput() will return NULL. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ServerDisableOutput +( + OCI_Connection *con +); + +/** + * @brief + * Retrieve one line of the server buffer + * + * @param con - Connection handle + * + * @note + * Internally, OCILIB gets the server buffer through an array of lines in + * order to minimize round-trips with the server + * + * @return + * return a server output buffer line or NULL if the server buffer is empty + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ServerGetOutput +( + OCI_Connection *con +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiCollections Oracle collections (VARRAYS and Nested Tables) + * @{ + * + * OCILIB supports all Oracle collections: + * + * - PL/SQL Tables: only available in PL/SQL, unbounded, sparse arrays of + homogeneous elements. + * - VARRAYS : available in SQL and PL/SQL, they are bounded arrays of + * homogeneous elements + * - Nested Tables: available in SQL and PL/SQL, they are unbounded arrays of + * homogeneous elements and can become sparse through deletions + * + * PL/SQL tables are implemented by binding regular C arrays with the array + * interface (using OCI_BindArrayOfXXX() calls) + * + * VARRAYS and Nested tables are implemented in OCILIB with the type OCI_Coll. + * It's possible to bind and fetch VARRAYS and Nested tables using OCI_Coll handle. + * + * It's also possible to declare local collections based on some database type without using queries + * + * OCI (and thus OCILIB) offers the possibility to access collection elements : + * + * - directly by index (OCI_CollGetElem() and OCI_CollSetElem()) + * - using an iterator (OCI_Iter) to iterate through the collection + * (OCI_IterGetNext(), OCI_IterGetPrev()) + * + * Collection Items are implemented through the type OCI_Elem and use the series + * of calls OCI_ElemGetXXX() and OCI_ElemSetXXX() to manipulate elements + * content values + * + * @par Example + * @include coll.c + * + */ + +/** + * @brief + * Create a local collection instance + * + * @param typinf - Type info handle of the collection type descriptor + * + * @return + * Return the collection object handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Coll * OCI_API OCI_CollCreate +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Free a local collection + * + * @param coll - Collection handle + * + * @warning + * Only collection created with OCI_CollCreate() should be freed + * by OCI_CollFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollFree +( + OCI_Coll *coll +); + +/** + * @brief + * Create an array of Collection object + * + * @param con - Connection handle + * @param typinf - Object type (type info handle) + * @param nbelem - number of elements in the array + * + * @note + * see OCI_ObjectCreate() for more details + * + * @return + * Return the Collection handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Coll ** OCI_API OCI_CollArrayCreate +( + OCI_Connection *con, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +/** + * @brief + * Free an array of Collection objects + * + * @param colls - Array of Collection objects + * + * @warning + * Only arrays of Collection created with OCI_CollArrayCreate() + * should be freed by OCI_CollArrayFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollArrayFree +( + OCI_Coll **colls +); + +/** + * @brief + * Assign a collection to another one + * + * @param coll - Destination Collection handle + * @param coll_src - Source Collection handle + * + * @note + * Oracle proceeds to a deep copy of the collection content + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollAssign +( + OCI_Coll *coll, + OCI_Coll *coll_src +); + +/** + * @brief + * Return the type info object associated to the collection + * + * @param coll - Collection handle + * + */ + +OCI_EXPORT OCI_TypeInfo * OCI_API OCI_CollGetTypeInfo +( + OCI_Coll *coll +); + +/** + * @brief + * Return the collection type + * + * @param coll - Collection handle + * + * @note + * Current collection types are: + * + * - OCI_COLL_VARRAY: Oracle VARRAY + * - OCI_COLL_NESTED_TABLE: Oracle Nested Table + * + * @return + * Collection type or OCI_UNKNOWN if the collection handle is null + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_CollGetType +( + OCI_Coll *coll +); + +/** + * @brief + * Returns the maximum number of elements of the given collection. + * + * @param coll - Collection handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_CollGetMax +( + OCI_Coll *coll +); + +/** + * @brief + * Returns the total number of elements of the given collection. + * + * @param coll - Collection handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_CollGetSize +( + OCI_Coll *coll +); + +/** + * @brief + * Returns the current number of elements of the given collection. + * + * @note + * - For VARRAYs, it returns the same value than OCI_CollGetSize() as VARRAYs cannot contains holes + * - For Nested Tables that are spare collections that can have holes, it returns the total number + * of elements minus the total of deleted elements + * + * @param coll - Collection handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_CollGetCount +( + OCI_Coll *coll +); + +/** + * @brief + * Trims the given number of elements from the end of the collection + * + * @param coll - Collection handle + * @param nb_elem - Number of elements to trim + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollTrim +( + OCI_Coll * coll, + unsigned int nb_elem +); + +/** + * @brief + * clear all items of the given collection + * + * @param coll - Collection handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollClear +( + OCI_Coll *coll +); + +/** + * @brief + * Return the element at the given position in the collection + * + * @param coll - Collection handle + * @param index - Index of the destination element + * + * @note + * Collection indexes start at position 1. + * + * @return + * Element handle on success otherwise FALSE + * + */ + +OCI_EXPORT OCI_Elem * OCI_API OCI_CollGetElem +( + OCI_Coll * coll, + unsigned int index +); + +/** + * @brief + * Return the element at the given position in the collection + * + * @param coll - Collection handle + * @param index - Index of the destination element + * @param elem - Element handle to hold the collection item data + * + * @note + * Collection indexes start at position 1. + * + * @return + * Element handle on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollGetElem2 +( + OCI_Coll * coll, + unsigned int index, + OCI_Elem * elem +); + +/** + * @brief + * Assign the given element value to the element at the given position in + * the collection + * + * @param coll - Collection handle + * @param index - Index of the destination element + * @param elem - Source element handle to assign + * + * @note + * Collection indexes start at position 1. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollSetElem +( + OCI_Coll * coll, + unsigned int index, + OCI_Elem * elem +); + +/** + * @brief + * Append the given element at the end of the collection + * + * @param coll - Collection handle + * @param elem - Element handle to add + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollAppend +( + OCI_Coll *coll, + OCI_Elem *elem +); + +/** + * @brief + * Convert a collection handle value to a string + * + * @param coll - Collection handle + * @param size - Destination string length pointer in characters + * @param str - Destination string + * + * @note + * In order to compute the needed string length, call the method with a NULL string + * Then call the method again with a valid buffer + * + * @note + * The resulting string is similar to the SQL*PLUS output for collections + * For RAWs and BLOBs attributes, their binary values are converted to hexadecimal strings + * + * @warning + * This convenient method shall not be used when performance matters. It is usually called twice (buffer length + * computation) and must also care about quotes within strings. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollToText +( + OCI_Coll * coll, + unsigned int *size, + otext * str +); + +/** + * @brief + * Delete the element at the given position in the Nested Table Collection + * + * @param coll - Collection handle + * @param index - Index of the element to delete + * + * @note + * Collection indexes start at position 1. + * + * @warning + * OCI_CollDeleteElem() is only valid for nested tables. + * + * @return + * - if the input collection is a nested table, it returns TRUE if the element + * is successfully deleted otherwise FALSE on error + * - if the input collection is a VARRAY, it always returns FALSE without spawning an exception + * + */ + +OCI_EXPORT boolean OCI_API OCI_CollDeleteElem +( + OCI_Coll * coll, + unsigned int index +); + +/** + * @brief + * Create an iterator handle to iterate through a collection + * + * @param coll - Collection handle + * + * @return + * Return the iterator handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Iter * OCI_API OCI_IterCreate +( + OCI_Coll *coll +); + +/** + * @brief + * Free an iterator handle + * + * @param iter - Iterator handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IterFree +( + OCI_Iter *iter +); + +/** + * @brief + * Get the next element in the collection + * + * @param iter - Iterator handle + * + * @return + * Element handle on success otherwise NULL if: + * - Empty collection + * - Iterator already positioned on the last collection element + * - An error occurred + * + */ + +OCI_EXPORT OCI_Elem * OCI_API OCI_IterGetNext +( + OCI_Iter *iter +); + +/** + * @brief + * Get the previous element in the collection + * + * @param iter - Iterator handle + * + * @return + * Element handle on success otherwise NULL if: + * - Empty collection + * - Iterator already positioned on the last collection element + * - An error occurred + * + */ + +OCI_EXPORT OCI_Elem * OCI_API OCI_IterGetPrev +( + OCI_Iter *iter +); + +/** + * @brief + * Get the current element in the collection + * + * @param iter - Iterator handle + * + * @return + * Element handle on success otherwise NULL if: + * - Empty collection + * - Iterator already positioned on the last collection element + * - An error occurred + * + */ + +OCI_EXPORT OCI_Elem * OCI_API OCI_IterGetCurrent +( + OCI_Iter *iter +); + +/** + * @brief + * Create a local collection element instance based on a collection type + * descriptor + * + * @param typinf - Type info handle + * + * @return + * Return the collection element handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Elem * OCI_API OCI_ElemCreate +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Free a local collection element + * + * @param elem - Element handle + * + * @warning + * Only element created with OCI_ElemCreate() should be freed + * by OCI_ElemFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemFree +( + OCI_Elem *elem +); + +/** +* @brief +* Return the boolean value of the given collection element +* +* @param elem - Element handle +* +* @warning +* OCI_ElemGetBoolean() returns a valid value only for collection elements of PL/SQL boolean type +* +* @return +* boolean value or FALSE on failure +* +*/ + +OCI_EXPORT boolean OCI_API OCI_ElemGetBoolean +( + OCI_Elem *elem +); + +/** +* @brief +* Return the number value of the given collection element +* +* @param elem - Element handle +* +* @return +* number handle or NULL on failure +* +*/ + +OCI_EXPORT OCI_Number * OCI_API OCI_ElemGetNumber +( + OCI_Elem *elem +); + +/** + * @brief + * Return the short value of the given collection element + * + * @param elem - Element handle + * + * @return + * Short value or 0 on failure + * + */ + +OCI_EXPORT short OCI_API OCI_ElemGetShort +( + OCI_Elem *elem +); + +/** + * @brief + * Return the unsigned short value of the given collection element + * + * @param elem - Element handle + * + * @return + * Unsigned short value or 0 on failure + * + */ + +OCI_EXPORT unsigned short OCI_API OCI_ElemGetUnsignedShort +( + OCI_Elem *elem +); + +/** + * @brief + * Return the int value of the given collection element + * + * @param elem - Element handle + * + * @return + * Int value or 0 on failure + * + */ + +OCI_EXPORT int OCI_API OCI_ElemGetInt +( + OCI_Elem *elem +); + +/** + * @brief + * Return the unsigned int value of the given collection element + * + * @param elem - Element handle + * + * @return + * Unsigned int value or 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ElemGetUnsignedInt +( + OCI_Elem *elem +); + +/** + * @brief + * Return the big int value of the given collection element + * + * @param elem - Element handle + * + * @return + * Big int value or 0 on failure + * + */ + +OCI_EXPORT big_int OCI_API OCI_ElemGetBigInt +( + OCI_Elem *elem +); + +/** + * @brief + * Return the unsigned big int value of the given collection element + * + * @param elem - Element handle + * + * @return + * Unsigned big int value or 0 on failure + * + */ + +OCI_EXPORT big_uint OCI_API OCI_ElemGetUnsignedBigInt +( + OCI_Elem *elem +); + +/** + * @brief + * Return the Double value of the given collection element + * + * @param elem - Element handle + * + * @return + * Double value or 0 on failure + * + */ + +OCI_EXPORT double OCI_API OCI_ElemGetDouble +( + OCI_Elem *elem +); + +/** + * @brief + * Return the float value of the given collection element + * + * @param elem - Element handle + * + * @return + * Double value or 0 on failure + * + */ + +OCI_EXPORT float OCI_API OCI_ElemGetFloat +( + OCI_Elem *elem +); + +/** + * @brief + * Return the String value of the given collection element + * + * @param elem - Element handle + * + * @return + * String value or NULL on failure + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ElemGetString +( + OCI_Elem *elem +); + +/** + * @brief + * Read the RAW value of the collection element into the given buffer + * + * @param elem - Element handle + * @param value - Buffer to store the RAW value + * @param len - Size of the buffer + * + * @return + * Number of bytes read from the RAW value or 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ElemGetRaw +( + OCI_Elem * elem, + void * value, + unsigned int len +); + +/** +* @brief +* Return the raw attribute value size of the given element handle +* +* @param elem - Element handle +* +* @return +* size in bytes of the RAW value or 0 on failure or wrong attribute type +* +*/ + +OCI_EXPORT unsigned int OCI_API OCI_ElemGetRawSize +( + OCI_Elem *elem +); + +/** + * @brief + * Return the Date value of the given collection element + * + * @param elem - Element handle + * + * @return + * Date handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Date * OCI_API OCI_ElemGetDate +( + OCI_Elem *elem +); + +/** + * @brief + * Return the Timestamp value of the given collection element + * + * @param elem - Element handle + * + * @return + * Timestamp handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Timestamp * OCI_API OCI_ElemGetTimestamp +( + OCI_Elem *elem +); + +/** + * @brief + * Return the Interval value of the given collection element + * + * @param elem - Element handle + * + * @return + * Interval handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Interval * OCI_API OCI_ElemGetInterval +( + OCI_Elem *elem +); + +/** + * @brief + * Return the Lob value of the given collection element + * + * @param elem - Element handle + * + * @return + * Lob handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Lob * OCI_API OCI_ElemGetLob +( + OCI_Elem *elem +); + +/** + * @brief + * Return the File value of the given collection element + * + * @param elem - Element handle + * + * @return + * File handle or NULL on failure + * + */ + +OCI_EXPORT OCI_File * OCI_API OCI_ElemGetFile +( + OCI_Elem *elem +); + +/** + * @brief + * Return the object value of the given collection element + * + * @param elem - Element handle + * + * @return + * Object handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_ElemGetObject +( + OCI_Elem *elem +); + +/** + * @brief + * Return the collection value of the given collection element + * + * @param elem - Element handle + * + * @return + * Collection handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Coll * OCI_API OCI_ElemGetColl +( + OCI_Elem *elem +); + +/** + * @brief + * Return the Ref value of the given collection element + * + * @param elem - Element handle + * + * @return + * Ref handle or NULL on failure + * + */ + +OCI_EXPORT OCI_Ref * OCI_API OCI_ElemGetRef +( + OCI_Elem *elem +); + +/** +* @brief +* Set a boolean value to a collection element +* +* @param elem - Element handle +* @param value - Short value +* +* @warning +* OCI_ElemSetBoolean() is only valid value only for collection elements of PL / SQL boolean type +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_ElemSetBoolean +( + OCI_Elem *elem, + boolean value +); + +/** +* @brief +* Set a number value to a collection element +* +* @param elem - Element handle +* @param value - number value +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_ElemSetNumber +( + OCI_Elem * elem, + OCI_Number *value +); + +/** + * @brief + * Set a short value to a collection element + * + * @param elem - Element handle + * @param value - Short value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetShort +( + OCI_Elem *elem, + short value +); + +/** + * @brief + * Set a unsigned short value to a collection element + * + * @param elem - Element handle + * @param value - Unsigned short value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedShort +( + OCI_Elem * elem, + unsigned short value +); + +/** + * @brief + * Set a int value to a collection element + * + * @param elem - Element handle + * @param value - Int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetInt +( + OCI_Elem *elem, + int value +); + +/** + * @brief + * Set a unsigned int value to a collection element + * + * @param elem - Element handle + * @param value - Unsigned int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedInt +( + OCI_Elem * elem, + unsigned int value +); + +/** + * @brief + * Set a big int value to a collection element + * + * @param elem - Element handle + * @param value - big int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetBigInt +( + OCI_Elem *elem, + big_int value +); + +/** + * @brief + * Set a unsigned big_int value to a collection element + * + * @param elem - Element handle + * @param value - Unsigned big int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedBigInt +( + OCI_Elem *elem, + big_uint value +); + +/** + * @brief + * Set a double value to a collection element + * + * @param elem - Element handle + * @param value - Double value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetDouble +( + OCI_Elem *elem, + double value +); + +/** + * @brief + * Set a float value to a collection element + * + * @param elem - Element handle + * @param value - float value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetFloat +( + OCI_Elem *elem, + float value +); + +/** + * @brief + * Set a string value to a collection element + * + * @param elem - Element handle + * @param value - String value + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetString +( + OCI_Elem * elem, + const otext *value +); + +/** + * @brief + * Set a RAW value to a collection element + * + * @param elem - Element handle + * @param value - Raw value + * @param len - Size of the raw value + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetRaw +( + OCI_Elem * elem, + void * value, + unsigned int len +); + +/** + * @brief + * Assign a Date handle to a collection element + * + * @param elem - Element handle + * @param value - Date Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetDate +( + OCI_Elem *elem, + OCI_Date *value +); + +/** + * @brief + * Assign a Timestamp handle to a collection element + * + * @param elem - Element handle + * @param value - Timestamp Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetTimestamp +( + OCI_Elem * elem, + OCI_Timestamp *value +); + +/** + * @brief + * Assign an Interval handle to a collection element + * + * @param elem - Element handle + * @param value - Interval Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetInterval +( + OCI_Elem * elem, + OCI_Interval *value +); + +/** + * @brief + * Assign a Collection handle to a collection element + * + * @param elem - Element handle + * @param value - Collection Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetColl +( + OCI_Elem *elem, + OCI_Coll *value +); + +/** + * @brief + * Assign an Object handle to a collection element + * + * @param elem - Element handle + * @param value - Object Handle + * + * @warning + * This function assigns a copy of the object to the given attribute. + * Any further modifications of the object passed as the parameter 'value' + * will not be reflected to object 's attribute set with this call + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetObject +( + OCI_Elem * elem, + OCI_Object *value +); + +/** + * @brief + * Assign a Lob handle to a collection element + * + * @param elem - Element handle + * @param value - Lob Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetLob +( + OCI_Elem *elem, + OCI_Lob * value +); + +/** + * @brief + * Assign a File handle to a collection element + * + * @param elem - Element handle + * @param value - File Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetFile +( + OCI_Elem *elem, + OCI_File *value +); + +/** + * @brief + * Assign a Ref handle to a collection element + * + * @param elem - Element handle + * @param value - Ref Handle + * + * @note + * passing a null pointer for value calls OCI_ElemSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetRef +( + OCI_Elem *elem, + OCI_Ref * value +); + +/** + * @brief + * Check if the collection element value is null + * + * @param elem - Element handle + * + * @return + * TRUE if it's null otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemIsNull +( + OCI_Elem *elem +); + +/** + * @brief + * Set a collection element value to null + * + * @param elem - Element handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ElemSetNull +( + OCI_Elem *elem +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiFeatureReturningInto Oracle Returning feature + * @{ + * + * OCILIB supports the Oracle feature 'Returning into' for DML statements. + * + * Let's Oracle talk about this features: + * + * @par + * 'Using the RETURNING clause with a DML statement allows you to essentially + * combine two SQL statements into one, possibly saving you a server round-trip. + * This is accomplished by adding an extra clause to the traditional UPDATE, + * INSERT, and DELETE statements. The extra clause effectively adds a query to + * the DML statement. In the OCI, the values are returned to the application + * through the use of OUT bind variables.' + * + * OCILIB implements this features by providing a set of functions that allows + * to register output placeholders for the returned values. + * Once the DML is executed with OCI_Execute(), the output returned data is + * available through a regular resultset object that can be fetched. + * + * @note + * Array binding interface is also supported with 'returning into' DML statement. + * Every iteration (or row of given arrays) generates an resultset object. + * Once a resultset is fetched, the next on can be retrieved with OCI_GetNextResultset() + * + * @par + * + * @note + * OCI_Long are not supported for 'returning into' clause .This is a limitation imposed by Oracle. + * + * @note + * OCI_Column objects retrieved from output OCI_Resultset have the following + * particularities: + * + * - their names are the provided bind names to the DML statement + * (by example, ':out1'). So any call to the functions OCI_GetXXX2() + * should be aware of it + * - The columns detailed SQL attributes might be not all set or accurate. By + * example, the scale and precision are not set, the SQL type is the one + * chosen by OCILIB regarding the OCILIB object data type and might be + * slightly different from the real one. + * + * @par Example + * @include returning.c + * + */ + +/** + * @brief + * Retrieve the next available resultset + * + * @param stmt - Statement handle + * + * @note + * it is only valid for the following statements: + * - Statements executing SQL UPDATE/DELETE using a RETURNING INTO clause + * - Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using + * DBMS_SQL.RETURN_RESULT() + * + * @note + * SQL statements with a 'returning' clause can return multiple resultsets. + * When arrays of program variables are binded to the statement, Oracle will + * execute the statement for every row (iteration). + * Each iteration generates a resultset that can be fetched like regular ones. + * + * @note + * Starting withOracle 12cR1, PL/SQ procedure and blocks ca return multiple implicit resultsets + * Refer to Oracle documentation for more information. + * + * @return + * A resultset handle on success otherwise NULL + * + */ + +OCI_EXPORT OCI_Resultset * OCI_API OCI_GetNextResultset +( + OCI_Statement *stmt +); + +/** +* @brief +* Register a register output bind placeholder +* +* @param stmt - Statement handle +* @param name - Output bind name +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_RegisterNumber +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register a short output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterShort +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register an unsigned short output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterUnsignedShort +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register an integer output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterInt +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register an unsigned integer output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterUnsignedInt +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register a big integer output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterBigInt +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register an unsigned big integer output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterUnsignedBigInt +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register a string output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param len - Max length of single string (in characters) + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterString +( + OCI_Statement *stmt, + const otext * name, + unsigned int len +); + +/** + * @brief + * Register an raw output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param len - Max length of the buffer (in bytes) + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterRaw +( + OCI_Statement *stmt, + const otext * name, + unsigned int len +); + +/** + * @brief + * Register a double output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterDouble +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register a float output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterFloat +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register a date output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterDate +( + OCI_Statement *stmt, + const otext * name +); + +/** + * @brief + * Register a timestamp output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param type - Timestamp type + * + * @note + * See OCI_TimestampCreate() for possible values of parameter 'type' + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterTimestamp +( + OCI_Statement *stmt, + const otext * name, + unsigned int type +); + +/** + * @brief + * Register an interval output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param type - Interval type + * + * @note + * See OCI_IntervalCreate() for possible values of parameter 'type' + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterInterval +( + OCI_Statement *stmt, + const otext * name, + unsigned int type +); + +/** + * @brief + * Register an object output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param typinf - Type info handle + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterObject +( + OCI_Statement *stmt, + const otext * name, + OCI_TypeInfo * typinf +); + +/** + * @brief + * Register a lob output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param type - Lob type + * + * @note + * See OCI_LobCreate() for possible values of parameter 'type' + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterLob +( + OCI_Statement *stmt, + const otext * name, + unsigned int type +); + +/** + * @brief + * Register a file output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param type - File type + * + * @note + * See OCI_FileCreate() for possible values of parameter 'type' + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterFile +( + OCI_Statement *stmt, + const otext * name, + unsigned int type +); + +/** + * @brief + * Register a Ref output bind placeholder + * + * @param stmt - Statement handle + * @param name - Output bind name + * @param typinf - Type info handle + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RegisterRef +( + OCI_Statement *stmt, + const otext * name, + OCI_TypeInfo * typinf +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiRowIds Oracle Rowids + * @{ + * + * OCILIB supports the Oracle ROWID type through C scalar string types (otext). + * + * - ROWIDs can be retrieved from resultset with OCI_GetString() + * - ROWIDs can be binded to statements with OCI_BindString() + * + * The maximum size of an ROWID buffer is defined by the constant OCI_SIZE_ROWID + * + * @par Example + * @include rowid.c + * + * @} + */ + +/** + * @defgroup OcilibCApiStatementControl Statements control + * @{ + * + * Those functions give extra information about OCILIB statements and can modify their behavior. + * + */ + +/** + * @brief + * Return the type of a SQL statement + * + * @param stmt - Statement handle + * + * @note + * Possible values are : + * + * - OCI_CST_SELECT : select statement + * - OCI_CST_UPDATE : update statement + * - OCI_CST_DELETE : delete statement + * - OCI_CST_INSERT : insert statement + * - OCI_CST_CREATE : create statement + * - OCI_CST_DROP : drop statement + * - OCI_CST_ALTER : alter statement + * - OCI_CST_BEGIN : begin (pl/sql) statement + * - OCI_CST_DECLARE : declare (pl/sql) statement + * - OCI_CST_CALL : kpu call + * - OCI_CST_MERGE : merge statement + * + * @return + * The statement type on success or OCI_UNKOWN on error + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetStatementType +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the fetch mode of a SQL statement + * + * @param stmt - Statement handle + * @param mode - fetch mode value + * + * @warning + * OCI_SetFetchMode() MUST be called before any OCI_ExecuteXXX() call + * + * @note + * Possible values are : + * - OCI_SFM_DEFAULT + * - OCI_SFM_SCROLLABLE + * + * @warning + * if Oracle Client is 9iR1: + * - when setting OCI_SFM_SCROLLABLE, OCI_SetPrefetch() is internally called with value 0 + * to disable prefetching (to avoid an oracle bug). + * - when re-setting OCI_SFM_DEFAULT after having set OCI_SFM_SCROLLABLE, OCI_SetPrefetch() + * is internally called with value OCI_PREFETCH_SIZE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetFetchMode +( + OCI_Statement *stmt, + unsigned int mode +); + +/** + * @brief + * Return the fetch mode of a SQL statement + * + * @param stmt - Statement handle + * + * @note + * See OCI_SetFetchMode() for possible values + * Default value is OCI_SFM_DEFAULT + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetFetchMode +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the binding mode of a SQL statement + * + * @param stmt - Statement handle + * @param mode - binding mode value + * + * @note + * Possible values are : + * - OCI_BIND_BY_POS : position binding + * - OCI_BIND_BY_NAME : name binding + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetBindMode +( + OCI_Statement *stmt, + unsigned int mode +); + +/** + * @brief + * Return the binding mode of a SQL statement + * + * @param stmt - Statement handle + * + * @note + * See OCI_SetBindMode() for possible values + * Default value is OCI_BIND_BY_NAME + * + * @note + * if stmt is NULL, the return value is OCI_UNKNOWN + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetBindMode +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the current bind allocation mode that will be used for subsequent binding calls + * + * @param stmt - Statement handle + * @param mode - bind allocation mode value + * + * @note + * Possible values are : + * - OCI_BAM_EXTERNAL : bind variable are allocated by user code + * - OCI_BAM_INTERNAL : bind variable are allocated internally + * + * @warning + * This call has to be made after preparing a statement as OCI_Prepare() reset it by default to OCI_BAM_EXTERNAL. + * When calling an OCI_BindXXXX() call, this value is used and stored in the OCI_Bind object created during the bind call. + * Each bind can have is own allocation mode that is returned by OCI_BindGetAllocationMode() + * OCI_SetBindAllocation() can be called before each binding call if needed, resulting having some bind allocated externally and other ones internally. + * + * @note + * Refer to the section "Binding variables and arrays" of the documentation about allocation mode as OCI_BAM_INTERNAL is not compatible with all bind calls + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetBindAllocation +( + OCI_Statement *stmt, + unsigned int mode +); + +/** + * @brief + * Return the current bind allocation mode used for subsequent binding calls + * + * @param stmt - Statement handle + * + * @note + * See OCI_SetBindAllocation() for possible values + * Default value is OCI_BAM_EXTERNAL + * + * @warning + * Each OCI_Bind object has its own allocation mode that may differ from the one returned by OCI_GetBindAllocation() + * The return value of OCI_GetBindAllocation() is the mode that will be used for any subsequent OCI_BindXXXX() calls + * + * @note + * if stmt is NULL, the return value is OCI_UNKNOWN + * + */ +OCI_EXPORT unsigned int OCI_API OCI_GetBindAllocation +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the number of rows fetched per internal server fetch call + * + * @param stmt - Statement handle + * @param size - number of rows to fetch + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetFetchSize +( + OCI_Statement *stmt, + unsigned int size +); + +/** + * @brief + * Return the number of rows fetched per internal server fetch call + * + * @param stmt - Statement handle + * + * @note + * Default value is set to constant OCI_FETCH_SIZE + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetFetchSize +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the number of rows pre-fetched by OCI Client + * + * @param stmt - Statement handle + * @param size - number of rows to pre-fetch + * + * @note + * To turn off pre-fetching, set both attributes (size and memory) to 0. + * + * @warning + * Prefetch is not working with scrollable cursors in Oracle 9iR1 + * In that case, argument 'size' is not used and replace by 0. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetPrefetchSize +( + OCI_Statement *stmt, + unsigned int size +); + +/** + * @brief + * Return the number of rows pre-fetched by OCI Client + * + * @param stmt - Statement handle + * + * @note + * Default value is set to constant OCI_PREFETCH_SIZE + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetPrefetchSize +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the amount of memory pre-fetched by OCI Client + * + * @param stmt - Statement handle + * @param size - amount of memory to fetch + * + * @note + * Default value is 0 and the pre-fetch size attribute is used instead. + * When both attributes are set (pre-fetch size and memory) and pre-fetch memory + * value can hold more rows than specified by pre-fetch size, OCI uses pre-fetch + * size instead. + * + * @note + * OCILIB set pre-fetch attribute to OCI_PREFETCH_SIZE when a statement is created. + * To setup a big value for OCI_SetPrefetchMemory(), you must call + * OCI_SetPrefetchSize() to 0 to make OCI consider this attribute. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetPrefetchMemory +( + OCI_Statement *stmt, + unsigned int size +); + +/** + * @brief + * Return the amount of memory used to retrieve rows pre-fetched by OCI Client + * + * @param stmt - Statement handle + * + * @note + * Default value is 0 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetPrefetchMemory +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the LONG data type piece buffer size + * + * @param stmt - Statement handle + * @param size - maximum size for long buffer + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetLongMaxSize +( + OCI_Statement *stmt, + unsigned int size +); + +/** + * @brief + * Return the LONG data type piece buffer size + * + * @param stmt - Statement handle + * + * @note + * Default value is set to constant OCI_SIZE_LONG + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetLongMaxSize +( + OCI_Statement *stmt +); + +/** + * @brief + * Set the long data type handling mode of a SQL statement + * + * @param stmt - Statement handle + * @param mode - long mode value + * + * @note + * Possible values are : + * + * - OCI_LONG_EXPLICIT : LONGs are explicitly handled by OCI_Long type + * - OCI_LONG_IMPLICIT : LONGs are implicitly mapped to string type in the + * limits of VARCHAR2 size capacity + * + * LONG RAWs cannot be handled with OCI_LONG_IMPLICIT + */ + +OCI_EXPORT boolean OCI_API OCI_SetLongMode +( + OCI_Statement *stmt, + unsigned int mode +); + +/** + * @brief + * Return the long data type handling mode of a SQL statement + * + * @param stmt - Statement handle + * + * @note + * See OCI_SetLongMode() for possible values + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_GetLongMode +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the connection handle associated with a statement handle + * + * @param stmt - Statement handle + * + */ + +OCI_EXPORT OCI_Connection * OCI_API OCI_StatementGetConnection +( + OCI_Statement *stmt +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiLobs Internal Large Objects (LOBs) + * @{ + * + * Large Objects (LOBs) were introduced with Oracle 8i to replace LONGs + * + * Oracle OCI supplies a set APIs to manipulate this data type. + * + * OCILIB encapsulates this API by supplying: + * + * - An OCI_Lob C type + * - A set of really easy APIs to manipulate OCI_Lob objects + * + * OCILIB currently supports 3 types of Lobs : + * + * - BLOB : Binary LOBs (replacement for LONG RAW data type) + * - CLOB : Character LOBs (replacement for LONG data type) + * - NCLOB : National Character LOBs + * + * OCI_Lob objects can be : + * + * - Created as standalone instances + * - Used for in/out binding + * - Retrieved from select statements + * - Manipulated (copy, append, ...) + * + * @par Lobs > 4 Go + * + * Oracle 10g extended lobs by increasing maximum size from 4Go to 128 To. + * + * OCILIB, with version 2.1.0, supports now this new limit. + * For handling sizes and offsets up to 128 To, 64 bit integers are requested. + * + * So, A new scalar integer type has been introduced: big_uint (elderly lobsize_t). + * This type can be a 32 bits or 64 bits integer depending on : + * - Compiler support for 64 bits integers (C99 compiler, MS compilers) + * - Oracle client version + * + * big_uint will be a 64 bits integer : + * - if the compiler supports it + * - if OCILIB is build with option OCI_IMPORT_LINKAGE and the Oracle version is >= 10.1 + * - or OCILIB is build with option OCI_IMPORT_RUNTIME (oracle version is not known at + * compilation stage) + * + * @par Example + * @include lob.c + * + */ + +/** + * @brief + * Create a local temporary Lob instance + * + * @param con - Connection handle + * @param type - Lob type + * + * Supported lob types : + * + * - OCI_BLOB : Binary Lob + * - OCI_CLOB : Character Lob + * - OCI_NCLOB ! National Character Lob + * + * @return + * Return the lob handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Lob * OCI_API OCI_LobCreate +( + OCI_Connection *con, + unsigned int type +); + +/** + * @brief + * Free a local temporary lob + * + * @param lob - Lob handle + * + * @warning + * Only lobs created with OCI_LobCreate() should be freed by OCI_LobFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobFree +( + OCI_Lob *lob +); + +/** + * @brief + * Create an array of lob object + * + * @param con - Connection handle + * @param type - Lob type + * @param nbelem - number of elements in the array + * + * @note + * see OCI_LobCreate() for more details + * + * @return + * Return the lob handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Lob ** OCI_API OCI_LobArrayCreate +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +/** +* @brief +* Free an array of lob objects +* +* @param lobs - Array of lob objects +* +* @warning +* Only arrays of lobs created with OCI_LobArrayCreate() should be freed +* by OCI_LobArrayFree() +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_LobArrayFree +( + OCI_Lob **lobs +); + +/** + * @brief + * Return the type of the given Lob object + * + * @param lob - Lob handle + * + * @note + * For possible values, see OCI_LobCreate() + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LobGetType +( + OCI_Lob *lob +); + +/** + * @brief + * Perform a seek operation on the OCI_lob content buffer + * + * @param lob - Lob handle + * @param offset - Offset from current position (bytes or characters) + * @param mode - Seek mode + * + * Parameter 'mode' can be one of the following value : + * + * - OCI_SEEK_SET : set the lob current offset to the given absolute offset + * - OCI_SEEK_END : set the lob current offset to the end of the lob + * - OCI_SEEK_CUR : move the lob current offset to the number of bytes or + * characters given by parameter 'offset' + * + * @note + * - For CLOB and CLOB, offset in characters + * - For BLOB and BFILE, offset is in bytes + * + * @note + * Position in the Lob buffer starts at 0. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobSeek +( + OCI_Lob * lob, + big_uint offset, + unsigned int mode +); + +/** + * @brief + * Return the current position in the Lob content buffer + * + * @param lob - Lob handle + * + * @return + * Lob position (starting with 0) or 0 on failure + */ + +OCI_EXPORT big_uint OCI_API OCI_LobGetOffset +( + OCI_Lob *lob +); + +/** + * @brief + * [OBSOLETE] Read a portion of a lob into the given buffer + * + * @param lob - Lob handle + * @param buffer - Pointer to a buffer + * @param len - Length of the buffer (in bytes or characters) + * + * @note + * Length is expressed in : + * - Bytes for BLOBs + * - Characters for CLOBs/NCLOBS + * + * @warning + * This call is obsolete ! Use OCI_LobRead2() instead. + * + * @return + * Number of bytes/characters read on success otherwise 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LobRead +( + OCI_Lob * lob, + void * buffer, + unsigned int len +); + +/** + * @brief + * Read a portion of a lob into the given buffer + * + * @param lob - Lob handle + * @param buffer - Pointer to a buffer + * @param char_count - [in/out] Pointer to maximum number of characters + * @param byte_count - [in/out] Pointer to maximum number of bytes + * + * @note + * In input, 'char_count' and 'byte_count' are values to read into the buffer + * In output, 'char_count' and 'byte_count' are values read into the buffer + * + * @note + * For BLOBs, only the parameter 'byte_count' is used + * For CLOBs, both parameters can be used : + * In input : + * - if 'byte_count' is set to zero, it is computed from 'char_count' + * - if 'char_count' is set to zero, it is computed from 'byte_count' + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobRead2 +( + OCI_Lob * lob, + void * buffer, + unsigned int *char_count, + unsigned int *byte_count +); + +/** + * @brief + * [OBSOLETE] Write a buffer into a LOB + * + * @param lob - Lob handle + * @param buffer - Pointer to a buffer + * @param len - Length of the buffer (in bytes or characters) + * + * @note + * Length is expressed in : + * - Bytes for BLOBs + * - Characters for CLOBs/NCLOBs + * + * @warning + * This call is obsolete ! Use OCI_LobWrite2() instead. + * + * @return + * Number of bytes / characters written on success otherwise 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LobWrite +( + OCI_Lob * lob, + void * buffer, + unsigned int len +); + +/** + * @brief + * Write a buffer into a LOB + * + * @param lob - Lob handle + * @param buffer - Pointer to a buffer + * @param char_count - [in/out] Pointer to maximum number of characters + * @param byte_count - [in/out] Pointer to maximum number of bytes + * + * @note + * In input, 'char_count' and 'byte_count' are values to write from the buffer + * In output, 'char_count' and 'byte_count' are values written from the buffer + * + * @note + * For BLOBs, only the parameter 'byte_count' is used + * For CLOBs, both parameters can be used : + * In input : + * - if 'byte_count' is set to zero, it is computed from 'char_count' + * - if 'char_count' is set to zero, it is computed from 'byte_count' + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobWrite2 +( + OCI_Lob * lob, + void * buffer, + unsigned int *char_count, + unsigned int *byte_count +); + +/** + * @brief + * Truncate the given lob to a shorter length + * + * @param lob - Lob handle + * @param size - New length (in bytes or characters) + * + * @note + * Length is expressed in : + * - Bytes for BLOBs + * - Characters for CLOBs/NCLOBs + * + * @note + * If current offset was beyond the new size, it is then updated to an eof position in order for further write calls to append data + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobTruncate +( + OCI_Lob *lob, + big_uint size +); + +/** + * @brief + * Return the actual length of a lob + * + * @param lob - Lob handle + * + * @note + * The returned value is in bytes for BLOBS and characters for CLOBS/NCLOBs + * + */ + +OCI_EXPORT big_uint OCI_API OCI_LobGetLength +( + OCI_Lob *lob +); + +/** + * @brief + * Returns the chunk size of a LOB + * + * @param lob - Lob handle + * + * @note + * This chunk size corresponds to the chunk size used by the LOB data layer + * when accessing and modifying the LOB value. According to Oracle + * documentation, performance will be improved if the application issues + * read or write requests using a multiple of this chunk size + * + * @note + * The returned value is in bytes for BLOBS and characters for CLOBS/NCLOBs + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LobGetChunkSize +( + OCI_Lob *lob +); + +/** + * @brief + * Erase a portion of the lob at a given position + * + * @param lob - Lob handle + * @param offset - Absolute position in source lob + * @param len - Number of bytes or characters to erase + * + * @note + * Absolute position starts at 0. + * Erasing means "overwriting" the range of values at the given offset with: + * - spaces for CLOB/NCLOB + * - 'zero' bytes for BLOB + * + * @return + * Number of bytes (BLOB) or characters (CLOB/NCLOB) erased on success + * otherwise 0 on failure + * + */ + +OCI_EXPORT big_uint OCI_API OCI_LobErase +( + OCI_Lob *lob, + big_uint offset, + big_uint len +); + +/** + * @brief + * Append a buffer at the end of a LOB + * + * @param lob - Lob handle + * @param buffer - Pointer to a buffer + * @param len - Length of the buffer (in bytes or characters) + * + * @note + * Length is expressed in : + * - Bytes for BLOBs + * - Characters for CLOBs + * + * @return + * Number of bytes / characters written on success otherwise 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LobAppend +( + OCI_Lob * lob, + void * buffer, + unsigned int len +); + +/** + * @brief + * Append a buffer at the end of a LOB + * + * @param lob - Lob handle + * @param buffer - Pointer to a buffer + * @param char_count - [in/out] Pointer to maximum number of characters + * @param byte_count - [in/out] Pointer to maximum number of bytes + * + * @note + * In input, 'char_count' and 'byte_count' are values to write from the buffer + * In output, 'char_count' and 'byte_count' are values written from the buffer + * + * @note + * For BLOBs, only the parameter 'byte_count' is used + * For CLOBs, both parameters can be used : + * In input : + * - if 'byte_count' is set to zero, it is computed from 'char_count' + * - if 'char_count' is set to zero, it is computed from 'byte_count' + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobAppend2 +( + OCI_Lob * lob, + void * buffer, + unsigned int *char_count, + unsigned int *byte_count +); + +/** + * @brief + * Append a source LOB at the end of a destination LOB + * + * @param lob - Destination Lob handle + * @param lob_src - Source Lob handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobAppendLob +( + OCI_Lob *lob, + OCI_Lob *lob_src +); + +/** + * @brief + * Check if the given lob is a temporary lob + * + * @param lob - Lob handle + * + * @return + * TRUE if it's a temporary lob otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobIsTemporary +( + OCI_Lob *lob +); + +/** + * @brief + * Copy a portion of a source LOB into a destination LOB + * + * @param lob - Destination Lob handle + * @param lob_src - Source Lob handle + * @param offset_dst - Absolute position in destination lob + * @param offset_src - Absolute position in source lob + * @param count - Number of bytes or character to copy + * + * @note + * For character LOB (CLOB/NCLOBS) the parameters count, offset_dst and + * offset_src are expressed in characters and not in bytes. + * + * @note + * Absolute position starts at 0. + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobCopy +( + OCI_Lob *lob, + OCI_Lob *lob_src, + big_uint offset_dst, + big_uint offset_src, + big_uint count +); + +/** + * @brief + * Copy a portion of a source FILE into a destination LOB + * + * @param lob - Destination Lob handle + * @param file - Source File handle + * @param offset_dst - Absolute position in destination lob + * @param offset_src - Absolute position in source file + * @param count - Number of bytes to copy + * + * @note + * - For character LOB (CLOB/NCLOB) the parameter offset_src are expressed in + * characters and not in bytes. + * - Offset_src is always in bytes + * + * @note + * Absolute position starts at 0. + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobCopyFromFile +( + OCI_Lob * lob, + OCI_File *file, + big_uint offset_dst, + big_uint offset_src, + big_uint count +); + +/** + * @brief + * Open explicitly a Lob + * + * @param lob - Lob handle + * @param mode - open mode + * + * Possible values for mode are : + * + * - OCI_LOB_READONLY : read only access + * - OCI_LOB_READWRITE : read/write access + * + * @note + * - A call to OCI_LobOpen is not necessary to manipulate a Lob. + * - If a lob has not been opened explicitly, triggers are fired and + * indexes updated at every read/write/append operation + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobOpen +( + OCI_Lob * lob, + unsigned int mode +); + +/** + * @brief + * Close explicitly a Lob + * + * @param lob - Lob handle + * + * @note + * - A call to OCI_LobClose is not necessary to manipulate a Lob. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobClose +( + OCI_Lob *lob +); + +/** + * @brief + * Compare two lob handles for equality + * + * @param lob - Lob handle + * @param lob2 - Lob2 handle + * + * @return + * TRUE is the lobs are not null and equal otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobIsEqual +( + OCI_Lob *lob, + OCI_Lob *lob2 +); + +/** + * @brief + * Assign a lob to another one + * + * @param lob - Destination Lob handle + * @param lob_src - Source Lob handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobAssign +( + OCI_Lob *lob, + OCI_Lob *lob_src +); + +/** + * @brief + * Return the maximum size that the lob can contain + * + * @param lob - Lob handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT big_uint OCI_API OCI_LobGetMaxSize +( + OCI_Lob *lob +); + +/** + * @brief + * Flush Lob content to the server + * + * @param lob - Lob handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobFlush +( + OCI_Lob *lob +); + +/** + * @brief + * Enable / disable buffering mode on the given lob handle + * + * @param lob - Lob handle + * @param value - Enable/disable buffering mode + * + * @note + * Oracle "LOB Buffering Subsystem" allows client applications + * to speedup read/write of small buffers on Lobs Objects. + * Check Oracle Documentation for more details on "LOB Buffering Subsystem". + * This reduces the number of network round trips and LOB versions, thereby + * improving LOB performance significantly. + * + * @warning + * According to Oracle documentation the following operations are not permitted + * on Lobs when buffering is on : OCI_LobCopy(), OCI_LobAppend, OCI_LobErase(), + * OCI_LobGetLength(), OCI_LobTruncate() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LobEnableBuffering +( + OCI_Lob *lob, + boolean value +); + +/** +* @brief +* Retrieve connection handle from the lob handle +* +* @param lob - lob handle +* +*/ + +OCI_EXPORT OCI_Connection * OCI_API OCI_LobGetConnection +( + OCI_Lob *lob +); + +/** +* @brief +* Indicates if the given lob belongs to a local or remote database table +* +* @param lob - lob handle +* +* @warning +* Requires Oracle 12cR2 (both client and server side), otherwise it returns FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_LobIsRemote +( + OCI_Lob *lob +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiFiles External Large Objects (FILEs) + * @{ + * + * External Large Objects (FILEs) were introduced with Oracle 8i + * + * Oracle OCI supplies a set APIs to manipulate this data type. + * + * OCILIB encapsulates this API by supplying: + * + * - An OCI_File C type + * - A set of really easy APIs to manipulate OCI_File objects + * + * OCILIB currently supports 2 types of Lobs : + * + * - BFILE : Binary files + * - CFILE : Character files + * + * @warning + * FILEs are read-only. + * + * OCI_Lob objects can be : + * + * - Created as standalone instances + * - Used for in/out binding + * - Retrieved from select statements + * - Used for reading server files content + * + * @par Files > 4 Go + * + * - New maximum file size limit (128 To) applies to OCI_Files objects. + * - See Internal Large Objects (LOBs) section for Files > 4 Go information + * + * @par Example + * @include file.c + * + */ + +/** + * @brief + * Create a file object instance + * + * @param con - Connection handle + * @param type - File type + * + * Supported file types : + * + * - OCI_BFILE : Binary file + * - OCI_CFILE : Character file + * + * @return + * Return the lob handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_File * OCI_API OCI_FileCreate +( + OCI_Connection *con, + unsigned int type +); + +/** + * @brief + * Free a local File object + * + * @param file - File handle + * + * @warning + * Only Files created with OCI_FileCreate() should be freed by OCI_FileFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileFree +( + OCI_File *file +); + +/** + * @brief + * Create an array of file object + * + * @param con - Connection handle + * @param type - File type + * @param nbelem - number of elements in the array + * + * @note + * see OCI_FileCreate() for more details + * + * @return + * Return the file handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_File ** OCI_API OCI_FileArrayCreate +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +/** +* @brief +* Free an array of file objects +* +* @param files - Array of file objects +* +* @warning +* Only arrays of lobs created with OCI_FileArrayCreate() should be freed by OCI_FileArrayFree() +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_FileArrayFree +( + OCI_File **files +); + +/** + * @brief + * Return the type of the given File object + * + * @param file - File handle + * + * @note + * For possible values, see OCI_FileCreate() + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_FileGetType +( + OCI_File *file +); + +/** + * @brief + * Perform a seek operation on the OCI_File content buffer + * + * @param file - File handle + * @param offset - Offset from current position + * @param mode - Seek mode + * + * Mode parameter can be one of the following value : + * + * - OCI_SEEK_SET : set the file current offset to the given absolute offset + * - OCI_SEEK_END : set the file current offset to the end of the lob + * - OCI_SEEK_CUR : move the file current offset to the number of bytes given by + * parameter 'offset' + * + * @note + * Position in the File buffer starts at 0. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileSeek +( + OCI_File * file, + big_uint offset, + unsigned int mode +); + +/** + * @brief + * Return the current position in the file + * + * @param file - File handle + * + * @return + * File position (starting with 0) or 0 on failure + */ + +OCI_EXPORT big_uint OCI_API OCI_FileGetOffset +( + OCI_File *file +); + +/** + * @brief + * Read a portion of a file into the given buffer + * + * @param file - File handle + * @param buffer - Pointer to a buffer + * @param len - Length of the buffer in bytes + * + * @return + * Number of bytes read on success otherwise 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_FileRead +( + OCI_File * file, + void * buffer, + unsigned int len +); + +/** + * @brief + * Return the size in bytes of a file + * + * @param file - File handle + * + */ + +OCI_EXPORT big_uint OCI_API OCI_FileGetSize +( + OCI_File *file +); + +/** + * @brief + * Check if the given file exists on server + * + * @param file - File handle + * + * @note + * For local FILEs object, OCI_LobFileSetName() must be called before to set the filename to check + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileExists +( + OCI_File *file +); + +/** + * @brief + * Set the directory and file name of FILE handle + * + * @param file - File handle + * @param dir - File directory + * @param name - File name + *in + * @note + * - For local FILEs only + * - Files fetched from resultset cannot be assigned a new directory and name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileSetName +( + OCI_File * file, + const otext *dir, + const otext *name +); + +/** + * @brief + * Return the directory of the given file + * + * @param file - File handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_FileGetDirectory +( + OCI_File *file +); + +/** + * @brief + * Return the name of the given file + * + * @param file - File handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_FileGetName +( + OCI_File *file +); + +/** + * @brief + * Open a file for reading + * + * @param file - File handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileOpen +( + OCI_File *file +); + +/** + * @brief + * Check if the specified file is opened within the file handle + * + * @param file - File handle + * + * @return + * TRUE if the file was opened with this handle otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileIsOpen +( + OCI_File *file +); + +/** + * @brief + * Close a file + * + * @param file - File handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileClose +( + OCI_File *file +); + +/** + * @brief + * Compare two file handle for equality + * + * @param file - File handle + * @param file2 - File2 handle + * + * @return + * TRUE is the lobs are not null and equal otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileIsEqual +( + OCI_File *file, + OCI_File *file2 +); + +/** + * @brief + * Assign a file to another one + * + * @param file - Destination File handle + * @param file_src - Source File handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_FileAssign +( + OCI_File *file, + OCI_File *file_src +); + +/** +* @brief +* Retrieve connection handle from the file handle +* +* @param file - file handle +* +*/ + +OCI_EXPORT OCI_Connection * OCI_API OCI_FileGetConnection +( + OCI_File *file +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiLongs Long objects + * @{ + * + * Long Objects encapsulate Oracle LONGs data types and were used to store large + * buffers in Oracle database. + * + * They're still supported but are depreciated. Oracle now provides a + * newer and better way to deal with data that needs large storage : LOBs + * + * OCILIB supports this data type because it was and still is widely used + * + * OCILIB provides a set of API for manipulating LONGs that is really close to + * the one provided for LOBs. + * + * OCILIB currently supports 3 types of Long Objects: + * + * - OCI_BLONG : LONG RAW columns + * - OCI_CLONG : LONG columns + * + * OCI_Lob objects can be : + * + * - Created as standalone instances + * - Used for in/out binding + * - Retrieved from select statement + * + * @par Example + * @include long.c + * + */ + +/** + * @brief + * Create a local temporary Long instance + * + * @param stmt - Statement handle + * @param type - Long type + * + * Supported lob types : + * + * - OCI_BLONG : Binary Long + * - OCI_CLONG : Character Long + * + * @return + * Return the long handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Long * OCI_API OCI_LongCreate +( + OCI_Statement *stmt, + unsigned int type +); + +/** + * @brief + * Free a local temporary long + * + * @param lg - Long handle + * + * @warning + * Only lobs created with OCI_LongCreate() should be freed by OCI_LongFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_LongFree +( + OCI_Long *lg +); + +/** + * @brief + * Return the type of the given Long object + * + * @param lg - Long handle + * + * @note + * For possible values, see OCI_LobCreate() + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LongGetType +( + OCI_Long *lg +); + +/** + * @brief + * Read a portion of a long into the given buffer [Obsolete] + * + * @param lg - Long handle + * @param buffer - Pointer to a buffer + * @param len - Length of the buffer in bytes / characters + * + * @note + * - From version 2.0.0, this function is obsolete because OCILIB fetches now + * all data during OCIFetchNext() call + * - So, this call reads now the internal OCI_Long object allocated buffer + * - The internal buffer can be directly accessed with OCI_LongGetBuffer() + * + * @note + * - For OCI_CLONG, parameter 'len' and returned value are expressed in characters + * - For OCI_BLONG, parameter 'len' and returned value are expressed in bytes + * + * @return + * - Number of bytes/characters read on success + * - 0 if there is nothing more to read + * - 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LongRead +( + OCI_Long * lg, + void * buffer, + unsigned int len +); + +/** + * @brief + * Write a buffer into a Long + * + * @param lg - Long handle + * @param buffer - the pointer to a buffer + * @param len - the length of the buffer in bytes (OCI_BLONG) or + * character (OCI_CLONG) + * + * @return + * Number of bytes (OCI_BLONG) / character (OCI_CLONG) written on success otherwise 0 on failure + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LongWrite +( + OCI_Long * lg, + void * buffer, + unsigned int len +); + +/** + * @brief + * Return the buffer size of a long object in bytes (OCI_BLONG) or character (OCI_CLONG) + * + * @param lg - Long handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_LongGetSize +( + OCI_Long *lg +); + +/** + * @brief + * Return the internal buffer of an OCI_Long object read from a fetch sequence + * + * @param lg - Long handle + * + */ + +OCI_EXPORT void * OCI_API OCI_LongGetBuffer +( + OCI_Long *lg +); + +/** +* @} +*/ + +/** +* @defgroup OcilibCApiOracleNumber Oracle NUMBER manipulation (optional) +* @{ +* +* OCILIB encapsulates Oracle SQL all Numeric types using C native data types. +* But it also provides an optional OCI_Number handle for manipulating and accessing Oracle NUMBER type. +* OCI_Number provides management for some special value that cannot be addressed in C such as positive +* and negative infinity. +* +* @par Example +* @include number.c +* +*/ + +/** +* @brief +* Create a local number object +* +* @param con - Connection handle +* +* @note +* Parameter 'con' can be NULL in order to manipulate numbers +* independently from database connections +* +* @return +* Return the number handle on success otherwise NULL on failure +* +*/ + +OCI_EXPORT OCI_Number * OCI_API OCI_NumberCreate +( + OCI_Connection *con +); + +/** +* @brief +* Free a number object +* +* @param number - Number handle +* +* @warning +* Only Numbers created with OCI_NumberCreate() should be freed by OCI_NumberFree() +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberFree +( + OCI_Number *number +); + +/** +* @brief +* Create an array of number object +* +* @param con - Connection handle +* @param nbelem - number of elements in the array +* +* @note +* see OCI_NumberCreate() for more details +* +* @return +* Return the number handle array on success otherwise NULL on failure +* +*/ + +OCI_EXPORT OCI_Number ** OCI_API OCI_NumberArrayCreate +( + OCI_Connection *con, + unsigned int nbelem +); + +/** +* @brief +* Free an array of number objects +* +* @param numbers - Array of number objects +* +* @warning +* Only arrays of numbers created with OCI_NumberArrayCreate() should be freed by OCI_NumberArrayFree() +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberArrayFree +( + OCI_Number **numbers +); + +/** +* @brief +* Assign the value of a number handle to another one +* +* @param number - Destination number handle +* @param number_src - Source number handle +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT int OCI_API OCI_NumberAssign +( + OCI_Number *number, + OCI_Number *number_src +); + +/** +* @brief +* Convert a number value from the given number handle to a string +* +* @param number - source number handle +* @param fmt - Number format +* @param size - Destination string size in characters +* @param str - Destination date string +* +* @note +* Output string can be one the following 'magic strings': +* - '~' for positive infinity +* - '-~' for negative infinity +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberToText +( + OCI_Number * number, + const otext *fmt, + int size, + otext * str +); + +/** +* @brief +* Convert a string to a number and store it in the given number handle +* +* @param number - Destination number handle +* @param str - Source number string +* @param fmt - Number format +* +* @note +* Input string can be one the following 'magic strings': +* - '~' for positive infinity +* - '-~' for negative infinity +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberFromText +( + OCI_Number * number, + const otext *str, + const otext *fmt +); + +/** +* @brief +* Return the number value content +* +* @param number - number handle +* +* @note +* Returned content is a buffer of 22 bytes corresponding to Oracle C native +* representation of NUMBER values +* See oracle Documentation of its layout +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT unsigned char * OCI_API OCI_NumberGetContent +( + OCI_Number *number +); + +/** +* @brief +* Assign the number value content +* +* @param number - number handle +* @param content - raw number content +* +* @note +* See OCI_NumberSetContent() for more information +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberSetContent +( + OCI_Number * number, + unsigned char *content +); + +/** +* @brief +* Assign the number value with the value of a native C numeric type +* +* @param number - number handle +* @param type - native C type to assign +* @param value - pointer to value to set +* +* @note +* Argument \p param type can be : +* +* - OCI_NUM_SHORT : value is a pointer to a signed short +* - OCI_NUM_USHORT : value is a pointer to an unsigned short +* - OCI_NUM_INT : value is a pointer to a signed int +* - OCI_NUM_UINT : value is a pointer to an unsigned short +* - OCI_NUM_BIGINT : value is a pointer to a signed big_int +* - OCI_NUM_BIGUINT : value is a pointer to an unsigned big_uint +* - OCI_NUM_FLOAT : value is a pointer to an float +* - OCI_NUM_DOUBLE : value is a pointer to a double +* - OCI_NUM_NUMBER : value is a pointer to the return value of OCI_NumberGetContent() +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberSetValue +( + OCI_Number * number, + unsigned int type, + void * value +); + +/** +* @brief +* Assign the number value to a native C numeric type +* +* @param number - number handle +* @param type - native C type to assign +* @param value - pointer to a native C variable +* +* @note +* See OCI_NumberSetValue() for more information +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberGetValue +( + OCI_Number * number, + unsigned int type, + void * value +); + +/** +* @brief +* Add the value of a native C numeric type to the given number +* +* @param number - number handle +* @param type - native C type of the variable +* @param value - pointer to a native C variable to add +* +* @note +* See OCI_NumberSetValue() for more information +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberAdd +( + OCI_Number * number, + unsigned int type, + void * value +); + +/** +* @brief +* Subtract the value of a native C numeric type to the given number +* +* @param number - number handle +* @param type - native C type of the variable +* @param value - pointer to a native C variable to subtract +* +* @note +* See OCI_NumberSetValue() for more information +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberSub +( + OCI_Number * number, + unsigned int type, + void * value +); + +/** +* @brief +* Multiply the given number with the value of a native C numeric +* +* @param number - number handle +* @param type - native C type of the variable +* @param value - pointer to a native C variable to multiply by +* +* @note +* See OCI_NumberSetValue() for more information +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberMultiply +( + OCI_Number * number, + unsigned int type, + void * value +); + +/** +* @brief +* Divide the given number with the value of a native C numeric +* +* @param number - number handle +* @param type - native C type of the variable +* @param value - pointer to a native C variable to divide by +* +* @note +* See OCI_NumberSetValue() for more information +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_NumberDivide +( + OCI_Number * number, + unsigned int type, + void * value +); + +/** + * @brief + * Compares two number handles + * + * @param number1 - number1 handle + * @param number2 - number2 handle + * + * @return + * - -1 if number1 is smaller than number2, + * - 0 if they are equal + * - 1 if number1 is greater than number2. + * + */ + +OCI_EXPORT int OCI_API OCI_NumberCompare +( + OCI_Number *number1, + OCI_Number *number2 +); + +/** +* @} +*/ + +/** + * @} + */ + +/** + * @defgroup OcilibCApiDatetimes Date/time manipulation + * @{ + * + * OCILIB encapsulates Oracle SQL Date data type within OCI_Date structure + * + * Basically, the OCI_Date routines are wrappers around the Oracle OCIDate APIs + * + * @par Example + * @include date.c + * + */ + +/** + * @brief + * Create a local date object + * + * @param con - Connection handle + * + * @note + * From version 2.5.0, parameter 'con' can be NULL in order to manipulate dates + * independently from database connections + * + * @return + * Return the date handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Date * OCI_API OCI_DateCreate +( + OCI_Connection *con +); + +/** + * @brief + * Free a date object + * + * @param date - Date handle + * + * @warning + * Only dates created with OCI_DateCreate() should be freed by OCI_DateFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateFree +( + OCI_Date *date +); + +/** + * @brief + * Create an array of date object + * + * @param con - Connection handle + * @param nbelem - number of elements in the array + * + * @note + * see OCI_DateCreate() for more details + * + * @return + * Return the date handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Date ** OCI_API OCI_DateArrayCreate +( + OCI_Connection *con, + unsigned int nbelem +); + +/** + * @brief + * Free an array of date objects + * + * @param dates - Array of date objects + * + * @warning + * Only arrays of dates created with OCI_DateArrayCreate() should be freed by OCI_DateArrayFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateArrayFree +( + OCI_Date **dates +); + +/** + * @brief + * Add or subtract days to a date handle + * + * @param date - Date handle + * @param nb - Number of days to add/remove + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateAddDays +( + OCI_Date *date, + int nb +); + +/** + * @brief + * Add or subtract months to a date handle + * + * @param date - Date handle + * @param nb - Number of months to add/remove + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateAddMonths +( + OCI_Date *date, + int nb +); + +/** + * @brief + * Assign the value of a date handle to another one + * + * @param date - Destination Date handle + * @param date_src - Source Date handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT int OCI_API OCI_DateAssign +( + OCI_Date *date, + OCI_Date *date_src +); + +/** + * @brief + * Check if the given date is valid + * + * @param date - Date handle + * + * @return + * - Zero if date is valid + * - Any other value means the date is invalid + * + */ + +OCI_EXPORT int OCI_API OCI_DateCheck +( + OCI_Date *date +); + +/** + * @brief + * Compares two date handles + * + * @param date - Date1 handle + * @param date2 - Date2 handle + * + * @return + * - -1 if date1 is smaller than date2, + * - 0 if they are equal + * - 1 if date1 is greater than date2. + * + */ + +OCI_EXPORT int OCI_API OCI_DateCompare +( + OCI_Date *date, + OCI_Date *date2 +); + +/** + * @brief + * Return the number of days betWeen two dates + * + * @param date - Date1 handle + * @param date2 - Date2 handle + * + * The number of days is the difference of (date2 - date) + * + * @return + * Number of days on success otherwise OCI_ERROR on failure + * + */ + +OCI_EXPORT int OCI_API OCI_DateDaysBetween +( + OCI_Date *date, + OCI_Date *date2 +); + +/** + * @brief + * Convert a string to a date and store it in the given date handle + * + * @param date - Destination Date handle + * @param str - Source date string + * @param fmt - Date format + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateFromText +( + OCI_Date * date, + const otext *str, + const otext *fmt +); + +/** + * @brief + * Convert a Date value from the given date handle to a string + * + * @param date - source Date handle + * @param fmt - Date format + * @param size - Destination string size in characters + * @param str - Destination date string + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateToText +( + OCI_Date * date, + const otext *fmt, + int size, + otext * str +); + +/** + * @brief + * Extract the date part from a date handle + * + * @param date - Date handle + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateGetDate +( + OCI_Date *date, + int * year, + int * month, + int * day +); + +/** + * @brief + * Extract the time part from a date handle + * + * @param date - Date handle + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateGetTime +( + OCI_Date *date, + int * hour, + int * min, + int * sec +); + +/** + * @brief + * Extract the date and time parts from a date handle + * + * @param date - Date handle + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateGetDateTime +( + OCI_Date *date, + int * year, + int * month, + int * day, + int * hour, + int * min, + int * sec +); + +/** + * @brief + * Set the date portion if the given date handle + * + * @param date - Date handle + * @param year - Year value + * @param month - Month value + * @param day - Day value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateSetDate +( + OCI_Date *date, + int year, + int month, + int day +); + +/** + * @brief + * Set the time portion if the given date handle + * + * @param date - Date handle + * @param hour - Hour value + * @param min - Minute value + * @param sec - Second value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateSetTime +( + OCI_Date *date, + int hour, + int min, + int sec +); + +/** + * @brief + * Set the date and time portions if the given date handle + * + * @param date - Date handle + * @param year - Year value + * @param month - Month value + * @param day - Day value + * @param hour - Hour value + * @param min - Minute value + * @param sec - Second value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateSetDateTime +( + OCI_Date *date, + int year, + int month, + int day, + int hour, + int min, + int sec +); + +/** + * @brief + * Place the last day of month (from the given date) into the given date + * + * @param date - Date handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateLastDay +( + OCI_Date *date +); + +/** + * @brief + * Gets the date of next day of the week, after a given date + * + * @param date - Date handle + * @param day - Day of the week + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateNextDay +( + OCI_Date * date, + const otext *day +); + +/** + * @brief + * Return the current system date/time into the date handle + * + * @param date - Date handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateSysDate +( + OCI_Date *date +); + +/** + * @brief + * Convert a date from one zone to another zone + * + * @param date - Date handle + * @param zone1 - Source zone + * @param zone2 - Destination zone + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateZoneToZone +( + OCI_Date * date, + const otext *zone1, + const otext *zone2 +); + +/** + * @brief + * Affect an OCI_Date handle value to ISO C time data types + * + * @param date - Date handle + * @param ptm - Pointer to a structure tm to receive date/time values + * @param pt - Pointer to a time_t to hold the date/time in the time_t format + * + * @note + * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateToCTime +( + OCI_Date * date, + struct tm *ptm, + time_t * pt +); + +/** + * @brief + * Affect ISO C time data types values to an OCI_Date handle + * + * @param date - Date handle + * @param ptm - Pointer to a structure tm that hold the date/time value + * @param t - Value (time_t) that hold the date/time in the time_t format + * + * @note + * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. + * If 'ptm' is not null, its value is affected to the OCI_Timestamp handle, + * otherwise the value of 't' is used. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DateFromCTime +( + OCI_Date * date, + struct tm *ptm, + time_t t +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiTimestamps Timestamps and intervals manipulation + * @{ + * + * OCILIB encapsulates Oracle : + * + * - SQL timestamp data type within OCI_Timestamp structure + * - SQL interval data type within OCI_Interval structure + * + * Basically, the OCI_Timestamp and OCI_Interval routines are wrappers around + * the Oracle OCIDatetime and OCIInterval APIs + * + * @par Examples + * @include timestamp.c + * + */ + +/** + * @brief + * Create a local Timestamp instance + * + * @param con - Connection handle + * @param type - Timestamp type + * + * @note + * From version 2.5.0, parameter 'con' can be NULL in order to manipulate + * timestamps independently from database connections + * + * @note + * Timestamp type can be : + * + * - OCI_TIMESTAMP : timestamp + * - OCI_TIMESTAMP_TZ : timestamp with time zone + * - OCI_TIMESTAMP_LTZ : timestamp with local time zone + * + * @return + * Return the Timestamp handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Timestamp * OCI_API OCI_TimestampCreate +( + OCI_Connection *con, + unsigned int type +); + +/** + * @brief + * Free an OCI_Timestamp handle + * + * @param tmsp - Timestamp handle + * + * @warning + * Only Timestamp created with OCI_TimestampCreate() should be freed by OCI_IntervalFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampFree +( + OCI_Timestamp *tmsp +); + +/** + * @brief + * Create an array of timestamp object + * + * @param con - Connection handle + * @param type - Timestamp type + * @param nbelem - number of elements in the array + * + * @note + * see OCI_TimestampCreate() for more details + * + * @return + * Return the timestamp handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Timestamp ** OCI_API OCI_TimestampArrayCreate +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +/** + * @brief + * Free an array of timestamp objects + * + * @param tmsps - Array of timestamp objects + * + * @warning + * Only arrays of timestamp created with OCI_TimestampArrayCreate() + * should be freed by OCI_TimestampArrayFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampArrayFree +( + OCI_Timestamp **tmsps +); + +/** + * @brief + * Return the type of the given Timestamp object + * + * @param tmsp - Timestamp handle + * + * @note + * For possible values, see OCI_TimestampCreate() + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_TimestampGetType +( + OCI_Timestamp *tmsp +); + +/** + * @brief + * Assign the value of a timestamp handle to another one + * + * @param tmsp - Destination Timestamp handle + * @param tmsp_src - Source Timestamp handle + * + * @note + * Both timestamp handles must be of the same type + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampAssign +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp_src +); + +/** + * @brief + * Check if the given timestamp is valid + * + * @param tmsp - Timestamp handle + * + * @return + * - Zero if the timestamp value is valid + * - Any other value means the timestamp value is invalid + * + */ + +OCI_EXPORT int OCI_API OCI_TimestampCheck +( + OCI_Timestamp *tmsp +); + +/** + * @brief + * Compares two timestamp handles + * + * @param tmsp - Timestamp1 handle + * @param tmsp2 - Timestamp2 handle + * + * @return + * - -1 if Timestamp1 is smaller than Timestamp2, + * - 0 if they are equal + * - 1 if Timestamp1 is greater than Timestamp2. + * + */ + +OCI_EXPORT int OCI_API OCI_TimestampCompare +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp2 +); + +/** + * @brief + * Set a timestamp handle value + * + * @param tmsp - Timestamp handle + * @param year - Year value + * @param month - Month value + * @param day - Day value + * @param hour - hour value + * @param min - minutes value + * @param sec - seconds value + * @param fsec - fractional part of seconds value + * @param time_zone - name of a time zone to use [optional] + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampConstruct +( + OCI_Timestamp *tmsp, + int year, + int month, + int day, + int hour, + int min, + int sec, + int fsec, + const otext * time_zone +); + +/** + * @brief + * Convert one timestamp value from one type to another. + * + * @param tmsp - Timestamp handle to convert + * @param tmsp_src - Timestamp handle to use for the type conversion + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampConvert +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp_src +); + +/** + * @brief + * Convert a string to a timestamp and store it in the given timestamp handle + * + * @param tmsp - Destination Timestamp handle + * @param str - Source date string + * @param fmt - Date format + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampFromText +( + OCI_Timestamp *tmsp, + const otext * str, + const otext * fmt +); + +/** + * @brief + * Convert a timestamp value from the given timestamp handle to a string + * + * @param tmsp - source Timestamp handle + * @param fmt - Timestamp format + * @param size - Destination string size in characters + * @param str - Destination date string + * @param precision - Precision for fractional part of the seconds + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampToText +( + OCI_Timestamp *tmsp, + const otext * fmt, + int size, + otext * str, + int precision +); + +/** + * @brief + * Extract the date part from a timestamp handle + * + * @param tmsp - Timestamp handle + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampGetDate +( + OCI_Timestamp *tmsp, + int * year, + int * month, + int * day +); + +/** + * @brief + * Extract the time portion from a timestamp handle + * + * @param tmsp - Timestamp handle + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * @param fsec - Place holder for fractional part of second value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampGetTime +( + OCI_Timestamp *tmsp, + int * hour, + int * min, + int * sec, + int * fsec +); + +/** + * @brief + * Extract the date and time parts from a date handle + * + * @param tmsp - Date handle + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * @param fsec - Place holder for fractional part of seconds value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampGetDateTime +( + OCI_Timestamp *tmsp, + int * year, + int * month, + int * day, + int * hour, + int * min, + int * sec, + int * fsec +); + +/** + * @brief + * Return the time zone name of a timestamp handle + * + * @param tmsp - Timestamp handle + * @param size - Destination string size in characters + * @param str - Destination zone name string + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampGetTimeZoneName +( + OCI_Timestamp *tmsp, + int size, + otext * str +); + +/** + * @brief + * Return the time zone (hour, minute) portion of a timestamp handle + * + * @param tmsp - Timestamp handle + * @param hour - Place holder for hour value + * @param min - Place holder for min value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampGetTimeZoneOffset +( + OCI_Timestamp *tmsp, + int * hour, + int * min +); + +/** + * @brief + * Add an interval value to a timestamp value of a timestamp handle + * + * @param tmsp - Timestamp handle + * @param itv - Interval handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampIntervalAdd +( + OCI_Timestamp *tmsp, + OCI_Interval * itv +); + +/** + * @brief + * Subtract an interval value from a timestamp value of a timestamp handle + * + * @param tmsp - Timestamp handle + * @param itv - Interval handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampIntervalSub +( + OCI_Timestamp *tmsp, + OCI_Interval * itv +); + +/** + * @brief + * Store the difference of two timestamp handles into an interval handle + * + * @param tmsp - Timestamp handle (subtrahend) + * @param tmsp2 - Timestamp2 handle (minuend) + * @param itv - Interval handle + * + * @note + * The function acts like tmsp - tmsp2 = itv + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampSubtract +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp2, + OCI_Interval * itv +); + +/** + * @brief + * Stores the system current date and time as a timestamp value with time zone + * into the timestamp handle. + * + * @param tmsp - Timestamp handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampSysTimestamp +( + OCI_Timestamp *tmsp +); + +/** + * @brief + * Affect an OCI_Timestamp handle value to ISO C time data types + * + * @param tmsp - Timestamp handle + * @param ptm - Pointer to a structure tm to receive date/time values + * @param pt - Pointer to a time_t to hold the date/time in the time_t format + * + * @note + * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampToCTime +( + OCI_Timestamp *tmsp, + struct tm * ptm, + time_t * pt +); + +/** + * @brief + * Affect ISO C time data types values to an OCI_Timestamp handle + * + * @param tmsp - Timestamp handle + * @param ptm - Pointer to a structure tm that hold the date/time value + * @param t - Value (time_t) that hold the date/time in the time_t format + * + * @note + * Both parameters 'ptm' and 'p' are optional but one of them has to be provided. + * If 'ptm' is not null, its value is affected to the OCI_Timestamp handle, + * otherwise the value of 't' is used. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TimestampFromCTime +( + OCI_Timestamp *tmsp, + struct tm * ptm, + time_t t +); + +/** + * @brief + * Create a local interval object + * + * @param con - Connection handle + * @param type - Type of Interval + * + * @note + * From version 2.5.0, parameter 'con' can be NULL in order to manipulate + * intervals independently from database connections + * + * @note + * Interval type can be : + * - OCI_INTERVAL_YM : year / month interval + * - OCI_INTERVAL_DS : date/ time interval + * + * @return + * Return the Interval handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Interval * OCI_API OCI_IntervalCreate +( + OCI_Connection *con, + unsigned int type +); + +/** + * @brief + * Free an OCI_Interval handle + * + * @param itv - Interval handle + * + * @warning + * Only Intervals created with OCI_IntervalCreate() should be freed by + * OCI_IntervalFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalFree +( + OCI_Interval *itv +); + +/** + * @brief + * Create an array of Interval object + * + * @param con - Connection handle + * @param type - Type of Interval + * @param nbelem - number of elements in the array + * + * @note + * see OCI_IntervalCreate() for more details + * + * @return + * Return the Interval handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Interval ** OCI_API OCI_IntervalArrayCreate +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +/** + * @brief + * Free an array of Interval objects + * + * @param itvs - Array of Interval objects + * + * @warning + * Only arrays of Interval created with OCI_IntervalArrayCreate() should be freed by + * OCI_IntervalArrayFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalArrayFree +( + OCI_Interval **itvs +); + +/** + * @brief + * Return the type of the given Interval object + * + * @param itv - Interval handle + * + * @note + * For possible values, see OCI_IntervalCreate() + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_IntervalGetType +( + OCI_Interval *itv +); + +/** + * @brief + * Assign the value of a interval handle to another one + * + * @param itv - Destination interval handle + * @param itv_src - Source interval handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalAssign +( + OCI_Interval *itv, + OCI_Interval *itv_src +); + +/** + * @brief + * Check if the given interval is valid + * + * @param itv - Interval handle + * + * @return + * - Zero if the interval value is valid + * - Any other value means the interval value is invalid + * + */ + +OCI_EXPORT int OCI_API OCI_IntervalCheck +( + OCI_Interval *itv +); + +/** + * @brief + * Compares two interval handles + * + * @param itv - Interval1 handle + * @param itv2 - Interval2 handle + * + * @return + * - -1 if interval1 is smaller than interval2, + * - 0 if they are equal + * - 1 if interval1 is greater than interval2. + * + */ + +OCI_EXPORT int OCI_API OCI_IntervalCompare +( + OCI_Interval *itv, + OCI_Interval *itv2 +); + +/** + * @brief + * Convert a string to an interval and store it in the given interval handle + * + * @param itv - Destination interval handle + * @param str - Source date string + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalFromText +( + OCI_Interval *itv, + const otext * str +); + +/** + * @brief + * Convert an interval value from the given interval handle to a string + * + * @param itv - source Interval handle + * @param leading_prec - Precision of the leading part + * @param fraction_prec - Precision of the fractional part + * @param size - Destination string size in characters + * @param str - Destination date string + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalToText +( + OCI_Interval *itv, + int leading_prec, + int fraction_prec, + int size, + otext * str +); + +/** + * @brief + * Correct an interval handle value with the given time zone + * + * @param itv - Interval handle + * @param str - Time zone name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalFromTimeZone +( + OCI_Interval *itv, + const otext * str +); + +/** + * @brief + * Return the day / time portion of an interval handle + * + * @param itv - Interval handle + * @param day - Place holder for day value + * @param hour - Place holder for hours value + * @param min - Place holder for minutes value + * @param sec - Place holder for seconds value + * @param fsec - Place holder for fractional part of seconds value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalGetDaySecond +( + OCI_Interval *itv, + int * day, + int * hour, + int * min, + int * sec, + int * fsec +); + +/** + * @brief + * Return the year / month portion of an interval handle + * + * @param itv - Interval handle + * @param year - Place holder for year value + * @param month - Place holder for month value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalGetYearMonth +( + OCI_Interval *itv, + int * year, + int * month +); + +/** + * @brief + * Set the day / time portion if the given interval handle + * + * @param itv - Interval handle + * @param day - day value + * @param hour - Hour value + * @param min - Minute value + * @param sec - Second value + * @param fsec - Fractional part of the seconds + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalSetDaySecond +( + OCI_Interval *itv, + int day, + int hour, + int min, + int sec, + int fsec +); + +/** + * @brief + * Set the year / month portion if the given Interval handle + * + * @param itv - Interval handle + * @param year - Year value + * @param month - Month value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalSetYearMonth +( + OCI_Interval *itv, + int year, + int month +); + +/** + * @brief + * Adds an interval handle value to another + * + * @param itv - Interval handle from witch to add + * @param itv2 - Interval handle to add + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalAdd +( + OCI_Interval *itv, + OCI_Interval *itv2 +); + +/** + * @brief + * Subtract an interval handle value from another + * + * @param itv - Interval handle from witch to remove + * @param itv2 - Interval handle to remove + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_IntervalSubtract +( + OCI_Interval *itv, + OCI_Interval *itv2 +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiUserTypes Oracle Named Types (Oracle OBJECTs) + * @{ + * + * OCILIB implements Oracle Named types (user types and built-in types) through + * the OCI_Object type. + * + * OTT and C structures are not required to use objects in OCILIB. + * + * In order to manipulate objects attributes, OCILIB proposes a set of functions + * to get/set properties for various supported types. + * + * Objects can be: + * - Created as standalone instances (transient objects) + * - Used for binding (persistent / transient objects) + * - Retrieved from select statements (persistent / embedded objects) + * + * References (Oracle type REF) are identifiers (smart pointers) to objects and + * are implemented in OCILIB with the type OCI_Ref. + * + * OCILIB implements Oracle REFs as strong typed Reference (underlying OCI REFs + * are weaker in terms of typing). + * It means it's mandatory to provide type information to: + * - create a local OCI_Ref handle. + * - register an OCI_Ref handle for a 'returning into' clause. + * + * @note + * See Oracle Database SQL Language Reference for more details about REF data type + * + * @warning + * Prior to v3.5.0, OCILIB relied on some OCI routines to set/get objects + * attributes. these OCI calls had known bugs in Unicode mode that has been fixed in Oracle 11gR2. + * From v3.5.0, OCILIB directly sets objects attributes and thus OCILIB objects + * can now be used in Unicode mode. + * + * @par Example : Inserting a local object into a table + * @include object.c + * + * @par Example : Using Object References + * @include ref.c + * + */ + +/** + * @brief + * Create a local object instance + * + * @param con - Connection handle + * @param typinf - Object type (type info handle) + * + * @return + * Return the object handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_ObjectCreate +( + OCI_Connection *con, + OCI_TypeInfo * typinf +); + +/** + * @brief + * Free a local object + * + * @param obj - Object handle + * + * @warning + * Only object created with OCI_ObjectCreate() should be freed + * by OCI_ObjectFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectFree +( + OCI_Object *obj +); + +/** + * @brief + * Create an array of Object objects + * + * @param con - Connection handle + * @param typinf - Object type (type info handle) + * @param nbelem - number of elements in the array + * + * @note + * see OCI_ObjectCreate() for more details + * + * @return + * Return the Object handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Object ** OCI_API OCI_ObjectArrayCreate +( + OCI_Connection *con, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +/** + * @brief + * Free an array of Object objects + * + * @param objs - Array of Object objects + * + * @warning + * Only arrays of Object created with OCI_ObjectArrayCreate() + * should be freed by OCI_ObjectArrayFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectArrayFree +( + OCI_Object **objs +); + +/** + * @brief + * Assign an object to another one + * + * @param obj - Destination Object handle + * @param obj_src - Source Object handle + * + * @note + * Oracle proceeds to a deep copy of the object content + * + * @note + * The two object handles must have the same type otherwise an exception is thrown + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectAssign +( + OCI_Object *obj, + OCI_Object *obj_src +); + +/** + * @brief + * Return the type of an object instance + * + * @param obj - Object handle + * + * @note + * Possibles values are : + * + * - OCI_OBJ_PERSISTENT: persistent object from the DB + * - OCI_OBJ_TRANSIENT : local temporary object + * - OCI_OBJ_VALUE : embedded object + * + * @return + * Instance type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ObjectGetType +( + OCI_Object *obj +); + +/** + * @brief + * Retrieve an Oracle Ref handle from an object and assign it to the given + * OCILIB OCI_Ref handle + * + * @param obj - Object handle + * @param ref - Ref handle + * + * @note + * The type information of the object and the ref must be the same, otherwise + * an exception is thrown + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectGetSelfRef +( + OCI_Object *obj, + OCI_Ref * ref +); + +/** + * @brief + * Return the type info object associated to the object + * + * @param obj - Object handle + * + */ + +OCI_EXPORT OCI_TypeInfo * OCI_API OCI_ObjectGetTypeInfo +( + OCI_Object *obj +); + +/** + * @brief + * Return the boolean value of the given object attribute (ONLY for PL/SQL records) + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetBoolean() returns a valid value only for PL/SQL boolean based attributes + * + * @warning + * - ONLY supported by Oracle 12c and above ! + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectGetBoolean +( + OCI_Object * obj, + const otext *attr +); + +/** +* @brief +* Return the number value of the given object attribute +* +* @param obj - Object handle +* @param attr - Attribute name +* +* @note +* If the attribute is found in the object descriptor attributes list, then a +* data type check is performed for integrity. +* OCI_ObjectGetNumber() returns a valid value only for number based attributes +* +* @return +* Attribute value or NULL on failure or wrong attribute type +* +*/ + +OCI_EXPORT OCI_Number * OCI_API OCI_ObjectGetNumber +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the short value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetShort() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT short OCI_API OCI_ObjectGetShort +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the unsigned short value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetUnsignedShort() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT unsigned short OCI_API OCI_ObjectGetUnsignedShort +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the integer value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetInt() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT int OCI_API OCI_ObjectGetInt +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the unsigned integer value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetUnsignedInt() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_ObjectGetUnsignedInt +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the big integer value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetBigInt() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT big_int OCI_API OCI_ObjectGetBigInt +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the unsigned big integer value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetUnsignedBigInt() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT big_uint OCI_API OCI_ObjectGetUnsignedBigInt +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the double value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetDouble() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0.0 on failure or wrong attribute type + * + */ + +OCI_EXPORT double OCI_API OCI_ObjectGetDouble +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the float value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetFloat() returns a valid value only for integer and number based attributes + * + * @return + * Attribute value or 0.0 on failure or wrong attribute type + * + */ + +OCI_EXPORT float OCI_API OCI_ObjectGetFloat +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the string value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * The method can return a string value for any attributes types. + * It performs implicit string conversions using the same + * mechanisms than OCI_GetString(). See its documentation for more details. + * + * @return + * Attribute value or NULL on failure + * + */ + +OCI_EXPORT const otext * OCI_API OCI_ObjectGetString +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the raw attribute value of the given object attribute into the + * given buffer + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Destination buffer + * @param len - Max size to write into buffer + + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetRaw() copies data into the buffer only for raw based attributes + * + * @return + * Number of bytes written to the buffer or 0 on failure or wrong attribute type + * + */ + +OCI_EXPORT int OCI_API OCI_ObjectGetRaw +( + OCI_Object * obj, + const otext *attr, + void * value, + unsigned int len +); + +/** +* @brief +* Return the raw attribute value size of the given object attribute into the +* given buffer +* +* @param obj - Object handle +* @param attr - Attribute name +* +* @note +* If the attribute is found in the object descriptor attributes list, then a +* data type check is performed for integrity. +* +* @return +* size in bytes of the RAW value or 0 on failure or wrong attribute type +* +*/ + +OCI_EXPORT unsigned int OCI_API OCI_ObjectGetRawSize +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the date value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetDate() returns a valid value only for date based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Date * OCI_API OCI_ObjectGetDate +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the timestamp value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetTimestamp() returns a valid value only for timestamps based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Timestamp * OCI_API OCI_ObjectGetTimestamp +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the interval value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetInterval() returns a valid value only for intervals based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Interval * OCI_API OCI_ObjectGetInterval +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the collection value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetColl() returns a valid value only for intervals based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Coll * OCI_API OCI_ObjectGetColl +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the Ref value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetRef() returns a valid value only for Refs based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Ref * OCI_API OCI_ObjectGetRef +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the object value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetObject() returns a valid value only for object based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_ObjectGetObject +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the lob value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetLob() returns a valid value only for lobs based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_Lob * OCI_API OCI_ObjectGetLob +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Return the file value of the given object attribute + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @note + * If the attribute is found in the object descriptor attributes list, then a + * data type check is performed for integrity. + * OCI_ObjectGetFile() returns a valid value only for files based attributes + * + * @return + * Attribute value or NULL on failure or wrong attribute type + * + */ + +OCI_EXPORT OCI_File * OCI_API OCI_ObjectGetFile +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Set an object attribute of type boolean (ONLY for PL/SQL records) + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - boolean value + * + * @warning + * - ONLY supported by Oracle 12c and above ! + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetBoolean +( + OCI_Object * obj, + const otext *attr, + boolean value +); + +/** +* @brief +* Set an object attribute of type number +* +* @param obj - Object handle +* @param attr - Attribute name +* @param value - number value +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetNumber +( + OCI_Object * obj, + const otext *attr, + OCI_Number * value +); + +/** + * @brief + * Set an object attribute of type short + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Short value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetShort +( + OCI_Object * obj, + const otext *attr, + short value +); + +/** + * @brief + * Set an object attribute of type unsigned short + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Unsigned short value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetUnsignedShort +( + OCI_Object * obj, + const otext * attr, + unsigned short value +); + +/** + * @brief + * Set an object attribute of type int + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetInt +( + OCI_Object * obj, + const otext *attr, + int value +); + +/** + * @brief + * Set an object attribute of type unsigned int + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Unsigned int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetUnsignedInt +( + OCI_Object * obj, + const otext *attr, + unsigned int value +); + +/** + * @brief + * Set an object attribute of type big int + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Big int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetBigInt +( + OCI_Object * obj, + const otext *attr, + big_int value +); + +/** + * @brief + * Set an object attribute of type unsigned big int + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Unsigned big int value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetUnsignedBigInt +( + OCI_Object * obj, + const otext *attr, + big_uint value +); + +/** + * @brief + * Set an object attribute of type double + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Double value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetDouble +( + OCI_Object * obj, + const otext *attr, + double value +); + +/** + * @brief + * Set an object attribute of type float + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Float value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetFloat +( + OCI_Object * obj, + const otext *attr, + float value +); + +/** + * @brief + * Set an object attribute of type string + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - String value + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetString +( + OCI_Object * obj, + const otext *attr, + const otext *value +); + +/** + * @brief + * Set an object attribute of type RAW + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Raw value + * @param len - Size of the raw value + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetRaw +( + OCI_Object * obj, + const otext *attr, + void * value, + unsigned int len +); + +/** + * @brief + * Set an object attribute of type Date + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Date Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetDate +( + OCI_Object * obj, + const otext *attr, + OCI_Date * value +); + +/** + * @brief + * Set an object attribute of type Timestamp + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Timestamp Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetTimestamp +( + OCI_Object * obj, + const otext * attr, + OCI_Timestamp *value +); + +/** + * @brief + * Set an object attribute of type Interval + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Interval Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetInterval +( + OCI_Object * obj, + const otext * attr, + OCI_Interval *value +); + +/** + * @brief + * Set an object attribute of type Collection + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Collection Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetColl +( + OCI_Object * obj, + const otext *attr, + OCI_Coll * value +); + +/** + * @brief + * Set an object attribute of type Object + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Object Handle + * + * @warning + * This function assigns a copy of the object to the given attribute. + * Any further modifications of the object passed as the parameter 'value' + * will not be reflected to object 's attribute set with this call + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetObject +( + OCI_Object * obj, + const otext *attr, + OCI_Object * value +); + +/** + * @brief + * Set an object attribute of type Lob + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Lob Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetLob +( + OCI_Object * obj, + const otext *attr, + OCI_Lob * value +); + +/** + * @brief + * Set an object attribute of type File + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - File Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetFile +( + OCI_Object * obj, + const otext *attr, + OCI_File * value +); + +/** + * @brief + * Set an object attribute of type Ref + * + * @param obj - Object handle + * @param attr - Attribute name + * @param value - Ref Handle + * + * @note + * passing a null pointer for value calls OCI_ObjectSetNull() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetRef +( + OCI_Object * obj, + const otext *attr, + OCI_Ref * value +); + +/** + * @brief + * Check if an object attribute is null + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @return + * FALSE if the attribute is not null otherwise TRUE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectIsNull +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Set an object attribute to null + * + * @param obj - Object handle + * @param attr - Attribute name + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectSetNull +( + OCI_Object * obj, + const otext *attr +); + +/** + * @brief + * Retrieve the underlying C (OTT/OCI style) structure of an OCI_Object handle + * + * @param obj - Object handle + * @param pp_struct - Address of a pointer that retrieve the C structure of data + * @param pp_ind - Address of a pointer that retrieve the C structure of indicators + * + * @note + * See Oracle OCI programming guide for more details about OTT structures. + * The members of these structures are OCI data types like OCINumber, OCIString + * that requires mixing OCILIB code and raw OCI code. + * OCI Object API headers have to be included to handle this data types using OCI object functions + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectGetStruct +( + OCI_Object *obj, + void ** pp_struct, + void ** pp_ind +); + +/** + * @brief + * Convert an object handle value to a string + * + * @param obj - Object handle + * @param size - Destination string length pointer in characters + * @param str - Destination string + * + * @note + * In order to compute the needed string length, call the method with a NULL string + * Then call the method again with a valid buffer + * + * @note + * The resulting string is similar to the SQL*PLUS output for UDTs (user types and objects) + * For RAWs and BLOBs attributes, their binary values are converted to hexadecimal strings + * + * @warning + * This convenient method shall not be used when performance matters. It is usually called twice (buffer length + * computation) and must also care about quotes within strings. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ObjectToText +( + OCI_Object * obj, + unsigned int *size, + otext * str +); + +/** + * @brief + * Create a local Ref instance + * + * @param con - Connection handle + * @param typinf - Ref type + * + * @return + * Return the Ref handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Ref * OCI_API OCI_RefCreate +( + OCI_Connection *con, + OCI_TypeInfo * typinf +); + +/** + * @brief + * Free a local Ref + * + * @param ref - Ref handle + * + * @warning + * Only Refs created with OCI_RefCreate() should be freed + * by OCI_RefFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RefFree +( + OCI_Ref *ref +); + +/** + * @brief + * Create an array of Ref object + * + * @param con - Connection handle + * @param typinf - Object type (type info handle) + * @param nbelem - number of elements in the array + * + * @note + * see OCI_RefCreate() for more details + * + * @return + * Return the Ref handle array on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Ref ** OCI_API OCI_RefArrayCreate +( + OCI_Connection *con, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +/** + * @brief + * Free an array of Ref objects + * + * @param refs - Array of Ref objects + * + * @warning + * Only arrays of Ref created with OCI_RefArrayCreate() + * should be freed by OCI_RefArrayFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RefArrayFree +( + OCI_Ref **refs +); + +/** + * @brief + * Assign a Ref to another one + * + * @param ref - Destination Ref handle + * @param ref_src - Source Ref handle + * + * @note + * The two Ref handles must have the same type otherwise an exception is thrown + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RefAssign +( + OCI_Ref *ref, + OCI_Ref *ref_src +); + +/** + * @brief + * Return the type info object associated to the Ref + * + * @param ref - Ref handle + * + */ + +OCI_EXPORT OCI_TypeInfo * OCI_API OCI_RefGetTypeInfo +( + OCI_Ref *ref +); + +/** + * @brief + * Returns the object pointed by the Ref handle. + * + * @param ref - Ref handle + * + * @return + * The object handle is the ref is not null otherwise NULL + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_RefGetObject +( + OCI_Ref *ref +); + +/** + * @brief + * Check if the Ref points to an object or not. + * + * @param ref - Ref handle + * + * @return + * TRUE if it does not point to a valid object otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RefIsNull +( + OCI_Ref *ref +); + +/** + * @brief + * Nullify the given Ref handle + * + * @param ref - Ref handle + * + * @note + * this call clears the reference to object pointed by the Ref handle. + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_RefSetNull +( + OCI_Ref *ref +); + +/** + * @brief + * Returns the size of the hex representation of the given Ref handle + * + * @param ref - Ref handle + * + * @note + * the returned size is the number of character needed to store the + * hex representation of the Ref that can be retrieved with OCI_RefToText() + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_RefGetHexSize +( + OCI_Ref *ref +); + +/** + * @brief + * Converts a Ref handle value to a hexadecimal string. + * + * @param ref - Ref handle + * @param size - Destination string size in characters + * @param str - Destination string + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_RefToText +( + OCI_Ref * ref, + unsigned int size, + otext * str +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiAbort Aborting long operations + * @{ + * + * The Oracle OCI provides the ability to establish a server connection in : + * + * - blocking mode: each call to an OCI function returns control to the + * application when the call completes + * - non-blocking mode (based on polling paradigm) : the application have to + * call each function until its has completed its job + * + * OCILIB implements OCI in blocking mode. The application has to wait for OCI + * calls to complete to continue. + * + * Some operations can be long to be processed by the server. + * + * In order to cancel the current pending call, OCILIB provides OCI_Break() that + * cancel the last internal OCI Call and then raise an OCI abortion error code. + * + * @note + * Any call to OCI_Break() has to be done from a separate thread because the + * thread that has executed a long OCI call is waiting for its OCI call to complete. + * + * @par Example + * @include abort.c + * + */ + +/** + * @brief + * Perform an immediate abort of any currently Oracle OCI call + * + * @param con - connection handle + * + * @note + * The current call will abort and generate an error + * + * @return + * Returns FALSE if connection handle is NULL otherwise TRUE + */ + +OCI_EXPORT boolean OCI_API OCI_Break +( + OCI_Connection *con +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiMetadata Describing Schema Meta data and Objects + * @{ + * + * + * @par Example + * @include desc.c + * + */ + +/** + * @brief + * Retrieve the available type info information + * + * @param con - Connection handle + * @param name - Table/view name to query for + * @param type - Type of object + * + * @note + * Possible values for parameter type are : + * + * - OCI_UNKNOWN + * - OCI_TIF_TABLE + * - OCI_TIF_VIEW + * - OCI_TIF_TYPE + * + * @return + * - Type info handle on success + = - NULL if the object does not exist + * - NULL on failure + * + */ + +OCI_EXPORT OCI_TypeInfo * OCI_API OCI_TypeInfoGet +( + OCI_Connection *con, + const otext * name, + unsigned int type +); + +/** + * @brief + * Return the type of the type info object + * + * @param typinf - Type info handle + * + * @note + * Possible values for parameter type are : + * + * - OCI_UNKNOWN + * - OCI_TIF_TABLE + * - OCI_TIF_VIEW + * - OCI_TIF_TYPE + * + * @return + * Object type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetType +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Retrieve connection handle from the type info handle + * + * @param typinf - Type info handle + * + */ + +OCI_EXPORT OCI_Connection * OCI_API OCI_TypeInfoGetConnection +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Free a type info object + * + * @param typinf - Type info handle + * + * @note + * this call is optional. + * OCI_TypeInfo object are internally tracked and + * automatically freed when their related connection is freed + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_TypeInfoFree +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Return the number of columns of a table/view/object + * + * @param typinf - Type info handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_TypeInfoGetColumnCount +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Return the column object handle at the given index in the table + * + * @param typinf - Type info handle + * @param index - Column position + * + * @return + * - Column handle on success + * - NULL if index is out of bounds or on error + * + */ + +OCI_EXPORT OCI_Column * OCI_API OCI_TypeInfoGetColumn +( + OCI_TypeInfo *typinf, + unsigned int index +); + +/** + * @brief + * Return the name described by the type info object + * + * @param typinf - Type info handle + * + */ + +OCI_EXPORT const otext * OCI_API OCI_TypeInfoGetName +( + OCI_TypeInfo *typinf +); + +/** +* @brief +* Indicate if the given UDT type if final +* +* @note +* Non-final types are virtual UDT type that can be inherited +* +* @param typinf - Type info handle +* +* @note +* This property is only valid for UDTs (OCI_TIF_TYPE) +* +* @return +* - when OCI_TypeInfoGetType() returns OCI_UNKNOWN, OCI_TIF_TABLE, OCI_TIF_VIEW: returns TRUE +* - when OCI_TypeInfoGetType() returns OCI_TIF_TYPE: returns TRUE if the type is final and FALSE if it is virtual +* +*/ + +OCI_EXPORT boolean OCI_API OCI_TypeInfoIsFinalType +( + OCI_TypeInfo *typinf +); + +/** +* @brief +* Return the super type of the given type (e.g. parent type for a derived ORACLE UDT type) +* +* @param typinf - Type info handle +* +* @note +* This property is only valid for UDTs (OCI_TIF_TYPE) +* +* @return +* - when OCI_TypeInfoGetType() returns OCI_UNKNOWN, OCI_TIF_TABLE, OCI_TIF_VIEW: +* - returns NULL +* - when OCI_TypeInfoGetType() returns OCI_TIF_TYPE: +* - returns the TypeInfo handle wrapping the parent super type +* - returns NULL if the given type is NOT deriving from a base type +* +*/ + +OCI_EXPORT OCI_TypeInfo * OCI_API OCI_TypeInfoGetSuperType +( + OCI_TypeInfo *typinf +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiFormatting Formatted functions + * @{ + * + * OCILIB offers some smart routines that takes a variable number of arguments + * in order to minimize OCILIB function calls and reduce the amount of code lines + * + * On Windows platforms, the target programming language must support the __cdecl + * calling convention + * + * @note + * OCI_Immediate() and OCI_ImmediateFmt() support all OCILIB supported types + * for output result, except : + * - OCI_Long + * - OCI_Statement + * If a query output result contains one of these unsupported types, the function returns FALSE + * + * @note + * In the parameter list, every output placeholder MUST be preceded by + * an integer parameter that indicates the type of the placeholder + * in order to handle correctly the given pointer. + * + * Possible values for indicating placeholders type : + * + * - OCI_ARG_SHORT ------> short * + * - OCI_ARG_USHORT -----> unsigned short * + * - OCI_ARG_INT --------> int * + * - OCI_ARG_UINT -------> unsigned int* + * - OCI_ARG_BIGINT -----> big_int * + * - OCI_ARG_BIGUINT ----> unsigned big_int * + * - OCI_ARG_DOUBLE ----> double * + * - OCI_ARG_FLOAT ------> float * + * - OCI_ARG_NUMBER -----> OCI_Number * + * - OCI_ARG_TEXT -------> otext * + * - OCI_ARG_RAW --------> void * + * - OCI_ARG_DATETIME ---> OCI_Date * + * - OCI_ARG_LOB --------> OCI_Lob * + * - OCI_ARG_FILE -------> OCI_File * + * - OCI_ARG_TIMESTAMP --> OCI_Timestamp * + * - OCI_ARG_INTERVAL ---> OCI_Interval * + * - OCI_ARG_OBJECT -----> OCI_Object * + * - OCI_ARG_COLLECTION -> OCI_Coll * + * - OCI_ARG_REF --------> OCI_Ref * + * + * @note + * For output strings and Raws, returned data is copied to the given buffer + * instead of returning a pointer the real data. + * So these buffers must be big enough to hold the column content. No size check is performed. + * + * - For strings, only the real string is copied. + * - For Raws, the number of bytes copied is the column size + * + * @warning + * Input parameters for formatted function only support a restricted set of data types ! + * + * Supported input identifiers : + * + * - '%s' : (otext *) ----------> input string (quotes are added) + * - '%m' : (otext *) ----------> meta data string (no quotes added) + * - '%t' : (OCI_Date *) -------> Date + * - '%p' : (OCI_Timestamp *) --> timestamp + * - '%v' : (OCI_Interval *) ---> Interval + * - '%i' : (int) --------------> signed 32 bits integer + * - '%u' : (unsigned int) -----> unsigned 32 bits integer + * - '%li' : (big_int) ----------> signed 64 bits integer + * - '%lu' : (big_uint) ---------> unsigned 64 bits integer + * - '%hi' : (short) ------------> signed 16 bits integer + * - '%hu' : (unsigned short) ---> unsigned 16 bits integer + * - '%g' : (double, float ) ---> Numerics + * - '%n' : (OCI_Number *) -----> Number + * - '%r' : (OCI_Ref *) --------> Reference + * - '%o' : (OCI_Object *) -----> Object (not implemented yet) + * - '%c' : (OCI_Coll *) -------> collection (not implemented yet) + * + * @par Example + * @include format.c + * + */ + +/** + * @brief + * Perform 3 calls (prepare+execute+fetch) in 1 call + * + * @param con - Connection handle + * @param sql - SQL statement + * @param ... - List of program variables address to store the result of fetch operation + * + * @note + * Every output parameter MUST be preceded by an integer parameter that indicates the type + * of the placeholder in order to handle correctly the given pointer. + * + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_Immediate +( + OCI_Connection *con, + const otext * sql, + ... +); + +/** + * @brief + * Performs 4 call (prepare+bind+execute+fetch) in 1 call + * + * @param con - Connection handle + * @param sql - SQL statement + * @param ... - List of program values to format the SQL followed by the + * output variables addresses for the fetch operation + * + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_ImmediateFmt +( + OCI_Connection *con, + const otext * sql, + ... +); + +/** + * @brief + * Prepare a formatted SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * @param sql - SQL statement + * @param ... - List of program values to format the SQL + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_PrepareFmt +( + OCI_Statement *stmt, + const otext * sql, + ... +); + +/** + * @brief + * Execute a formatted SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * @param sql - SQL statement + * @param ... - List of program values to format the SQL + * + * @return + * TRUE on success otherwise FALSE + * + * @warning + * If a SQL warning occurs: + * - the function returns TRUE + * - the SQL warning triggers the global error handler with an OCI_Error having its OCI_ErrorGetType() + * attribute set to OCI_ERR_WARNING + * - If OCILIB is initialized with the OCI_ENV_CONTEXT mode, OCI_GetLastError() will return the OCI_Error + * object corresponding to the warning + * + */ + +OCI_EXPORT boolean OCI_ExecuteStmtFmt +( + OCI_Statement *stmt, + const otext * sql, + ... +); + +/** + * @brief + * Parse a formatted SQL statement or PL/SQL block. + * + * @param stmt - Statement handle + * @param sql - SQL statement + * @param ... - List of program values to format the SQL + * + * @note + * This call sends the SQL or PL/SQL command to the server for parsing only. + * The command is not executed. + * This call is only useful to check is a command is valid or not. + * + * @note + * This call prepares the statement (internal call to OCI_Prepare()) and ask + * the Oracle server to parse its SQL or PL/SQL command. + * OCI_Execute() can be call after OCI_ParseFmt() in order to execute the + * statement, which means that the server will re-parse again the command. + * + * @warning + * Do not use OCI_ParseFmt() unless you're only interested in the parsing result + * because the statement will be parsed again when executed and thus leading to + * unnecessary server round-trips and less performance + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_ParseFmt +( + OCI_Statement *stmt, + const otext * sql, + ... +); + +/** + * @brief + * Describe the select list of a formatted SQL select statement. + * + * @param stmt - Statement handle + * @param sql - SQL statement + * @param ... - List of program values to format the SQL + * + * @note + * This call sends the SELECT SQL order to the server for retrieving the + * description of the select order only. + * The command is not executed. + * This call is only useful to retrieve information on the associated resultset + * Call OCI_GetResultset() after OCI_Describe() to access to SELECT list + * information + * + * @note + * This call prepares the statement (internal call to OCI_Prepare()) and ask + * the Oracle server to describe the output SELECT list. + * OCI_Execute() can be call after OCI_Describe() in order to execute the + * statement, which means that the server will parse, and describe again the SQL + * order. + * + * @warning + * Do not use OCI_Describe() unless you're only interested in the resultset + * information because the statement will be parsed again when executed and thus + * leading to unnecessary server round-trips and less performance + * + * @return + * TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_DescribeFmt +( + OCI_Statement *stmt, + const otext * sql, + ... +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiHashTables Hash tables + * @{ + * + * OCILIB uses hash tables internally for index/name columns mapping. + * + * OCILIB makes public its hash table’s implementation public for general purpose + * uses. + * + * OCI_HashTable objects manage string keys / values that can be : + * + * - integers + * - strings + * - pointers + * + * This hash table implementation : + * + * - handle collisions + * - allows multiple values per key + * + * @par Internal conception + * + * - The hash table is composed of an array of slots. + * - Each slot can hold a linked list of entries (one per key) + * - Each entry can hold a linked list of values + * + * @note + * - The internal hash function computes the index in the array where the entry + * has to be inserted/looked up. + * + * + * @note + * Collisions are handled by chaining method. + * + * @include hash.c + * + */ + +/** + * @brief + * Create a hash table + * + * @param size - size of the hash table + * @param type - type of the hash table + * + * @note + * Parameter can be one of the following values : + * + * - OCI_HASH_STRING : string values + * - OCI_HASH_INTEGER : integer values + * - OCI_HASH_POINTER : pointer values + * + * @return + * Hash handle on success or NULL on failure + * + */ + +OCI_EXPORT OCI_HashTable * OCI_API OCI_HashCreate +( + unsigned int size, + unsigned int type +); + +/** + * @brief + * Destroy a hash table + * + * @param table - Table handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_HashFree +( + OCI_HashTable *table +); + +/** + * @brief + * Return the size of the hash table + * + * @param table - Table handle + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_HashGetSize +( + OCI_HashTable *table +); + +/** + * @brief + * Return the type of the hash table + * + * @param table - Table handle + * + * @note + * the return value can be one of the following values : + * + * - OCI_HASH_STRING : string values + * - OCI_HASH_INTEGER : integer values + * - OCI_HASH_POINTER : pointer values + * + * @return + * Hash table data type or OCI_UNKNOWN the input handle is NULL + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_HashGetType +( + OCI_HashTable *table +); + +/** + * @brief + * Add a pair string key / string value to the hash table + * + * @param table - Table handle + * @param key - String key + * @param value - string value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_HashAddString +( + OCI_HashTable *table, + const otext * key, + const otext * value +); + +/** + * @brief + * Return the string value associated to the given key + * + * @param table - Table handle + * @param key - String key + * + * @return + * Stored string associated with the key otherwise NULL + * + */ + +OCI_EXPORT const otext * OCI_API OCI_HashGetString +( + OCI_HashTable *table, + const otext * key +); + +/** + * @brief + * Adds a pair string key / integer value to the hash table + * + * @param table - Table handle + * @param key - String key + * @param value - Integer value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_HashAddInt +( + OCI_HashTable *table, + const otext * key, + int value +); + +/** + * @brief + * Return the integer value associated to the given key + * + * @param table - Table handle + * @param key - String key + * + * @return + * Stored integer associated with the key otherwise 0 + * + */ + +OCI_EXPORT int OCI_API OCI_HashGetInt +( + OCI_HashTable *table, + const otext * key +); + +/** + * @brief + * Adds a pair string key / pointer value to the hash table + * + * @param table - Table handle + * @param key - String key + * @param value - Pointer value + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_HashAddPointer +( + OCI_HashTable *table, + const otext * key, + void * value +); + +/** + * @brief + * Return a pointer associated with the given key + * + * @param table - Table handle + * @param key - String key + * + * @return + * Stored pointer associated with the key otherwise NULL + * + */ + +OCI_EXPORT void * OCI_API OCI_HashGetPointer +( + OCI_HashTable *table, + const otext * key +); + +/** + * @brief + * Lookup for an entry matching the key in the table + * + * @param table - Table handle + * @param key - String key + * @param create - Do create the entry if not exists + * + * @return + * Entry handle if key found/added otherwise NULL + * + */ + +OCI_EXPORT OCI_HashEntry * OCI_API OCI_HashLookup +( + OCI_HashTable *table, + const otext * key, + boolean create +); + +/** + * @brief + * Return the first hash slot that matches the key + * + * @param table - Table handle + * @param key - String key + * + * @return + * Slot handle if key found otherwise NULL + * + */ + +OCI_EXPORT OCI_HashValue * OCI_API OCI_HashGetValue +( + OCI_HashTable *table, + const otext * key +); + +/** + * @brief + * Return the entry slot of the hash table internal list at the given position + * + * @param table - Table handle + * @param index - index + * + * @warning + * Index start at at + * + * @return + * Slot handle otherwise NULL + * + */ + +OCI_EXPORT OCI_HashEntry * OCI_API OCI_HashGetEntry +( + OCI_HashTable *table, + unsigned int index +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiThreading Threads and mutexes + * @{ + * + * Oracle proposes a portable implementation of Mutex and Thread objects + * + * OCILIB implements these OCI features for portable multi-threading support. + * + * Mutexes are designed for mutual exclusion between thread in order to lock resources temporarily + * + * Thread keys can be seen as process-wide variables that have a thread-specific + * values. It allows to create a unique key identified by a name (string) that + * can store values specific to each thread. + * + * OCILIB exposes the types OCI_Mutex, OCI_Thread + * + * @warning + * OCILIB MUST be initialized with OCI_ENV_THREADED to enable threads support + * + * @warning + * OCI_Thread relies on Oracle API which uses natives threading capabilities of + * the supported platform + * + * @warning + * Using OCI_Mutex : + * - On Microsoft Windows, a thread can call OCI_MutexAcquire() more than once + * without any blocking. Just be sure that there is an OCI_MutexRelease() for + * every OCI_MutexAcquire() call + * - On Unix systems, a thread MUST call OCI_MutexRelease() after every call to + * OCI_MutexAcquire() in order to be able to call OCI_MutexAcquire() again. If + * not, it will be blocked... + * + * @par Example + * @include thread.c + * + */ + +/** + * @brief + * Create a Mutex object + * + * @return + * Mutex handle on success or NULL on failure + * + */ + +OCI_EXPORT OCI_Mutex * OCI_API OCI_MutexCreate +( + void +); + +/** + * @brief + * Destroy a mutex object + * + * @param mutex - Mutex handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MutexFree +( + OCI_Mutex *mutex +); + +/** + * @brief + * Acquire a mutex lock + * + * @param mutex - Mutex handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MutexAcquire +( + OCI_Mutex *mutex +); + +/** + * @brief + * Release a mutex lock + * + * @param mutex - Mutex handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MutexRelease +( + OCI_Mutex *mutex +); + +/** + * @brief + * Create a Thread object + * + * @return + * Thread handle on success or NULL on failure + * + */ + +OCI_EXPORT OCI_Thread * OCI_API OCI_ThreadCreate +( + void +); + +/** + * @brief + * Destroy a thread object + * + * @param thread - Thread handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ThreadFree +( + OCI_Thread *thread +); + +/** + * @brief + * Execute the given routine within the given thread object + * + * @param thread - Thread handle + * @param proc - routine to execute + * @param arg - parameter to pass to the routine + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ThreadRun +( + OCI_Thread *thread, + POCI_THREAD proc, + void * arg +); + +/** + * @brief + * Join the given thread + * + * @param thread - Thread handle + * + * @note + * This function waits for the given thread to finish + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ThreadJoin +( + OCI_Thread *thread +); + +/** + * @brief + * Create a thread key object + * + * @param name - Thread key name + * @param destfunc - Thread key value destructor function + * + * @note + * Parameter proc is optional. It's called when the thread terminates to allow + * the program to deal with the thread specific value of the key + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ThreadKeyCreate +( + const otext * name, + POCI_THREADKEYDEST destfunc +); + +/** + * @brief + * Set a thread key value + * + * @param name - Thread key name + * @param value - user value to set + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_ThreadKeySetValue +( + const otext *name, + void * value +); + +/** + * @brief + * Get a thread key value + * + * @param name - Thread key name + * + * @return + * Thread key value on success otherwise FALSE + * + */ + +OCI_EXPORT void * OCI_API OCI_ThreadKeyGetValue +( + const otext *name +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiDirectPath Direct Path loading + * @{ + * + * OCILIB (from version 3.2.0) support the OCI direct Path API. + * + * Actual implementation of direct path API does not support the following + * elements : + * - Objects data types (User Defined Types and Object References) + * - Object tables + * - Nested tables + * - SQL String functions + * + * All scalar data types (numerics, characters and date/time), including LOBs + * and LONG types are supported + * + * @par Oracle direct API features (from Oracle Documentation) + * + * The direct path load interface allows an application to access the direct path + * load engine of the Oracle database server to perform the functions of the + * Oracle SQL*Loader utility. + * This functionality provides the ability to load data from external files + * into Oracle database objects, either a table or a partition of a partitioned + * table. + * The OCI direct path load interface has the ability to load multiple rows by + * loading a direct path stream which contains data for multiple rows. + * + * @par Oracle direct API limitation (from Oracle Documentation) + * The direct path load interface has the following limitations which are the + * same as SQL*Loader: + * - triggers are not supported + * - check constraints are not supported + * - referential integrity constraints are not supported + * - clustered tables are not supported + * - loading of remote objects is not supported + * - user-defined types are not supported + * - LOBs must be specified after all scalar columns + * - LONGs must be specified last + * + * @warning + * + * Its recommended to use direct path interface with an Oracle client that is + * the same version than the database. With version < 10g, it is mandatory + * regarding that it causes segmentation faults and it's known from Oracle that + * advices to use the same version for client and server (see metalink KB) + * + * @par How to use direct path + * + * - 1 : Create a direct path handle with OCI_DirPathCreate() + * - 2 : Set (optional) some direct path load attributes + * - 3 : Describe the columns to load with OCI_DirPathSetColumn() + * - 4 : Populate data with OCI_DirPathSetEntry() + * - 5 : Convert the data with OCI_DirPathConvert() + * - 6 : Load the data into the database with OCI_DirPathLoad() + * - 7 : Repeat step 4,5,6 + reset the stream with OCI_DirPathReset() until all + * rows has been loaded + * - 8 : Commit the load with OCI_DirPathFinish() + * - 9 : Free the direct path handle with OCI_DirPathFree() + * + * @par Example + * @include dirpath.c + * + */ + +/** + * @brief + * Create a direct path object + * + * @param typinf - Table type info handle + * @param partition - Partition name + * @param nb_cols - Number of columns to load + * @param nb_rows - Maximum of rows to handle per load operation + * + * @note + * Retrieve the table type info handle with OCI_TypeInfoGet(). + * The partition name is not mandatory + * + * @note + * Parameter 'nb_rows' is ignored for Oracle 8i. Prior to Oracle 9i, it's the + * OCI client that decides of the number of rows to process per convert/load calls. + * From Oracle 9i, OCI allows application to specify this value. Note that, the + * OCI client might not accept the input value. After OCI_DirPathPrepare() has + * been successfully called, OCI_DirPathGetMaxRows() returns the final number + * of rows used for the given direct path operation. + * + * @return + * Return the direct path handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_DirPath * OCI_API OCI_DirPathCreate +( + OCI_TypeInfo *typinf, + const otext * partition, + unsigned int nb_cols, + unsigned int nb_rows +); + +/** + * @brief + * Free an OCI_DirPath handle + * + * @param dp - Direct path Handle + * + * @return + * TRUE on success otherwise FALSE + * + */ +OCI_EXPORT boolean OCI_API OCI_DirPathFree +( + OCI_DirPath *dp +); + +/** + * @brief + * Describe a column to load into the given table + * + * @param dp - Direct path Handle + * @param index - Column index + * @param name - Column name + * @param maxsize - Maximum input value size for a column entry + * @param format - Date or numeric format to use + * + * @note + * An error is thrown if : + * - If the column specified by the 'name' parameter is not found in the table + * referenced by the type info handle passed to OCI_DirPathCreate() + * - the index is out of bounds (= 0 or >= number of columns) + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetColumn +( + OCI_DirPath *dp, + unsigned int index, + const otext *name, + unsigned int maxsize, + const otext *format +); + +/** + * @brief + * Prepares the OCI direct path load interface before any rows can be converted + * or loaded + * + * @param dp - Direct path Handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathPrepare +( + OCI_DirPath *dp +); + +/** + * @brief + * Set the value of the given row/column array entry + * + * @param dp - Direct path Handle + * @param row - Row index + * @param index - Column index + * @param value - Value to set + * @param size - Size of the input value + * @param complete - Is the entry content fully provided ? + * + * @note + * Rows and columns indexes start at 1. + * + * @note + * The 'size' parameter is expressed in number of : + * - bytes for binary columns + * - characters for other columns + * + * @note + * Direct path support piece loading for LONGs and LOBs columns. When filling + * these columns, it's possible to provide input buffer piece by piece. In order + * to do so : + * - set the 'complete' parameter to FALSE + * - set the 'size' parameter to the piece size + * - Repeat calls to OCI_DirPathSetEntry() until the data is totally provided + * - The last call that set the last piece or an entry must specify the value + * TRUE for the 'complete' parameter + * + * @warning + * Current Direct Path OCILIB implementation DOES NOT support setting entry + * content piece by piece as mentioned above. It was planned in the original design + * but not supported yet. So, always set the complete parameter to TRUE. + * Setting entries content piece by piece may be supported in future releases + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetEntry +( + OCI_DirPath *dp, + unsigned int row, + unsigned int index, + void * value, + unsigned size, + boolean complete +); + +/** + * @brief + * Convert provided user data to the direct path stream format + * + * @param dp - Direct path Handle + * + * @return + * Possible return values : + * - OCI_DPR_COMPLETE : load has been successful + * - OCI_DPR_ERROR : an error happened while loading data + * - OCI_DPR_FULL : the internal stream is full + * - OCI_DPR_PARTIAL : a column has not been fully filled yet + * - OCI_DPR_EMPTY : no data was found to convert + * + * @note + * - When using conversion mode OCI_DCM_DEFAULT, OCI_DirPathConvert() stops when + * any error is encountered and returns OCI_DPR_ERROR + * - When using conversion mode OCI_DCM_FORCE, OCI_DirPathConvert() does not stop + * on errors. Instead it discards any erred rows and returns OCI_DPR_COMPLETE once + * all rows are processed. + * + * @note + * List of faulted rows and columns can be retrieved using OCI_DirPathGetErrorRow() and + * OCI_DirPathGetErrorColumn() + * + * @note + * OCI_DirPathGetAffectedRows() returns the number of rows converted in the last call. + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathConvert +( + OCI_DirPath *dp +); + +/** + * @brief + * Loads the data converted to direct path stream format + * + * @param dp - Direct path Handle + * + * @return + * Possible return values : + * - OCI_DPR_COMPLETE : conversion has been successful + * - OCI_DPR_ERROR : an error happened while converting data + * - OCI_DPR_FULL : the internal stream is full + * - OCI_DPR_PARTIAL : a column has not been fully filled yet + * - OCI_DPR_EMPTY : no data was found to load + * + * @note + * List of faulted rows can be retrieved using OCI_DirPathGetErrorRow() + * + * @note + * OCI_DirPathGetAffectedRows() returns the number of rows successfully loaded in the last call. + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathLoad +( + OCI_DirPath *dp +); + +/** + * @brief + * Reset internal arrays and streams to prepare another load + * + * @param dp - Direct path Handle + * + * @note + * Once some data have been converted or loaded, OCI_DirPathReset() resets + * internal OCI structures in order to prepare another load operation + * (set entries, convert and load) + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathReset +( + OCI_DirPath *dp +); + +/** + * @brief + * Terminate a direct path operation and commit changes into the database + * + * @param dp - Direct path Handle + * + * @warning + * The direct path handle cannot be used anymore after this call for any more + * loading operations and must be freed with OCI_DirPathFree(). + * + * @note + * Some properties functions of the direct path handle, such as + * OCI_DirPathGetRowCount() can be called on a terminated direct path handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathFinish +( + OCI_DirPath *dp +); + +/** + * @brief + * Terminate a direct path operation without committing changes + * + * @param dp - Direct path Handle + * + * @note + * Any pending loaded data are canceled. + * Any load completion operations, such as index maintenance operations, are not performed. + * + * @warning + * The direct path handle cannot be used anymore after this call for any more + * loading operations and must be freed with OCI_DirPathFree(). + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathAbort +( + OCI_DirPath *dp +); + +/** + * @brief + * Execute a data save-point (server side) + * + * @param dp - Direct path Handle + * + * @note + * Executing a data save-point is not allowed for LOBs + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSave +( + OCI_DirPath *dp +); + +/** + * @brief + * Flushes a partially loaded row from server + * + * @param dp - Direct path Handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathFlushRow +( + OCI_DirPath *dp +); + +/** + * @brief + * Set the current number of rows to convert and load + * + * @param dp - Direct path Handle + * @param nb_rows - Number of row to process + * + * @warning + * An OCILIB error will be thrown if the value exceeds the maximum number of + * rows in the internals arrays + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetCurrentRows +( + OCI_DirPath *dp, + unsigned int nb_rows +); + +/** + * @brief + * Return the current number of rows used in the OCILIB internal + * arrays of rows + * + * @param dp - Direct path Handle + * + * @return + * Internal current array size on SUCCESS otherwise 0 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathGetCurrentRows +( + OCI_DirPath *dp +); + +/** + * @brief + * Return the maximum number of rows allocated in the OCI and OCILIB + * internal arrays of rows + * + * @param dp - Direct path Handle + * + * @return + * Internal maximum array size on SUCCESS otherwise 0 + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathGetMaxRows +( + OCI_DirPath *dp +); + +/** + * @brief + * Set the default date format string for input conversion + * + * @param dp - Direct path Handle + * @param format - date format + * + * @note + * For string to date conversion, Oracle uses : + * - Column date format + * - Default date format (modified by this call) + * - Default global support environment setting + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetDateFormat +( + OCI_DirPath *dp, + const otext *format +); + +/** + * @brief + * Set the parallel loading mode + * + * @param dp - Direct path Handle + * @param value - enable/disable parallel mode + * + * @note + * Default value is FALSE. + * + * @note + * Setting the value to TRUE allows multiple load sessions to load the same + * segment concurrently + * + * @par Parallel loading mode (From Oracle documentation) + * + * A direct load operation requires that the object being loaded is locked to + * prevent DML on the object. + * Note that queries are lock-free and are allowed while the object is being loaded. + * - For a table load, if the option is set to: + * - FALSE, then the table DML X-Lock is acquired. + * - TRUE, then the table DML S-Lock is acquired. + * - For a partition load, if the option is set to: + * - FALSE, then the table DML SX-Lock and partition DML X-Lock is acquired. + * - TRUE, then the table DML SS-Lock and partition DML S-Lock is acquired. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetParallel +( + OCI_DirPath *dp, + boolean value +); + +/** + * @brief + * Set the logging mode for the loading operation + * + * @param dp - Direct path Handle + * @param value - enable/disable logging + * + * @par Logging mode (from Oracle Documentation) + * + * The NOLOG attribute of each segment determines whether image redo or + * invalidation redo is generated: + * - FALSE : Use the attribute of the segment being loaded. + * - TRUE : No logging. Overrides DDL statement, if necessary. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetNoLog +( + OCI_DirPath *dp, + boolean value +); + +/** + * @brief + * Set number of elements in the date cache + * + * @param dp - Direct path Handle + * @param size - Buffer size + * + * @note + * Default value is 0. + * + * @note + * Setting the value to 0 disables the cache + * + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetCacheSize +( + OCI_DirPath *dp, + unsigned int size +); + +/** + * @brief + * Set the size of the internal stream transfer buffer + * + * @param dp - Direct path Handle + * @param size - Buffer size + * + * @note + * Default value is 64KB. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetBufferSize +( + OCI_DirPath *dp, + unsigned int size +); + +/** + * @brief + * Set the direct path conversion mode + * + * @param dp - Direct path Handle + * @param mode - Conversion mode + * + * @note + * Possible values for parameter 'mode' : + * - OCI_DCM_DEFAULT : conversion fails on error + * - OCI_DCM_FORCE : conversion does not fail on error + * + * @note + * See OCI_DirPathConvert() for conversion mode details + * + * @note + * Default value is OCI_DCM_DEFAULT + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DirPathSetConvertMode +( + OCI_DirPath *dp, + unsigned int mode +); + +/** + * @brief + * Return the number of rows successfully loaded into the database so far + * + * @param dp - Direct path Handle + * + * @note + * Insertions are committed with OCI_DirPathFinish() + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathGetRowCount +( + OCI_DirPath *dp +); + +/** + * @brief + * return the number of rows successfully processed during in the last + * conversion or loading call + * + * @param dp - Direct path Handle + * + * @note + * This function called after : + * + * - OCI_DirPathConvert(), returns the number of converted rows + * - OCI_DirPathLoad(), returns the number of loaded rows + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathGetAffectedRows +( + OCI_DirPath *dp +); + +/** + * @brief + * Return the index of a column which caused an error during data conversion + * + * @param dp - Direct path Handle + * + * @warning + * Direct path column indexes start at 1. + * + * @note + * Errors may happen while data is converted to direct path stream format + * using OCI_DirPathConvert(). + * When using conversion mode OCI_DCM_DEFAULT, OCI_DirPathConvert() returns + * OCI_DPR_ERROR on error. OCI_DirPathGetErrorColumn() returns the column index + * that caused the error + * When using conversion mode OCI_DCM_FORCE, OCI_DirPathConvert() returns + * OCI_DPR_COMPLETE even on errors. In order to retrieve the list of all column + * indexes that have erred, the application can call OCI_DirPathGetErrorColumn() + * repeatedly until it returns 0. + * + * @note + * The internal value is reset to 0 when calling OCI_DirPathConvert() + * + * @return + * 0 is no error occurs otherwise the index of the given column which caused an + * error + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorColumn +( + OCI_DirPath *dp +); + +/** + * @brief + * Return the index of a row which caused an error during data conversion + * + * @param dp - Direct path Handle + * + * @warning + * Direct path row indexes start at 1. + * + * @note + * Errors may happen : + * - while data is converted to direct path stream format using OCI_DirPathConvert() + * - while data is loaded to database using OCI_DirPathLoad() + * + * @note + * When using conversion mode OCI_DCM_DEFAULT, OCI_DirPathConvert() returns + * OCI_DPR_ERROR on error. OCI_DirPathGetErrorRow() returns the row index that + * caused the error. + * When using conversion mode OCI_DCM_FORCE, OCI_DirPathConvert() returns + * OCI_DPR_COMPLETE even on errors. In order to retrieve the list of all row + * indexes that have erred, the application can call OCI_DirPathGetErrorRow() + * repeatedly until it returns 0. + * + * @note + * After a call to OCI_DirPathLoad(), in order to retrieve the list of all faulted rows + * indexes, the application can call OCI_DirPathGetErrorRow() repeatedly until it returns 0. + * + * @note + * The internal value is reset to 0 when calling OCI_DirPathConvert(), + * OCI_DirPathReset() or OCI_DirPathLoad() + * + * @return + * 0 is no error occurs otherwise the index of the given row which caused an + * error + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorRow +( + OCI_DirPath *dp +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiAdvancedQueuing Oracle Advanced Queuing (A/Q) + * @{ + * + * OCILIB supports Oracle Advanced Queues features + * + * Let's Oracle talk about this features ! + * + * @par Oracle Queues (from Oracle Streams - Advanced Queuing User's Guide) + * + * Oracle Streams AQ provides database-integrated message queuing functionality. + * It is built on top of Oracle Streams and leverages the functions of Oracle + * Database so that messages can be stored persistently, propagated between + * queues on different computers and databases, and transmitted using Oracle + * Net Services and HTTP(S). + * Because Oracle Streams AQ is implemented in database tables, all operational + * benefits of high availability, scalability, and reliability are also + * applicable to queue data. Standard database features such as recovery, + * restart, and security are supported by Oracle Streams AQ. You can use + * database development and management tools such as Oracle Enterprise Manager + * to monitor queues. Like other database tables, queue tables can be imported + * and exported. + * + * @par OCILIB implementation + * + * OCILIB provides a (nearly) full C implementation of Advanced Queues available in + * Oracle OCI and proposes the following data types : + * - OCI_Msg : Implementation of message to enqueue/dequeue from/to queues + * - OCI_Enqueue : Implementation of enqueuing process + * - OCI_Dequeue : Implementation of dequeuing process + * - OCI_Agent : Implementation of Advanced queues Agents + * + * OCILIB support AQ messages notification with Oracle Client 10gR2 or above + * + * Note that the only AQ features not supported yet by OCILIB are : + * - Payloads of type AnyData + * - Enqueuing/dequeuing arrays of messages + * - Optional delivery mode introduced in 10gR2 + * + * OCILIB provides as well a C API to administrate queues and queue tables initially + * reserved to PL/SQL and Java (wrappers around PL/SQL calls). + * This API, based on internal PL/SQL calls wrapping the DBMS_AQADM packages procedures, allow the + * following actions : + * - create, alter, drop and purge queue tables (OCI_QueueTableXXX calls) + * - create, alter, drop, start, stop queues (OCI_QueueXXX calls) + * + * Note that the user connected to the database needs particular privileges to manipulate or + * administrate queues (See Oracle Streams - Advanced Queuing User's Guide for more information + * on these privileges) + * + * @par Example + * @include queue.c + * + */ + +/** + * @brief + * Create a message object based on the given payload type + * + * @param typinf - Type info handle + * + * @note + * OCILIB supports 2 type of message payload : + * - Oracle types (UDT) + * - RAW data + * + * @note + * Oracle Type AnyData is not supported in the current version of OCILIB + * + * @note + * the parameter 'typinf' indicates the type of payload : + * - For object payload, retrieve the object type information handle with + * OCI_TypeInfoGet() using the object type name + * - For RAW payload, you MUST pass the object type information retrieved with + * OCI_TypeInfoGet() using "SYS.RAW" as object type name + * + * @warning + * Newly created Message handles have NULL payloads. + * For Message handling Objects payloads, OCI_MsgGetObject() returns NULL until an object handle is + * assigned to the message. + * + * @note + * When a local OCI_Msg handle is enqueued, it keeps its attributes. If it's enqueued again, another + * identical message is posted into the queue. + * To reset a message and empty all its properties, call OCI_MsgReset() + * Note that OCI_MsgReset() clears the message payload. + * + * @return + * Return the message handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Msg * OCI_API OCI_MsgCreate +( + OCI_TypeInfo *typinf +); + +/** + * @brief + * Free a message object + * + * @param msg - Message handle + * + * @warning + * Only message handles created with OCI_MsgCreate() should be freed by OCI_MsgFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgFree +( + OCI_Msg *msg +); + +/** + * @brief + * Reset all attributes of a message object + * + * @param msg - Message handle + * + * @note + * This function calls OCI_MsgSetxxx() with default or NULL attributes + * + * @warning + * OCI_MsgReset() clears the message payload and set it to NULL + * For messages handling objects payloads, OCI_MsgSetObject() must be called again to assign a + * payload. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgReset +( + OCI_Msg *msg +); + +/** + * @brief + * Get the object payload of the given message + * + * @param msg - Message handle + * + * @return + * Return the object handle on success otherwise NULL on failure or if payload is NULL + * + */ + +OCI_EXPORT OCI_Object * OCI_API OCI_MsgGetObject +( + OCI_Msg *msg +); + +/** + * @brief + * Set the object payload of the given message + * + * @param msg - Message handle + * @param obj - Object handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetObject +( + OCI_Msg * msg, + OCI_Object *obj +); + +/** + * @brief + * Get the RAW payload of the given message + * + * @param msg - Message handle + * @param raw - Input buffer + * @param size - Input buffer maximum size + * + * @note + * On output, parameter 'size' holds the number of bytes copied into the given buffer + * + * @return + * TRUE on success otherwise FALSE on failure or if payload is object based. + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgGetRaw +( + OCI_Msg * msg, + void * raw, + unsigned int *size +); + +/** + * @brief + * Set the RAW payload of the given message + * + * @param msg - Message handle + * @param raw - Raw data + * @param size - Raw data size + * + * @return + * TRUE on success otherwise FALSE on failure or if payload is object based. + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetRaw +( + OCI_Msg * msg, + const void * raw, + unsigned int size +); + +/** + * @brief + * Return the number of attempts that have been made to dequeue the message + * + * @param msg - Message handle + * + */ + +OCI_EXPORT int OCI_API OCI_MsgGetAttemptCount +( + OCI_Msg *msg +); + +/** + * @brief + * Return the number of seconds that a message is delayed for dequeuing + * + * @param msg - Message handle + * + * @note + * see OCI_MsgSetEnqueueDelay() for more details + * + */ + +OCI_EXPORT int OCI_API OCI_MsgGetEnqueueDelay +( + OCI_Msg *msg +); + +/** + * @brief + * set the number of seconds to delay the enqueued message + * + * @param msg - Message handle + * @param value - Delay in seconds + * + * @note + * The delay represents the number of seconds after which a message is available for dequeuing. + * When the message is enqueued, its state is set to OCI_AMS_WAITING. + * When the delay expires, its state is set to OCI_AMS_READY. + * + * @note + * If parameter 'value' is set to zero (default value), the message will be immediately available + * for dequeuing + * + * @warning + * Dequeuing by Message ID overrides the delay specification. + * + * @warning + * Delaying processing requires the queue monitor to be started. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetEnqueueDelay +( + OCI_Msg *msg, + int value +); + +/** + * @brief + * return the time the message was enqueued + * + * @param msg - Message handle + * + * @note + * Only use this function for message dequeued from queues + * + */ + +OCI_EXPORT OCI_Date * OCI_API OCI_MsgGetEnqueueTime +( + OCI_Msg *msg +); + +/** + * @brief + * Return the duration that the message is available for dequeuing + * + * @param msg - Message handle + * + * @note + * see OCI_MsgSetExpiration() for more details + * + */ + +OCI_EXPORT int OCI_API OCI_MsgGetExpiration +( + OCI_Msg *msg +); + +/** + * @brief + * set the duration that the message is available for dequeuing + * + * @param msg - Message handle + * @param value - duration in seconds + * + * @note + * This parameter is an offset from the delay (see OCI_MsgSetEnqueueDelay()) + * While waiting for expiration, the message state is set to OCI_AMS_READY. + * If the message is not dequeued before it expires, it will be moved to the exception queue + * with the state OCI_AMS_EXPIRED. + * + * @note + * If parameter 'value' is set to -1 (default value), the message will not expire + * + * @warning + * Expiration processing requires the queue monitor to be started. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetExpiration +( + OCI_Msg *msg, + int value +); + +/** + * @brief + * Return the state of the message at the time of the dequeue + * + * @param msg - Message handle + * + * @return + * - OCI_UNKNOWN : the function has failed to get the message state + * - OCI_AMS_READY : the message is ready to be processed + * - OCI_AMS_WAITING : the message delay has not yet completed + * - OCI_AMS_PROCESSED : the message has been processed + * - OCI_AMS_EXPIRED : the message has moved to exception queue + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_MsgGetState +( + OCI_Msg *msg +); + +/** + * @brief + * Return the priority of the message + * + * @param msg - Message handle + * + * @note + * see OCI_MsgSetPriority() for more details + * + */ + +OCI_EXPORT int OCI_API OCI_MsgGetPriority +( + OCI_Msg *msg +); + +/** + * @brief + * Set the priority of the message + * + * @param msg - Message handle + * @param value - Message priority + * + * @note + * - The priority can be any number, including negative numbers. + * - A smaller number indicates higher priority. + * - Default value is zero. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetPriority +( + OCI_Msg *msg, + int value +); + +/** + * @brief + * Return the ID of the message + * + * @param msg - Message handle + * @param id - Input buffer + * @param len - Input buffer maximum size + * + * @note + * The message ID is : + * - generated when the message is enqueued in the queue + * - retrieved when the message is dequeued from the queue + * + * @note + * On output, parameter 'len' holds the number of bytes copied into the given buffer + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgGetID +( + OCI_Msg * msg, + void * id, + unsigned int *len +); + +/** + * @brief + * Return the original ID of the message in the last queue that generated this message + * + * @param msg - Message handle + * @param id - Input buffer + * @param len - Input buffer maximum size + * + * @warning + * When a message is propagated from/to different queues, this ID is the one generated for the + * message in the previous queue. + * + * @note + * On output, parameter 'len' holds the number of bytes copied into the given buffer + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgGetOriginalID +( + OCI_Msg * msg, + void * id, + unsigned int *len +); + +/** + * @brief + * Set the original ID of the message in the last queue that generated this message + * + * @param msg - Message handle + * @param id - Message ID + * @param len - Message ID size + * + * @warning + * When a message is propagated from/to different queues, this ID is the one generated for the + * message in the previous queue. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetOriginalID +( + OCI_Msg * msg, + const void * id, + unsigned int len +); + +/** + * @brief + * Return the original sender of a message + * + * @param msg - Message handle + * + * @return + * Sender Handle (OCI_Agent *) on success (if set at enqueue time) otherwise NULL + * + */ + +OCI_EXPORT OCI_Agent * OCI_API OCI_MsgGetSender +( + OCI_Msg *msg +); + +/** + * @brief + * Set the original sender of a message + * + * @param msg - Message handle + * @param sender - Message sender + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetSender +( + OCI_Msg * msg, + OCI_Agent *sender +); + +/** + * @brief + * Set the recipient list of a message to enqueue + * + * @param msg - Message handle + * @param consumers - Recipients list (array of agent handles) + * @param count - Number of recipients + * + * @warning + * This function should only be used for queues which allow multiple consumers. + * The default recipients are the queue subscribers. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetConsumers +( + OCI_Msg * msg, + OCI_Agent ** consumers, + unsigned int count +); + +/** + * @brief + * Get the correlation identifier of the message + * + * @param msg - Message handle + * + * @note + * see OCI_MsgSetCorrelation() for more details + * + */ + +OCI_EXPORT const otext * OCI_API OCI_MsgGetCorrelation +( + OCI_Msg *msg +); + +/** + * @brief + * set the correlation identifier of the message + * + * @param msg - Message handle + * @param correlation - Message correlation text + * + * @note + * see OCI_DequeueSetCorrelation() for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetCorrelation +( + OCI_Msg * msg, + const otext *correlation +); + +/** + * @brief + * Get the Exception queue name of the message + * + * @param msg - Message handle + * + * @warning + * When calling this function on a message retrieved with OCI_DequeueGet(), the returned value is + * NULL if the default exception queue associated with the current queue is used (e.g. no user + * defined specified at enqueue time for the message) + * + * @note + * see OCI_MsgSetExceptionQueue() for more details + * + */ +OCI_EXPORT const otext * OCI_API OCI_MsgGetExceptionQueue +( + OCI_Msg *msg +); + +/** + * @brief + * Set the name of the queue to which the message is moved to if it cannot be + * processed successfully + * + * @param msg - Message handle + * @param queue - Exception queue name + * + * @warning + * From Oracle Documentation : + * + * "Messages are moved into exception queues in two cases : + * - If the number of unsuccessful dequeue attempts has exceeded the attribute 'max_retries' of + * given queue + * - if the message has expired. + * + * All messages in the exception queue are in the EXPIRED state. + * + * The default is the exception queue associated with the queue table. + * + * If the exception queue specified does not exist at the time of the move the message will be + * moved to the default exception queue associated with the queue table and a warning will be + * logged in the alert file. + * + * This attribute must refer to a valid queue name." + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_MsgSetExceptionQueue +( + OCI_Msg * msg, + const otext *queue +); + +/** + * @brief + * Create a Enqueue object for the given queue + * + * @param typinf - Type info handle + * @param name - Queue name + * + * @note + * OCILIB supports 2 type of message payload : + * - Oracle types (UDT) + * - RAW data + * + * @note + * Oracle Type AnyData is not supported in the current version of OCILIB + * + * @note + * the parameter 'typinf' indicates the type of payload to enqueue to the given queue : + * - For object payload, retrieve the object type information handle with + * OCI_TypeInfoGet() using the object type name + * - For RAW payload, you MUST pass the object type information retrieved with + * OCI_TypeInfoGet() using "SYS.RAW" as object type name + * + * @return + * Return the Enqueue handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Enqueue * OCI_API OCI_EnqueueCreate +( + OCI_TypeInfo *typinf, + const otext * name +); + +/** + * @brief + * Free a Enqueue object + * + * @param enqueue - Enqueue handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_EnqueueFree +( + OCI_Enqueue *enqueue +); + +/** + * @brief + * Enqueue a message on the queue associated to the Enqueue object + * + * @param enqueue - Enqueue handle + * @param msg - Message handle to enqueue + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_EnqueuePut +( + OCI_Enqueue *enqueue, + OCI_Msg * msg +); + +/** +* @brief +* Set the enqueuing sequence of messages to put in the queue +* +* @param enqueue - Enqueue handle +* @param sequence - enqueuing sequence +* +* @note +* Possible values for parameter 'sequence' : +* - OCI_ASD_BEFORE : enqueue message before another message +* - OCI_ASD_TOP : enqueue message before all messages +* +* @note +* Default value is OCI_ASD_TOP +* +* @note +* if the parameter 'sequence' is set to OCI_ASD_BEFORE, the application must +* call OCI_EnqueueSetRelativeMsgID() before enqueuing the next message in the queue. +* +* @note +* In order to stop enqueuing message using a sequence deviation, call +* OCI_EnqueueSetSequenceDeviation() with the value OCI_ASD_TOP +* +* @return +* TRUE on success otherwise FALSE +* +*/ + +OCI_EXPORT boolean OCI_API OCI_EnqueueSetSequenceDeviation +( + OCI_Enqueue *enqueue, + unsigned int sequence +); + +/** + * @brief + * Return the sequence deviation of messages to enqueue to the queue + * + * @param enqueue - Enqueue handle + * + * @note + * see OCI_EnqueueSetSequenceDeviation() for more details + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_EnqueueGetSequenceDeviation +( + OCI_Enqueue *enqueue +); + +/** + * @brief + * Set whether the new message is enqueued as part of the current transaction + * + * @param enqueue - Enqueue handle + * @param visibility - Enqueuing visibility + * + * @note + * Possible values for parameter 'visibility' : + * - OCI_AMV_IMMEDIATE : enqueue is an independent transaction + * - OCI_AMV_ON_COMMIT : enqueue is part of current transaction + * + * @note + * Default value is OCI_AMV_ON_COMMIT + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_EnqueueSetVisibility +( + OCI_Enqueue *enqueue, + unsigned int visibility +); + +/** + * @brief + * Get the enqueuing/locking behavior + * + * @param enqueue - Enqueue handle + * + * @note + * see OCI_EnqueueSetVisibility() for more details + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_EnqueueGetVisibility +( + OCI_Enqueue *enqueue +); + +/** + * @brief + * Set a message identifier to use for enqueuing messages using a sequence deviation + * + * @param enqueue - Enqueue handle + * @param id - message identifier + * @param len - pointer to message identifier length + * + * @note + * This call is only valid if OCI_EnqueueSetSequenceDeviation() has been called + * with the value OCI_ASD_BEFORE + * + * @warning + * if the function cannot assign the message id, the content of the parameter 'len' is set to zero. + * + * @note + * see OCI_EnqueueSetSequenceDeviation() for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_EnqueueSetRelativeMsgID +( + OCI_Enqueue *enqueue, + const void * id, + unsigned int len +); + +/** + * @brief + * Get the current associated message identifier used for enqueuing messages + * using a sequence deviation + * + * @param enqueue - Enqueue handle + * @param id - buffer to receive the message identifier + * @param len - pointer to buffer max length + * + * @warning + * When the function returns, parameter 'len' hold the number of bytes assigned to parameter 'id' + * + * @note + * see OCI_EnqueueGetRelativeMsgID() for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_EnqueueGetRelativeMsgID +( + OCI_Enqueue * enqueue, + void * id, + unsigned int *len +); + +/** + * @brief + * Create a Dequeue object for the given queue + * + * @param typinf - Type info handle + * @param name - Queue name + * + * @note + * OCILIB supports 2 type of message payload : + * - Oracle types (UDT) + * - RAW data + * + * @note + * Oracle Type AnyData is not supported in the current version of OCILIB + * + * @note + * the parameter 'typinf' indicates the type of payload to dequeue from the given queue : + * - For object payload, retrieve the object type information handle with + * OCI_TypeInfoGet() using the object type name + * - For RAW payload, you MUST pass the object type information retrieved with + * OCI_TypeInfoGet() using "SYS.RAW" as object type name + * + * @return + * Return the Dequeue handle on success otherwise NULL on failure + * + */ + +OCI_EXPORT OCI_Dequeue * OCI_API OCI_DequeueCreate +( + OCI_TypeInfo *typinf, + const otext * name +); + +/** + * @brief + * Free a Dequeue object + * + * @param dequeue - Dequeue handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueFree +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Dequeue messages from the given queue + * + * @param dequeue - Dequeue handle + * + * @warning + * The returned message is handled by the dequeue object. + * Do not release it with OCI_MsgFree() + * + * @warning + * When dequeuing from a multiple consumer queue, you need + * to set the navigation mode to OCI_ADN_FIRST_MSG using + * OCI_DequeueSetNavigation() + * + * @return + * Message handle on success otherwise NULL on failure or on timeout + * + */ + +OCI_EXPORT OCI_Msg * OCI_API OCI_DequeueGet +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Subscribe for asynchronous messages notifications + * + * @param dequeue - Dequeue handle + * @param port - Port to use for notifications + * @param timeout - notification timeout + * @param callback - User handler callback fired when messages are ready to be dequeued + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * asynchronous messages notifications + * + * @note + * Requires Oracle Client 10gR2 or above + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSubscribe +( + OCI_Dequeue * dequeue, + unsigned int port, + unsigned int timeout, + POCI_NOTIFY_AQ callback +); + +/** + * @brief + * Unsubscribe for asynchronous messages notifications + * + * @param dequeue - Dequeue handle + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueUnsubscribe +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Set the current consumer name to retrieve message for. + * + * @param dequeue - Dequeue handle + * @param consumer - consumer name + * + * @warning + * If a queue is not set up for multiple consumers, OCI_DequeueSetConsumer() + * should not be called or called with parameter 'consumer' set to NULL + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetConsumer +( + OCI_Dequeue *dequeue, + const otext *consumer +); + +/** + * @brief + * Get the current consumer name associated with the dequeuing process. + * + * @param dequeue - Dequeue handle + * + * @note + * see OCI_DequeueSetConsumer() for more details + * + */ + +OCI_EXPORT const otext * OCI_API OCI_DequeueGetConsumer +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * set the correlation identifier of the message to be dequeued + * + * @param dequeue - Dequeue handle + * @param pattern - correlation identifier + * + * @note + * Special pattern matching characters, such as "%" or "_" can be used. + * If more than one message satisfies the pattern, the order of dequeuing is undetermined. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetCorrelation +( + OCI_Dequeue *dequeue, + const otext *pattern +); + +/** + * @brief + * Get the correlation identifier of the message to be dequeued + * + * @param dequeue - Dequeue handle + * + * @note + * see OCI_DequeueSetCorrelation() for more details + * + */ + +OCI_EXPORT const otext * OCI_API OCI_DequeueGetCorrelation +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Set the message identifier of the message to be dequeued + * + * @param dequeue - Dequeue handle + * @param id - message identifier + * @param len - size of the message identifier + * + * @warning + * if the function cannot assign the message id, the content of the parameter 'len' is set to zero. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetRelativeMsgID +( + OCI_Dequeue *dequeue, + const void * id, + unsigned int len +); + +/** + * @brief + * Get the message identifier of the message to be dequeued + * + * @param dequeue - Dequeue handle + * @param id - message identifier + * @param len - size of the message identifier + * + * @warning + * When the function returns, parameter 'len' hold the number of bytes assigned to parameter 'id' + * + * @note + * see OCI_DequeueSetRelativeMsgID() for more details + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueGetRelativeMsgID +( + OCI_Dequeue * dequeue, + void * id, + unsigned int *len +); + +/** + * @brief + * Set whether the new message is dequeued as part of the current transaction + * + * @param dequeue - Dequeue handle + * @param visibility - dequeuing mode + * + * @warning + * The visibility parameter is ignored when using the OCI_ADM_BROWSE dequeuing + * mode (see OCI_DequeueSetMode()) + * + * @note + * Possible values for parameter 'mode' : + * - OCI_AMV_IMMEDIATE : dequeue is an independent transaction + * - OCI_AMV_ON_COMMIT : dequeue is part of current transaction + * + * @note + * Default value is OCI_AMV_ON_COMMIT + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetVisibility +( + OCI_Dequeue *dequeue, + unsigned int visibility +); + +/** + * @brief + * Get the dequeuing/locking behavior + * + * @param dequeue - Dequeue handle + * + * @note + * see OCI_DequeueSetVisibility() for more details + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DequeueGetVisibility +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Set the dequeuing/locking behavior + * + * @param dequeue - Dequeue handle + * @param mode - dequeuing mode + * + * @note + * Possible values for parameter 'mode' : + * - OCI_ADM_BROWSE : read message without acquiring a lock + * - OCI_ADM_LOCKED : read and obtain write lock on message + * - OCI_ADM_REMOVE : read the message and delete it + * - OCI_ADM_REMOVE_NODATA : confirm receipt of the message, but do not + * deliver the actual message content + * + * @note + * Default value is OCI_ADM_REMOVE + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetMode +( + OCI_Dequeue *dequeue, + unsigned int mode +); + +/** + * @brief + * Get the dequeuing/locking behavior + * + * @param dequeue - Dequeue handle + * + * @note + * see OCI_DequeueSetMode() for more details + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DequeueGetMode +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Set the position of messages to be retrieved. + * + * @param dequeue - Dequeue handle + * @param position - navigation position + * + * @note + * The dequeuing uses the following sequence : + * - find messages using the navigation position + * - apply search criteria (message correlation) + * - get message + * + * @note + * Possible values for parameter 'position' : + * - OCI_ADN_FIRST_MSG : retrieves the first message which is available + * - OCI_ADN_NEXT_MSG : retrieves the next message which is available + * - OCI_ADN_NEXT_TRANSACTION : skips the remainder of the current transaction + * group (if any) and retrieves the first message + * of the next transaction group. + * + * @note + * Default value is OCI_ADN_NEXT_MSG + * + * @warning + * OCI_ADN_NEXT_TRANSACTION can only be used if message grouping is enabled for the given queue. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetNavigation +( + OCI_Dequeue *dequeue, + unsigned int position +); + +/** + * @brief + * Return the navigation position of messages to retrieve from the queue + * + * @param dequeue - Dequeue handle + * + * @note + * see OCI_DequeueSetNavigation() for more details + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_DequeueGetNavigation +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * set the time that OCIDequeueGet() waits for messages if no messages are + * currently available + * + * @param dequeue - Dequeue handle + * @param timeout - timeout in seconds + * + * @note + * - Any positive values in seconds are valid. + * - The value 0 is accepted and means OCIDequeueGet() does not wait for + * messages and returns immediately if no messages are available + * - The value -1 is accepted and means OCIDequeueGet() waits for ever (until + * a message is available in the queue) + * + * @note + * Default value is -1 (wait for ever) + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetWaitTime +( + OCI_Dequeue *dequeue, + int timeout +); + +/** + * @brief + * Return the time that OCIDequeueGet() waits for messages if no messages are currently available + * + * @param dequeue - Dequeue handle + * + * @note + * see OCI_DequeueSetWaitTime() for more details + * + */ + +OCI_EXPORT int OCI_API OCI_DequeueGetWaitTime +( + OCI_Dequeue *dequeue +); + +/** + * @brief + * Set the Agent list to listen to message for + * + * @param dequeue - Dequeue handle + * @param consumers - Agent handle array + * @param count - Number of agents the array + * + * @return + * return TRUE on success otherwise FALSE + */ + +OCI_EXPORT boolean OCI_API OCI_DequeueSetAgentList +( + OCI_Dequeue *dequeue, + OCI_Agent ** consumers, + unsigned int count +); + +/** + * @brief + * Listen for messages that match any recipient of the associated Agent list + * + * @param dequeue - Dequeue handle + * @param timeout - Timeout in second + * + * @note + * If an Agent handle is returned, messages are available for this agent. + * In order to retrieve its messages : + * - call OCI_DequeueSetConsumer() with the name of agent using OCI_AgentGetName() + * - call OCI_DequeueGet() to dequeue it's pending messages + * + * @warning + * The return value is valid only until: + * - OCIDequeueListen() is called again + * - OCI_DequeueFree(à is called to free the Dequeue object + * So Do not store the handle value across calls to OCIDequeueListen() + * + * @return + * An Agent handle for who messages are available on success otherwise NULL + */ + +OCI_EXPORT OCI_Agent * OCI_API OCI_DequeueListen +( + OCI_Dequeue *dequeue, + int timeout +); + +/** + * @brief + * Create an AQ agent object + * + * @param con - Connection handle + * @param name - Agent name + * @param address - Agent address + * + * @note + * An AQ agent object is : + * - used as recipient information when enqueuing a message + * - used as sender information when dequeuing a message + * - used for listening message only from identified senders + * + * @note + * the AQ agent address can be any Oracle identifier, up to 128 bytes. + * the AQ agent name can be any Oracle identifier, up to 30 bytes. + * + * @return + * AQ agent handle on success otherwise NULL + * + */ + +OCI_EXPORT OCI_Agent * OCI_API OCI_AgentCreate +( + OCI_Connection *con, + const otext * name, + const otext * address +); + +/** + * @brief + * Free an AQ agent object + * + * @param agent - AQ agent handle + * + * @warning + * Only AQ agent handle created with OCI_AgentCreate() should be freed by OCI_AgentFree() + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_AgentFree +( + OCI_Agent *agent +); + +/** + * @brief + * Set the given AQ agent name + * + * @param agent - AQ agent handle + * @param name - AQ agent name + * + * @note + * the AQ agent name is used to identified an message send or recipient when enqueuing/dequeuing + * a message + * + * @note + * the AQ agent name can be any Oracle identifier, up to 30 bytes. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_AgentSetName +( + OCI_Agent * agent, + const otext *name +); + +/** + * @brief + * Get the given AQ agent name + * + * @param agent - AQ agent handle + * + * @return + * AQ agent name on success otherwise NULL on failure + * + */ + +OCI_EXPORT const otext * OCI_API OCI_AgentGetName +( + OCI_Agent *agent +); + +/** + * @brief + * Set the given AQ agent address + * + * @param agent - AQ agent handle + * @param address - AQ agent address + * + * @note + * the parameter 'address' must be of the form : [schema.]queue_name[\@dblink] + * + * @note + * the AQ agent address can be any Oracle identifier, up to 128 bytes. + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_AgentSetAddress +( + OCI_Agent * agent, + const otext *address +); + +/** + * @brief + * Get the given AQ agent address + * + * @param agent - AQ agent handle + * + * @note + * See OCI_AgentSetAddress() + * + * @return + * AQ agent address on success otherwise NULL on failure + * + */ + +OCI_EXPORT const otext * OCI_API OCI_AgentGetAddress +( + OCI_Agent *agent +); + +/** + * @brief + * Create a queue + * + * @param con - Connection handle + * @param queue_name - Queue name + * @param queue_table - Queue table name + * @param queue_type - Queue type + * @param max_retries - Maximum number of attempts to dequeue a message + * @param retry_delay - Number of seconds between attempts to dequeue a message + * @param retention_time - number of seconds a message is retained in the queue table after + * being dequeued from the queue + * @param dependency_tracking - Parameter reserved for future use by Oracle (MUST be set to FALSE) + * @param comment - Description of the queue + * + * @note + * Parameter 'queue_name' can specify the schema where to create to queue ([schema.]queue_name) + * Queue names cannot be longer than 24 characters (Oracle limit for user queues) + * + * @note + * Possible values for parameter 'queue_type' : + * - OCI_AQT_NORMAL : Normal queue + * - OCI_AQT_EXCEPTION : Exception queue + * - OCI_AQT_NON_PERSISTENT : Non persistent queue + * + * To set default values, pass : + * - queue_type : OCI_AQT_NORMAL + * - max_retries : 0 + * - retry_delay : 0 + * - retention_time : 0 + * - comment : NULL + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueCreate +( + OCI_Connection *con, + const otext * queue_name, + const otext * queue_table, + unsigned int queue_type, + unsigned int max_retries, + unsigned int retry_delay, + unsigned int retention_time, + boolean dependency_tracking, + const otext * comment +); + +/** + * @brief + * Alter the given queue + * + * @param con - Connection handle + * @param queue_name - Queue name + * @param max_retries - Maximum number of attempts to dequeue a message + * @param retry_delay - Number of seconds between attempts to dequeue a message + * @param retention_time - number of seconds a message is retained in the queue table after + * being dequeued from the queue + * @param comment - Description of the queue + * + * @note + * See OCI_QueueCreate() for more details + * + * @warning + * This function updates all attributes handled in the parameter list ! + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueAlter +( + OCI_Connection *con, + const otext * queue_name, + unsigned int max_retries, + unsigned int retry_delay, + unsigned int retention_time, + const otext * comment +); + +/** + * @brief + * Drop the given queue + * + * @param con - Connection handle + * @param queue_name - Queue name + * + * @warning + * A queue can be dropped only if it has been stopped before. + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueDrop +( + OCI_Connection *con, + const otext * queue_name +); + +/** + * @brief + * Start the given queue + * + * @param con - Connection handle + * @param queue_name - Queue name + * @param enqueue - Enable enqueue + * @param dequeue - Enable dequeue + * + * @warning + * For exception queues, only enqueuing is allowed + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.START_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueStart +( + OCI_Connection *con, + const otext * queue_name, + boolean enqueue, + boolean dequeue +); + +/** + * @brief + * Stop enqueuing or dequeuing or both on the given queue + * + * @param con - Connection handle + * @param queue_name - Queue name + * @param enqueue - Disable enqueue + * @param dequeue - Disable dequeue + * @param wait - Wait for current pending enqueues/dequeues + * + * @warning + * A queue cannot be stopped if there are pending transactions against the queue. + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.STOP_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueStop +( + OCI_Connection *con, + const otext * queue_name, + boolean enqueue, + boolean dequeue, + boolean wait +); + +/** + * @brief + * Create a queue table for messages of the given type + * + * @param con - Connection handle + * @param queue_table - Queue table name + * @param queue_payload_type - Message type name + * @param storage_clause - Additional clauses for the table storage + * @param sort_list - Additional columns name to use for sorting + * @param multiple_consumers - Enable multiple consumers for each messages + * @param message_grouping - Specifies if messages are grouped within a transaction + * @param comment - Description of the queue table + * @param primary_instance - primary owner (instance) of the queue table + * @param secondary_instance - Owner of the queue table if the primary instance is not available + * @param compatible - lowest database version with which the queue table is compatible + * + * @note + * Parameter 'queue_table' can specify the schema where to create to queue table ([schema.]queue_table) + * Queue table names cannot be longer than 24 characters (Oracle limit for user queue tables) + * + * @note + * Possible values for parameter 'queue_payload_type' : + * - For Oracle types (UDT) : use the type name ([schema.].type_name) + * - For RAW data : use "SYS.RAW" or "RAW" + * + * @note + * Possible values for parameter 'message_grouping' : + * - OCI_AGM_NONE : each message is treated individually + * - OCI_AGM_TRANSACTIONNAL : all messages enqueued in one transaction are considered part of + * the same group and can be dequeued as a group of related messages. + * + * @note + * Possible values for parameter 'compatible' : + * - "8.0", "8.1", "10.0" + * + * To set default values, pass : + * - storage_clause : NULL + * - sort_list : NULL + * - message_grouping : OCI_AGM_NONE + * - comment : NULL + * - primary_instance : 0 + * - primary_instance : 0 + * - compatible : NULL + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueTableCreate +( + OCI_Connection *con, + const otext * queue_table, + const otext * queue_payload_type, + const otext * storage_clause, + const otext * sort_list, + boolean multiple_consumers, + unsigned int message_grouping, + const otext * comment, + unsigned int primary_instance, + unsigned int secondary_instance, + const otext * compatible +); + +/** + * @brief + * Alter the given queue table + * + * @param con - Connection handle + * @param queue_table - Queue table name + * @param comment - Description of the queue table + * @param primary_instance - primary owner (instance) of the queue table + * @param secondary_instance - Owner of the queue table if the primary instance is not available + * + * @note + * See OCI_QueueTableCreate() from more details + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueTableAlter +( + OCI_Connection *con, + const otext * queue_table, + const otext * comment, + unsigned int primary_instance, + unsigned int secondary_instance +); + +/** + * @brief + * Drop the given queue table + * + * @param con - Connection handle + * @param queue_table - Queue table name + * @param force - Force the deletion of objects related to the queue table + * + * @note + * Possible values for 'force' : + * - TRUE : all queues using the queue table and their associated propagation schedules are + * dropped automatically + * - FALSE : All the queues using the given queue table must be stopped and dropped before the + * queue table can be dropped. + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueTableDrop +( + OCI_Connection *con, + const otext * queue_table, + boolean force +); + +/** + * @brief + * Purge messages from the given queue table + * + * @param con - Connection handle + * @param queue_table - Queue table name + * @param purge_condition - Optional SQL based conditions (see notes) + * @param block - Lock all queues using the queue table while doing the purge + * @param delivery_mode - Type of message to purge + * + * @note + * Possible values for parameter 'delivery_mode' : + * - OCI_APM_BUFFERED : purge only buffered messages + * - OCI_APM_PERSISTENT : purge only persistent messages + * - OCI_APM_ALL : purge all messages + * + * @note + * For more information about the SQL purge conditions, refer to + * Oracle Streams - Advanced Queuing User's Guide for more details + * + * @warning + * This feature is only available from Oracle 10gR2. + * This function does nothing and returns TRUE is the server version is < Oracle 10gR2 + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.PURGE_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueTablePurge +( + OCI_Connection *con, + const otext * queue_table, + const otext * purge_condition, + boolean block, + unsigned int delivery_mode +); + +/** + * @brief + * Migrate a queue table from one version to another + * + * @param con - Connection handle + * @param queue_table - Queue table name + * @param compatible - Database version with witch the queue table has to migrate + * + * @note + * Possible values for parameter 'compatible' : + * - "8.0", "8.1", "10.0" + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.MIGRATE_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_QueueTableMigrate +( + OCI_Connection *con, + const otext * queue_table, + const otext * compatible +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiSubscriptions Database Change notifications (DCN or CQN) + * @{ + * + * OCILIB supports Oracle 10gR2 feature Database Change Notifications (DCN) + * also named Continuous Query Notifications (CQN) + * + * This features allows a client application to register notifications + * when some changes are made in a database : + * - Database status changes : startup and shutdown + * - Database objects changes : + * - DDL changes : alter or drop actions + * - DML changes : insert, delete, update actions + * + * This feature can be really useful in applications that hold + * a cache of data. Instead of refreshing data periodically by + * connecting to the server, the application could only refresh + * modified data when necessary or perform specific tasks depending on + * the events. It saves application time, network traffic and can help + * the design of the application logic. + * + * The database status change notification is also interesting to be + * informed of instance startup / shutdown + * + * Check Oracle documentation for more details about this feature + * + * @note + * No active database connection is required to receive the + * notifications as they are handled by the Oracle client using a + * dedicated socket connection to the server + * + * @par Database changes + * + * The client application can be notified of any database status + * change (single DB or multiple DB in a RAC environment). + * + * @par Object changes + * + * The notifications of object changes are based on the registration + * of a query ('select' SQL statement). + * + * Oracle server will notify of any changes of any object that is + * part of the statement result set. + * + * Registering a statement will notify about any changes on its + * result set rows performed after the registration of the query. + * + * The query can be a simple 'select * from table' or a complex + * query involving many tables and/or criteria in the where clause. + * + * For Object changes, the notification can be at : + * - At Object level : only the object name (schema + object) is given + * - At row level : same that object level + RowID of the altered row + * + * @warning + * Trying to use this features with a client/server version < 10gR2 will raise an error + * + * @par Example + * @include notification.c + * + */ + +/** + * @brief + * Register a notification against the given database + * + * @param con - Connection handle + * @param name - Notification name + * @param type - Subscription type + * @param handler - User handler callback + * @param port - Port to use for notifications + * @param timeout - notification timeout + * + * @note + * Parameter 'type' can be one of the following values : + * + * - OCI_CNT_OBJECTS : request for changes at objects (e.g. tables) level (DDL / DML) + * - OCI_CNT_ROWS : request for changes at rows level (DML) + * - OCI_CNT_DATABASES : request for changes at database level (startup, shutdown) + * - OCI_CNT_ALL : request for all changes + * + * @note + * Parameter 'port' and 'timeout' are optional (use value 0 a optional value) + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + * @ @warning Port usage + * All notifications are using the same port. + * Port number can be either: + * - determined automatically by Oracle client once the first subscription had been created and can be retrieved using OCI_SubscriptionGetPort() + * - Set by the parameter 'port' during the first call to OCI_SubscriptionRegister(). In this case later calls can provide same port number or 0 + * + * @note + * Requires Oracle Client 10gR2 or above + * + * @note + * Subscription handles are automatically managed by the library + * + * @return + * Subscription handle on success or NULL on failure + * + */ + +OCI_EXPORT OCI_Subscription * OCI_API OCI_SubscriptionRegister +( + OCI_Connection *con, + const otext * name, + unsigned int type, + POCI_NOTIFY handler, + unsigned int port, + unsigned int timeout +); + +/** + * @brief + * Unregister a previously registered notification + * + * @param sub - Subscription handle + * + * @note + * OCI_Cleanup() will automatically unregister any registered subscriptions + * + * @note + * If the database connection passed to OCI_SubscriptionRegister() + * has been closed by the time that the application calls + * OCI_SubscriptionUnregister, the library internally reconnects + * to the given database, performs the unregistration and then disconnects + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SubscriptionUnregister +( + OCI_Subscription *sub +); + +/** + * @brief + * Add a statement to the notification to monitor + * + * @param sub - Subscription handle + * @param stmt - Statement handle + * + * @note + * The given statement must be prepared but not executed before being passed to this function. + * OCI_SubscriptionAddStatement() executes the statement and register it for notifications + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + * @note + * The given statement must hold a 'SELECT' SQL statement + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_SubscriptionAddStatement +( + OCI_Subscription *sub, + OCI_Statement * stmt +); + +/** + * @brief + * Return the name of the given registered subscription + * + * @param sub - Subscription handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT const otext * OCI_API OCI_SubscriptionGetName +( + OCI_Subscription *sub +); + +/** + * @brief + * Return the port used by the notification + * + * @param sub - Subscription handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_SubscriptionGetPort +( + OCI_Subscription *sub +); + +/** + * @brief + * Return the timeout of the given registered subscription + * + * @param sub - Subscription handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_SubscriptionGetTimeout +( + OCI_Subscription *sub +); + +/** + * @brief + * Return the connection handle associated with a subscription handle + * + * @param sub - Subscription handle + * + * @note + * It may return a NULL handle if the connection used in OCI_SubscriptionRegister has been closed. + * + */ + +OCI_EXPORT OCI_Connection * OCI_API OCI_SubscriptionGetConnection +( + OCI_Subscription *sub +); + +/** + * @brief + * Return the type of event reported by a notification + * + * @param event - Event handle + * + * @note + * The returned value can be one of the following values : + * + * - OCI_ENT_STARTUP : a database has been started up + * - OCI_ENT_SHUTDOWN : a database has been shut down + * - OCI_ENT_SHUTDOWN_ANY : a database has been shut down (RAC) + * - OCI_ENT_DROP_DATABASE : a database has been dropped + * - OCI_ENT_DEREGISTER : the notification is timed out + * - OCI_ENT_OBJECT_CHANGED : a database object has been modified + * + * @note + * OCI_EventGetDatabase() returns the affected database + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + * @note + * OCI_EventGetObject() returns the affected object + * ('schema_name'.'object_name') + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_EventGetType +( + OCI_Event *event +); + +/** + * @brief + * Return the type of operation reported by a notification + * + * @param event - Event handle + * + * @note + * This call is only valid when OCI_EventGetType() reports the + * event type OCI_ENT_OBJECT_CHANGED + * + * @note + * The returned value can be one of the following values : + * + * - OCI_ONT_INSERT : an insert has been performed + * - OCI_ONT_UPDATE : an update has been performed + * - OCI_ONT_DELETE : a delete has been performed + * - OCI_ONT_ALTER : an alter has been performed + * - OCI_ONT_DROP : a drop has been performed + * - OCI_ONT_GENERIC : generic undefined action + * + * @note + * OCI_EventGetDatabase() returns the affected database + * + * @note + * OCI_EventGetObject() returns the affected object ('schema_name'.'object_name') + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + * @note + * if OCI_CNT_ROWS is passed to OCI_SubscriptionRegister(), + * the rowid of the altered row can be retrieved with OCI_EventGetRowid() + * + */ + +OCI_EXPORT unsigned int OCI_API OCI_EventGetOperation +( + OCI_Event *event +); + +/** + * @brief + * Return the name of the database that generated the event + * + * @param event - Event handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT const otext * OCI_API OCI_EventGetDatabase +( + OCI_Event *event +); + +/** + * @brief + * Return the name of the object that generated the event + * + * @param event - Event handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT const otext * OCI_API OCI_EventGetObject +( + OCI_Event *event +); + +/** + * @brief + * Return the rowid of the altered database object row + * + * @param event - Event handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT const otext * OCI_API OCI_EventGetRowid +( + OCI_Event *event +); + +/** + * @brief + * Return the subscription handle that generated this event + * + * @param event - Event handle + * + * @note + * OCI_ENV_EVENTS flag must be passed to OCI_Initialize() to be able to use + * subscriptions + * + */ + +OCI_EXPORT OCI_Subscription * OCI_API OCI_EventGetSubscription +( + OCI_Event *event +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiInstancesManagement Remote Instance startup/shutdown + * @{ + * + * OCILIB supports Oracle 11g client features for manipulating remote Oracle instances. + * + * Oracle instances (on the same computer or on a remote server) can be : + * + * - started with OCI_DatabaseStartup() + * - shutdown with OCI_DatabaseShutdown() + * + * Several options are handled for this actions + * + * @par Example + * @include instance.c + * + */ + +/** + * @brief + * Start a database instance + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param sess_mode - Session mode + * @param start_mode - Start mode + * @param start_flag - Start flags + * @param spfile - Client-side spfile to start up the database (optional) + * + * Possible values for parameter session mode : + * - OCI_SESSION_SYSDBA + * - OCI_SESSION_SYSOPER + * + * @note + * External credentials are supported by supplying a null value for the 'user' and 'pwd' parameters + * If the param 'db' is NULL then a connection to the default local DB is done + * + * Possible (combined) values for parameter start_mode : + * - OCI_DB_SPM_START : start the instance + * - OCI_DB_SPM_MOUNT : mount the instance + * - OCI_DB_SPM_OPEN : open the instance + * - OCI_DB_SPM_FULL : start, mount and open the instance + * + * Possible (combined) values for parameter start_flag : + * - OCI_DB_SPF_DEFAULT : default startup + * - OCI_DB_SPF_FORCE : shuts down a running instance (if needed) using + * ABORT command and starts a new instance + * - OCI_DB_SPF_RESTRICT : allows database access only to users with both + * CREATE SESSION and RESTRICTED SESSION privileges + * + * @note + * If the client side spfile is not provided, the database is started with its server-side spfile + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DatabaseStartup +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int sess_mode, + unsigned int start_mode, + unsigned int start_flag, + const otext *spfile +); + +/** + * @brief + * Shutdown a database instance + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param sess_mode - Session mode + * @param shut_mode - Shutdown mode + * @param shut_flag - Shutdown flag + * + * + * @warning + * Possible values for parameter session mode : + * - OCI_SESSION_SYSDBA + * - OCI_SESSION_SYSOPER + * + * @note + * External credentials are supported by supplying a null value for the 'user' and 'pwd' parameters + * If the param 'db' is NULL then a connection to the default local DB is done + * + * Possible (combined) values for parameter shut_mode : + * - OCI_DB_SDM_SHUTDOWN : shutdown the instance + * - OCI_DB_SDM_CLOSE : close the instance + * - OCI_DB_SDM_DISMOUNT : dismount the instance + * - OCI_DB_SDM_FULL : shutdown, close and dismount the instance + * + * Possible (exclusive) value for parameter shut_flag (from Oracle documentation) : + * - OCI_DB_SDF_DEFAULT : + * - Further connects are prohibited. + * - Waits for users to disconnect from the database + * - OCI_DB_SDF_TRANS : + * - Further connects are prohibited + * - No new transactions are allowed. + * - Waits for active transactions to complete + * - OCI_DB_SDF_TRANS_LOCAL : + * - Further connects are prohibited + * - No new transactions are allowed. + * - Waits only for local transactions to complete + * - OCI_DB_SDF_IMMEDIATE : + * - Does not wait for current calls to complete or users to disconnect from the database. + * - All uncommitted transactions are terminated and rolled back + * - OCI_DB_SDF_ABORT : + * - Does not wait for current calls to complete or users to disconnect from the database. + * - All uncommitted transactions are terminated and are not rolled back. + * - This is the fastest possible way to shut down the database, but the next + * database startup may require instance recovery. + * - Therefore, this option should be used only in unusual circumstances + * + * @return + * TRUE on success otherwise FALSE + * + */ + +OCI_EXPORT boolean OCI_API OCI_DatabaseShutdown +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int sess_mode, + unsigned int shut_mode, + unsigned int shut_flag +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiRawHandles Using OCI Handles directly + * @{ + * + * OCILIB conception was focused on a full but closed encapsulation of OCI. + * + * All OCI headers, data types, prototypes are imported internally + * (linkage or runtime import). + * + * OCILIB public interface exposes only ISO C scalar types and OCILIB objects + * + * OCI is a wide and rich API that can deals with hundreds of options ! + * + * OCILIB tries to implements most of it. But, sometimes in really specific + * contexts, it might be necessary to directly call OCI APIs in order to use + * uncovered OCI functionalities or options + * + * OCILIB proposes now a set of functions to retrieve its internal OCI handles + * + * @warning + * + * The OCILIB author strongly advises against the use of internal handles, + * unless there is no other way to accomplish the task + * + * @warning + * + * Using these handles for direct application calls to OCI might lead + * to OCILIB instability or crash if handles are incorrectly used ! + * + */ + +/** + * @brief + * Return the OCI Environment Handle (OCIEnv *) of OCILIB library + * + * @return + * OCI Environment handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetEnvironment +( + void +); + +/** + * @brief + * Return the OCI Context Handle (OCISvcCtx *) of an OCILIB OCI_Connection object + * + * @param con - Connection handle + * + * @return + * OCI Context handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetContext +( + OCI_Connection *con +); + +/** + * @brief + * Return the OCI Server Handle (OCIServer *) of an OCILIB OCI_Connection object + * + * @param con - Connection handle + * + * @return + * OCI Server handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetServer +( + OCI_Connection *con +); + +/** + * @brief + * Return the OCI Error Handle (OCIError *) of an OCILIB OCI_Connection object + * + * @param con - Connection handle + * + * @return + * OCI Error handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetError +( + OCI_Connection *con +); + +/** + * @brief + * Return the OCI Session Handle (OCISession *) of an OCILIB OCI_Connection object + * + * @param con - Connection handle + * + * @return + * OCI Session handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetSession +( + OCI_Connection *con +); + +/** + * @brief + * Return the OCI Transaction Handle (OCITrans *) of an OCILIB OCI_Transaction object + * + * @param trans - Transaction handle + * + * @return + * OCI Transaction handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetTransaction +( + OCI_Transaction *trans +); + +/** + * @brief + * Return the OCI Statement Handle (OCIStmt *) of an OCILIB OCI_Statement object + * + * @param stmt - Statement handle + * + * @return + * OCI Statement handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetStatement +( + OCI_Statement *stmt +); + +/** + * @brief + * Return the OCI LobLocator Handle (OCILobLocator *) of an OCILIB OCI_Lob object + * + * @param lob - Lob handle + * + * @return + * OCI LobLocator handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetLob +( + OCI_Lob *lob +); + +/** + * @brief + * Return the OCI LobLocator Handle (OCILobLocator *) of an OCILIB OCI_File object + * + * @param file - File handle + * + * @return + * OCI LobLocator handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetFile +( + OCI_File *file +); + +/** + * @brief + * Return the OCI Date Handle (OCIDate *) of an OCILIB OCI_Date object + * + * @param date - Date handle + * + * @return + * OCI Date handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetDate +( + OCI_Date *date +); + +/** + * @brief + * Return the OCI Date time Handle (OCIDatetime *) of an OCILIB OCI_Timestamp object + * + * @param tmsp - Timestamp handle + * + * @return + * OCI Date time handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetTimestamp +( + OCI_Timestamp *tmsp +); + +/** + * @brief + * Return OCI Interval Handle (OCIInterval *) of an OCILIB OCI_Interval object + * + * @param itv - Interval handle + * + * @return + * OCI Interval handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetInterval +( + OCI_Interval *itv +); + +/** + * @brief + * Return OCI Object Handle (void *) of an OCILIB OCI_Object object + * + * @param obj - Object handle + * + * @return + * OCI Object handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetObject +( + OCI_Object *obj +); + +/** + * @brief + * Return OCI Collection Handle (OCIColl *) of an OCILIB OCI_Coll object + * + * @param coll - Collection handle + * + * @return + * OCI Collection handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetColl +( + OCI_Coll *coll +); + +/** + * @brief + * Return OCI Ref Handle (OCIRef *) of an OCILIB OCI_Ref object + * + * @param ref - Ref handle + * + * @return + * OCI Ref handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetRef +( + OCI_Ref *ref +); + +/** + * @brief + * Return OCI Mutex handle (OCIThreadMutex *) of an OCILIB OCI_Mutex object + * + * @param mutex - Mutex handle + * + * @return + * OCI Mutex handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetMutex +( + OCI_Mutex *mutex +); + +/** + * @brief + * Return OCI Thread ID (OCIThreadId *) of an OCILIB OCI_Thread object + * + * @param thread - Thread handle + * + * @return + * OCI Thread ID otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetThreadID +( + OCI_Thread *thread +); + +/** + * @brief + * Return OCI Thread handle (OCIThreadHandle *) of an OCILIB OCI_Thread object + * + * @param thread - Thread handle + * + * @return + * OCI Thread handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetThread +( + OCI_Thread *thread +); + +/** + * @brief + * Return OCI DirectPath Context handle (OCIDirPathCtx *) of an OCILIB OCI_DirPath object + * + * @param dp - DirectPath handle + * + * @return + * OCI DirectPath Context handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetDirPathCtx +( + OCI_DirPath *dp +); + +/** + * @brief + * Return OCI DirectPath Column array handle (OCIDirPathColArray *) of an OCILIB OCI_DirPath object + * + * @param dp - DirectPath handle + * + * @return + * OCI DirectPath Column array handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetDirPathColArray +( + OCI_DirPath *dp +); + +/** + * @brief + * Return OCI DirectPath Stream handle (OCIDirPathStream *) of an OCILIB OCI_DirPath object + * + * @param dp - DirectPath handle + * + * @return + * OCI DirectPath Stream handle otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetDirPathStream +( + OCI_DirPath *dp +); + +/** + * @brief + * Return OCI Subscription handle (OCISubscription *) of an OCILIB OCI_Subscription object + * + * @param sub - Subscription handle + * + * @return + * OCI Subscription otherwise NULL + * + */ + +OCI_EXPORT const void * OCI_API OCI_HandleGetSubscription +( + OCI_Subscription *sub +); + +/** + * @} + */ + +/** + * @defgroup OcilibCApiDemoApplication OCILIB main demo application code + * @{ + * + * Portable Main demo application header + * @include ocilib_demo.h + * + * Portable Main demo application source + * @include ocilib_demo.c + * + * @} + */ + +/** +* @} +*/ + +#endif /* OCILIB_API_H_INCLUDED */ diff --git a/include/ocilib_compat.h b/include/ocilib_compat.h new file mode 100644 index 00000000..26b857a5 --- /dev/null +++ b/include/ocilib_compat.h @@ -0,0 +1,310 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* IMPORTANT NOTICE + * + * This file contains explanations about Oracle and OCI technologies. + * OCILIB is a wrapper around OCI and thus exposes OCI features. + * The OCILIB documentation intends to explain Oracle / OCI concepts + * and is naturally based on the official Oracle OCI documentation. + * + * Some parts of OCILIB documentation may include some information + * taken and adapted from the following Oracle documentations : + * - Oracle Call Interface Programmer's Guide + * - Oracle Streams - Advanced Queuing User's Guide + */ + +#ifndef OCILIB_COMPAT_H_INCLUDED +#define OCILIB_COMPAT_H_INCLUDED + +#include "ocilib_api.h" + +/** + * @defgroup OcilibCApi C API + * @{ + * + */ + +/* Compatibility with sources built with older versions of OCILIB */ + +/* macros added in version 2.3.0 */ + +#define OCI_CreateConnection OCI_ConnectionCreate +#define OCI_FreeConnection OCI_ConnectionFree +#define OCI_CreateStatement OCI_StatementCreate +#define OCI_FreeStatement OCI_StatementFree + +/* macros added in version 2.4.0 */ + +#define OCI_CreateTransaction OCI_TransactionCreate +#define OCI_FreeTransaction OCI_TransactionFree +#define OCI_CreateHashTable OCI_HashCreate +#define OCI_FreeHashTable OCI_HashFree + +/* macros added in version 3.0.0 */ + +#define OCI_GetColumnName OCI_ColumnGetName +#define OCI_GetColumnType OCI_ColumnGetType +#define OCI_GetColumnCharsetForm OCI_ColumnGetCharsetForm +#define OCI_GetColumnSQLType OCI_ColumnGetSQLType +#define OCI_GetColumnFullSQLType OCI_ColumnGetFullSQLType +#define OCI_GetColumnSize OCI_ColumnGetSize +#define OCI_GetColumnScale OCI_ColumnGetScale +#define OCI_GetColumnPrecision OCI_ColumnGetPrecision +#define OCI_GetColumnFractionnalPrecision OCI_ColumnGetFractionnalPrecision +#define OCI_GetColumnLeadingPrecision OCI_ColumnGetLeadingPrecision +#define OCI_GetColumnNullable OCI_ColumnGetNullable +#define OCI_GetColumnCharUsed OCI_ColumnGetCharUsed + +#define OCI_GetFormatDate(s) OCI_GetDefaultFormatDate(OCI_StatementGetConnection(s)) +#define OCI_SetFormatDate(s, f) OCI_SetDefaultFormatDate(OCI_StatementGetConnection( \ + s), f) + +#define OCI_ERR_API OCI_ERR_ORACLE + +/* macros added in version 3.2.0 */ + +#define OCI_ERR_NOT_SUPPORTED OCI_ERR_DATATYPE_NOT_SUPPORTED +#define OCI_SCHEMA_TABLE OCI_TIF_TABLE +#define OCI_SCHEMA_VIEW OCI_TIF_VIEW +#define OCI_SCHEMA_TYPE OCI_TIF_TYPE + +#define OCI_Schema OCI_TypeInfo + +#define OCI_SchemaGet OCI_TypeInfoGet +#define OCI_SchemaFree OCI_TypeInfoFree +#define OCI_SchemaGetColumnCount OCI_TypeInfoGetColumnCount +#define OCI_SchemaGetColumn OCI_TypeInfoGetColumn +#define OCI_SchemaGetName OCI_TypeInfoGetName + +#define OCI_ColumnGetFractionnalPrecision OCI_ColumnGetFractionalPrecision + +/* macro added in version 3.3.0 */ + +/** + * @brief + * [OBSOLETE] Set the bind variable at the given index to null + * + * @param stmt - OCI_Statement handle + * @param index - Index of the bind variable + * + * @warning + * This call is obsolete ! Use OCI_BindSetNull() instead. + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @warning + * Index starts with 1 + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + */ + +#define OCI_SetNull(stmt, index) \ + OCI_BindSetNull(OCI_GetBind(stmt, index)) + +/** + * @brief + * [OBSOLETE] Set the bind variable of the given name to null + * + * @param stmt - OCI_Statement handle + * @param name - OCI_Bind variable name + * + * @warning + * This call is obsolete ! Use OCI_BindSetNull() instead. + * + * @note + * There is no notion of null value in C. + * it's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + */ + +#define OCI_SetNull2(stmt, name) \ + OCI_BindSetNull(OCI_GetBind2(stmt, name)) + +/** + * @brief + * [OBSOLETE] Set to null the bind variable at the given position in an input array + * + * @param stmt - OCI_Statement handle + * @param index - Index of the bind variable + * @param position - Position in the array + * + * @warning + * This call is obsolete ! Use OCI_BindSetNullAtPos() instead. + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @warning + * Index and Position starts with 1 + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + * + */ + +#define OCI_SetNullAtPos(stmt, index, position) \ + OCI_BindSetNullAtPos(OCI_GetBind(stmt, index), position) + +/** + * @brief + * [OBSOLETE] Set to null the bind variable of the given name in an input array + * + * @param stmt - OCI_Statement handle + * @param name - OCI_Bind variable name + * @param position - Position in the array + * + * @warning + * This call is obsolete ! Use OCI_BindSetNullAtPos() instead. + * + * @note + * There is no notion of null value in C. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an OCI_Execute() call + * + * @warning + * Position starts with 1 + * + * @note + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @return + * TRUE on success otherwise FALSE + * + */ + +#define OCI_SetNullAtPos2(stmt, name, position) \ + OCI_BindSetNullAtPos(OCI_GetBind2(stmt, name), position) + +/* macro added in version 3.4.0 */ + +#define OCI_8 OCI_8_1 +#define OCI_9 OCI_9_0 +#define OCI_10 OCI_10_1 +#define OCI_11 OCI_11_1 + +/* macro added in version 3.6.0 */ + +#define OCI_CHAR_UNICODE OCI_CHAR_WIDE +#define OCI_CSF_CHARSET OCI_CSF_DEFAULT + +/* macro added in version 3.7.0 */ + +#define OCI_ConnPool OCI_Pool + +#define OCI_ConnPoolCreate(db, us, pw, mo, mi, ma, in) \ + OCI_PoolCreate(db, us, pw, OCI_POOL_CONNECTION, mo, mi, ma, in) + +#define OCI_ConnPoolGetConnection(p) \ + OCI_PoolGetConnection(p, NULL) + +#define OCI_ConnPoolFree OCI_PoolFree +#define OCI_ConnPoolGetTimeout OCI_PoolGetConnection +#define OCI_ConnPoolSetTimeout OCI_PoolSetTimeout +#define OCI_ConnPoolGetNoWait OCI_PoolGetNoWait +#define OCI_ConnPoolSetNoWait OCI_PoolSetNoWait +#define OCI_ConnPoolGetBusyCount OCI_PoolGetBusyCount +#define OCI_ConnPoolGetOpenedCount OCI_PoolGetOpenedCount +#define OCI_ConnPoolGetMin OCI_PoolGetMin +#define OCI_ConnPoolGetMax OCI_PoolGetMax +#define OCI_ConnPoolGetIncrement OCI_PoolGetIncrement + +/* macro added in version 3.8.0 */ + +#define OCI_ObjectGetTimeStamp OCI_ObjectGetTimestamp +#define OCI_ElemGetTimeStamp OCI_ElemGetTimestamp +#define OCI_TimestampSysTimeStamp OCI_TimestampSysTimestamp + +/* macro added in version 4.0.0 */ + +#define OCI_CollSetAt OCI_CollSetElem +#define OCI_CollGetAt OCI_CollGetElem +#define OCI_CollGetAt2 OCI_CollGetElem2 + +#define OCI_GetCharsetMetaData OCI_GetCharset +#define OCI_GetCharsetUserData OCI_GetCharset +#define OCI_SIZE_TRACE_INF0 OCI_SIZE_TRACE_INFO + +#define MT(x) OTEXT(x) +#define mtext otext +#define DT(x) OTEXT(x) +#define dtext otext + +#define mtsdup ostrdup +#define mtscpy ostrcpy +#define mtsncpy ostrncpy +#define mtscat ostrcat +#define mtsncat ostrncat +#define mtslen ostrlen +#define mtscmp ostrcmp +#define mtscasecmp ostrcasecmp +#define mtsprintf osprintf +#define mtstol ostrtol +#define mtsscanf osscanf + +#define dtsdup ostrdup +#define dtscpy ostrcpy +#define dtsncpy ostrncpy +#define dtscat ostrcat +#define dtsncat ostrncat +#define dtslen ostrlen +#define dtscmp ostrcmp +#define dtscasecmp ostrcasecmp +#define dtsprintf osprintf +#define dtstol ostrtol +#define dtsscanf osscanf + +/* macro added in version 4.1.0 */ + +#define OCI_SetDefaultFormatDate(con, fmt) OCI_SetFormat(con, OCI_FMT_DATE, fmt) +#define OCI_SetDefaultFormatNumeric(con, fmt) OCI_SetFormat(con, OCI_FMT_NUMERIC, fmt) + +#define OCI_GetDefaultFormatDate(con) OCI_GetFormat(con, OCI_FMT_DATE) +#define OCI_GetDefaultFormatNumeric(con) OCI_GetFormat(con, OCI_FMT_NUMERIC) + +#define OCI_STRING_FORMAT_NUM_BIN OCI_STRING_FORMAT_NUM_BDOUBLE + +/** + * @} + */ + +#endif /* OCILIB_COMPAT_H_INCLUDED */ diff --git a/include/ocilib_config.h b/include/ocilib_config.h new file mode 100644 index 00000000..03e9ab91 --- /dev/null +++ b/include/ocilib_config.h @@ -0,0 +1,1248 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* IMPORTANT NOTICE + * + * This file contains explanations about Oracle and OCI technologies. + * OCILIB is a wrapper around OCI and thus exposes OCI features. + * The OCILIB documentation intends to explain Oracle / OCI concepts + * and is naturally based on the official Oracle OCI documentation. + * + * Some parts of OCILIB documentation may include some information + * taken and adapted from the following Oracle documentations : + * - Oracle Call Interface Programmer's Guide + * - Oracle Streams - Advanced Queuing User's Guide + */ + +#ifndef OCILIB_CONFIG_H_INCLUDED +#define OCILIB_CONFIG_H_INCLUDED + +/** + * @defgroup OcilibCApi C API + * @{ + * + */ + +/* --------------------------------------------------------------------------------------------- * + * Platform configuration + * --------------------------------------------------------------------------------------------- */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +/* --------------------------------------------------------------------------------------------- * + * C headers + * --------------------------------------------------------------------------------------------- */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* --------------------------------------------------------------------------------------------- * + * MS Windows platform detection + * --------------------------------------------------------------------------------------------- */ + +#ifndef _WINDOWS +#if defined(_WIN32)|| defined(WIN32) || defined(_WIN64) || defined(WIN64) || defined(_WIN32_WINNT) + #define _WINDOWS +#endif +#endif + +#ifdef _WINDOWS +#ifdef boolean + #undef boolean +#endif +#include +#ifdef boolean + #undef boolean +#endif +#endif + +/* --------------------------------------------------------------------------------------------- * + * OCILIB version information + * --------------------------------------------------------------------------------------------- */ + +#define OCILIB_MAJOR_VERSION 4 +#define OCILIB_MINOR_VERSION 6 +#define OCILIB_REVISION_VERSION 4 + +/* Import mode */ + +#define OCI_IMPORT_MODE_LINKAGE 1 +#define OCI_IMPORT_MODE_RUNTIME 2 + +#ifdef OCI_IMPORT_RUNTIME +#undef OCI_IMPORT_LINKAGE +#endif + +#ifdef OCI_IMPORT_LINKAGE + #undef OCI_IMPORT_RUNTIME +#endif + +#if !defined(OCI_IMPORT_RUNTIME) && !defined(OCI_IMPORT_LINKAGE) + #define OCI_IMPORT_LINKAGE +#endif + +#ifdef OCI_IMPORT_RUNTIME +#define OCI_IMPORT_MODE OCI_IMPORT_MODE_RUNTIME +#else + #define OCI_IMPORT_MODE OCI_IMPORT_MODE_LINKAGE +#endif + +/* Charset modes */ + +#ifdef OCI_CHARSET_UNICODE + #define OCI_CHARSET_WIDE +#endif + +#ifdef OCI_CHARSET_WIDE +#undef OCI_CHARSET_ANSI +#endif + +#ifdef OCI_CHARSET_ANSI + #undef OCI_CHARSET_ANSI +#endif + +#if !defined(OCI_CHARSET_ANSI) && !defined(OCI_CHARSET_WIDE) + #define OCI_CHARSET_ANSI +#endif + +/* Calling convention */ + +#ifndef OCI_API +#ifdef _MSC_VER + #define OCI_API __stdcall +#else + #define OCI_API +#endif +#endif + +/* Build mode */ + +#ifndef OCI_EXPORT + #define OCI_EXPORT +#endif + +/** + * @defgroup OcilibCApiSupportedCharsets Character sets + * @{ + * + * OCILIB supports both ANSI and Unicode. + * + * Oracle started a real Unicode support with Oracle8i but only for bind and fetch data. + * All SQL and PL/SQ/ statements, database objects names were still only supported in ANSI. + * + * With Oracle 9i, Oracle provides a full Unicode support. + * + * So depending on the compile time Oracle library or the runtime loaded library, Unicode support differs. + * + * OCILIB supports: + * + * - ANSI (char) + * - Unicode (wchar_t) + * - UTF8 strings + * + * OCILIB uses the character type 'otext' that is a define around char and wchar_t depending on the charset mode. + * + * @par Option OCI_CHARSET_ANSI + * + * - otext --> char + * - OTEXT(x) --> x + * + * @par Option OCI_CHARSET_WIDE + * + * - otext --> wchar_t + * - OTEXT(x) --> L ## x + * + * @par Unicode and ISO C + * + * Well, ISO C: + * - does not know anything about Unicode. + * - makes wide characters support tricky because wide character size is not defined and is freely adaptable by implementations. + * + * OCILIB uses char/wchar_t strings for both public interface and internal storage. + * + * Unicode builds of OCILIB initialize OCI in UTF16 Unicode mode. + * Oracle implements this mode with a 2 bytes (fixed length) UTF16 encoding. + * + * @warning + * When using Unicode builds of OCILIB, make sure that the target + * Database charset is also using an Unicode charset or is a superset of UTF16. + * If not, strings may be converted with substitution characters by the Oracle client ! + * + * So, on systems implementing wchar_t as 2 bytes based UTF16 (e.g. Ms Windows), + * strings are directly passed to Oracle and taken back from it. + * + * On other systems (most of the Unix systems) that use UTF32 as encoding, (4 bytes based wchar_t), OCILIB uses: + * - temporary buffers for statements and object names + * - buffer expansion from UTF16 to UTF32 for fetch and bind string: + * - allocation based on sizeof(wchar_t) + * - data filling based on sizeof(short) -> (UTF16 2 bytes) + * - data expansion to sizeof(wchar_t). + * + * Buffer expansion is done in place and has the advantage of not requiring extra buffer. + * That reduces the cost of the Unicode/ISO C handling overhead on Unix systems. + * + * @par UTF8 strings + * + * OCILIB fully supports UTF8 strings : + * - Within OCI_CHARSET_ANSI builds + * - NLS_LANG environment variable must be set to any valid UTF8 Oracle charset string + * + * @par Charset mapping macros + * + * OCILIB main header file provides macro around most common string functions of + * the C standard library. + * + * these macros are based on the model: ostr[libc function name]() + * + * xxx is the standard C library string function name without the character type prefix (str/wcs). + * + * List of available macros: + * - ostrdup + * - ostrcpy + * - ostrncpy + * - ostrcat + * - ostrncat + * - ostrlen + * - ostrcmp + * - ostrcasecmp + * - osprintf + * - ostol + * +**/ + +#if defined(__cplusplus) && defined(_MSC_VER) && (_MSC_VER < 1300) +extern "C++" { +#endif + +#include + +#if defined(__cplusplus) && defined(_MSC_VER) && (_MSC_VER < 1300) +} +#endif + +/* Charset macros */ + +#define OCI_CHAR_ANSI 1 +#define OCI_CHAR_WIDE 2 + +#ifdef OCI_CHARSET_ANSI +typedef char otext; +#define OTEXT(x) x +#define OCI_CHAR_TEXT OCI_CHAR_ANSI +#else +typedef wchar_t otext; +#define OTEXT(x) L ## x +#define OCI_CHAR_TEXT OCI_CHAR_WIDE +#endif + +/* + For ISO conformance, strdup/wcsdup/stricmp/strncasecmp are not used. + All wide char routines are part of the 1995 Normative Addendum 1 to the ISO C90 standard. + OCILIB also needs an ANSI equivalent to swprintf => ocisprintf + Thus OCILIB exports the following helper functions + +*/ + +OCI_EXPORT int ocisprintf +( + char * str, + int size, + const char *format, + ... +); + +OCI_EXPORT char * ocistrdup +( + const char *src +); + +OCI_EXPORT int ocistrcasecmp +( + const char *str1, + const char *str2 +); + +OCI_EXPORT wchar_t * ociwcsdup +( + const wchar_t *src +); + +OCI_EXPORT int ociwcscasecmp +( + const wchar_t *str1, + const wchar_t *str2 +); + +/* special defines for Microsoft C runtime that is not C ISO compliant */ + +#ifdef _WINDOWS + +#define vsnprintf _vsnprintf +#define swprintf _snwprintf + +#endif + +/* helpers mapping macros */ + +#ifdef OCI_CHARSET_ANSI + #define ostrdup ocistrdup + #define ostrcpy strcpy + #define ostrncpy strncpy + #define ostrcat strcat + #define ostrncat strncat + #define ostrlen strlen + #define ostrcmp strcmp + #define ostrcasecmp ocistrcasecmp + #define osprintf ocisprintf + #define ostrtol strtol + #define osscanf sscanf + #define otoupper toupper + #define oisdigit isdigit +#else +#define ostrdup ociwcsdup +#define ostrcpy wcscpy +#define ostrncpy wcsncpy +#define ostrcat wcscat +#define ostrncat wcsncat +#define ostrlen wcslen +#define ostrcmp wcscmp +#define ostrcasecmp ociwcscasecmp +#define osprintf swprintf +#define ostrtol wcstol +#define osscanf swscanf +#define otoupper towupper +#define oisdigit iswdigit + +#endif + +/* string size macros */ + +#define otextsize(s) (ostrlen(s) * sizeof(otext)) + +/** + * @} + */ + +/** + * @typedef big_int + * + * @brief + * big_int is a C scalar integer (32 or 64 bits) depending on compiler support for 64bits integers. + * big_uint is an unsigned big_int + * + */ + +/* check for long long support */ + +#if defined(_LONGLONG) || defined(LONG_LONG_MAX) || defined(LLONG_MAX) || defined(__LONG_LONG_MAX__) + +/* C99 long long supported */ + +typedef long long big_int; +typedef unsigned long long big_uint; + +#define OCI_BIG_UINT_ENABLED + +#elif defined(_WINDOWS) + +/* Microsoft extension supported */ + +typedef __int64 big_int; +typedef unsigned __int64 big_uint; + + #define OCI_BIG_UINT_ENABLED + +#else + +typedef int big_int; +typedef unsigned int big_uint; + +#endif + +/** + * @} + */ + +/* boolean values */ + +#ifndef TRUE + #define TRUE 1 + #define FALSE 0 +#endif + +#ifndef boolean +#define boolean int +#endif + +/* versions extract macros */ + +#define OCI_VER_MAJ(v) (unsigned int) ((v)/100) +#define OCI_VER_MIN(v) (unsigned int) (((v)/10) - (((v)/100)*10)) +#define OCI_VER_REV(v) (unsigned int) ((v) - (((v)/10)*10)) + +#define OCI_VER_MAKE(x, y, z) ((x)*100 + (y)*10 + (z)) + +/* oracle OCI key versions*/ + +#define OCI_8_0 OCI_VER_MAKE( 8, 0, 0) +#define OCI_8_1 OCI_VER_MAKE( 8, 1, 0) +#define OCI_9_0 OCI_VER_MAKE( 9, 0, 0) +#define OCI_9_2 OCI_VER_MAKE( 9, 2, 0) +#define OCI_10_1 OCI_VER_MAKE(10, 1, 0) +#define OCI_10_2 OCI_VER_MAKE(10, 2, 0) +#define OCI_11_1 OCI_VER_MAKE(11, 1, 0) +#define OCI_11_2 OCI_VER_MAKE(11, 2, 0) +#define OCI_12_1 OCI_VER_MAKE(12, 1, 0) +#define OCI_12_2 OCI_VER_MAKE(12, 2, 0) +#define OCI_18_1 OCI_VER_MAKE(18, 1, 0) +#define OCI_18_2 OCI_VER_MAKE(18, 2, 0) +#define OCI_18_3 OCI_VER_MAKE(18, 3, 0) +#define OCI_18_4 OCI_VER_MAKE(18, 4, 0) +#define OCI_18_5 OCI_VER_MAKE(18, 5, 0) +#define OCI_19_3 OCI_VER_MAKE(19, 3, 0) +#define OCI_19_5 OCI_VER_MAKE(19, 5, 0) + +/* OCILIB Error types */ + +#define OCI_ERR_ORACLE 1 +#define OCI_ERR_OCILIB 2 +#define OCI_ERR_WARNING 3 + +/* OCILIB Error codes */ + +#define OCI_ERR_NONE 0 +#define OCI_ERR_NOT_INITIALIZED 1 +#define OCI_ERR_LOADING_SHARED_LIB 2 +#define OCI_ERR_LOADING_SYMBOLS 3 +#define OCI_ERR_MULTITHREADED 4 +#define OCI_ERR_MEMORY 5 +#define OCI_ERR_NOT_AVAILABLE 6 +#define OCI_ERR_NULL_POINTER 7 +#define OCI_ERR_DATATYPE_NOT_SUPPORTED 8 +#define OCI_ERR_PARSE_TOKEN 9 +#define OCI_ERR_MAP_ARGUMENT 10 +#define OCI_ERR_OUT_OF_BOUNDS 11 +#define OCI_ERR_UNFREED_DATA 12 +#define OCI_ERR_MAX_BIND 13 +#define OCI_ERR_ATTR_NOT_FOUND 14 +#define OCI_ERR_MIN_VALUE 15 +#define OCI_ERR_NOT_COMPATIBLE 16 +#define OCI_ERR_STMT_STATE 17 +#define OCI_ERR_STMT_NOT_SCROLLABLE 18 +#define OCI_ERR_BIND_ALREADY_USED 19 +#define OCI_ERR_BIND_ARRAY_SIZE 20 +#define OCI_ERR_COLUMN_NOT_FOUND 21 +#define OCI_ERR_DIRPATH_STATE 22 +#define OCI_ERR_CREATE_OCI_ENVIRONMENT 23 +#define OCI_ERR_REBIND_BAD_DATATYPE 24 +#define OCI_ERR_TYPEINFO_DATATYPE 25 +#define OCI_ERR_ITEM_NOT_FOUND 26 +#define OCI_ERR_ARG_INVALID_VALUE 27 +#define OCI_ERR_XA_ENV_FROM_STRING 28 +#define OCI_ERR_XA_CONN_FROM_STRING 29 +#define OCI_ERR_BIND_EXTERNAL_NOT_ALLOWED 30 + +#define OCI_ERR_COUNT 31 + +/* Public OCILIB handles */ + +#define OCI_IPC_TYPE_INFO 10 +#define OCI_IPC_CONNECTION 11 +#define OCI_IPC_POOL 12 +#define OCI_IPC_TRANSACTION 13 +#define OCI_IPC_STATEMENT 14 +#define OCI_IPC_RESULTSET 15 +#define OCI_IPC_COLUMN 16 +#define OCI_IPC_DATE 17 +#define OCI_IPC_TIMESTAMP 18 +#define OCI_IPC_INTERVAL 19 +#define OCI_IPC_LOB 20 +#define OCI_IPC_FILE 21 +#define OCI_IPC_LONG 22 +#define OCI_IPC_OBJECT 23 +#define OCI_IPC_COLLECTION 24 +#define OCI_IPC_ITERATOR 25 +#define OCI_IPC_ELEMENT 26 +#define OCI_IPC_NUMBER 27 +#define OCI_IPC_HASHTABLE 28 +#define OCI_IPC_THREAD 29 +#define OCI_IPC_MUTEX 30 +#define OCI_IPC_BIND 31 +#define OCI_IPC_REF 32 +#define OCI_IPC_DIRPATH 33 +#define OCI_IPC_NOTIFY 34 +#define OCI_IPC_EVENT 35 +#define OCI_IPC_ARRAY 36 +#define OCI_IPC_MSG 37 +#define OCI_IPC_ENQUEUE 38 +#define OCI_IPC_DEQUEUE 39 +#define OCI_IPC_AGENT 40 + +/* allocated bytes types */ + +#define OCI_MEM_ORACLE 1 +#define OCI_MEM_OCILIB 2 +#define OCI_MEM_ALL (OCI_MEM_ORACLE | OCI_MEM_OCILIB) + +/* binding */ + +#define OCI_BIND_BY_POS 0 +#define OCI_BIND_BY_NAME 1 +#define OCI_BIND_SIZE 6 +#define OCI_BIND_MAX 65535 + +/* fetching */ + +#define OCI_FETCH_SIZE 20 +#define OCI_PREFETCH_SIZE 20 +#define OCI_LONG_EXPLICIT 1 +#define OCI_LONG_IMPLICIT 2 + +/* unknown value */ + +#define OCI_UNKNOWN 0 + +/* C Data Type mapping */ + +#define OCI_CDT_NUMERIC 1 +#define OCI_CDT_DATETIME 3 +#define OCI_CDT_TEXT 4 +#define OCI_CDT_LONG 5 +#define OCI_CDT_CURSOR 6 +#define OCI_CDT_LOB 7 +#define OCI_CDT_FILE 8 +#define OCI_CDT_TIMESTAMP 9 +#define OCI_CDT_INTERVAL 10 +#define OCI_CDT_RAW 11 +#define OCI_CDT_OBJECT 12 +#define OCI_CDT_COLLECTION 13 +#define OCI_CDT_REF 14 +#define OCI_CDT_BOOLEAN 15 + +/* Data Type codes for OCI_ImmediateXXX() calls */ + +#define OCI_ARG_SHORT 1 +#define OCI_ARG_USHORT 2 +#define OCI_ARG_INT 3 +#define OCI_ARG_UINT 4 +#define OCI_ARG_BIGINT 5 +#define OCI_ARG_BIGUINT 6 +#define OCI_ARG_DOUBLE 7 +#define OCI_ARG_DATETIME 8 +#define OCI_ARG_TEXT 9 +#define OCI_ARG_LOB 10 +#define OCI_ARG_FILE 11 +#define OCI_ARG_TIMESTAMP 12 +#define OCI_ARG_INTERVAL 13 +#define OCI_ARG_RAW 14 +#define OCI_ARG_OBJECT 15 +#define OCI_ARG_COLLECTION 16 +#define OCI_ARG_REF 17 +#define OCI_ARG_FLOAT 18 +#define OCI_ARG_NUMBER 19 + +/* statement types */ + +#define OCI_CST_SELECT 1 +#define OCI_CST_UPDATE 2 +#define OCI_CST_DELETE 3 +#define OCI_CST_INSERT 4 +#define OCI_CST_CREATE 5 +#define OCI_CST_DROP 6 +#define OCI_CST_ALTER 7 +#define OCI_CST_BEGIN 8 +#define OCI_CST_DECLARE 9 +#define OCI_CST_CALL 10 +#define OCI_CST_MERGE 16 + +/* environment modes */ + +#define OCI_ENV_DEFAULT 0 +#define OCI_ENV_THREADED 1 +#define OCI_ENV_CONTEXT 2 +#define OCI_ENV_EVENTS 4 + +/* sessions modes */ + +#define OCI_SESSION_DEFAULT 0x00000000 /* any version */ +#define OCI_SESSION_SYSDBA 0x00000002 /* any version */ +#define OCI_SESSION_SYSOPER 0x00000004 /* any version */ +#define OCI_SESSION_SYSASM 0x00008000 /* From 11gR1 */ +#define OCI_SESSION_SYSBKP 0x00020000 /* From 12cR1 */ +#define OCI_SESSION_SYSDGD 0x00040000 /* From 12cR1 */ +#define OCI_SESSION_SYSKMT 0x00080000 /* From 12cR1 */ +#define OCI_SESSION_SYSRAC 0x00100000 /* From 12cR2 */ + +#define OCI_SESSION_XA 0x00000001 +#define OCI_SESSION_PRELIM_AUTH 0x00000008 + +/* change notification types */ + +#define OCI_CNT_OBJECTS 1 +#define OCI_CNT_ROWS 2 +#define OCI_CNT_DATABASES 4 +#define OCI_CNT_ALL (OCI_CNT_OBJECTS | OCI_CNT_ROWS | OCI_CNT_DATABASES) + +/* event notification types */ + +#define OCI_ENT_STARTUP 1 +#define OCI_ENT_SHUTDOWN 2 +#define OCI_ENT_SHUTDOWN_ANY 3 +#define OCI_ENT_DROP_DATABASE 4 +#define OCI_ENT_DEREGISTER 5 +#define OCI_ENT_OBJECT_CHANGED 6 + +/* event object notification types */ + +#define OCI_ONT_INSERT 0x2 +#define OCI_ONT_UPDATE 0x4 +#define OCI_ONT_DELETE 0x8 +#define OCI_ONT_ALTER 0x10 +#define OCI_ONT_DROP 0x20 +#define OCI_ONT_GENERIC 0x40 + +/* database startup modes */ + +#define OCI_DB_SPM_START 1 +#define OCI_DB_SPM_MOUNT 2 +#define OCI_DB_SPM_OPEN 4 +#define OCI_DB_SPM_FULL (OCI_DB_SPM_START | OCI_DB_SPM_MOUNT | OCI_DB_SPM_OPEN) + +/* database startup flags */ + +#define OCI_DB_SPF_DEFAULT 0 +#define OCI_DB_SPF_FORCE 1 +#define OCI_DB_SPF_RESTRICT 2 + +/* database shutdown modes */ + +#define OCI_DB_SDM_SHUTDOWN 1 +#define OCI_DB_SDM_CLOSE 2 +#define OCI_DB_SDM_DISMOUNT 4 +#define OCI_DB_SDM_FULL (OCI_DB_SDM_SHUTDOWN | OCI_DB_SDM_CLOSE | OCI_DB_SDM_DISMOUNT) + +/* database shutdown flags */ + +#define OCI_DB_SDF_DEFAULT 0 +#define OCI_DB_SDF_TRANS 1 +#define OCI_DB_SDF_TRANS_LOCAL 2 +#define OCI_DB_SDF_IMMEDIATE 3 +#define OCI_DB_SDF_ABORT 4 + +/* charset form types */ + +#define OCI_CSF_NONE 0 +#define OCI_CSF_DEFAULT 1 +#define OCI_CSF_NATIONAL 2 + +/* statement fetch mode */ + +#define OCI_SFM_DEFAULT 0 +#define OCI_SFM_SCROLLABLE 0x08 + +/* statement fetch direction */ + +#define OCI_SFD_ABSOLUTE 0x20 +#define OCI_SFD_RELATIVE 0x40 + +/* bind allocation mode */ + +#define OCI_BAM_EXTERNAL 1 +#define OCI_BAM_INTERNAL 2 + +/* bind direction mode */ + +#define OCI_BDM_IN 1 +#define OCI_BDM_OUT 2 +#define OCI_BDM_IN_OUT (OCI_BDM_IN | OCI_BDM_OUT) + +/* Column property flags */ + +#define OCI_CPF_NONE 0 +#define OCI_CPF_IS_IDENTITY 1 +#define OCI_CPF_IS_GEN_ALWAYS 2 +#define OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL 4 +#define OCI_CPF_IS_LPART 8 +#define OCI_CPF_IS_CONID 16 + +/* Column collation IDs */ + +#define OCI_CCI_NONE 0x00000000 +#define OCI_CCI_NLS_COMP 0x00003FFE +#define OCI_CCI_NLS_SORT 0x00003FFD +#define OCI_CCI_NLS_SORT_CI 0x00003FFC +#define OCI_CCI_NLS_SORT_AI 0x00003FFB +#define OCI_CCI_NLS_SORT_CS 0x00003FFA +#define OCI_CCI_NLS_SORT_VAR1 0x00003FF9 +#define OCI_CCI_NLS_SORT_VAR1_CI 0x00003FF8 +#define OCI_CCI_NLS_SORT_VAR1_AI 0x00003FF7 +#define OCI_CCI_NLS_SORT_VAR1_CS 0x00003FF6 +#define OCI_CCI_BINARY 0x00003FFF +#define OCI_CCI_BINARY_CI 0x00023FFF +#define OCI_CCI_BINARY_AI 0x00013FFF + +/* Integer sign flag */ + +#define OCI_NUM_UNSIGNED 2 + +/* External Integer types */ + +#define OCI_NUM_SHORT 4 +#define OCI_NUM_INT 8 +#define OCI_NUM_BIGINT 16 +#define OCI_NUM_FLOAT 32 +#define OCI_NUM_DOUBLE 64 +#define OCI_NUM_NUMBER 128 + +#define OCI_NUM_USHORT (OCI_NUM_SHORT | OCI_NUM_UNSIGNED) +#define OCI_NUM_UINT (OCI_NUM_INT | OCI_NUM_UNSIGNED) +#define OCI_NUM_BIGUINT (OCI_NUM_BIGINT | OCI_NUM_UNSIGNED) + +/* timestamp types */ + +#define OCI_TIMESTAMP 1 +#define OCI_TIMESTAMP_TZ 2 +#define OCI_TIMESTAMP_LTZ 3 + +/* interval types */ + +#define OCI_INTERVAL_YM 1 +#define OCI_INTERVAL_DS 2 + +/* long types */ + +#define OCI_BLONG 1 +#define OCI_CLONG 2 + +/* lob types */ + +#define OCI_BLOB 1 +#define OCI_CLOB 2 +#define OCI_NCLOB 3 + +/* lob opening mode */ + +#define OCI_LOB_READONLY 1 +#define OCI_LOB_READWRITE 2 + +/* file types */ + +#define OCI_BFILE 1 +#define OCI_CFILE 2 + +/* lob browsing mode */ + +#define OCI_SEEK_SET 1 +#define OCI_SEEK_END 2 +#define OCI_SEEK_CUR 3 + +/* type info types */ + +#define OCI_TIF_TABLE 1 +#define OCI_TIF_VIEW 2 +#define OCI_TIF_TYPE 3 + +/* object type */ + +#define OCI_OBJ_PERSISTENT 1 +#define OCI_OBJ_TRANSIENT 2 +#define OCI_OBJ_VALUE 3 + +/* collection types */ + +#define OCI_COLL_VARRAY 1 +#define OCI_COLL_NESTED_TABLE 2 +#define OCI_COLL_INDEXED_TABLE 3 + +/* pool types */ + +#define OCI_POOL_CONNECTION 1 +#define OCI_POOL_SESSION 2 + +/* AQ message state */ + +#define OCI_AMS_READY 1 +#define OCI_AMS_WAITING 2 +#define OCI_AMS_PROCESSED 3 +#define OCI_AMS_EXPIRED 4 + +/* AQ sequence deviation */ + +#define OCI_ASD_BEFORE 2 +#define OCI_ASD_TOP 3 + +/* AQ message visibility */ + +#define OCI_AMV_IMMEDIATE 1 +#define OCI_AMV_ON_COMMIT 2 + +/* AQ dequeue mode */ + +#define OCI_ADM_BROWSE 1 +#define OCI_ADM_LOCKED 2 +#define OCI_ADM_REMOVE 3 +#define OCI_ADM_REMOVE_NODATA 4 + +/* AQ dequeue navigation */ + +#define OCI_ADN_FIRST_MSG 1 +#define OCI_ADN_NEXT_TRANSACTION 2 +#define OCI_ADN_NEXT_MSG 3 + +/* AQ queue table purge mode */ + +#define OCI_APM_BUFFERED 1 +#define OCI_APM_PERSISTENT 2 +#define OCI_APM_ALL (OCI_APM_BUFFERED | OCI_APM_PERSISTENT) + +/* AQ queue table grouping mode */ + +#define OCI_AGM_NONE 0 +#define OCI_AGM_TRANSACTIONNAL 1 + +/* AQ queue table type */ + +#define OCI_AQT_NORMAL 0 +#define OCI_AQT_EXCEPTION 1 +#define OCI_AQT_NON_PERSISTENT 2 + +/* direct path processing return status */ + +#define OCI_DPR_COMPLETE 1 +#define OCI_DPR_ERROR 2 +#define OCI_DPR_FULL 3 +#define OCI_DPR_PARTIAL 4 +#define OCI_DPR_EMPTY 5 + +/* direct path conversion modes */ + +#define OCI_DCM_DEFAULT 1 +#define OCI_DCM_FORCE 2 + +/* trace size constants */ + +#define OCI_SIZE_TRACE_ID 64 +#define OCI_SIZE_TRACE_MODULE 48 +#define OCI_SIZE_TRACE_ACTION 32 +#define OCI_SIZE_TRACE_INFO 64 +#define OCI_SIZE_TRACE_OPERATION 32 + +/* trace types */ + +#define OCI_TRC_IDENTITY 1 +#define OCI_TRC_MODULE 2 +#define OCI_TRC_ACTION 3 +#define OCI_TRC_DETAIL 4 +#define OCI_TRC_OPERATION 5 + +/* Network timeout type */ + +#define OCI_NTO_SEND 1 +#define OCI_NTO_RECEIVE 2 +#define OCI_NTO_CALL 3 + +/* HA event type */ + +#define OCI_HET_DOWN 0 +#define OCI_HET_UP 1 + +/* HA event source */ +#define OCI_HES_INSTANCE 0 +#define OCI_HES_DATABASE 1 +#define OCI_HES_NODE 2 +#define OCI_HES_SERVICE 3 +#define OCI_HES_SERVICE_MEMBER 4 +#define OCI_HES_ASM_INSTANCE 5 +#define OCI_HES_PRECONNECT 6 + +/* Fail over types */ + +#define OCI_FOT_NONE 1 +#define OCI_FOT_SESSION 2 +#define OCI_FOT_SELECT 4 + +/* fail over notifications */ + +#define OCI_FOE_END 1 +#define OCI_FOE_ABORT 2 +#define OCI_FOE_REAUTH 4 +#define OCI_FOE_BEGIN 8 +#define OCI_FOE_ERROR 16 + +/* fail over callback return code */ + +#define OCI_FOC_OK 0 +#define OCI_FOC_RETRY 25410 + +/* hash tables support */ + +#define OCI_HASH_STRING 1 +#define OCI_HASH_INTEGER 2 +#define OCI_HASH_POINTER 3 + +/* transaction types */ + +#define OCI_TRS_NEW 0x00000001 +#define OCI_TRS_READONLY 0x00000100 +#define OCI_TRS_READWRITE 0x00000200 +#define OCI_TRS_SERIALIZABLE 0x00000400 +#define OCI_TRS_LOOSE 0x00010000 +#define OCI_TRS_TIGHT 0x00020000 + +/* format types */ + +#define OCI_FMT_DATE 1 +#define OCI_FMT_TIMESTAMP 2 +#define OCI_FMT_NUMERIC 3 +#define OCI_FMT_BINARY_DOUBLE 4 +#define OCI_FMT_BINARY_FLOAT 5 +#define OCI_FMT_TIMESTAMP_TZ 6 + +/* sql function codes */ + +#define OCI_SFC_CREATE_TABLE 1 +#define OCI_SFC_INSERT 2 +#define OCI_SFC_SELECT 3 +#define OCI_SFC_CREATE_CLUSTER 4 +#define OCI_SFC_ALTER_CLUSTER 5 +#define OCI_SFC_UPDATE 6 +#define OCI_SFC_DELETE 7 +#define OCI_SFC_DROP_CLUSTER 8 +#define OCI_SFC_CREATE_INDEX 9 +#define OCI_SFC_DROP_INDEX 10 +#define OCI_SFC_ALTER_INDEX 11 +#define OCI_SFC_DROP_TABLE 12 +#define OCI_SFC_CREATE_SEQUENCE 13 +#define OCI_SFC_ALTER_SEQUENCE 14 +#define OCI_SFC_ALTER_TABLE 15 +#define OCI_SFC_DROP_SEQUENCE 16 +#define OCI_SFC_GRANT_OBJECT 17 +#define OCI_SFC_REVOKE_OBJECT 18 +#define OCI_SFC_CREATE_SYNONYM 19 +#define OCI_SFC_DROP_SYNONYM 20 +#define OCI_SFC_CREATE_VIEW 21 +#define OCI_SFC_DROP_VIEW 22 +#define OCI_SFC_VALIDATE_INDEX 23 +#define OCI_SFC_CREATE_PROCEDURE 24 +#define OCI_SFC_ALTER_PROCEDURE 25 +#define OCI_SFC_LOCK 26 +#define OCI_SFC_NO_OP 27 +#define OCI_SFC_RENAME 28 +#define OCI_SFC_COMMENT 29 +#define OCI_SFC_AUDIT_OBJECT 30 +#define OCI_SFC_NOAUDIT_OBJECT 31 +#define OCI_SFC_CREATE_DATABASE_LINK 32 +#define OCI_SFC_DROP_DATABASE_LINK 33 +#define OCI_SFC_CREATE_DATABASE 34 +#define OCI_SFC_ALTER_DATABASE 35 +#define OCI_SFC_CREATE_ROLLBACK_SEG 36 +#define OCI_SFC_ALTER_ROLLBACK_SEG 37 +#define OCI_SFC_DROP_ROLLBACK_SEG 38 +#define OCI_SFC_CREATE_TABLESPACE 39 +#define OCI_SFC_ALTER_TABLESPACE 40 +#define OCI_SFC_DROP_TABLESPACE 41 +#define OCI_SFC_ALTER_SESSION 42 +#define OCI_SFC_ALTER_USER 43 +#define OCI_SFC_COMMIT 44 +#define OCI_SFC_ROLLBACK 45 +#define OCI_SFC_SAVEPOINT 46 +#define OCI_SFC_PL_SQL_EXECUTE 47 +#define OCI_SFC_SET_TRANSACTION 48 +#define OCI_SFC_ALTER_SYSTEM 49 +#define OCI_SFC_EXPLAIN 50 +#define OCI_SFC_CREATE_USER 51 +#define OCI_SFC_CREATE_ROLE 52 +#define OCI_SFC_DROP_USER 53 +#define OCI_SFC_DROP_ROLE 54 +#define OCI_SFC_SET_ROLE 55 +#define OCI_SFC_CREATE_SCHEMA 56 +#define OCI_SFC_CREATE_CONTROL_FILE 57 +#define OCI_SFC_ALTER_TRACING 58 +#define OCI_SFC_CREATE_TRIGGER 59 +#define OCI_SFC_ALTER_TRIGGER 60 +#define OCI_SFC_DROP_TRIGGER 61 +#define OCI_SFC_ANALYZE_TABLE 62 +#define OCI_SFC_ANALYZE_INDEX 63 +#define OCI_SFC_ANALYZE_CLUSTER 64 +#define OCI_SFC_CREATE_PROFILE 65 +#define OCI_SFC_DROP_PROFILE 66 +#define OCI_SFC_ALTER_PROFILE 67 +#define OCI_SFC_DROP_PROCEDURE 68 +#define OCI_SFC_ALTER_RESOURCE_COST 70 +#define OCI_SFC_CREATE_MATERIALIZED_VIEW_LOG 71 +#define OCI_SFC_ALTER_MATERIALIZED_VIEW_LOG 72 +#define OCI_SFC_DROP_MATERIALIZED_VIEW_LOG 73 +#define OCI_SFC_CREATE_MATERIALIZED_VIEW 74 +#define OCI_SFC_ALTER_MATERIALIZED_VIEW 75 +#define OCI_SFC_DROP_MATERIALIZED_VIEW 76 +#define OCI_SFC_CREATE_TYPE 77 +#define OCI_SFC_DROP_TYPE 78 +#define OCI_SFC_ALTER_ROLE 79 +#define OCI_SFC_ALTER_TYPE 80 +#define OCI_SFC_CREATE_TYPE_BODY 81 +#define OCI_SFC_ALTER_TYPE_BODY 82 +#define OCI_SFC_DROP_TYPE_BODY 83 +#define OCI_SFC_DROP_LIBRARY 84 +#define OCI_SFC_TRUNCATE_TABLE 85 +#define OCI_SFC_TRUNCATE_CLUSTER 86 +#define OCI_SFC_ALTER_VIEW 88 +#define OCI_SFC_SET_CONSTRAINTS 90 +#define OCI_SFC_CREATE_FUNCTION 91 +#define OCI_SFC_ALTER_FUNCTION 92 +#define OCI_SFC_DROP_FUNCTION 93 +#define OCI_SFC_CREATE_PACKAGE 94 +#define OCI_SFC_ALTER_PACKAGE 95 +#define OCI_SFC_DROP_PACKAGE 96 +#define OCI_SFC_CREATE_PACKAGE_BODY 97 +#define OCI_SFC_ALTER_PACKAGE_BODY 98 +#define OCI_SFC_DROP_PACKAGE_BODY 99 +#define OCI_SFC_LOGON 100 +#define OCI_SFC_LOGOFF 101 +#define OCI_SFC_LOGOFF_BY_CLEANUP 102 +#define OCI_SFC_SESSION_REC 103 +#define OCI_SFC_SYSTEM_AUDIT 104 +#define OCI_SFC_SYSTEM_NOAUDIT 105 +#define OCI_SFC_AUDIT_DEFAULT 106 +#define OCI_SFC_NOAUDIT_DEFAULT 107 +#define OCI_SFC_SYSTEM_GRANT 108 +#define OCI_SFC_SYSTEM_REVOKE 109 +#define OCI_SFC_CREATE_PUBLIC_SYNONYM 110 +#define OCI_SFC_DROP_PUBLIC_SYNONYM 111 +#define OCI_SFC_CREATE_PUBLIC_DATABASE_LINK 112 +#define OCI_SFC_DROP_PUBLIC_DATABASE_LINK 113 +#define OCI_SFC_GRANT_ROLE 114 +#define OCI_SFC_REVOKE_ROLE 115 +#define OCI_SFC_EXECUTE_PROCEDURE 116 +#define OCI_SFC_USER_COMMENT 117 +#define OCI_SFC_ENABLE_TRIGGER 118 +#define OCI_SFC_DISABLE_TRIGGER 119 +#define OCI_SFC_ENABLE_ALL_TRIGGERS 120 +#define OCI_SFC_DISABLE_ALL_TRIGGERS 121 +#define OCI_SFC_NETWORK_ERROR 122 +#define OCI_SFC_EXECUTE_TYPE 123 +#define OCI_SFC_READ_DIRECTORY 125 +#define OCI_SFC_WRITE_DIRECTORY 126 +#define OCI_SFC_FLASHBACK 128 +#define OCI_SFC_BECOME_USER 129 +#define OCI_SFC_ALTER_MINING_MODEL 130 +#define OCI_SFC_SELECT_MINING_MODEL 131 +#define OCI_SFC_CREATE_MINING_MODEL 133 +#define OCI_SFC_ALTER_PUBLIC_SYNONYM 134 +#define OCI_SFC_EXECUTE_DIRECTORY 135 +#define OCI_SFC_SQL_LOADER_DIRECT_PATH_LOAD 136 +#define OCI_SFC_DATAPUMP_DIRECT_PATH_UNLOAD 137 +#define OCI_SFC_DATABASE_STARTUP 138 +#define OCI_SFC_DATABASE_SHUTDOWN 139 +#define OCI_SFC_CREATE_SQL_TXLN_PROFILE 140 +#define OCI_SFC_ALTER_SQL_TXLN_PROFILE 141 +#define OCI_SFC_USE_SQL_TXLN_PROFILE 142 +#define OCI_SFC_DROP_SQL_TXLN_PROFILE 143 +#define OCI_SFC_CREATE_MEASURE_FOLDER 144 +#define OCI_SFC_ALTER_MEASURE_FOLDER 145 +#define OCI_SFC_DROP_MEASURE_FOLDER 146 +#define OCI_SFC_CREATE_CUBE_BUILD_PROCESS 147 +#define OCI_SFC_ALTER_CUBE_BUILD_PROCESS 148 +#define OCI_SFC_DROP_CUBE_BUILD_PROCESS 149 +#define OCI_SFC_CREATE_CUBE 150 +#define OCI_SFC_ALTER_CUBE 151 +#define OCI_SFC_DROP_CUBE 152 +#define OCI_SFC_CREATE_CUBE_DIMENSION 153 +#define OCI_SFC_ALTER_CUBE_DIMENSION 154 +#define OCI_SFC_DROP_CUBE_DIMENSION 155 +#define OCI_SFC_CREATE_DIRECTORY 157 +#define OCI_SFC_DROP_DIRECTORY 158 +#define OCI_SFC_CREATE_LIBRARY 159 +#define OCI_SFC_CREATE_JAVA 160 +#define OCI_SFC_ALTER_JAVA 161 +#define OCI_SFC_DROP_JAVA 162 +#define OCI_SFC_CREATE_OPERATOR 163 +#define OCI_SFC_CREATE_INDEXTYPE 164 +#define OCI_SFC_DROP_INDEXTYPE 165 +#define OCI_SFC_ALTER_INDEXTYPE 166 +#define OCI_SFC_DROP_OPERATOR 167 +#define OCI_SFC_ASSOCIATE_STATISTICS 168 +#define OCI_SFC_DISASSOCIATE_STATISTICS 169 +#define OCI_SFC_CALL_METHOD 170 +#define OCI_SFC_CREATE_SUMMARY 171 +#define OCI_SFC_ALTER_SUMMARY 172 +#define OCI_SFC_DROP_SUMMARY 173 +#define OCI_SFC_CREATE_DIMENSION 174 +#define OCI_SFC_ALTER_DIMENSION 175 +#define OCI_SFC_DROP_DIMENSION 176 +#define OCI_SFC_CREATE_CONTEXT 177 +#define OCI_SFC_DROP_CONTEXT 178 +#define OCI_SFC_ALTER_OUTLINE 179 +#define OCI_SFC_CREATE_OUTLINE 180 +#define OCI_SFC_DROP_OUTLINE 181 +#define OCI_SFC_UPDATE_INDEXES 182 +#define OCI_SFC_ALTER_OPERATOR 183 +#define OCI_SFC_CREATE_SPFILE 187 +#define OCI_SFC_CREATE_PFILE 188 +#define OCI_SFC_MERGE 189 +#define OCI_SFC_PASSWORD_CHANGE 190 +#define OCI_SFC_ALTER_SYNONYM 192 +#define OCI_SFC_ALTER_DISKGROUP 193 +#define OCI_SFC_CREATE_DISKGROUP 194 +#define OCI_SFC_DROP_DISKGROUP 195 +#define OCI_SFC_PURGE_RECYCLEBIN 197 +#define OCI_SFC_PURGE_DBA_RECYCLEBIN 198 +#define OCI_SFC_PURGE_TABLESPACE 199 +#define OCI_SFC_PURGE_TABLE 200 +#define OCI_SFC_PURGE_INDEX 201 +#define OCI_SFC_UNDROP_OBJECT 202 +#define OCI_SFC_DROP_DATABASE 203 +#define OCI_SFC_FLASHBACK_DATABASE 204 +#define OCI_SFC_FLASHBACK_TABLE 205 +#define OCI_SFC_CREATE_RESTORE_POINT 206 +#define OCI_SFC_DROP_RESTORE_POINT 207 +#define OCI_SFC_PROXY_AUTHENTICATION_ONLY 208 +#define OCI_SFC_DECLARE_REWRITE_EQUIVALENCE 209 +#define OCI_SFC_ALTER_REWRITE_EQUIVALENCE 210 +#define OCI_SFC_DROP_REWRITE_EQUIVALENCE 211 +#define OCI_SFC_CREATE_EDITION 212 +#define OCI_SFC_ALTER_EDITION 213 +#define OCI_SFC_DROP_EDITION 214 +#define OCI_SFC_DROP_ASSEMBLY 215 +#define OCI_SFC_CREATE_ASSEMBLY 216 +#define OCI_SFC_ALTER_ASSEMBLY 217 +#define OCI_SFC_CREATE_FLASHBACK_ARCHIVE 218 +#define OCI_SFC_ALTER_FLASHBACK_ARCHIVE 219 +#define OCI_SFC_DROP_FLASHBACK_ARCHIVE 220 +#define OCI_SFC_DEBUG_CONNECT 221 +#define OCI_SFC_DEBUG_PROCEDURE 223 +#define OCI_SFC_ALTER_DATABASE_LINK 225 +#define OCI_SFC_CREATE_PLUGGABLE_DATABASE 226 +#define OCI_SFC_ALTER_PLUGGABLE_DATABASE 227 +#define OCI_SFC_DROP_PLUGGABLE_DATABASE 228 +#define OCI_SFC_CREATE_AUDIT_POLICY 229 +#define OCI_SFC_ALTER_AUDIT_POLICY 230 +#define OCI_SFC_DROP_AUDIT_POLICY 231 +#define OCI_SFC_CODE_BASED_GRANT 232 +#define OCI_SFC_CODE_BASED_REVOKE 233 +#define OCI_SFC_CREATE_LOCKDOWN_PROFILE 234 +#define OCI_SFC_DROP_LOCKDOWN_PROFILE 235 +#define OCI_SFC_ALTER_LOCKDOWN_PROFILE 236 +#define OCI_SFC_TRANSLATE_SQL 237 +#define OCI_SFC_ADMINISTER_KEY_MANAGEMENT 238 +#define OCI_SFC_CREATE_MATERIALIZED_ZONEMAP 239 +#define OCI_SFC_ALTER_MATERIALIZED_ZONEMAP 240 +#define OCI_SFC_DROP_MATERIALIZED_ZONEMAP 241 +#define OCI_SFC_DROP_MINING_MODEL 242 +#define OCI_SFC_CREATE_ATTRIBUTE_DIMENSION 243 +#define OCI_SFC_ALTER_ATTRIBUTE_DIMENSION 244 +#define OCI_SFC_DROP_ATTRIBUTE_DIMENSION 245 +#define OCI_SFC_CREATE_HIERARCHY 246 +#define OCI_SFC_ALTER_HIERARCHY 247 +#define OCI_SFC_DROP_HIERARCHY 248 +#define OCI_SFC_CREATE_ANALYTIC_VIEW 249 +#define OCI_SFC_ALTER_ANALYTIC_VIEW 250 +#define OCI_SFC_DROP_ANALYTIC_VIEW 251 +#define OCI_SFC_ALTER_PUBLIC_DATABASE_LINK 305 + +/* size constants */ + +#define OCI_SIZE_FORMAT 64 +#define OCI_SIZE_BUFFER 512 +#define OCI_SIZE_LARGE_BUFFER ((64*1024)-1) +#define OCI_SIZE_LONG ((64*1024)-1) +#define OCI_SIZE_DATE 45 +#define OCI_SIZE_TIMESTAMP 54 +#define OCI_SIZE_FORMAT_TODATE 14 +#define OCI_SIZE_NULL 4 +#define OCI_SIZE_PRECISION 10 +#define OCI_SIZE_ROWID 23 +#define OCI_SIZE_DIRECTORY 30 +#define OCI_SIZE_FILENAME 255 +#define OCI_SIZE_FORMAT_NUMS 40 +#define OCI_SIZE_FORMAT_NUML 65 +#define OCI_SIZE_OBJ_NAME 128 + +#define OCI_HASH_DEFAULT_SIZE 256 + +/* string constants */ + +#define OCILIB_DRIVER_NAME OTEXT("OCILIB") +#define OCI_STRING_NULL OTEXT("NULL") +#define OCI_STRING_EMPTY OTEXT("") +#define OCI_STRING_FORMAT_DATE OTEXT("YYYY-MM-DD") +#define OCI_STRING_FORMAT_TIME OTEXT("HH24:MI:SS") +#define OCI_STRING_FORMAT_DATETIME OTEXT("YYYY-MM-DD HH24:MI:SS") +#define OCI_STRING_FORMAT_TIMESTAMP OTEXT("YYYY-MM-DD HH24:MI:SS.FF") +#define OCI_STRING_FORMAT_TIMESTAMP_TZ OTEXT("YYYY-MM-DD HH24:MI:SS.FF TZR") +#define OCI_STRING_DEFAULT_PREC 3 +#define OCI_STRING_FORMAT_NUM \ + OTEXT("FM99999999999999999999999999999999999990.999999999999999999999999") +#define OCI_STRING_FORMAT_NUM_BDOUBLE OTEXT("%lf") +#define OCI_STRING_FORMAT_NUM_BFLOAT OTEXT("%f") +#define OCI_STRING_FORMAT_NUM_SHORT OTEXT("%hd") +#define OCI_STRING_FORMAT_NUM_INT OTEXT("%d") +#define OCI_STRING_TRUE OTEXT("TRUE") +#define OCI_STRING_FALSE OTEXT("FALSE") +#define OCI_STRING_TRUE_SIZE 4 +#define OCI_STRING_FALSE_SIZE 5 +#define OCI_STRING_NULL_SIZE 4 + +#ifdef _WINDOWS +#define OCI_CHAR_SLASH '\\' +#else + #define OCI_CHAR_SLASH '/' +#endif + +#define OCI_STRING_FORMAT_NUM_BIN OCI_STRING_FORMAT_NUM_BDOUBLE + +/** +* @} +*/ + +/** +* @defgroup OcilibCApiEnvironmentVariables Environment Variables +* @{ +* +* Some environment variables can be defined in order to activate specific features +* They must have one of the following values (case insensitive) for being enabled : "TRUE", "1" +* +* - "OCILIB_WORKAROUND_UTF16_COLUMN_NAME": This variable enables an experimental workaround for the Oracle bug 9838993: +* - When executing select statements, OCILIB queries column names against the Oracle Client +* - Unicode builds of OCILIB initialize Oracle client into UTF16 mode +* - In such environments, a memory leak occurs when statements are re-executed multiple times followed by retrieving the resultset +* - This workaround retrieves column names using direct access to undocumented Oracle structures instead of using buggy Oracle calls +* - As Oracle undocumented structures may change upon versions, this workaround is provided as-is in case the Oracle bug represents an real issue for applications +* - This workaround has been tested with 32bit and 64bit Oracle 12g clients and Unicode OCILIB builds +*/ + +#define VAR_OCILIB_WORKAROUND_UTF16_COLUMN_NAME "OCILIB_WORKAROUND_UTF16_COLUMN_NAME" + +/** +* @} +*/ + +/** + * @} + */ + +#endif /* OCILIB_CONFIG_H_INCLUDED */ diff --git a/include/ocilib_types.h b/include/ocilib_types.h new file mode 100644 index 00000000..7a499198 --- /dev/null +++ b/include/ocilib_types.h @@ -0,0 +1,718 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* IMPORTANT NOTICE + * + * This file contains explanations about Oracle and OCI technologies. + * OCILIB is a wrapper around OCI and thus exposes OCI features. + * The OCILIB documentation intends to explain Oracle / OCI concepts + * and is naturally based on the official Oracle OCI documentation. + * + * Some parts of OCILIB documentation may include some information + * taken and adapted from the following Oracle documentations : + * - Oracle Call Interface Programmer's Guide + * - Oracle Streams - Advanced Queuing User's Guide + */ + +#ifndef OCILIB_OCILIB_TYPES_H_INCLUDED +#define OCILIB_OCILIB_TYPES_H_INCLUDED + +#include "ocilib_config.h" + +/** + * @defgroup OcilibCApi C API + * @{ + * + */ + +/** + * @defgroup OcilibCApiDatatypes Data types + * @{ + * + * OCILIB implements: + * + * - Oracle Scalar data types through scalar C data types + * - Oracle opaque/complex objects though opaque library handles + * - Library objects for manipulating the database: connections, transactions, statements... + * + * @par Supported Oracle data types + * + * - All Database types are supported excluding REFs. + * + * Here is a summary of the supported data types: + * + * - Scalar types CHAR/NCHAR, VARCHAR2/NVARCHAR2, NUMBER, FLOAT, REAL, RAW, ... + * - Binary types: RAW, LONG RAW, VARRAW, .. + * - Larges Objects (Lobs and Files) : BLOB, CLOB, NCLOB, BFILE + * - LONG types: LONG, VAR LONG + * - Date, Timestamps et Intervals: DATE, TIMESTAMP, INTERVAL + * - PL/SQL types: Ref cursors, PL/SQL Tables + * - Named Types (by value): Built-in system objects and User defined objects + * - VARRAYs and Nested Tables + * - ROWIDs + * + * @par OCILIB library objects + * + * The public OCILIB library interface implements encapsulation for + * representing database objects (such as connections, statements ...) through + * opaque structures (pointers to structures whose definition is kept private) + * + * Instead of directly manipulating the structures and their members, the library + * has functions to access the underlying members. + * + * It's designed to make the user code as more independent as possible of + * the library details. + * +**/ + +/** + * @typedef OCI_Pool + * + * @brief + * Pool object (session or connection) + * + * A pool is a set of pooled objects + * + */ + +typedef struct OCI_Pool OCI_Pool; + +/** + * @typedef OCI_Connection + * + * @brief + * Oracle physical connection. + * + * It holds all information about a connection such as error handling, associated statements, ... + * Error handling and transactions are embedded within a connection object. + * + * @warning + * Multi threaded applications that use multiple connections should use one connection per thread + * as all statements associated with a connection share the same context. + * + */ + +typedef struct OCI_Connection OCI_Connection; + +/** + * @typedef OCI_Statement + * + * @brief + * Oracle SQL or PL/SQL statement. + * + * A Statement object allows users to prepare, execute SQL orders or PL/SQL blocks + * + */ + +typedef struct OCI_Statement OCI_Statement; + +/** + * @typedef OCI_Bind + * + * @brief + * Internal bind representation. + * + * A bind object is an object that holds all information about an Oracle statement binding operation + * + */ + +typedef struct OCI_Bind OCI_Bind; + +/** + * @typedef OCI_Resultset + * + * @brief + * Collection of output columns from a select statement. + * + * A resultset object is the result of 'select' SQL Statement. + * + * It's a set of data (ordered in columns) that can be fetched row by row + * to get data returned by the SQL statement + * + */ + +typedef struct OCI_Resultset OCI_Resultset; + +/** + * @typedef OCI_Column + * + * @brief + * Oracle SQL Column and Type member representation. + * + * A column object represents an output column from a select statement + * + */ + +typedef struct OCI_Column OCI_Column; + +/** + * @typedef OCI_Lob + * + * @brief + * Oracle Internal Large objects: + * + * The following internal Larges Objects are supported: + * + * - BLOBs : Binary large objects + * - CLOBs / NCLOBs : Character large objects + * + * LOBs were introduced by OCI8 to replace Long data types. + * + * It's designed to store really larges objects (buffer, files) inside the database + * + * Oracle encourages programmers to use those objects instead of LONG, LONG RAW, ... + * + * OCILIB supports both LOBs and LONGs + * + */ + +typedef struct OCI_Lob OCI_Lob; + +/** + * @typedef OCI_File + * + * @brief + * Oracle External Large objects: + * + * The following external Larges Objects are supported: + * + * - BFILEs : Binary files + * - CFILEs : Character files + * + * FILEs were introduced by OCI8 in order to store references to files located outside the database. + * + * @warning + * Only Read-only access is allowed on BFILEs + * + * Two way to use FILEs : + * + * - within statement context (query, binding) + * - without statement context (server files reading) through OCI_File properties functions + * + */ + +typedef struct OCI_File OCI_File; + +/** + * @typedef OCI_Transaction + * + * @brief + * Oracle Transaction. + * + * A transaction can be: + * + * - Local: it's implicitly created by OCILIB + * - Global: it's explicitly created by the program + * + */ + +typedef struct OCI_Transaction OCI_Transaction; + +/** + * @typedef OCI_Long + * + * @brief Oracle Long data type. + * + * The following long Objects are supported: + * + * - LONG RAW : Binary long objects + * - LONG : Character long objects + * + * Those types were used in older versions of Oracle (before Oracle8i) to store + * large chunks of data in the database. + * + * It's now depreciated by Oracle that recommends using LOBs + * + * Many databases and applications are still designed to use LONGs that's why + * OCILIB supports Long Objects and piecewise operations + * + */ + +typedef struct OCI_Long OCI_Long; + +/** +* @typedef OCI_Number +* +* @brief +* Oracle NUMBER representation. +* +*/ +typedef struct OCI_Number OCI_Number; + +/** + * @typedef OCI_Date + * + * @brief + * Oracle internal date representation. + * + */ + +typedef struct OCI_Date OCI_Date; + +/** + * @typedef OCI_Timestamp + * + * @brief + * Oracle internal timestamp representation. + * + */ + +typedef struct OCI_Timestamp OCI_Timestamp; + +/** + * @typedef OCI_Interval + * + * @brief + * Oracle internal interval representation. + * + */ + +typedef struct OCI_Interval OCI_Interval; + +/** + * @typedef OCI_Object + * + * @brief + * Oracle Named types representation. + * + */ + +typedef struct OCI_Object OCI_Object; + +/** + * @typedef OCI_Coll + * + * @brief + * Oracle Collections (VARRAYs and Nested Tables) representation. + * + */ + +typedef struct OCI_Coll OCI_Coll; + +/** + * @typedef OCI_Elem + * + * @brief + * Oracle Collection item representation. + * + */ + +typedef struct OCI_Elem OCI_Elem; + +/** + * @typedef OCI_Iter + * + * @brief + * Oracle Collection iterator representation. + * + */ +typedef struct OCI_Iter OCI_Iter; + +/** + * @typedef OCI_TypeInfo + * + * @brief + * Type info metadata handle. + * + */ + +/** + * @typedef OCI_Ref + * + * @brief + * Oracle REF type representation. + * + */ + +typedef struct OCI_Ref OCI_Ref; + +/** + * @typedef OCI_TypeInfo + * + * @brief + * Type info meta data handle. + * + */ + +typedef struct OCI_TypeInfo OCI_TypeInfo; + +/** + * @typedef OCI_HashTable + * + * @brief + * OCILIB implementation of hash tables. + * + */ + +typedef struct OCI_HashTable OCI_HashTable; + +/** + * @typedef OCI_Error + * + * @brief + * Encapsulates an Oracle or OCILIB exception. + * + * The error object is used to raise internal or oracle errors. + * When an error occurs, if the application has provided an error handler, an + * error object is constructed and passed to the handler + * + */ + +typedef struct OCI_Error OCI_Error; + +/** + * @typedef OCI_Mutex + * + * @brief + * OCILIB encapsulation of OCI mutexes. + * + */ + +typedef struct OCI_Mutex OCI_Mutex; + +/** + * @typedef OCI_Thread + * + * @brief + * OCILIB encapsulation of OCI Threads. + * + */ + +typedef struct OCI_Thread OCI_Thread; + +/** + * @typedef OCI_DirPath + * + * @brief + * OCILIB encapsulation of OCI Direct Path handle. + * + */ + +typedef struct OCI_DirPath OCI_DirPath; + +/** + * @typedef OCI_Subscription + * + * @brief + * OCILIB encapsulation of Oracle DCN notification + * + */ + +typedef struct OCI_Subscription OCI_Subscription; + +/** + * @typedef OCI_Event + * + * @brief + * OCILIB encapsulation of Oracle DCN event + * + */ + +typedef struct OCI_Event OCI_Event; + +/** + * @typedef OCI_Msg + * + * @brief + * OCILIB encapsulation of A/Q message + * + */ + +typedef struct OCI_Msg OCI_Msg; + +/** + * @typedef OCI_Agent + * + * @brief + * OCILIB encapsulation of A/Q Agent + * + */ + +typedef struct OCI_Agent OCI_Agent; + +/** + * @typedef OCI_Dequeue + * + * @brief + * OCILIB encapsulation of A/Q dequeuing operations + * + */ + +typedef struct OCI_Dequeue OCI_Dequeue; + +/** + * @typedef OCI_Enqueue + * + * @brief + * OCILIB encapsulation of A/Q enqueuing operations + * + */ + +typedef struct OCI_Enqueue OCI_Enqueue; + +/** + * @var POCI_ERROR + * + * @brief + * Error procedure prototype + * + * @param err - Error handle + * + */ + +typedef void (*POCI_ERROR) +( + OCI_Error *err +); + +/** + * @var POCI_THREAD + * + * @brief + * Thread procedure prototype + * + * @param thread - Thread handle + * @param arg - Pointer passed to OCI_ThreadRun() + * + */ + +typedef void (*POCI_THREAD) +( + OCI_Thread *thread, + void * arg +); + +/** + * @var POCI_THREADKEYDEST + * + * @brief + * Thread key destructor prototype. + * + * @param data - Thread Key current pointer value + * + */ + +typedef void (*POCI_THREADKEYDEST) +( + void *data +); + +/** + * @var POCI_NOTIFY + * + * @brief + * Database Change Notification User callback prototype. + * + * @param event - Event handle + * + */ + +typedef void (*POCI_NOTIFY) +( + OCI_Event *event +); + +/** + * @var POCI_NOTIFY_AQ + * + * @brief + * AQ notification callback prototype. + * + * @param dequeue - dequeue handle + * + */ + +typedef void (*POCI_NOTIFY_AQ) +( + OCI_Dequeue *dequeue +); + +/** + * @var POCI_TAF_HANDLER + * + * @brief + * Failover Notification User callback prototype. + * + * @param con - Connection handle related to the event + * @param type - Event type + * @param event - Event code + * + * @note + * Possible values for parameter 'type' : + * - OCI_FOT_NONE + * - OCI_FOT_SESSION + * - OCI_FOT_SELECT + * + * @note + * Possible values for parameter 'event' : + * - OCI_FOE_END + * - OCI_FOE_ABORT + * - OCI_FOE_REAUTH + * - OCI_FOE_BEGIN + * - OCI_FOE_ERROR + * + * @return + * User callback should return one of the following value : + * - OCI_FOC_OK + * - OCI_FOC_RETRY + * + */ + +typedef unsigned int (*POCI_TAF_HANDLER) +( + OCI_Connection *con, + unsigned int type, + unsigned int event +); + +/** + * @var POCI_HA_HANDLER + * + * @brief + * HA (High Availability) events Notification User callback prototype. + * + * @param con - Connection handle related to the event + * @param source - source of the event + * @param event - type of the event + * @param time - Timestamp of the event + * + * @note + * Currently, Oracle only send HA down events + * + * @note + * Possible values for parameter 'source' : + * - OCI_HES_INSTANCE + * - OCI_HES_DATABASE + * - OCI_HES_NODE + * - OCI_HES_SERVICE + * - OCI_HES_SERVICE_MEMBER + * - OCI_HES_ASM_INSTANCE + * - OCI_HES_PRECONNECT + * + * @note + * Possible values for parameter 'event' : + * - OCI_HET_DOWN : HA event type down + * - OCI_HET_UP : HA event type up + * + */ + +typedef void (*POCI_HA_HANDLER) +( + OCI_Connection *con, + unsigned int source, + unsigned int event, + OCI_Timestamp * time +); + +/* public structures */ + +/** + * @typedef OCI_XID + * + * @brief + * Global transaction identifier + * + */ + +typedef struct OCI_XID +{ + long formatID; + long gtrid_length; + long bqual_length; + char data[128]; +} OCI_XID; + +/** + * @typedef OCI_Variant + * + * @brief + * Internal Variant type based on union C type. + * + * @note + * Helpful for generic buffer, it reduces the amount of casts + * + */ + +typedef union OCI_Variant +{ + /* integers */ + int num; + + /* raw data */ + unsigned char *p_bytes; + + /* pointer to c natives types */ + void * p_void; + int * p_int; + float * p_float; + double *p_double; + otext * p_text; + + /* ocilib object types */ + OCI_Date * p_date; + OCI_Interval * p_interval; + OCI_Timestamp *p_timestamp; + OCI_Long * p_long; + OCI_Lob * p_lob; + OCI_File * p_file; + OCI_Statement *p_stmt; + OCI_Column * p_col; + OCI_Object * p_obj; + OCI_Coll * p_coll; + OCI_Iter * p_iter; + OCI_Elem * p_elem; +} OCI_Variant; + +/** +* @typedef OCI_HashValue +* +* @brief +* Hash table entry value +* +* OCILIB implementation of hash tables uses chaining method for dealing with collisions +* +*/ + +typedef struct OCI_HashValue +{ + OCI_Variant value; + struct OCI_HashValue *next; +} OCI_HashValue; + +/** + * @typedef OCI_HashEntry + * + * @brief + * Hash table entry + * + */ + +typedef struct OCI_HashEntry +{ + otext * key; + struct OCI_HashValue *values; + struct OCI_HashEntry *next; +} OCI_HashEntry; + +/** + * @} + */ + +#endif /* OCILIB_OCILIB_TYPES_H_INCLUDED */ diff --git a/proj/dll/ocilib_dll_vs2013.sln b/proj/dll/ocilib_dll_vs2013.sln deleted file mode 100644 index 2a044416..00000000 --- a/proj/dll/ocilib_dll_vs2013.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCILIB Dynamic Library", "ocilib_dll_vs2013.vcxproj", "{B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release - ANSI|Win32 = Release - ANSI|Win32 - Release - ANSI|Win64 = Release - ANSI|Win64 - Release - UNICODE|Win32 = Release - UNICODE|Win32 - Release - UNICODE|Win64 = Release - UNICODE|Win64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win32.ActiveCfg = Release - ANSI|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win32.Build.0 = Release - ANSI|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win64.ActiveCfg = Release - ANSI|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win64.Build.0 = Release - ANSI|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win32.ActiveCfg = Release - UNICODE|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win32.Build.0 = Release - UNICODE|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win64.ActiveCfg = Release - UNICODE|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win64.Build.0 = Release - UNICODE|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/proj/dll/ocilib_dll_vs2013.vcxproj b/proj/dll/ocilib_dll_vs2013.vcxproj deleted file mode 100644 index 83b8b5b8..00000000 --- a/proj/dll/ocilib_dll_vs2013.vcxproj +++ /dev/null @@ -1,371 +0,0 @@ - - - - - Release - ANSI - Win32 - - - Release - ANSI - x64 - - - Release - UNICODE - Win32 - - - Release - UNICODE - x64 - - - - OCILIB Dynamic Library - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D} - OCILIBDynamicLibrary - Win32Proj - - - - DynamicLibrary - Unicode - true - v120_xp - - - DynamicLibrary - MultiByte - true - v120_xp - - - DynamicLibrary - Unicode - true - v120_xp - - - DynamicLibrary - MultiByte - true - v120_xp - - - - - - - - - - - - - - - - - - - .\..\..\lib32\ - .\temp\ - true - false - false - false - .\..\..\lib64\ - .\temp\ - true - false - false - false - .\..\..\lib32\ - .\temp\ - true - false - false - false - .\..\..\lib64\ - .\temp\ - true - false - false - false - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ociliba - ociliba - ocilibw - ocilibw - - - - Full - true - _WIN32;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_ANSI;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - false - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - - - OCI_CHARSET_ANSI;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ociliba.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ociliba.lib - MachineX86 - .\..\..\lib32\$(TargetName).pdb - - - true - true - - - - - X64 - - - Full - true - _WIN64;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_ANSI;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - - - OCI_CHARSET_ANSI;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ociliba.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ociliba.lib - MachineX64 - .\..\..\lib64\$(TargetName).pdb - - - true - true - - - - - Full - true - _WIN32;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_WIDE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - false - - - OCI_CHARSET_WIDE;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ocilibw.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ocilibw.lib - MachineX86 - .\..\..\lib32\$(TargetName).pdb - - - true - false - - - - - X64 - - - Full - true - _WIN64;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_WIDE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - - - OCI_CHARSET_WIDE;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ocilibw.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ocilibw.lib - MachineX64 - .\..\..\lib64\$(TargetName).pdb - - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/proj/dll/ocilib_dll_vs2015.sln b/proj/dll/ocilib_dll_vs2015.sln deleted file mode 100644 index c0c77fa9..00000000 --- a/proj/dll/ocilib_dll_vs2015.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCILIB Dynamic Library", "ocilib_dll_vs2015.vcxproj", "{B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release - ANSI|Win32 = Release - ANSI|Win32 - Release - ANSI|Win64 = Release - ANSI|Win64 - Release - UNICODE|Win32 = Release - UNICODE|Win32 - Release - UNICODE|Win64 = Release - UNICODE|Win64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win32.ActiveCfg = Release - ANSI|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win32.Build.0 = Release - ANSI|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win64.ActiveCfg = Release - ANSI|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win64.Build.0 = Release - ANSI|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win32.ActiveCfg = Release - UNICODE|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win32.Build.0 = Release - UNICODE|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win64.ActiveCfg = Release - UNICODE|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win64.Build.0 = Release - UNICODE|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/proj/dll/ocilib_dll_vs2015.vcxproj b/proj/dll/ocilib_dll_vs2015.vcxproj deleted file mode 100644 index 9037f59e..00000000 --- a/proj/dll/ocilib_dll_vs2015.vcxproj +++ /dev/null @@ -1,371 +0,0 @@ - - - - - Release - ANSI - Win32 - - - Release - ANSI - x64 - - - Release - UNICODE - Win32 - - - Release - UNICODE - x64 - - - - OCILIB Dynamic Library - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D} - OCILIBDynamicLibrary - Win32Proj - - - - DynamicLibrary - Unicode - true - v140_xp - - - DynamicLibrary - MultiByte - true - v140_xp - - - DynamicLibrary - Unicode - true - v140_xp - - - DynamicLibrary - MultiByte - true - v140_xp - - - - - - - - - - - - - - - - - - - .\..\..\lib32\ - .\temp\ - true - false - false - false - .\..\..\lib64\ - .\temp\ - true - false - false - false - .\..\..\lib32\ - .\temp\ - true - false - false - false - .\..\..\lib64\ - .\temp\ - true - false - false - false - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ociliba - ociliba - ocilibw - ocilibw - - - - Full - true - _WIN32;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_ANSI;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - false - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - - - OCI_CHARSET_ANSI;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ociliba.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ociliba.lib - MachineX86 - .\..\..\lib32\$(TargetName).pdb - - - true - true - - - - - X64 - - - Full - true - _WIN64;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_ANSI;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - - - OCI_CHARSET_ANSI;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ociliba.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ociliba.lib - MachineX64 - .\..\..\lib64\$(TargetName).pdb - - - true - true - - - - - Full - true - _WIN32;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_WIDE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - false - - - OCI_CHARSET_WIDE;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ocilibw.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ocilibw.lib - MachineX86 - .\..\..\lib32\$(TargetName).pdb - - - true - false - - - - - X64 - - - Full - true - _WIN64;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_WIDE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820 - - - OCI_CHARSET_WIDE;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ocilibw.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ocilibw.lib - MachineX64 - .\..\..\lib64\$(TargetName).pdb - - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/proj/dll/ocilib_dll_vs2017.sln b/proj/dll/ocilib_dll_vs2017.sln deleted file mode 100644 index a75b9225..00000000 --- a/proj/dll/ocilib_dll_vs2017.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCILIB Dynamic Library", "ocilib_dll_vs2017.vcxproj", "{B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release - ANSI|Win32 = Release - ANSI|Win32 - Release - ANSI|Win64 = Release - ANSI|Win64 - Release - UNICODE|Win32 = Release - UNICODE|Win32 - Release - UNICODE|Win64 = Release - UNICODE|Win64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win32.ActiveCfg = Release - ANSI|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win32.Build.0 = Release - ANSI|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win64.ActiveCfg = Release - ANSI|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - ANSI|Win64.Build.0 = Release - ANSI|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win32.ActiveCfg = Release - UNICODE|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win32.Build.0 = Release - UNICODE|Win32 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win64.ActiveCfg = Release - UNICODE|x64 - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D}.Release - UNICODE|Win64.Build.0 = Release - UNICODE|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/proj/dll/ocilib_dll_vs2017.vcxproj b/proj/dll/ocilib_dll_vs2017.vcxproj deleted file mode 100644 index 08e01ae9..00000000 --- a/proj/dll/ocilib_dll_vs2017.vcxproj +++ /dev/null @@ -1,375 +0,0 @@ - - - - - Release - ANSI - Win32 - - - Release - ANSI - x64 - - - Release - UNICODE - Win32 - - - Release - UNICODE - x64 - - - - OCILIB Dynamic Library - {B5B9DE0E-C2BE-4D75-BDA0-CBF81BD18D7D} - OCILIBDynamicLibrary - Win32Proj - - - - DynamicLibrary - Unicode - true - v141_xp - - - DynamicLibrary - MultiByte - true - v141_xp - - - DynamicLibrary - Unicode - true - v141_xp - - - DynamicLibrary - MultiByte - true - v141_xp - - - - - - - - - - - - - - - - - - - - - - - .\..\..\lib32\ - .\temp\ - true - false - false - false - .\..\..\lib64\ - .\temp\ - true - false - false - false - .\..\..\lib32\ - .\temp\ - true - false - false - false - .\..\..\lib64\ - .\temp\ - true - false - false - false - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ..\..\include;$(IncludePath) - ociliba - ociliba - ocilibw - ocilibw - - - - Full - true - _WIN32;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_ANSI;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - false - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820;5045 - - - OCI_CHARSET_ANSI;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ociliba.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ociliba.lib - MachineX86 - .\..\..\lib32\$(TargetName).pdb - - - true - true - - - - - X64 - - - Full - true - _WIN64;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_ANSI;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820;5045 - - - OCI_CHARSET_ANSI;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ociliba.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ociliba.lib - MachineX64 - .\..\..\lib64\$(TargetName).pdb - - - true - true - - - - - Full - true - _WIN32;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_WIDE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820;5045 - false - - - OCI_CHARSET_WIDE;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ocilibw.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ocilibw.lib - MachineX86 - .\..\..\lib32\$(TargetName).pdb - - - true - false - - - - - X64 - - - Full - true - _WIN64;_DEBUG;_WINDOWS;_USRDLL;OCI_EXPORT=__declspec(dllexport);OCI_API=__stdcall;OCI_CHARSET_WIDE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - false - - - MultiThreaded - - - EnableAllWarnings - - - CompileAsC - 4255;4668;4996;4710;4711;4738;4774;4820;5045 - - - OCI_CHARSET_WIDE;%(PreprocessorDefinitions) - - - false - NotSet - $(TargetDir)\ocilibw.dll - %(AdditionalLibraryDirectories) - - - false - ocilib.lib;%(IgnoreSpecificDefaultLibraries) - - - true - Windows - true - UseLinkTimeCodeGeneration - - - false - - - $(TargetDir)\ocilibw.lib - MachineX64 - .\..\..\lib64\$(TargetName).pdb - - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/proj/dll/ocilib_dll_vs2019.vcxproj b/proj/dll/ocilib_dll_vs2019.vcxproj index 08e01ae9..3adf3072 100644 --- a/proj/dll/ocilib_dll_vs2019.vcxproj +++ b/proj/dll/ocilib_dll_vs2019.vcxproj @@ -308,7 +308,9 @@ - + + + @@ -316,12 +318,14 @@ + + @@ -329,23 +333,24 @@ + - - + + - + - + @@ -353,21 +358,65 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj/dll/ocilib_dll_vs2019.vcxproj.filters b/proj/dll/ocilib_dll_vs2019.vcxproj.filters new file mode 100644 index 00000000..47de7d3c --- /dev/null +++ b/proj/dll/ocilib_dll_vs2019.vcxproj.filters @@ -0,0 +1,344 @@ + + + + + {41e51a6c-1c9a-47de-894f-cfe004d13868} + + + {0229706c-26ac-4bfe-ad5a-ae631239b6a3} + + + {5a204776-f9e7-466f-b517-238e40b57bdb} + + + {7b4e72bd-746a-40d7-b757-d3f5ff256983} + + + {fd2b217d-6121-4eed-be01-d73044bd9774} + + + {c9624fb7-d573-4e70-b5c5-4af3d41e0b4d} + + + + + Resources + + + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28OCI%29 + + + Headers %28OCI%29 + + + Headers %28OCI%29 + + + Headers %28Public%29 + + + Headers %28Public%29 + + + Headers %28Public%29 + + + Headers %28Public%29 + + + Headers %28Public%29 + + + Headers %28Core%29 + + + Headers %28Core%29 + + + Headers %28Core%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Core%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + Headers %28Private%29 + + + \ No newline at end of file diff --git a/scripts/uncrustify.cfg b/scripts/uncrustify.cfg index a7117237..34321949 100644 --- a/scripts/uncrustify.cfg +++ b/scripts/uncrustify.cfg @@ -41,7 +41,7 @@ align_on_operator=false align_mix_var_proto=true align_single_line_func=true align_single_line_brace=true -align_nl_cont=false +align_nl_cont=true align_left_shift=true align_pp_define_together=true nl_collapse_empty_body=false @@ -109,10 +109,10 @@ align_struct_init_span=1 align_single_line_brace_gap=6 align_oc_msg_spec_span=0 align_pp_define_span=0 -code_width=100 +code_width=140 nl_max=2 nl_before_block_comment=2 -nl_before_c_comment=2 +nl_before_c_comment=1 cmt_width=100 cmt_sp_before_star_cont=0 cmt_sp_after_star_cont=0 diff --git a/scripts/uncrustify.cmd b/scripts/uncrustify.cmd new file mode 100644 index 00000000..5c162b00 --- /dev/null +++ b/scripts/uncrustify.cmd @@ -0,0 +1 @@ +uncrustify.exe --replace --nobackup -c uncrustify.cfg -F uncrustify.txt \ No newline at end of file diff --git a/scripts/uncrustify.txt b/scripts/uncrustify.txt index afe0a9d5..279c04c6 100644 --- a/scripts/uncrustify.txt +++ b/scripts/uncrustify.txt @@ -1,106 +1,96 @@ -c:\perso\git\ocilib\src\oci\api.h -c:\perso\git\ocilib\src\oci\defines.h -c:\perso\git\ocilib\src\oci\types.h -c:\perso\git\ocilib\src\agent.c -c:\perso\git\ocilib\src\agent.h -c:\perso\git\ocilib\src\array.c -c:\perso\git\ocilib\src\array.h -c:\perso\git\ocilib\src\bind.c -c:\perso\git\ocilib\src\bind.h -c:\perso\git\ocilib\src\callback.c -c:\perso\git\ocilib\src\callback.h -c:\perso\git\ocilib\src\collection.c -c:\perso\git\ocilib\src\collection.h -c:\perso\git\ocilib\src\column.c -c:\perso\git\ocilib\src\column.h -c:\perso\git\ocilib\src\connection.c -c:\perso\git\ocilib\src\connection.h -c:\perso\git\ocilib\src\context.h -c:\perso\git\ocilib\src\database.c -c:\perso\git\ocilib\src\database.h -c:\perso\git\ocilib\src\date.c -c:\perso\git\ocilib\src\date.h -c:\perso\git\ocilib\src\dequeue.c -c:\perso\git\ocilib\src\dequeue.h -c:\perso\git\ocilib\src\dirpath.c -c:\perso\git\ocilib\src\dirpath.h -c:\perso\git\ocilib\src\element.c -c:\perso\git\ocilib\src\element.h -c:\perso\git\ocilib\src\enqueue.c -c:\perso\git\ocilib\src\enqueue.h -c:\perso\git\ocilib\src\environment.c -c:\perso\git\ocilib\src\environment.h -c:\perso\git\ocilib\src\error.c -c:\perso\git\ocilib\src\error.h -c:\perso\git\ocilib\src\event.c -c:\perso\git\ocilib\src\event.h -c:\perso\git\ocilib\src\exception.c -c:\perso\git\ocilib\src\exception.h -c:\perso\git\ocilib\src\external.h -c:\perso\git\ocilib\src\file.c -c:\perso\git\ocilib\src\file.h -c:\perso\git\ocilib\src\format.c -c:\perso\git\ocilib\src\format.h -c:\perso\git\ocilib\src\handle.c -c:\perso\git\ocilib\src\handle.h -c:\perso\git\ocilib\src\hash.c -c:\perso\git\ocilib\src\hash.h -c:\perso\git\ocilib\src\helpers.h -c:\perso\git\ocilib\src\import.h -c:\perso\git\ocilib\src\internal.h -c:\perso\git\ocilib\src\interval.c -c:\perso\git\ocilib\src\interval.h -c:\perso\git\ocilib\src\iterator.c -c:\perso\git\ocilib\src\iterator.h -c:\perso\git\ocilib\src\list.c -c:\perso\git\ocilib\src\list.h -c:\perso\git\ocilib\src\loader.h -c:\perso\git\ocilib\src\lob.c -c:\perso\git\ocilib\src\lob.h -c:\perso\git\ocilib\src\long.c -c:\perso\git\ocilib\src\long.h -c:\perso\git\ocilib\src\macro.h -c:\perso\git\ocilib\src\memory.c -c:\perso\git\ocilib\src\memory.h -c:\perso\git\ocilib\src\message.c -c:\perso\git\ocilib\src\message.h -c:\perso\git\ocilib\src\mutex.c -c:\perso\git\ocilib\src\mutex.h -c:\perso\git\ocilib\src\names.c -c:\perso\git\ocilib\include\ocilib.h -c:\perso\git\ocilib\include\ocilib_api.h -c:\perso\git\ocilib\include\ocilib_compat.h -c:\perso\git\ocilib\include\ocilib_config.h -c:\perso\git\ocilib\include\ocilib_types.h -c:\perso\git\ocilib\src\number.c -c:\perso\git\ocilib\src\number.h -c:\perso\git\ocilib\src\object.c -c:\perso\git\ocilib\src\object.h -c:\perso\git\ocilib\src\ocilib.c -c:\perso\git\ocilib\src\pool.c -c:\perso\git\ocilib\src\pool.h -c:\perso\git\ocilib\src\queue.c -c:\perso\git\ocilib\src\queue.h -c:\perso\git\ocilib\src\reference.c -c:\perso\git\ocilib\src\reference.h -c:\perso\git\ocilib\src\resultset.c -c:\perso\git\ocilib\src\resultset.h -c:\perso\git\ocilib\src\statement.c -c:\perso\git\ocilib\src\statement.h -c:\perso\git\ocilib\src\string.c -c:\perso\git\ocilib\src\string.h -c:\perso\git\ocilib\src\subscription.c -c:\perso\git\ocilib\src\subscription.h -c:\perso\git\ocilib\src\thread.c -c:\perso\git\ocilib\src\thread.h -c:\perso\git\ocilib\src\threadkey.c -c:\perso\git\ocilib\src\threadkey.h -c:\perso\git\ocilib\src\timestamp.c -c:\perso\git\ocilib\src\timestamp.h -c:\perso\git\ocilib\src\trace.c -c:\perso\git\ocilib\src\trace.h -c:\perso\git\ocilib\src\transaction.c -c:\perso\git\ocilib\src\transaction.h -c:\perso\git\ocilib\src\typeinfo.c -c:\perso\git\ocilib\src\typeinfo.h -c:\perso\git\ocilib\src\types.h +c:\Perso\Git\ocilib\src\agent.c +c:\Perso\Git\ocilib\src\agent.h +c:\Perso\Git\ocilib\src\array.c +c:\Perso\Git\ocilib\src\array.h +c:\Perso\Git\ocilib\src\bind.c +c:\Perso\Git\ocilib\src\bind.h +c:\Perso\Git\ocilib\src\callback.c +c:\Perso\Git\ocilib\src\callback.h +c:\Perso\Git\ocilib\src\collection.c +c:\Perso\Git\ocilib\src\collection.h +c:\Perso\Git\ocilib\src\column.c +c:\Perso\Git\ocilib\src\column.h +c:\Perso\Git\ocilib\src\connection.c +c:\Perso\Git\ocilib\src\connection.h +c:\Perso\Git\ocilib\src\database.c +c:\Perso\Git\ocilib\src\database.h +c:\Perso\Git\ocilib\src\date.c +c:\Perso\Git\ocilib\src\date.h +c:\Perso\Git\ocilib\src\define.c +c:\Perso\Git\ocilib\src\define.h +c:\Perso\Git\ocilib\src\defs.h +c:\Perso\Git\ocilib\src\dequeue.c +c:\Perso\Git\ocilib\src\dequeue.h +c:\Perso\Git\ocilib\src\dirpath.c +c:\Perso\Git\ocilib\src\dirpath.h +c:\Perso\Git\ocilib\src\element.c +c:\Perso\Git\ocilib\src\element.h +c:\Perso\Git\ocilib\src\enqueue.c +c:\Perso\Git\ocilib\src\enqueue.h +c:\Perso\Git\ocilib\src\environment.c +c:\Perso\Git\ocilib\src\environment.h +c:\Perso\Git\ocilib\src\error.c +c:\Perso\Git\ocilib\src\error.h +c:\Perso\Git\ocilib\src\event.c +c:\Perso\Git\ocilib\src\event.h +c:\Perso\Git\ocilib\src\exception.c +c:\Perso\Git\ocilib\src\exception.h +c:\Perso\Git\ocilib\src\file.c +c:\Perso\Git\ocilib\src\file.h +c:\Perso\Git\ocilib\src\format.c +c:\Perso\Git\ocilib\src\format.h +c:\Perso\Git\ocilib\src\handle.c +c:\Perso\Git\ocilib\src\handle.h +c:\Perso\Git\ocilib\src\hash.c +c:\Perso\Git\ocilib\src\hash.h +c:\Perso\Git\ocilib\src\helpers.c +c:\Perso\Git\ocilib\src\helpers.h +c:\Perso\Git\ocilib\src\import.h +c:\Perso\Git\ocilib\src\interval.c +c:\Perso\Git\ocilib\src\interval.h +c:\Perso\Git\ocilib\src\iterator.c +c:\Perso\Git\ocilib\src\iterator.h +c:\Perso\Git\ocilib\src\list.c +c:\Perso\Git\ocilib\src\list.h +c:\Perso\Git\ocilib\src\loader.h +c:\Perso\Git\ocilib\src\lob.c +c:\Perso\Git\ocilib\src\lob.h +c:\Perso\Git\ocilib\src\long.c +c:\Perso\Git\ocilib\src\long.h +c:\Perso\Git\ocilib\src\macros.h +c:\Perso\Git\ocilib\src\memory.c +c:\Perso\Git\ocilib\src\memory.h +c:\Perso\Git\ocilib\src\message.c +c:\Perso\Git\ocilib\src\message.h +c:\Perso\Git\ocilib\src\mutex.c +c:\Perso\Git\ocilib\src\mutex.h +c:\Perso\Git\ocilib\src\number.c +c:\Perso\Git\ocilib\src\number.h +c:\Perso\Git\ocilib\src\object.c +c:\Perso\Git\ocilib\src\object.h +c:\Perso\Git\ocilib\src\ocilib.c +c:\Perso\Git\ocilib\src\pool.c +c:\Perso\Git\ocilib\src\pool.h +c:\Perso\Git\ocilib\src\queue.c +c:\Perso\Git\ocilib\src\queue.h +c:\Perso\Git\ocilib\src\reference.c +c:\Perso\Git\ocilib\src\reference.h +c:\Perso\Git\ocilib\src\resultset.c +c:\Perso\Git\ocilib\src\resultset.h +c:\Perso\Git\ocilib\src\statement.c +c:\Perso\Git\ocilib\src\statement.h +c:\Perso\Git\ocilib\src\strings.c +c:\Perso\Git\ocilib\src\strings.h +c:\Perso\Git\ocilib\src\subscription.c +c:\Perso\Git\ocilib\src\subscription.h +c:\Perso\Git\ocilib\src\thread.c +c:\Perso\Git\ocilib\src\thread.h +c:\Perso\Git\ocilib\src\threadkey.c +c:\Perso\Git\ocilib\src\threadkey.h +c:\Perso\Git\ocilib\src\timestamp.c +c:\Perso\Git\ocilib\src\timestamp.h +c:\Perso\Git\ocilib\src\transaction.c +c:\Perso\Git\ocilib\src\transaction.h +c:\Perso\Git\ocilib\src\typeinfo.c +c:\Perso\Git\ocilib\src\typeinfo.h +c:\Perso\Git\ocilib\src\types.h \ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index 9778f1b3..fec19ca1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,64 +13,120 @@ AM_CPPFLAGS= @ORACLE_INCLUDES@ -I$(top_srcdir)/include lib_LTLIBRARIES= libocilib.la libocilib_la_LIBADD= @ORACLE_LIBADD@ -libocilib_la_SOURCES= \ - array.c \ - bind.c \ - callback.c \ - connection.c \ - define.c \ - exception.c \ - handle.c \ - iterator.c \ - lob.c \ - mutex.c \ - resultset.c \ - string.c \ - timestamp.c \ - collection.c \ - pool.c \ - element.c \ - file.c \ - hash.c \ - library.c \ - long.c \ - number.c \ - typeinfo.c \ - thread.c \ - transaction.c \ - column.c \ - date.c \ - error.c \ - format.c \ - interval.c \ - list.c \ - memory.c \ - object.c \ - statement.c \ - ref.c \ - threadkey.c \ - dirpath.c \ - event.c \ - subscription.c \ - agent.c \ - dequeue.c \ - enqueue.c \ - msg.c \ - queue.c +libocilib_la_SOURCES= \ + agent.c \ + array.c \ + bind.c \ + callback.c \ + collection.c \ + column.c \ + connection.c \ + date.c \ + database.c \ + define.c \ + dequeue.c \ + dirpath.c \ + element.c \ + enqueue.c \ + environment.c \ + error.c \ + event.c \ + exception.c \ + file.c \ + format.c \ + handle.c \ + hash.c \ + helpers.c \ + interval.c \ + iterator.c \ + list.c \ + lob.c \ + long.c \ + memory.c \ + message.c \ + mutex.c \ + number.c \ + object.c \ + ocilib.c \ + pool.c \ + queue.c \ + reference.c \ + resultset.c \ + statement.c \ + strings.c \ + subscription.c \ + thread.c \ + threadkey.c \ + timestamp.c \ + transaction.c \ + typeinfo.c libocilib_la_CFLAGS= -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS= @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -include_HEADERS= $(top_srcdir)/include/ocilib.h $(top_srcdir)/include/ocilib.hpp $(top_srcdir)/include/ocilib_core.hpp $(top_srcdir)/include/ocilib_impl.hpp -noinst_HEADERS= \ - ocilib_internal.h \ - ocilib_types.h \ - ocilib_checks.h \ - ocilib_defs.h \ - oci_types.h \ - oci_import.h \ - oci_loader.h \ - oci_defs.h \ - oci_api.h +include_HEADERS= \ + $(top_srcdir)/include/ocilib.h \ + $(top_srcdir)/include/ocilib_api.h \ + $(top_srcdir)/include/ocilib_compat.h \ + $(top_srcdir)/include/ocilib_config.h \ + $(top_srcdir)/include/ocilib_types.h \ + $(top_srcdir)/include/ocilib.hpp \ + $(top_srcdir)/include/ocilib_core.hpp \ + $(top_srcdir)/include/ocilib_impl.hpp + +noinst_HEADERS= \ + agent.h \ + array.h \ + bind.h \ + callback.h \ + collection.h \ + column.h \ + connection.h \ + database.h \ + date.h \ + define.h \ + defs.h \ + dequeue.h \ + dirpath.h \ + element.h \ + enqueue.h \ + environment.h \ + error.h \ + event.h \ + exception.h \ + file.h \ + format.h \ + handle.h \ + hash.h \ + helpers.h \ + import.h \ + interval.h \ + iterator.h \ + list.h \ + loader.h \ + lob.h \ + long.h \ + macros.h \ + memory.h \ + message.h \ + mutex.h \ + number.h \ + object.h \ + pool.h \ + queue.h \ + reference.h \ + resultset.h \ + statement.h \ + strings.h \ + subscription.h \ + thread.h \ + threadkey.h \ + timestamp.h \ + transaction.h \ + typeinfo.h \ + types.h \ + oci/types.h \ + oci/defs.h \ + oci/api.h CLEANFILES = *~ diff --git a/src/Makefile.in b/src/Makefile.in index 18755755..a70932ce 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -368,64 +368,119 @@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = @ORACLE_INCLUDES@ -I$(top_srcdir)/include lib_LTLIBRARIES = libocilib.la libocilib_la_LIBADD = @ORACLE_LIBADD@ -libocilib_la_SOURCES = \ - array.c \ - bind.c \ - callback.c \ - connection.c \ - define.c \ - exception.c \ - handle.c \ - iterator.c \ - lob.c \ - mutex.c \ - resultset.c \ - string.c \ - timestamp.c \ - collection.c \ - pool.c \ - element.c \ - file.c \ - hash.c \ - library.c \ - long.c \ - number.c \ - typeinfo.c \ - thread.c \ - transaction.c \ - column.c \ - date.c \ - error.c \ - format.c \ - interval.c \ - list.c \ - memory.c \ - object.c \ - statement.c \ - ref.c \ - threadkey.c \ - dirpath.c \ - event.c \ - subscription.c \ - agent.c \ - dequeue.c \ - enqueue.c \ - msg.c \ - queue.c +libocilib_la_SOURCES= \ + agent.c \ + array.c \ + bind.c \ + callback.c \ + collection.c \ + column.c \ + connection.c \ + date.c \ + database.c \ + define.c \ + dequeue.c \ + dirpath.c \ + element.c \ + enqueue.c \ + environment.c \ + error.c \ + event.c \ + exception.c \ + file.c \ + format.c \ + handle.c \ + hash.c \ + helpers.c \ + interval.c \ + iterator.c \ + list.c \ + lob.c \ + long.c \ + memory.c \ + message.c \ + mutex.c \ + number.c \ + object.c \ + ocilib.c \ + pool.c \ + queue.c \ + reference.c \ + resultset.c \ + statement.c \ + strings.c \ + subscription.c \ + thread.c \ + threadkey.c \ + timestamp.c \ + transaction.c \ + typeinfo.c libocilib_la_CFLAGS = -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS = @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -include_HEADERS = $(top_srcdir)/include/ocilib.h $(top_srcdir)/include/ocilib.hpp $(top_srcdir)/include/ocilib_core.hpp $(top_srcdir)/include/ocilib_impl.hpp -noinst_HEADERS = \ - ocilib_internal.h \ - ocilib_types.h \ - ocilib_checks.h \ - ocilib_defs.h \ - oci_types.h \ - oci_import.h \ - oci_loader.h \ - oci_defs.h \ - oci_api.h +include_HEADERS= \ + $(top_srcdir)/include/ocilib.h \ + $(top_srcdir)/include/ocilib_api.h \ + $(top_srcdir)/include/ocilib_compat.h \ + $(top_srcdir)/include/ocilib_config.h \ + $(top_srcdir)/include/ocilib_types.h \ + $(top_srcdir)/include/ocilib.hpp \ + $(top_srcdir)/include/ocilib_core.hpp \ + $(top_srcdir)/include/ocilib_impl.hpp +noinst_HEADERS= \ + agent.h \ + array.h \ + bind.h \ + callback.h \ + collection.h \ + column.h \ + connection.h \ + database.h \ + date.h \ + define.h \ + defs.h \ + dequeue.h \ + dirpath.h \ + element.h \ + enqueue.h \ + environment.h \ + error.h \ + event.h \ + exception.h \ + file.h \ + format.h \ + handle.h \ + hash.h \ + helpers.h \ + import.h \ + interval.h \ + iterator.h \ + list.h \ + loader.h \ + lob.h \ + long.h \ + macros.h \ + memory.h \ + message.h \ + mutex.h \ + number.h \ + object.h \ + pool.h \ + queue.h \ + reference.h \ + resultset.h \ + statement.h \ + strings.h \ + subscription.h \ + thread.h \ + threadkey.h \ + timestamp.h \ + transaction.h \ + typeinfo.h \ + types.h \ + oci/types.h \ + oci/defs.h \ + oci/api.h CLEANFILES = *~ all: all-am @@ -802,12 +857,12 @@ libocilib_la-statement.lo: statement.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-statement.lo `test -f 'statement.c' || echo '$(srcdir)/'`statement.c -libocilib_la-ref.lo: ref.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-ref.lo -MD -MP -MF $(DEPDIR)/libocilib_la-ref.Tpo -c -o libocilib_la-ref.lo `test -f 'ref.c' || echo '$(srcdir)/'`ref.c +libocilib_la-ref.lo: reference.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-ref.lo -MD -MP -MF $(DEPDIR)/libocilib_la-ref.Tpo -c -o libocilib_la-ref.lo `test -f 'reference.c' || echo '$(srcdir)/'`reference.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-ref.Tpo $(DEPDIR)/libocilib_la-ref.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ref.c' object='libocilib_la-ref.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='reference.c' object='libocilib_la-ref.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-ref.lo `test -f 'ref.c' || echo '$(srcdir)/'`ref.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-ref.lo `test -f 'reference.c' || echo '$(srcdir)/'`reference.c libocilib_la-threadkey.lo: threadkey.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-threadkey.lo -MD -MP -MF $(DEPDIR)/libocilib_la-threadkey.Tpo -c -o libocilib_la-threadkey.lo `test -f 'threadkey.c' || echo '$(srcdir)/'`threadkey.c @@ -858,12 +913,12 @@ libocilib_la-enqueue.lo: enqueue.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-enqueue.lo `test -f 'enqueue.c' || echo '$(srcdir)/'`enqueue.c -libocilib_la-msg.lo: msg.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-msg.lo -MD -MP -MF $(DEPDIR)/libocilib_la-msg.Tpo -c -o libocilib_la-msg.lo `test -f 'msg.c' || echo '$(srcdir)/'`msg.c +libocilib_la-msg.lo: message.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-msg.lo -MD -MP -MF $(DEPDIR)/libocilib_la-msg.Tpo -c -o libocilib_la-msg.lo `test -f 'message.c' || echo '$(srcdir)/'`message.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-msg.Tpo $(DEPDIR)/libocilib_la-msg.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='msg.c' object='libocilib_la-msg.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='message.c' object='libocilib_la-msg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-msg.lo `test -f 'msg.c' || echo '$(srcdir)/'`msg.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-msg.lo `test -f 'message.c' || echo '$(srcdir)/'`message.c libocilib_la-queue.lo: queue.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-queue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-queue.Tpo -c -o libocilib_la-queue.lo `test -f 'queue.c' || echo '$(srcdir)/'`queue.c diff --git a/src/agent.c b/src/agent.c index 1ac604be..54f7bbc9 100644 --- a/src/agent.c +++ b/src/agent.c @@ -18,17 +18,16 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "agent.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "macros.h" +#include "strings.h" /* --------------------------------------------------------------------------------------------- * - * OCI_AgentInit + * AgentInit * --------------------------------------------------------------------------------------------- */ -OCI_Agent * OCI_AgentInit +OCI_Agent * AgentInitialize ( OCI_Connection *con, OCI_Agent *agent, @@ -37,195 +36,238 @@ OCI_Agent * OCI_AgentInit const otext *address ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Agent*, agent, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_ALLOCATE_DATA(OCI_IPC_AGENT, agent, 1); + CHECK_PTR(OCI_IPC_CONNECTION, con) - if (OCI_STATUS) - { - OCI_FREE(agent->name) - OCI_FREE(agent->address) - - agent->con = con; - agent->handle = handle; + ALLOC_DATA(OCI_IPC_AGENT, agent, 1) - if (!handle) - { - agent->hstate = OCI_OBJECT_ALLOCATED; + FREE(agent->name) + FREE(agent->address) - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)agent->con->env, (dvoid **)&agent->handle, OCI_DTYPE_AQAGENT); - } - else - { - agent->hstate = OCI_OBJECT_FETCHED_CLEAN; - } + agent->con = con; + agent->handle = handle; - /* set name attribute if provided */ + if (NULL == handle) + { + agent->hstate = OCI_OBJECT_ALLOCATED; - if (OCI_STATUS && OCI_STRING_VALID(name)) - { - OCI_STATUS = OCI_AgentSetName(agent, name); - } + CHECK(MemoryAllocDescriptor((dvoid *)agent->con->env, (dvoid **)&agent->handle, OCI_DTYPE_AQAGENT)) + } + else + { + agent->hstate = OCI_OBJECT_FETCHED_CLEAN; + } - /* set address attribute if provided */ + /* set name attribute if provided */ - if (OCI_STATUS && OCI_STRING_VALID(address)) - { - OCI_STATUS = OCI_AgentSetAddress(agent, address); - } + if (IS_STRING_VALID(name)) + { + CHECK(AgentSetName(agent, name)) } - /* check for failure */ + /* set address attribute if provided */ - if (!OCI_STATUS && agent) + if (IS_STRING_VALID(address)) { - OCI_AgentFree(agent); - agent = NULL; + CHECK(AgentSetAddress(agent, address)) } - return agent; -} + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + AgentFree(agent); + agent = NULL; + } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + SET_RETVAL(agent) + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_AgentCreate + * AgentCreate * --------------------------------------------------------------------------------------------- */ -OCI_Agent * OCI_API OCI_AgentCreate +OCI_Agent * AgentCreate ( OCI_Connection *con, const otext *name, const otext *address ) { - OCI_CALL_ENTER(OCI_Agent *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Agent*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = OCI_AgentInit(con, NULL, NULL, name, address); - OCI_STATUS = (NULL != OCI_RETVAL); + SET_RETVAL(AgentInitialize(con, NULL, NULL, name, address)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_AgentFree + * AgentFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_AgentFree +boolean AgentFree ( OCI_Agent *agent ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_AGENT, agent) - OCI_CALL_CONTEXT_SET_FROM_CONN(agent->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_AGENT, agent + ) + + CHECK_PTR(OCI_IPC_AGENT, agent) if (OCI_OBJECT_ALLOCATED == agent->hstate) { - OCI_DescriptorFree((dvoid *) agent->handle, OCI_DTYPE_AQAGENT); + MemoryFreeDescriptor((dvoid*)agent->handle, OCI_DTYPE_AQAGENT); } - OCI_FREE(agent->address) - OCI_FREE(agent->name) - OCI_FREE(agent) + FREE(agent->address) + FREE(agent->name) + FREE(agent) + + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_AgentGetName + * AgentGetName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_AgentGetName +const otext * AgentGetName ( OCI_Agent *agent ) { - OCI_CALL_ENTER(otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_AGENT, agent) - OCI_CALL_CONTEXT_SET_FROM_CONN(agent->con) + ENTER_FUNC + ( + /* returns */ otext*, NULL, + /* context */ OCI_IPC_AGENT, agent + ) - if (!agent->name) + CHECK_PTR(OCI_IPC_AGENT, agent) + + if (NULL == agent->name) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT, - OCI_ATTR_AGENT_NAME, &agent->name, &size); + + CHECK(StringGetAttribute(agent->con, + agent->handle, + OCI_DTYPE_AQAGENT, + OCI_ATTR_AGENT_NAME, + &agent->name, + &size)) } - OCI_RETVAL = agent->name; + SET_RETVAL(agent->name) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_AgentSetName + * AgentSetName * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_AgentSetName +boolean AgentSetName ( OCI_Agent *agent, const otext *name ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_AGENT, agent) - OCI_CALL_CONTEXT_SET_FROM_CONN(agent->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_AGENT, agent + ) - OCI_STATUS = OCI_SetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT, OCI_ATTR_AGENT_NAME, &agent->name, name); - OCI_RETVAL = OCI_STATUS; + CHECK_PTR(OCI_IPC_AGENT, agent) - OCI_CALL_EXIT() + CHECK(StringSetAttribute(agent->con, + agent->handle, + OCI_DTYPE_AQAGENT, + OCI_ATTR_AGENT_NAME, + &agent->name, + name)) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_AgentGetAddress + * AgentGetAddress * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_AgentGetAddress +const otext * AgentGetAddress ( OCI_Agent *agent ) { - - OCI_CALL_ENTER(otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_AGENT, agent) - OCI_CALL_CONTEXT_SET_FROM_CONN(agent->con) + ENTER_FUNC + ( + /* returns */ otext*, NULL, + /* context */ OCI_IPC_AGENT, agent + ) - if (!agent->address) + CHECK_PTR(OCI_IPC_AGENT, agent) + + if (NULL == agent->address) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT, - OCI_ATTR_AGENT_ADDRESS, &agent->address, &size); + + CHECK(StringGetAttribute(agent->con, + agent->handle, + OCI_DTYPE_AQAGENT, + OCI_ATTR_AGENT_ADDRESS, + &agent->address, + &size)) } - OCI_RETVAL = agent->address; + SET_RETVAL(agent->address) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_AgentSetAddress + * AgentSetAddress * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_AgentSetAddress +boolean AgentSetAddress ( OCI_Agent *agent, const otext *address ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_AGENT, agent) - OCI_CALL_CONTEXT_SET_FROM_CONN(agent->con) - - OCI_STATUS = OCI_SetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT, OCI_ATTR_AGENT_ADDRESS, &agent->address, address); - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_AGENT, agent + ) + + CHECK_PTR(OCI_IPC_AGENT, agent) + + CHECK(StringSetAttribute(agent->con, + agent->handle, + OCI_DTYPE_AQAGENT, + OCI_ATTR_AGENT_ADDRESS, + &agent->address, + address)) + + SET_SUCCESS() + + EXIT_FUNC() } diff --git a/src/agent.h b/src/agent.h new file mode 100644 index 00000000..e55e6d2d --- /dev/null +++ b/src/agent.h @@ -0,0 +1,69 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_AGENT_H_INCLUDED +#define OCILIB_AGENT_H_INCLUDED + +#include "types.h" + +OCI_Agent * AgentInitialize +( + OCI_Connection *con, + OCI_Agent *agent, + OCIAQAgent *handle, + const otext *name, + const otext *address +); + +OCI_Agent* AgentCreate +( + OCI_Connection* con, + const otext * name, + const otext * address +); + +boolean AgentFree +( + OCI_Agent* agent +); + +const otext* AgentGetName +( + OCI_Agent* agent +); + +boolean AgentSetName +( + OCI_Agent * agent, + const otext* name +); + +const otext* AgentGetAddress +( + OCI_Agent* agent +); + +boolean AgentSetAddress +( + OCI_Agent * agent, + const otext* address +); + +#endif /* OCILIB_AGENT_H_INCLUDED */ diff --git a/src/array.c b/src/array.c index 6230458e..74e9c183 100644 --- a/src/array.c +++ b/src/array.c @@ -18,53 +18,80 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "array.h" + +#include "collection.h" +#include "date.h" +#include "file.h" +#include "helpers.h" +#include "interval.h" +#include "list.h" +#include "lob.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "timestamp.h" + +#define ARRAY_INIT(type, exp) \ + data = exp; \ + CHECK_NULL(data) \ + ((void **)(arr->mem_handle))[i] = ((type *) data)->handle; \ -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ -#define OCI_ARRAY_INIT_HANDLE(type, func) \ - arr->tab_obj[i] = func; \ - ((void **)(arr->mem_handle))[i] = ((type *) arr->tab_obj[i])->handle; \ - - /* --------------------------------------------------------------------------------------------- * - * OCI_ArrayFindAny +/* --------------------------------------------------------------------------------------------- * + * ArrayFindAny * --------------------------------------------------------------------------------------------- */ -boolean OCI_ArrayFindAny(OCI_Array *arr, void**handles) +boolean ArrayFindAny +( + OCI_Array *arr, + void **handles +) { return arr && (arr->tab_obj == handles || arr->mem_struct == handles); } /* --------------------------------------------------------------------------------------------- * -* OCI_ArrayFindObjects +* ArrayFindObjects * --------------------------------------------------------------------------------------------- */ -boolean OCI_ArrayFindObjects(OCI_Array *arr, void**handles) +boolean ArrayFindObjects +( + OCI_Array *arr, + void **handles +) { return arr && arr->tab_obj == handles; } /* --------------------------------------------------------------------------------------------- * - * OCI_ArrayInit + * ArrayInitialize * --------------------------------------------------------------------------------------------- */ -boolean OCI_ArrayInit +boolean ArrayInitialize ( OCI_Array *arr, OCI_TypeInfo *typinf ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, arr ? arr->con : NULL + ) + for (unsigned int i = 0; i < arr->nb_elem; i++) { void *handle = NULL; + void *data = ((char*)arr->mem_struct) + (arr->struct_size * i);; if (OCI_CDT_DATETIME == arr->elem_type) { handle = &(((OCIDate *)(arr->mem_handle))[i]); } - else if (OCI_IS_OCI_NUMBER(arr->elem_type, arr->elem_subtype)) + else if (IS_OCI_NUMBER(arr->elem_type, arr->elem_subtype)) { handle = &(((OCINumber *)(arr->mem_handle))[i]); } @@ -73,9 +100,9 @@ boolean OCI_ArrayInit handle = ((void **)(arr->mem_handle))[i]; } - arr->tab_obj[i] = ((char *) arr->mem_struct) + (arr->struct_size * i); + arr->tab_obj[i] = data; - ((OCI_Datatype *) (arr->tab_obj[i]))->hstate = OCI_OBJECT_ALLOCATED_ARRAY; + ((OCI_Datatype *) data)->hstate = OCI_OBJECT_ALLOCATED_ARRAY; switch (arr->elem_type) { @@ -83,74 +110,84 @@ boolean OCI_ArrayInit { if (OCI_NUM_NUMBER == arr->elem_subtype) { - arr->tab_obj[i] = OCI_NumberInit(arr->con, (OCI_Number *) arr->tab_obj[i], (OCINumber *) handle); + data = NumberInitialize(arr->con, (OCI_Number*)data, (OCINumber*)handle); + CHECK_NULL(data) } break; } case OCI_CDT_DATETIME: { - arr->tab_obj[i] = OCI_DateInit(arr->con, (OCI_Date *) arr->tab_obj[i], (OCIDate *) handle, FALSE, FALSE); + data = DateInitialize(arr->con, (OCI_Date*)data, (OCIDate*)handle, FALSE, FALSE); + CHECK_NULL(data) break; } case OCI_CDT_LOB: { - OCI_ARRAY_INIT_HANDLE(OCI_Lob, OCI_LobInit(arr->con, (OCI_Lob *) arr->tab_obj[i], (OCILobLocator *) handle, arr->elem_subtype)) + ARRAY_INIT(OCI_Lob, LobInitialize(arr->con, (OCI_Lob *)data, (OCILobLocator *) handle, arr->elem_subtype)) break; } case OCI_CDT_FILE: { - OCI_ARRAY_INIT_HANDLE(OCI_File, OCI_FileInit(arr->con, (OCI_File *) arr->tab_obj[i], (OCILobLocator *) handle, arr->elem_subtype)) + ARRAY_INIT(OCI_File, FileInitialize(arr->con, (OCI_File *)data, (OCILobLocator *) handle, arr->elem_subtype)) break; } case OCI_CDT_TIMESTAMP: { - OCI_ARRAY_INIT_HANDLE(OCI_Timestamp, OCI_TimestampInit(arr->con, (OCI_Timestamp *) arr->tab_obj[i], (OCIDateTime *) handle, arr->elem_subtype)) + ARRAY_INIT(OCI_Timestamp, TimestampInitialize(arr->con, (OCI_Timestamp *)data, (OCIDateTime *) handle, arr->elem_subtype)) break; } case OCI_CDT_INTERVAL: { - OCI_ARRAY_INIT_HANDLE(OCI_Interval, OCI_IntervalInit(arr->con, (OCI_Interval *) arr->tab_obj[i], (OCIInterval *) handle, arr->elem_subtype)) + ARRAY_INIT(OCI_Interval, IntervalInitialize(arr->con, (OCI_Interval *)data, (OCIInterval *) handle, arr->elem_subtype)) break; } case OCI_CDT_OBJECT: { - OCI_ARRAY_INIT_HANDLE(OCI_Object, OCI_ObjectInit(arr->con, (OCI_Object *)arr->tab_obj[i], handle, typinf, NULL, -1, TRUE)) + ARRAY_INIT(OCI_Object, ObjectInitialize(arr->con, (OCI_Object *)data, handle, typinf, NULL, -1, TRUE)) break; } case OCI_CDT_COLLECTION: { - OCI_ARRAY_INIT_HANDLE(OCI_Coll, OCI_CollInit(arr->con, (OCI_Coll *) arr->tab_obj[i], handle, typinf)) + ARRAY_INIT(OCI_Coll, CollectionInitialize(arr->con, (OCI_Coll *)data, handle, typinf)) break; } case OCI_CDT_REF: { - OCI_ARRAY_INIT_HANDLE(OCI_Ref, OCI_RefInit(arr->con, typinf, (OCI_Ref *) arr->tab_obj[i], handle)) + ARRAY_INIT(OCI_Ref, ReferenceInitialize(arr->con, typinf, (OCI_Ref *) data, handle)) break; } } } - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ArrayClose + * ArrayClose * --------------------------------------------------------------------------------------------- */ -boolean OCI_ArrayClose +boolean ArrayDispose ( OCI_Array *arr ) { - OCI_CHECK(NULL == arr, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, arr ? arr->con : NULL + ) - if (OCI_IS_OCILIB_OBJECT(arr->elem_type, arr->elem_subtype)) + CHECK_PTR(OCI_IPC_ARRAY, arr) + + if (IS_OCILIB_OBJECT(arr->elem_type, arr->elem_subtype)) { /* Cleanup OCILIB Objects */ for (unsigned int i = 0; i < arr->nb_elem; i++) { - OCI_FreeObjectFromType(arr->tab_obj[i], arr->elem_type); + FreeObjectFromType(arr->tab_obj[i], arr->elem_type); } } @@ -158,21 +195,28 @@ boolean OCI_ArrayClose if (OCI_UNKNOWN != arr->handle_type) { - OCI_DescriptorArrayFree((dvoid **) arr->mem_handle, (ub4) arr->handle_type, (ub4) arr->nb_elem); + MemoryFreeDescriptorArray + ( + (dvoid**)arr->mem_handle, + (ub4)arr->handle_type, + (ub4)arr->nb_elem + ); } - OCI_FREE(arr->mem_handle) - OCI_FREE(arr->mem_struct) - OCI_FREE(arr->tab_obj) + FREE(arr->mem_handle) + FREE(arr->mem_struct) + FREE(arr->tab_obj) + + SET_SUCCESS() - return TRUE; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ArrayCreate + * ArrayCreate * --------------------------------------------------------------------------------------------- */ -OCI_Array * OCI_ArrayCreate +OCI_Array * ArrayCreate ( OCI_Connection *con, unsigned int nb_elem, @@ -183,101 +227,101 @@ OCI_Array * OCI_ArrayCreate unsigned int handle_type, OCI_TypeInfo *typinf ) -{ - OCI_Array *arr = NULL; +{ + ENTER_FUNC + ( + /* returns */ OCI_Array*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + OCI_Array* arr = NULL; - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) /* create array object */ - arr = OCI_ListAppend(OCILib.arrs, sizeof(*arr)); - OCI_STATUS = (NULL != arr); + arr = ListAppend(Env.arrs, sizeof(*arr)); + CHECK_NULL(arr) - if (OCI_STATUS) - { - arr->con = con; - arr->err = con ? con->err : OCILib.err; - arr->env = con ? con->env : OCILib.env; - arr->elem_type = elem_type; - arr->elem_subtype = elem_subtype; - arr->elem_size = elem_size; - arr->nb_elem = nb_elem; - arr->struct_size = struct_size; - arr->handle_type = handle_type; - - /* allocate buffers */ - - if (OCI_IS_OCILIB_OBJECT(arr->elem_type, arr->elem_subtype)) - { - OCI_ALLOCATE_DATA(OCI_IPC_VOID, arr->tab_obj, nb_elem) - } + arr->con = con; + arr->err = con ? con->err : Env.err; + arr->env = con ? con->env : Env.env; + arr->elem_type = elem_type; + arr->elem_subtype = elem_subtype; + arr->elem_size = elem_size; + arr->nb_elem = nb_elem; + arr->struct_size = struct_size; + arr->handle_type = handle_type; - OCI_ALLOCATE_BUFFER(OCI_IPC_VOID, arr->mem_handle, elem_size, nb_elem) - OCI_ALLOCATE_BUFFER(OCI_IPC_VOID, arr->mem_struct, struct_size, nb_elem) + /* allocate buffers */ - /* allocate OCI handle descriptors */ + if (IS_OCILIB_OBJECT(arr->elem_type, arr->elem_subtype)) + { + ALLOC_DATA(OCI_IPC_VOID, arr->tab_obj, nb_elem) + } - if (OCI_STATUS && handle_type != 0) - { - OCI_STATUS = OCI_DescriptorArrayAlloc((dvoid *)arr->env, (dvoid **)arr->mem_handle, (ub4)handle_type, (ub4)nb_elem); - } + ALLOC_BUFFER(OCI_IPC_VOID, arr->mem_handle, elem_size, nb_elem) + ALLOC_BUFFER(OCI_IPC_VOID, arr->mem_struct, struct_size, nb_elem) - if (OCI_STATUS && arr->tab_obj && arr->mem_handle) - { - OCI_STATUS = OCI_ArrayInit(arr, typinf); - } - } + /* allocate OCI handle descriptors */ - /* check for failure */ + if (OCI_UNKNOWN != handle_type) + { + CHECK + ( + MemoryAllocDescriptorArray + ( + (dvoid *)arr->env, + (dvoid **)arr->mem_handle, + (ub4)handle_type, (ub4)nb_elem + ) + ) + } - if (!OCI_STATUS) + if (arr->tab_obj && arr->mem_handle) { - OCI_ArrayClose(arr); - OCI_FREE(arr) + CHECK(ArrayInitialize(arr, typinf)) } - return arr; + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ArrayDispose(arr); + arr = NULL; + } + + SET_RETVAL(arr) + ) } /* --------------------------------------------------------------------------------------------- * * OCI_ArrayFreeFromHandles * --------------------------------------------------------------------------------------------- */ -boolean OCI_ArrayFreeFromHandles +boolean ArrayFreeFromHandles ( void **handles ) { - boolean res = FALSE; - OCI_Array *arr = OCI_ListFind(OCILib.arrs, (POCI_LIST_FIND) OCI_ArrayFindAny, handles); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - if (arr) - { - res = OCI_ListRemove(OCILib.arrs, arr); - OCI_ArrayClose(arr); - OCI_FREE(arr) - } + OCI_Array* arr = NULL; - return res; -} + CHECK_PTR(OCI_IPC_VOID, handles) -/* --------------------------------------------------------------------------------------------- * - * OCI_ArrayGetOCIHandlesFromHandles - * --------------------------------------------------------------------------------------------- */ + arr = ListFind(Env.arrs, (POCI_LIST_FIND)ArrayFindAny, handles); + CHECK_NULL(arr) -void * OCI_ArrayGetOCIHandlesFromHandles -( - void **handles -) -{ - void *ret = NULL; - OCI_Array *arr = OCI_ListFind(OCILib.arrs, (POCI_LIST_FIND)OCI_ArrayFindObjects, handles); + ListRemove(Env.arrs, arr); + ArrayDispose(arr); + FREE(arr) - if (arr) - { - ret = arr->mem_handle; - } + SET_SUCCESS() - return ret; + EXIT_FUNC() } diff --git a/src/array.h b/src/array.h new file mode 100644 index 00000000..2f192b1e --- /dev/null +++ b/src/array.h @@ -0,0 +1,54 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_ARRAY_H_INCLUDED +#define OCILIB_ARRAY_H_INCLUDED + +#include "types.h" + +boolean ArrayInitialize +( + OCI_Array *arr, + OCI_TypeInfo *typinf +); + +boolean ArrayDispose +( + OCI_Array* arr +); + +OCI_Array* ArrayCreate +( + OCI_Connection* con, + unsigned int nb_elem, + unsigned int elem_type, + unsigned int elem_subtype, + unsigned int elem_size, + unsigned int struct_size, + unsigned int handle_type, + OCI_TypeInfo * typinf +); + +boolean ArrayFreeFromHandles +( + void** handles +); + +#endif /* OCILIB_ARRAY_H_INCLUDED */ diff --git a/src/bind.c b/src/bind.c index 9d1f7cf3..045bfdd9 100644 --- a/src/bind.c +++ b/src/bind.c @@ -18,25 +18,360 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "bind.h" + +#include "array.h" +#include "callback.h" +#include "collection.h" +#include "date.h" +#include "file.h" +#include "hash.h" +#include "helpers.h" +#include "interval.h" +#include "lob.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "strings.h" +#include "timestamp.h" + +static const unsigned int CharsetFormValues[] = +{ + OCI_CSF_DEFAULT, + OCI_CSF_NATIONAL +}; + +static const unsigned int BindDirectionValues[] = +{ + OCI_BDM_IN, + OCI_BDM_OUT, + OCI_BDM_IN_OUT +}; + +/* --------------------------------------------------------------------------------------------- * + * BindAllocateInternalData + * --------------------------------------------------------------------------------------------- */ + +boolean BindAllocateInternalData +( + OCI_Bind* bnd +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ + CHECK_PTR(OCI_IPC_BIND, bnd) -static const unsigned int CharsetFormValues[] = { OCI_CSF_DEFAULT, OCI_CSF_NATIONAL }; -static const unsigned int BindDirectionValues[] = { OCI_BDM_IN, OCI_BDM_OUT, OCI_BDM_IN_OUT }; + if (bnd->is_array) + { + unsigned int struct_size = 0; + unsigned int elem_size = 0; + unsigned int handle_type = 0; -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ + OCI_Array* arr = NULL; + switch (bnd->type) + { + case OCI_CDT_NUMERIC: + { + if (SQLT_VNU == bnd->code) + { + struct_size = sizeof(big_int); + elem_size = sizeof(OCINumber); + } + else + { + struct_size = bnd->size; + } + break; + } + case OCI_CDT_DATETIME: + { + struct_size = sizeof(OCI_Date); + elem_size = sizeof(OCIDate); + break; + } + case OCI_CDT_TEXT: + { + struct_size = bnd->size; + if (Env.use_wide_char_conv) + { + elem_size = bnd->size * (sizeof(otext) / sizeof(dbtext)); + } + break; + } + case OCI_CDT_LOB: + { + struct_size = sizeof(OCI_Lob); + elem_size = sizeof(OCILobLocator*); + handle_type = OCI_DTYPE_LOB; + break; + } + case OCI_CDT_FILE: + { + struct_size = sizeof(OCI_File); + elem_size = sizeof(OCILobLocator*); + handle_type = OCI_DTYPE_LOB; + break; + } + case OCI_CDT_TIMESTAMP: + { + struct_size = sizeof(OCI_Timestamp); + elem_size = sizeof(OCIDateTime*); + handle_type = ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, bnd->subtype); + break; + } + case OCI_CDT_INTERVAL: + { + struct_size = sizeof(OCI_Interval); + elem_size = sizeof(OCIInterval*); + handle_type = ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, bnd->subtype); + break; + } + case OCI_CDT_RAW: + { + struct_size = bnd->size; + break; + } + case OCI_CDT_OBJECT: + { + struct_size = sizeof(OCI_Object); + elem_size = sizeof(void*); + break; + } + case OCI_CDT_COLLECTION: + { + struct_size = sizeof(OCI_Coll); + elem_size = sizeof(OCIColl*); + break; + } + case OCI_CDT_REF: + { + struct_size = sizeof(OCI_Ref); + elem_size = sizeof(OCIRef*); + break; + } + } + + arr = ArrayCreate(bnd->stmt->con, bnd->buffer.count, + bnd->type, bnd->subtype, elem_size, + struct_size, handle_type, bnd->typinf); + + CHECK_NULL(arr) + + switch (bnd->type) + { + case OCI_CDT_NUMERIC: + { + if (bnd->subtype == OCI_NUM_NUMBER) + { + bnd->buffer.data = (void**)arr->mem_handle; + bnd->input = (void**)arr->tab_obj; + + } + else if (SQLT_VNU == bnd->code) + { + bnd->buffer.data = (void**)arr->mem_handle; + bnd->input = (void**)arr->mem_struct; + bnd->alloc = TRUE; + } + else + { + bnd->buffer.data = (void**)arr->mem_struct; + bnd->input = (void**)bnd->buffer.data; + } + break; + } + case OCI_CDT_TEXT: + { + if (Env.use_wide_char_conv) + { + bnd->buffer.data = (void**)arr->mem_handle; + bnd->input = (void**)arr->mem_struct; + bnd->alloc = TRUE; + } + else + { + bnd->buffer.data = (void**)arr->mem_struct; + bnd->input = (void**)bnd->buffer.data; + } + + break; + } + case OCI_CDT_RAW: + { + bnd->buffer.data = (void**)arr->mem_struct; + bnd->input = (void**)bnd->buffer.data; + break; + } + case OCI_CDT_DATETIME: + case OCI_CDT_LOB: + case OCI_CDT_FILE: + case OCI_CDT_TIMESTAMP: + case OCI_CDT_INTERVAL: + case OCI_CDT_OBJECT: + case OCI_CDT_COLLECTION: + case OCI_CDT_REF: + { + bnd->buffer.data = (void**)arr->mem_handle; + bnd->input = (void**)arr->tab_obj; + break; + } + } + } + else + { + switch (bnd->type) + { + case OCI_CDT_NUMERIC: + { + if (bnd->subtype == OCI_NUM_NUMBER) + { + OCI_Number* number = NumberCreate(bnd->stmt->con); + + CHECK_NULL(number) + + bnd->input = (void**)number; + bnd->buffer.data = (void**)number->handle; + } + else if (SQLT_VNU == bnd->code) + { + bnd->input = (void**)MemoryAlloc(OCI_IPC_VOID, sizeof(big_int), 1, TRUE); + bnd->buffer.data = (void**)MemoryAlloc(OCI_IPC_VOID, sizeof(OCINumber), 1, TRUE); + } + else + { + bnd->input = (void**)MemoryAlloc(OCI_IPC_VOID, bnd->size, 1, TRUE); + bnd->buffer.data = (void**)bnd->input; + } + break; + } + case OCI_CDT_DATETIME: + { + OCI_Date* date = DateCreate(bnd->stmt->con); + CHECK_NULL(date) -void OCI_BindAllocateBuffers + bnd->input = (void**)date; + bnd->buffer.data = (void**)date->handle; + + break; + } + case OCI_CDT_TEXT: + { + if (Env.use_wide_char_conv) + { + bnd->buffer.data = (void**)MemoryAlloc(OCI_IPC_STRING, bnd->size * (sizeof(otext) / sizeof(dbtext)), 1, TRUE); + bnd->input = (void**)MemoryAlloc(OCI_IPC_STRING, bnd->size, 1, TRUE); + } + else + { + bnd->buffer.data = (void**)MemoryAlloc(OCI_IPC_STRING, bnd->size, 1, TRUE); + bnd->input = (void**)bnd->buffer.data; + } + break; + } + case OCI_CDT_LOB: + { + OCI_Lob* lob = LobCreate(bnd->stmt->con, bnd->subtype); + + CHECK_NULL(lob) + + bnd->input = (void**)lob; + bnd->buffer.data = (void**)lob->handle; + + break; + } + case OCI_CDT_FILE: + { + OCI_File* file = FileCreate(bnd->stmt->con, bnd->subtype); + + CHECK_NULL(file) + + bnd->input = (void**)file; + bnd->buffer.data = (void**)file->handle; + + break; + } + case OCI_CDT_TIMESTAMP: + { + OCI_Timestamp* tmsp = TimestampCreate(bnd->stmt->con, bnd->subtype); + + CHECK_NULL(tmsp) + + bnd->input = (void**)tmsp; + bnd->buffer.data = (void**)tmsp->handle; + + break; + } + case OCI_CDT_INTERVAL: + { + OCI_Interval* itv = IntervalCreate(bnd->stmt->con, bnd->subtype); + + CHECK_NULL(itv) + + bnd->input = (void**)itv; + bnd->buffer.data = (void**)itv->handle; + + break; + } + case OCI_CDT_RAW: + { + bnd->input = (void**)MemoryAlloc(OCI_IPC_VOID, bnd->size, 1, TRUE); + bnd->buffer.data = (void**)bnd->input; + break; + } + case OCI_CDT_OBJECT: + { + OCI_Object* obj = ObjectCreate(bnd->stmt->con, bnd->typinf); + + CHECK_NULL(obj) + + bnd->input = (void**)obj; + bnd->buffer.data = (void**)obj->handle; + + break; + } + case OCI_CDT_COLLECTION: + { + OCI_Coll* coll = CollectionCreate(bnd->typinf); + + CHECK_NULL(coll) + + bnd->input = (void**)coll; + bnd->buffer.data = (void**)coll->handle; + + break; + } + case OCI_CDT_REF: + { + OCI_Ref* ref = ReferenceCreate(bnd->stmt->con, bnd->typinf); + + CHECK_NULL(ref) + + bnd->input = (void**)ref; + bnd->buffer.data = (void**)ref->handle; + + break; + } + } + } + + CHECK_NULL(bnd->input) + + SET_SUCCESS() + + EXIT_FUNC() +} + +boolean BindAllocateBuffers ( - OCI_Context *ctx, OCI_Bind *bnd, unsigned int mode, boolean reused, @@ -45,40 +380,42 @@ void OCI_BindAllocateBuffers boolean plsql_table ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + /* allocate indicators array */ - if (OCI_STATUS) - { - OCI_ALLOCATE_DATA(OCI_IPC_BIND, bnd->buffer.inds, nballoc) + ALLOC_DATA(OCI_IPC_BIND, bnd->buffer.inds, nballoc) - if (OCI_STATUS && SQLT_NTY == bnd->code) - { - OCI_ALLOCATE_DATA(OCI_IPC_INDICATOR_ARRAY, bnd->buffer.obj_inds, nballoc) - } + if (SQLT_NTY == bnd->code) + { + ALLOC_DATA(OCI_IPC_INDICATOR_ARRAY, bnd->buffer.obj_inds, nballoc) } /* check need for PL/SQL table extra info */ - if (OCI_STATUS && plsql_table) + if (plsql_table) { bnd->nbelem = nbelem; /* allocate array of returned codes */ - OCI_ALLOCATE_DATA(OCI_IPC_PLS_RCODE_ARRAY, bnd->plrcds, nballoc) + ALLOC_DATA(OCI_IPC_PLS_RCODE_ARRAY, bnd->plrcds, nballoc) } /* set allocation mode prior any required data allocation */ - if (OCI_STATUS) - { - bnd->alloc_mode = (ub1)bnd->stmt->bind_alloc_mode; - } + bnd->alloc_mode = (ub1)bnd->stmt->bind_alloc_mode; /* for handle based data types, we need to allocate an array of handles for bind calls because OCILIB uses external arrays of OCILIB Objects */ - if (OCI_STATUS && (OCI_BIND_INPUT == mode)) + if (OCI_BIND_INPUT == mode) { if (OCI_BAM_EXTERNAL == bnd->alloc_mode) { @@ -88,16 +425,16 @@ void OCI_BindAllocateBuffers (OCI_CDT_LONG != bnd->type) && (OCI_CDT_BOOLEAN != bnd->type) && (OCI_CDT_NUMERIC != bnd->type || SQLT_VNU == bnd->code) && - (OCI_CDT_TEXT != bnd->type || OCILib.use_wide_char_conv)) + (OCI_CDT_TEXT != bnd->type || Env.use_wide_char_conv)) { bnd->alloc = TRUE; if (reused) { - OCI_FREE(bnd->buffer.data) + FREE(bnd->buffer.data) } - OCI_ALLOCATE_BUFFER(OCI_IPC_BUFF_ARRAY, bnd->buffer.data, bnd->size, nballoc) + ALLOC_BUFFER(OCI_IPC_BUFF_ARRAY, bnd->buffer.data, bnd->size, nballoc) } else { @@ -108,18 +445,15 @@ void OCI_BindAllocateBuffers /* setup data length array */ - if (OCI_STATUS && ((OCI_CDT_RAW == bnd->type) || (OCI_CDT_TEXT == bnd->type))) + if (OCI_CDT_RAW == bnd->type || OCI_CDT_TEXT == bnd->type) { - OCI_ALLOCATE_BUFFER(OCI_IPC_BUFF_ARRAY, bnd->buffer.lens, sizeof(ub2), nballoc) + ALLOC_BUFFER(OCI_IPC_BUFF_ARRAY, bnd->buffer.lens, sizeof(ub2), nballoc) /* initialize length array with buffer default size */ - if (OCI_STATUS) + for (unsigned int i = 0; i < nbelem; i++) { - for (unsigned int i = 0; i < nbelem; i++) - { - *(ub2*)(((ub1 *)bnd->buffer.lens) + sizeof(ub2) * (size_t) i) = (ub2)bnd->size; - } + *(ub2*)(((ub1 *)bnd->buffer.lens) + sizeof(ub2) * (size_t) i) = (ub2)bnd->size; } } @@ -127,36 +461,45 @@ void OCI_BindAllocateBuffers if (!bnd->input && (OCI_BAM_INTERNAL == bnd->alloc_mode)) { - OCI_STATUS = OCI_BindAllocData(bnd); + CHECK(BindAllocateInternalData(bnd)) } + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_BindCheckAvailability +* BindCheckAvailability * --------------------------------------------------------------------------------------------- */ -void OCI_BindCheckAvailability +boolean BindCheckAvailability ( - OCI_Context *ctx, OCI_Statement *stmt, unsigned int mode, boolean reused ) { - if (OCI_STATUS && !reused) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + if (!reused) { if (OCI_BIND_INPUT == mode) { if (stmt->nb_ubinds >= OCI_BIND_MAX) { - OCI_ExceptionMaxBind(stmt); - OCI_STATUS = FALSE; + THROW_NO_ARGS(ExceptionMaxBind) } /* allocate user bind array if necessary */ - OCI_REALLOCATE_DATA + REALLOC_DATA ( OCI_IPC_BIND_ARRAY, stmt->ubinds, @@ -169,13 +512,12 @@ void OCI_BindCheckAvailability { if (stmt->nb_rbinds >= OCI_BIND_MAX) { - OCI_ExceptionMaxBind(stmt); - OCI_STATUS = FALSE; + THROW_NO_ARGS(ExceptionMaxBind) } /* allocate register bind array if necessary */ - OCI_REALLOCATE_DATA + REALLOC_DATA ( OCI_IPC_BIND_ARRAY, stmt->rbinds, @@ -185,89 +527,95 @@ void OCI_BindCheckAvailability ) } } + + SET_SUCCESS() + + EXIT_FUNC() } - /* --------------------------------------------------------------------------------------------- * - * OCI_BindPerformBinding +/* --------------------------------------------------------------------------------------------- * + * BindPerformBinding * --------------------------------------------------------------------------------------------- */ -void OCI_BindPerformBinding +boolean BindPerformBinding ( - OCI_Context *ctx, - OCI_Bind *bnd, - unsigned int mode, - unsigned int index, - unsigned int exec_mode, - boolean plsql_table + OCI_Bind *bnd, + unsigned int mode, + unsigned int index, + unsigned int exec_mode, + boolean plsql_table ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + dbtext* dbstr = NULL; + int dbsize = -1; + + CHECK_PTR(OCI_IPC_BIND, bnd) + if (OCI_BIND_BY_POS == bnd->stmt->bind_mode) { - OCI_EXEC + CHECK_OCI ( - OCIBindByPos - ( - bnd->stmt->stmt, - (OCIBind **)&bnd->buffer.handle, - bnd->stmt->con->err, - (ub4)index, - (void *)bnd->buffer.data, - bnd->size, - bnd->code, - (void *)bnd->buffer.inds, - (ub2 *)bnd->buffer.lens, - bnd->plrcds, - (ub4)(plsql_table ? bnd->nbelem : 0), - (ub4*)(plsql_table ? &bnd->nbelem : NULL), - (ub4) exec_mode - ) + bnd->stmt->con->err, + OCIBindByPos, + bnd->stmt->stmt, + (OCIBind **)&bnd->buffer.handle, + bnd->stmt->con->err, + (ub4)index, + (void *)bnd->buffer.data, + bnd->size, + bnd->code, + (void *)bnd->buffer.inds, + (ub2 *)bnd->buffer.lens, + bnd->plrcds, + (ub4)(plsql_table ? bnd->nbelem : 0), + (ub4*)(plsql_table ? &bnd->nbelem : NULL), + (ub4) exec_mode ) } else { - dbtext * dbstr = NULL; - int dbsize = -1; - - dbstr = OCI_StringGetOracleString(bnd->name, &dbsize); + dbstr = StringGetDBString(bnd->name, &dbsize); - OCI_EXEC + CHECK_OCI ( - OCIBindByName - ( - bnd->stmt->stmt, - (OCIBind **)&bnd->buffer.handle, - bnd->stmt->con->err, - (OraText *)dbstr, - (sb4)dbsize, - (void *)bnd->buffer.data, - bnd->size, - bnd->code, - (void *)bnd->buffer.inds, - (ub2 *)bnd->buffer.lens, - bnd->plrcds, - (ub4)(plsql_table ? bnd->nbelem : 0), - (ub4*)(plsql_table ? &bnd->nbelem : NULL), - (ub4) exec_mode - ) + bnd->stmt->con->err, + OCIBindByName, + bnd->stmt->stmt, + (OCIBind **)&bnd->buffer.handle, + bnd->stmt->con->err, + (OraText *)dbstr, + (sb4)dbsize, + (void *)bnd->buffer.data, + bnd->size, + bnd->code, + (void *)bnd->buffer.inds, + (ub2 *)bnd->buffer.lens, + bnd->plrcds, + (ub4)(plsql_table ? bnd->nbelem : 0), + (ub4*)(plsql_table ? &bnd->nbelem : NULL), + (ub4) exec_mode ) - - OCI_StringReleaseOracleString(dbstr); } if (SQLT_NTY == bnd->code || SQLT_REF == bnd->code) { - OCI_EXEC + CHECK_OCI ( - OCIBindObject - ( - (OCIBind *)bnd->buffer.handle, - bnd->stmt->con->err, - (OCIType *)bnd->typinf->tdo, - (void **)bnd->buffer.data, - (ub4 *)NULL, - (void **)bnd->buffer.obj_inds, - (ub4 *)NULL - ) + bnd->stmt->con->err, + OCIBindObject, + (OCIBind *)bnd->buffer.handle, + bnd->stmt->con->err, + (OCIType *)bnd->typinf->tdo, + (void **)bnd->buffer.data, + (ub4 *)NULL, + (void **)bnd->buffer.obj_inds, + (ub4 *)NULL ) } @@ -275,32 +623,47 @@ void OCI_BindPerformBinding { /* register output placeholder */ - OCI_EXEC + CHECK_OCI ( - OCIBindDynamic - ( - (OCIBind *)bnd->buffer.handle, - bnd->stmt->con->err, - (dvoid *)bnd, - OCI_ProcInBind, - (dvoid *)bnd, - OCI_ProcOutBind - ) + bnd->stmt->con->err, + OCIBindDynamic, + (OCIBind *)bnd->buffer.handle, + bnd->stmt->con->err, + (dvoid *)bnd, + CallbackInBind, + (dvoid *)bnd, + CallbackOutBind ) } + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) + } - /* --------------------------------------------------------------------------------------------- * - * OCI_BindAddToStatement +/* --------------------------------------------------------------------------------------------- * + * BindAddToStatement * --------------------------------------------------------------------------------------------- */ -void OCI_BindAddToStatement +boolean BindAddToStatement ( - OCI_Bind *bnd, - unsigned int mode, - boolean reused + OCI_Bind *bnd, + unsigned int mode, + boolean reused ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + if (OCI_BIND_INPUT == mode) { if (!reused) @@ -309,7 +672,7 @@ void OCI_BindAddToStatement /* for user binds, add a positive index */ - OCI_HashAddInt(bnd->stmt->map, bnd->name, bnd->stmt->nb_ubinds); + CHECK(HashAddInt(bnd->stmt->map, bnd->name, bnd->stmt->nb_ubinds)) } } else @@ -320,17 +683,20 @@ void OCI_BindAddToStatement const int index = (int)bnd->stmt->nb_rbinds; - OCI_HashAddInt(bnd->stmt->map, bnd->name, -index); + CHECK(HashAddInt(bnd->stmt->map, bnd->name, -index)) } + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindCreate + * BindCreate * --------------------------------------------------------------------------------------------- */ -OCI_Bind* OCI_BindCreate +OCI_Bind* BindCreate ( - OCI_Context *ctx, OCI_Statement *stmt, void *data, const otext *name, @@ -343,14 +709,23 @@ OCI_Bind* OCI_BindCreate unsigned int nbelem ) { - OCI_Bind *bnd = NULL; - ub4 exec_mode = OCI_DEFAULT; - boolean plsql_table = FALSE; - boolean is_array = FALSE; - boolean reused = FALSE; - int index = 0; - int prev_index = -1; - unsigned int nballoc = nbelem; + ENTER_FUNC + ( + /* returns */ OCI_Bind*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + OCI_Bind *bnd = NULL; + + ub4 exec_mode = OCI_DEFAULT; + boolean plsql_table = FALSE; + boolean is_array = FALSE; + boolean reused = FALSE; + int index = 0; + int prev_index = -1; + unsigned int nballoc = nbelem; + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) /* check index if necessary */ @@ -360,159 +735,143 @@ OCI_Bind* OCI_BindCreate if (index <= 0 || index > OCI_BIND_MAX) { - OCI_ExceptionOutOfBounds(stmt->con, index); - OCI_STATUS = FALSE; + THROW(ExceptionOutOfBounds, index) } } /* check if the bind name has already been used */ - if (OCI_STATUS) + if (OCI_BIND_INPUT == mode) { - if (OCI_BIND_INPUT == mode) - { - prev_index = OCI_BindGetInternalIndex(stmt, name); + prev_index = BindGetIndex(stmt, name); - if (prev_index > 0) + if (prev_index > 0) + { + if (!stmt->bind_reuse) { - if (!stmt->bind_reuse) + THROW(ExceptionBindAlreadyUsed, name) + } + else + { + bnd = stmt->ubinds[prev_index-1]; + + if (bnd->type != type) { - OCI_ExceptionBindAlreadyUsed(stmt, name); - OCI_STATUS = FALSE; + THROW(ExceptionRebindBadDatatype, name) } else { - bnd = stmt->ubinds[prev_index-1]; - - if (bnd->type != type) - { - OCI_ExceptionRebindBadDatatype(stmt, name); - OCI_STATUS = FALSE; - } - else - { - reused = TRUE; - } + reused = TRUE; } - - index = prev_index; } + + index = prev_index; } } /* check if we can handle another bind */ - OCI_BindCheckAvailability(ctx, stmt, mode, reused); + CHECK(BindCheckAvailability(stmt, mode, reused)) - /* checks done */ + /* check out the number of elements that the bind variable will hold */ - if (OCI_STATUS) + if (nbelem > 0) { - /* check out the number of elements that the bind variable will hold */ - - if (nbelem > 0) - { - /* is it a pl/sql table bind ? */ + /* is it a pl/sql table bind ? */ - if (OCI_IS_PLSQL_STMT(stmt->type)) - { - plsql_table = TRUE; - is_array = TRUE; - } - } - else + if (IS_PLSQL_STMT(stmt->type)) { - nbelem = stmt->nb_iters; - is_array = stmt->bind_array; + plsql_table = TRUE; + is_array = TRUE; } + } + else + { + nbelem = stmt->nb_iters; + is_array = stmt->bind_array; + } - /* compute iterations */ - if (nballoc < stmt->nb_iters_init) - { - nballoc = (size_t) stmt->nb_iters_init; - } + /* compute iterations */ - /* create hash table for mapping bind names / index */ + if (nballoc < stmt->nb_iters_init) + { + nballoc = (size_t) stmt->nb_iters_init; + } - if (!stmt->map) - { - stmt->map = OCI_HashCreate(OCI_HASH_DEFAULT_SIZE, OCI_HASH_INTEGER); - OCI_STATUS = (NULL != stmt->map); - } + /* create hash table for mapping bind names / index */ + + if (NULL == stmt->map) + { + stmt->map = HashCreate(OCI_HASH_DEFAULT_SIZE, OCI_HASH_INTEGER); + CHECK_NULL(stmt->map) } /* allocate bind object */ - OCI_ALLOCATE_DATA(OCI_IPC_BIND, bnd, 1) + ALLOC_DATA(OCI_IPC_BIND, bnd, 1) /* initialize bind object */ - if (OCI_STATUS) + bnd->stmt = stmt; + bnd->input = (void **) data; + bnd->type = type; + bnd->size = size; + bnd->code = (ub2) code; + bnd->subtype = (ub1) subtype; + bnd->is_array = is_array; + bnd->typinf = typinf; + bnd->csfrm = OCI_CSF_NONE; + bnd->direction = OCI_BDM_IN_OUT; + + if (NULL == bnd->name) { - /* initialize bind attributes */ - - bnd->stmt = stmt; - bnd->input = (void **) data; - bnd->type = type; - bnd->size = size; - bnd->code = (ub2) code; - bnd->subtype = (ub1) subtype; - bnd->is_array = is_array; - bnd->typinf = typinf; - bnd->csfrm = OCI_CSF_NONE; - bnd->direction = OCI_BDM_IN_OUT; - - if (!bnd->name) - { - bnd->name = ostrdup(name); - } + bnd->name = ostrdup(name); + } - /* initialize buffer */ + /* initialize buffer */ - bnd->buffer.count = nbelem; - bnd->buffer.sizelen = sizeof(ub2); + bnd->buffer.count = nbelem; + bnd->buffer.sizelen = sizeof(ub2); - OCI_BindAllocateBuffers(ctx, bnd, mode, reused, nballoc, nbelem, plsql_table); - - /* if we bind an OCI_Long or any output bind, we need to change the - execution mode to provide data at execute time */ + CHECK(BindAllocateBuffers(bnd, mode, reused, nballoc, nbelem, plsql_table)) - if (OCI_CDT_LONG == bnd->type) - { - OCI_Long *lg = (OCI_Long *) bnd->input; + /* if we bind an OCI_Long or any output bind, we need to change the + execution mode to provide data at execute time */ - lg->maxsize = size; - exec_mode = OCI_DATA_AT_EXEC; + if (OCI_CDT_LONG == bnd->type) + { + OCI_Long *lg = (OCI_Long *) bnd->input; - if (OCI_CLONG == bnd->subtype) - { - lg->maxsize /= (unsigned int) sizeof(otext); - lg->maxsize *= (unsigned int) sizeof(dbtext); - } - } - else if (OCI_BIND_OUTPUT == mode) + lg->maxsize = size; + exec_mode = OCI_DATA_AT_EXEC; + + if (OCI_CLONG == bnd->subtype) { - exec_mode = OCI_DATA_AT_EXEC; + lg->maxsize /= (unsigned int) sizeof(otext); + lg->maxsize *= (unsigned int) sizeof(dbtext); } } + else if (OCI_BIND_OUTPUT == mode) + { + exec_mode = OCI_DATA_AT_EXEC; + } /* OCI binding */ - if (OCI_STATUS) - { - OCI_BindPerformBinding(ctx, bnd, mode, index, exec_mode, plsql_table); - } + CHECK(BindPerformBinding(bnd, mode, index, exec_mode, plsql_table)) /* set charset form */ - if (OCI_STATUS) + if ((OCI_CDT_LOB == bnd->type) && (OCI_NCLOB == bnd->subtype)) { - if ((OCI_CDT_LOB == bnd->type) && (OCI_NCLOB == bnd->subtype)) - { - ub1 csfrm = SQLCS_NCHAR; + ub1 csfrm = SQLCS_NCHAR; - OCI_SET_ATTRIB(OCI_HTYPE_BIND, OCI_ATTR_CHARSET_FORM, bnd->buffer.handle, &csfrm, sizeof(csfrm)) - } + CHECK_ATTRIB_SET + ( + OCI_HTYPE_BIND, OCI_ATTR_CHARSET_FORM, + bnd->buffer.handle, &csfrm, sizeof(csfrm), + bnd->stmt->con->err + ) } /* on success, we : @@ -520,41 +879,44 @@ OCI_Bind* OCI_BindCreate - add the bind index to the map */ - if (OCI_STATUS) - { - OCI_BindAddToStatement(bnd, mode, reused); - } + CHECK(BindAddToStatement(bnd, mode, reused)) - if (!OCI_STATUS) - { - if (bnd && (prev_index == -1)) + CLEANUP_AND_EXIT_FUNC + ( + /* on error, only free the bind if it was a new one */ + + if (FAILURE && NULL != bnd && prev_index == -1) { - OCI_BindFree(bnd); + BindFree(bnd); bnd = NULL; } - } - return bnd; + SET_RETVAL(bnd) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindFree + * BindFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindFree +boolean BindFree ( OCI_Bind *bnd ) { - boolean res = TRUE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) - OCI_CHECK(NULL == bnd, FALSE) + CHECK_PTR(OCI_IPC_BIND, bnd) if (OCI_BAM_INTERNAL == bnd->alloc_mode) { if (bnd->is_array) { - res = OCI_ArrayFreeFromHandles(bnd->input); + ArrayFreeFromHandles(bnd->input); } else { @@ -567,24 +929,24 @@ boolean OCI_BindFree if (bnd->type == OCI_CDT_NUMERIC && bnd->subtype == OCI_NUM_NUMBER) { - OCI_FreeObjectFromType(bnd->input, bnd->type); + FreeObjectFromType(bnd->input, bnd->type); } else { /* strings requiring otext / dbtext conversions and 64 bit integers */ - OCI_MemFree(bnd->input); + MemoryFree(bnd->input); if (bnd->alloc) { - OCI_FREE(bnd->buffer.data) + FREE(bnd->buffer.data) } } break; } default: { - OCI_FreeObjectFromType(bnd->input, bnd->type); + FreeObjectFromType(bnd->input, bnd->type); } } } @@ -593,394 +955,157 @@ boolean OCI_BindFree { if (bnd->alloc) { - OCI_FREE(bnd->buffer.data) + FREE(bnd->buffer.data) } } - OCI_FREE(bnd->buffer.inds) - OCI_FREE(bnd->buffer.obj_inds) - OCI_FREE(bnd->buffer.lens) - OCI_FREE(bnd->buffer.tmpbuf) - OCI_FREE(bnd->plrcds) - OCI_FREE(bnd->name) - OCI_FREE(bnd) + FREE(bnd->buffer.inds) + FREE(bnd->buffer.obj_inds) + FREE(bnd->buffer.lens) + FREE(bnd->buffer.tmpbuf) + FREE(bnd->plrcds) + FREE(bnd->name) + FREE(bnd) - return res; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindAllocData + * BindGetIndex * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindAllocData +int BindGetIndex ( - OCI_Bind *bnd + OCI_Statement* stmt, + const otext * name ) { - OCI_CHECK(NULL == bnd, FALSE) - - if (bnd->is_array) - { - unsigned int struct_size = 0; - unsigned int elem_size = 0; - unsigned int handle_type = 0; - - OCI_Array *arr = NULL; - - switch (bnd->type) - { - case OCI_CDT_NUMERIC: - { - if (SQLT_VNU == bnd->code) - { - struct_size = sizeof(big_int); - elem_size = sizeof(OCINumber); - } - else - { - struct_size = bnd->size; - } - break; - } - case OCI_CDT_DATETIME: - { - struct_size = sizeof(OCI_Date); - elem_size = sizeof(OCIDate); - break; - } - case OCI_CDT_TEXT: - { - struct_size = bnd->size; + ENTER_FUNC + ( + /* returns */ int, -1, + /* context */ OCI_IPC_STATEMENT, stmt + ) - if (OCILib.use_wide_char_conv) - { - elem_size = bnd->size * (sizeof(otext) / sizeof(dbtext)); - } - break; - } - case OCI_CDT_LOB: - { - struct_size = sizeof(OCI_Lob); - elem_size = sizeof(OCILobLocator *); - handle_type = OCI_DTYPE_LOB; - break; - } - case OCI_CDT_FILE: - { - struct_size = sizeof(OCI_File); - elem_size = sizeof(OCILobLocator *); - handle_type = OCI_DTYPE_LOB; - break; - } - case OCI_CDT_TIMESTAMP: - { - struct_size = sizeof(OCI_Timestamp); - elem_size = sizeof(OCIDateTime *); - handle_type = OCI_ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, bnd->subtype); - break; - } - case OCI_CDT_INTERVAL: - { - struct_size = sizeof(OCI_Interval); - elem_size = sizeof(OCIInterval *); - handle_type = OCI_ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, bnd->subtype); - break; - } - case OCI_CDT_RAW: - { - struct_size = bnd->size; - break; - } - case OCI_CDT_OBJECT: - { - struct_size = sizeof(OCI_Object); - elem_size = sizeof(void *); - break; - } - case OCI_CDT_COLLECTION: - { - struct_size = sizeof(OCI_Coll); - elem_size = sizeof(OCIColl *); - break; - } - case OCI_CDT_REF: - { - struct_size = sizeof(OCI_Ref); - elem_size = sizeof(OCIRef *); - break; - } - } + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, name) - arr = OCI_ArrayCreate(bnd->stmt->con, bnd->buffer.count, bnd->type, bnd->subtype, - elem_size, struct_size, handle_type, bnd->typinf); + CHECK_NULL(stmt->map) - if (arr) - { - switch (bnd->type) - { - case OCI_CDT_NUMERIC: - { - if (bnd->subtype == OCI_NUM_NUMBER) - { - bnd->buffer.data = (void **)arr->mem_handle; - bnd->input = (void **)arr->tab_obj; + OCI_HashEntry* he = HashLookup(stmt->map, name, FALSE); - } - else if (SQLT_VNU == bnd->code) - { - bnd->buffer.data = (void **) arr->mem_handle; - bnd->input = (void **) arr->mem_struct; - bnd->alloc = TRUE; - } - else - { - bnd->buffer.data = (void **) arr->mem_struct; - bnd->input = (void **) bnd->buffer.data; - } - break; - } - case OCI_CDT_TEXT: - { - if (OCILib.use_wide_char_conv) - { - bnd->buffer.data = (void **) arr->mem_handle; - bnd->input = (void **) arr->mem_struct; - bnd->alloc = TRUE; - } - else - { - bnd->buffer.data = (void **) arr->mem_struct; - bnd->input = (void **) bnd->buffer.data; - } + int index = -1; - break; - } - case OCI_CDT_RAW: - { - bnd->buffer.data = (void **) arr->mem_struct; - bnd->input = (void **) bnd->buffer.data; - break; - } - case OCI_CDT_DATETIME: - case OCI_CDT_LOB: - case OCI_CDT_FILE: - case OCI_CDT_TIMESTAMP: - case OCI_CDT_INTERVAL: - case OCI_CDT_OBJECT: - case OCI_CDT_COLLECTION: - case OCI_CDT_REF: - { - bnd->buffer.data = (void **) arr->mem_handle; - bnd->input = (void **) arr->tab_obj; - break; - } - } - } - } - else + while (NULL != he) { - switch (bnd->type) - { - case OCI_CDT_NUMERIC: - { - if (bnd->subtype == OCI_NUM_NUMBER) - { - OCI_Number *number = OCI_NumberCreate(bnd->stmt->con); - - if (number) - { - bnd->input = (void **)number; - bnd->buffer.data = (void **)number->handle; - } - - } - else if (SQLT_VNU == bnd->code) - { - bnd->input = (void **) OCI_MemAlloc(OCI_IPC_VOID, sizeof(big_int), 1, TRUE); - bnd->buffer.data = (void **) OCI_MemAlloc(OCI_IPC_VOID, sizeof(OCINumber), 1, TRUE); - } - else - { - bnd->input = (void **) OCI_MemAlloc(OCI_IPC_VOID, bnd->size, 1, TRUE); - bnd->buffer.data = (void **) bnd->input; - } - break; - } - case OCI_CDT_DATETIME: - { - OCI_Date *date = OCI_DateCreate(bnd->stmt->con); - - if (date) - { - bnd->input = (void **) date; - bnd->buffer.data = (void **) date->handle; - } - break; - } - case OCI_CDT_TEXT: - { - if (OCILib.use_wide_char_conv) - { - bnd->buffer.data = (void **) OCI_MemAlloc(OCI_IPC_STRING, bnd->size * (sizeof(otext) / sizeof(dbtext)), 1, TRUE); - bnd->input = (void **) OCI_MemAlloc(OCI_IPC_STRING, bnd->size, 1, TRUE); - } - else - { - bnd->buffer.data = (void **) OCI_MemAlloc(OCI_IPC_STRING, bnd->size, 1, TRUE); - bnd->input = (void **) bnd->buffer.data; - } - break; - } - case OCI_CDT_LOB: - { - OCI_Lob *lob = OCI_LobCreate(bnd->stmt->con, bnd->subtype); - - if (lob) - { - bnd->input = (void **) lob; - bnd->buffer.data = (void **) lob->handle; - } - break; - } - case OCI_CDT_FILE: - { - OCI_File *file = OCI_FileCreate(bnd->stmt->con, bnd->subtype); - - if (file) - { - bnd->input = (void **) file; - bnd->buffer.data = (void **) file->handle; - } - break; - } - case OCI_CDT_TIMESTAMP: - { - OCI_Timestamp *tmsp = OCI_TimestampCreate(bnd->stmt->con, bnd->subtype); + /* no more entries or key matched => so we got it ! */ - if (tmsp) - { - bnd->input = (void **) tmsp; - bnd->buffer.data = (void **) tmsp->handle; - } - break; - } - case OCI_CDT_INTERVAL: - { - OCI_Interval *itv = OCI_IntervalCreate(bnd->stmt->con, bnd->subtype); + if (NULL == he->next || ostrcasecmp(he->key, name) == 0) + { + /* in order to use the same map for user binds and + register binds : + - user binds are stored as positive values + - registers binds are stored as negatives values + */ - if (itv) - { - bnd->input = (void **) itv; - bnd->buffer.data = (void **) itv->handle; - } - break; - } - case OCI_CDT_RAW: - { - bnd->input = (void **) OCI_MemAlloc(OCI_IPC_VOID, bnd->size, 1, TRUE); - bnd->buffer.data = (void **) bnd->input; - break; - } - case OCI_CDT_OBJECT: - { - OCI_Object *obj = OCI_ObjectCreate(bnd->stmt->con, bnd->typinf); + index = he->values->value.num; - if (obj) - { - bnd->input = (void **) obj; - bnd->buffer.data = (void **) obj->handle; - } - break; - } - case OCI_CDT_COLLECTION: + if (index < 0) { - OCI_Coll *coll = OCI_CollCreate(bnd->typinf); - - if (coll) - { - bnd->input = (void **) coll; - bnd->buffer.data = (void **) coll->handle; - } - break; + index = -index; } - case OCI_CDT_REF: - { - OCI_Ref *ref = OCI_RefCreate(bnd->stmt->con, bnd->typinf); - if (ref) - { - bnd->input = (void **) ref; - bnd->buffer.data = (void **) ref->handle; - } - break; - } + break; } } - return (NULL != bnd->input); + SET_RETVAL(index) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetNullIndicator + * BindSetNullIndicator * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindSetNullIndicator +boolean BindSetNullIndicator ( OCI_Bind *bnd, unsigned int position, sb2 value ) { - OCI_CHECK(NULL == bnd, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) if (bnd->buffer.inds) { bnd->buffer.inds[position - 1] = value; } - return TRUE; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetName + * BindGetName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_BindGetName +const otext * BindGetName ( OCI_Bind *bnd ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_BIND, bnd, name, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ const otext*, NULL, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ name + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetType + * BindGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetType +unsigned int BindGetType ( OCI_Bind *bnd ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_BIND, bnd, type, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetSubtype + * BindGetSubtype * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetSubtype +unsigned int BindGetSubtype ( OCI_Bind *bnd ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + + unsigned int type = OCI_UNKNOWN; if (OCI_CDT_NUMERIC == bnd->type || OCI_CDT_LONG == bnd->type || @@ -989,256 +1114,300 @@ unsigned int OCI_API OCI_BindGetSubtype OCI_CDT_TIMESTAMP == bnd->type || OCI_CDT_INTERVAL == bnd->type) { - OCI_RETVAL = (unsigned int)bnd->subtype; + type = (unsigned int)bnd->subtype; } - OCI_CALL_EXIT() + SET_RETVAL(type) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetDataCount + * BindGetDataCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetDataCount +unsigned int BindGetDataCount ( OCI_Bind *bnd ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_BIND, bnd, buffer.count, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ unsigned int, 0, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ buffer.count + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetData + * BindGetData * --------------------------------------------------------------------------------------------- */ -void * OCI_API OCI_BindGetData +void * BindGetData ( OCI_Bind *bnd ) { - OCI_GET_PROP(void *, NULL, OCI_IPC_BIND, bnd, input, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ void *, NULL, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ input + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetStatement + * BindGetStatement * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_API OCI_BindGetStatement +OCI_Statement * BindGetStatement ( OCI_Bind *bnd ) { - OCI_GET_PROP(OCI_Statement *, NULL, OCI_IPC_BIND, bnd, stmt, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ OCI_Statement *, NULL, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ stmt + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetDataSize + * BindSetDataSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetDataSize +boolean BindSetDataSize ( OCI_Bind *bnd, unsigned int size ) { - return OCI_BindSetDataSizeAtPos(bnd, 1, size); + return BindSetDataSizeAtPos(bnd, 1, size); } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetDataSizeAtPos + * BindSetDataSizeAtPos * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetDataSizeAtPos +boolean BindSetDataSizeAtPos ( OCI_Bind *bnd, unsigned int position, unsigned int size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buffer.count) - OCI_CALL_CHECK_MIN(bnd->stmt->con, bnd->stmt, size, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_BOUND(position, 1, bnd->buffer.count) + CHECK_MIN(size, 1) + + CHECK_NULL(bnd->buffer.lens) - if (bnd->buffer.lens) + if (OCI_CDT_TEXT == bnd->type) { - if (OCI_CDT_TEXT == bnd->type) + if (bnd->size == (sb4) size) { - if (bnd->size == (sb4) size) - { - size += (unsigned int) (size_t) sizeof(dbtext); - } - - size *= (unsigned int) sizeof(dbtext); + size += (unsigned int) (size_t) sizeof(dbtext); } - ((ub2 *) bnd->buffer.lens)[position-1] = (ub2) size; - - OCI_RETVAL = TRUE; + size *= (unsigned int) sizeof(dbtext); } - OCI_CALL_EXIT() + ((ub2 *) bnd->buffer.lens)[position-1] = (ub2) size; + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetDataSize + * BindGetDataSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetDataSize +unsigned int BindGetDataSize ( OCI_Bind *bnd ) { - return OCI_BindGetDataSizeAtPos(bnd, 1); + return BindGetDataSizeAtPos(bnd, 1); } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetDataSizeAtPos + * BindGetDataSizeAtPos * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetDataSizeAtPos +unsigned int BindGetDataSizeAtPos ( OCI_Bind *bnd, unsigned int position ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buffer.count) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_BIND, bnd + ) - if (bnd->buffer.lens) - { - OCI_RETVAL = (unsigned int)((ub2 *)bnd->buffer.lens)[position - 1]; + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_BOUND(position, 1, bnd->buffer.count) - if (OCI_CDT_TEXT == bnd->type) - { - if (bnd->size == (sb4)call_retval) - { - OCI_RETVAL -= (unsigned int) sizeof(dbtext); - } + CHECK_NULL(bnd->buffer.lens) - OCI_RETVAL /= (unsigned int) sizeof(dbtext); + unsigned int size = (unsigned int)((ub2 *)bnd->buffer.lens)[position - 1]; + + if (OCI_CDT_TEXT == bnd->type) + { + if (bnd->size == (sb4)size) + { + size -= (unsigned int) sizeof(dbtext); } + + size /= (unsigned int) sizeof(dbtext); } - OCI_CALL_EXIT() + SET_RETVAL(size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetNullAtPos + * BindSetNullAtPos * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetNullAtPos +boolean BindSetNullAtPos ( OCI_Bind *bnd, unsigned int position ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buffer.count) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_BOUND(position, 1, bnd->buffer.count) - OCI_RETVAL = OCI_STATUS = OCI_BindSetNullIndicator(bnd, position, OCI_IND_NULL); + CHECK(BindSetNullIndicator(bnd, position, OCI_IND_NULL)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetNull + * BindSetNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetNull +boolean BindSetNull ( OCI_Bind *bnd ) { - return OCI_BindSetNullAtPos(bnd, 1); + return BindSetNullAtPos(bnd, 1); } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetNotNullAtPos + * BindSetNotNullAtPos * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetNotNullAtPos +boolean BindSetNotNullAtPos ( OCI_Bind *bnd, unsigned int position ) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buffer.count) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_BOUND(position, 1, bnd->buffer.count) + + CHECK(BindSetNullIndicator(bnd, position, OCI_IND_NOTNULL)) - OCI_RETVAL = OCI_STATUS = OCI_BindSetNullIndicator(bnd, position, OCI_IND_NOTNULL); + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetNotNull + * BindSetNotNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetNotNull +boolean BindSetNotNull ( OCI_Bind *bnd ) { - return OCI_BindSetNotNullAtPos(bnd, 1); + return BindSetNotNullAtPos(bnd, 1); } /* --------------------------------------------------------------------------------------------- * - * OCI_BindIsNullAtPos + * BindIsNullAtPos * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindIsNullAtPos +boolean BindIsNullAtPos ( OCI_Bind *bnd, unsigned int position ) { - OCI_CALL_ENTER(boolean, TRUE) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CHECK_BOUND(bnd->stmt->con, position, 1, bnd->buffer.count) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + ENTER_FUNC + ( + /* returns */ boolean, TRUE, + /* context */ OCI_IPC_BIND, bnd + ) - if (bnd->buffer.inds) - { - OCI_RETVAL = (OCI_IND_NULL == bnd->buffer.inds[position - 1]); - } + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_BOUND(position, 1, bnd->buffer.count) + + CHECK_NULL(bnd->buffer.inds) - OCI_CALL_EXIT() + SET_RETVAL(OCI_IND_NULL == bnd->buffer.inds[position - 1]); + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindIsNull + * BindIsNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindIsNull +boolean BindIsNull ( OCI_Bind *bnd ) { - return OCI_BindIsNullAtPos(bnd, 1); + return BindIsNullAtPos(bnd, 1); } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetCharsetForm + * BindSetCharsetForm * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetCharsetForm +boolean BindSetCharsetForm ( OCI_Bind *bnd, unsigned int csfrm ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_BIND, bnd) - OCI_CALL_CHECK_ENUM_VALUE(bnd->stmt->con, bnd->stmt, csfrm, CharsetFormValues, OTEXT("CharsetForm")) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) + + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_ENUM_VALUE(csfrm, CharsetFormValues, OTEXT("CharsetForm")) if ((OCI_CDT_TEXT == bnd->type) || (OCI_CDT_LONG == bnd->type)) { @@ -1251,47 +1420,67 @@ boolean OCI_API OCI_BindSetCharsetForm bnd->csfrm = SQLCS_IMPLICIT; } - OCI_SET_ATTRIB(OCI_HTYPE_BIND, OCI_ATTR_CHARSET_FORM, bnd->buffer.handle, &bnd->csfrm, sizeof(bnd->csfrm)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_BIND, OCI_ATTR_CHARSET_FORM, + bnd->buffer.handle, &bnd->csfrm, sizeof(bnd->csfrm), + bnd->stmt->con->err + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindSetDirection + * BindSetDirection * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindSetDirection +boolean BindSetDirection ( OCI_Bind *bnd, unsigned int direction ) { - OCI_SET_PROP_ENUM(ub1, OCI_IPC_BIND, bnd, direction, direction, BindDirectionValues, OTEXT("Direction"), bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + SET_PROP_ENUM + ( + /* handle */ OCI_IPC_BIND, bnd, + /* member */ direction, ub1, + /* value */ direction, BindDirectionValues, OTEXT("Direction") + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindGetDirection + * BindGetDirection * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetDirection +unsigned int BindGetDirection ( OCI_Bind *bnd ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_BIND, bnd, direction, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ direction + ) } /* --------------------------------------------------------------------------------------------- * -* OCI_BindGetAllocationMode +* BindGetAllocationMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindGetAllocationMode +unsigned int BindGetAllocationMode ( OCI_Bind *bnd ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_BIND, bnd, alloc_mode, bnd->stmt->con, bnd->stmt, bnd->stmt->con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_BIND, bnd, + /* member */ alloc_mode + ) } diff --git a/src/bind.h b/src/bind.h new file mode 100644 index 00000000..046939bb --- /dev/null +++ b/src/bind.h @@ -0,0 +1,167 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_BIND_H_INCLUDED +#define OCILIB_BIND_H_INCLUDED + +#include "types.h" + +OCI_Bind* BindCreate +( + OCI_Statement* stmt, + void * data, + const otext * name, + unsigned int mode, + ub4 size, + ub1 type, + unsigned int code, + unsigned int subtype, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +boolean BindFree +( + OCI_Bind* bnd +); + +int BindGetIndex +( + OCI_Statement* stmt, + const otext * name +); + +boolean BindSetNullIndicator +( + OCI_Bind * bnd, + unsigned int position, + sb2 value +); + +const otext* BindGetName +( + OCI_Bind* bnd +); + +unsigned int BindGetType +( + OCI_Bind* bnd +); + +unsigned int BindGetSubtype +( + OCI_Bind* bnd +); + +unsigned int BindGetDataCount +( + OCI_Bind* bnd +); + +void* BindGetData +( + OCI_Bind* bnd +); + +OCI_Statement* BindGetStatement +( + OCI_Bind* bnd +); + +boolean BindSetDataSize +( + OCI_Bind * bnd, + unsigned int size +); + +boolean BindSetDataSizeAtPos +( + OCI_Bind * bnd, + unsigned int position, + unsigned int size +); + +unsigned int BindGetDataSize +( + OCI_Bind* bnd +); + +unsigned int BindGetDataSizeAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +boolean BindSetNullAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +boolean BindSetNull +( + OCI_Bind* bnd +); + +boolean BindSetNotNullAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +boolean BindSetNotNull +( + OCI_Bind* bnd +); + +boolean BindIsNullAtPos +( + OCI_Bind * bnd, + unsigned int position +); + +boolean BindIsNull +( + OCI_Bind* bnd +); + +boolean BindSetCharsetForm +( + OCI_Bind *bnd, + unsigned int csfrm +); + +boolean BindSetDirection +( + OCI_Bind *bnd, + unsigned int direction +); + +unsigned int BindGetDirection +( + OCI_Bind* bnd +); + +unsigned int BindGetAllocationMode +( + OCI_Bind* bnd +); + +#endif /* OCILIB_BIND_H_INCLUDED */ diff --git a/src/callback.c b/src/callback.c index 43d9da6a..5aef7689 100644 --- a/src/callback.c +++ b/src/callback.c @@ -18,25 +18,28 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "callback.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "event.h" +#include "list.h" +#include "macros.h" +#include "resultset.h" +#include "strings.h" +#include "timestamp.h" typedef struct HAEventParams { - OCIServer *srvhp; + OCIServer *srvhp; OCIDateTime *dthp; - ub4 source; - ub4 event; + ub4 source; + ub4 event; } HAEventParams; /* --------------------------------------------------------------------------------------------- * - * OCI_ProcInBind + * ProcInBind * --------------------------------------------------------------------------------------------- */ -sb4 OCI_ProcInBind +sb4 CallbackInBind ( dvoid *ictxp, OCIBind *bindp, @@ -48,9 +51,15 @@ sb4 OCI_ProcInBind dvoid **indp ) { + ENTER_FUNC + ( + /* returns */ sb4, OCI_ERROR, + /* context */ OCI_IPC_BIND, ictxp + ) + OCI_Bind * bnd = (OCI_Bind *) ictxp; - sb2 *ind = (sb2 *) bnd ? bnd->buffer.inds : NULL; - ub4 i = 0; + sb2 *ind = (sb2 *) bnd ? bnd->buffer.inds : NULL; + ub4 i = 0; /* those checks may be not necessary but they keep away compilers warning away if the warning level is set to maximum ! @@ -61,8 +70,7 @@ sb4 OCI_ProcInBind /* check objects and bounds */ - OCI_CHECK(NULL == bnd, OCI_ERROR) - OCI_CHECK(iter >= bnd->buffer.count, OCI_ERROR) + CHECK_PTR(OCI_IPC_BIND, bnd) /* indicators must be set to -1 depending on data type, so let's do it for all */ @@ -87,14 +95,16 @@ sb4 OCI_ProcInBind *indp = (dvoid *) bnd->buffer.inds; *piecep = (ub1 ) OCI_ONE_PIECE; - return OCI_CONTINUE; + SET_RETVAL(OCI_CONTINUE) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ProcOutBind + * ProcOutBind * --------------------------------------------------------------------------------------------- */ -sb4 OCI_ProcOutBind +sb4 CallbackOutBind ( dvoid *octxp, OCIBind *bindp, @@ -106,26 +116,27 @@ sb4 OCI_ProcOutBind dvoid **indp, ub2 **rcodep ) -{ - OCI_Bind *bnd = (OCI_Bind *)octxp; +{ + ENTER_FUNC + ( + /* returns */ sb4, OCI_ERROR, + /* context */ OCI_IPC_BIND, octxp + ) + + OCI_Bind *bnd = (OCI_Bind *)octxp; OCI_Define *def = NULL; OCI_Resultset *rs = NULL; ub4 rows = 0; - OCI_CALL_DECLARE_CONTEXT(TRUE) - /* those checks may be not necessary but they keep away compilers warning away if the warning level is set to maximum ! */ OCI_NOT_USED(bindp) - /* check objects and bounds */ - - OCI_CHECK(NULL == bnd, OCI_ERROR) - OCI_CHECK(iter >= bnd->buffer.count, OCI_ERROR) + /* check objects */ - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + CHECK_PTR(OCI_IPC_BIND, bnd) /* update statement status */ @@ -140,74 +151,72 @@ sb4 OCI_ProcOutBind /* allocate resultset handles array */ - OCI_ALLOCATE_DATA(OCI_IPC_RESULTSET_ARRAY, bnd->stmt->rsts, bnd->stmt->nb_rs) + ALLOC_DATA(OCI_IPC_RESULTSET_ARRAY, bnd->stmt->rsts, bnd->stmt->nb_rs) /* create resultset as needed */ - if (OCI_STATUS && !bnd->stmt->rsts[iter]) + if (NULL == bnd->stmt->rsts[iter]) { - OCI_GET_ATTRIB(OCI_HTYPE_BIND, OCI_ATTR_ROWS_RETURNED, bnd->buffer.handle, &rows, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_BIND, OCI_ATTR_ROWS_RETURNED, + bnd->buffer.handle, &rows, NULL, + bnd->stmt->con->err + ) - if (OCI_STATUS) - { - bnd->stmt->rsts[iter] = OCI_ResultsetCreate(bnd->stmt, rows); + bnd->stmt->rsts[iter] = ResultsetCreate(bnd->stmt, rows); - if (bnd->stmt->rsts[iter]) - { - bnd->stmt->rsts[iter]->row_count = rows; - } - } + CHECK_NULL(bnd->stmt->rsts[iter]) + + bnd->stmt->rsts[iter]->row_count = rows; } } - OCI_CHECK(NULL == bnd->stmt->rsts, OCI_ERROR) + CHECK_NULL(bnd->stmt->rsts) rs = bnd->stmt->rsts[iter]; - OCI_CHECK(NULL == rs, OCI_ERROR) + CHECK_NULL(rs) /* Let's Oracle update its buffers */ - if (OCI_STATUS) - { - /* update pointers contents */ - - def = &rs->defs[bnd->dynpos]; + def = &rs->defs[bnd->dynpos]; - switch (def->col.datatype) + switch (def->col.datatype) + { + case OCI_CDT_CURSOR: + case OCI_CDT_TIMESTAMP: + case OCI_CDT_INTERVAL: + case OCI_CDT_LOB: + case OCI_CDT_FILE: { - case OCI_CDT_CURSOR: - case OCI_CDT_TIMESTAMP: - case OCI_CDT_INTERVAL: - case OCI_CDT_LOB: - case OCI_CDT_FILE: - { - *bufpp = def->buf.data[index]; - break; - } - default: - { - *bufpp = (((ub1*)def->buf.data) + (size_t) (def->col.bufsize * index)); - break; - } + *bufpp = def->buf.data[index]; + break; + } + default: + { + *bufpp = (((ub1*)def->buf.data) + (size_t) (def->col.bufsize * index)); + break; } - - *alenp = (ub4 *) (((ub1 *) def->buf.lens) + (size_t) ((ub4) def->buf.sizelen * index)); - *indp = (dvoid *) (((ub1 *) def->buf.inds) + (size_t) ((ub4) sizeof(sb2) * index)); - *piecep = (ub1 ) OCI_ONE_PIECE; - *rcodep = (ub2 *) NULL; } - return (OCI_STATUS ? OCI_CONTINUE : OCI_ERROR); + *alenp = (ub4 *) (((ub1 *) def->buf.lens) + (size_t) ((ub4) def->buf.sizelen * index)); + *indp = (dvoid *) (((ub1 *) def->buf.inds) + (size_t) ((ub4) sizeof(sb2) * index)); + *piecep = (ub1 ) OCI_ONE_PIECE; + *rcodep = (ub2 *) NULL; + + SET_RETVAL(OCI_CONTINUE) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ProcNotifyMessages + * ProcNotifyMessages * --------------------------------------------------------------------------------------------- */ -ub4 OCI_ProcNotifyMessages +ub4 CallbackNotifyMessages ( - void *ctx, + void *oci_ctx, OCISubscription *subscrhp, void *payload, ub4 paylen, @@ -215,7 +224,13 @@ ub4 OCI_ProcNotifyMessages ub4 mode ) { - OCI_Dequeue *dequeue = (OCI_Dequeue *)ctx; + ENTER_FUNC + ( + /* returns */ ub4, OCI_SUCCESS, + /* context */ OCI_IPC_DEQUEUE, oci_ctx + ) + + OCI_Dequeue *dequeue = (OCI_Dequeue *)oci_ctx; OCI_NOT_USED(paylen) OCI_NOT_USED(payload) @@ -223,18 +238,20 @@ ub4 OCI_ProcNotifyMessages OCI_NOT_USED(subscrhp) OCI_NOT_USED(desc) - OCI_CHECK(NULL == dequeue, OCI_SUCCESS) - + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) + dequeue->callback(dequeue); - - return OCI_SUCCESS; + + SET_RETVAL(OCI_SUCCESS) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ProcNotifyChanges + * ProcNotifyChanges * --------------------------------------------------------------------------------------------- */ -ub4 OCI_ProcNotifyChanges +ub4 CallbackNotifyChanges ( void *oci_ctx, OCISubscription *subscrhp, @@ -244,31 +261,40 @@ ub4 OCI_ProcNotifyChanges ub4 mode ) { - OCI_Subscription *sub = (OCI_Subscription *)oci_ctx; - ub4 type = 0; + ENTER_FUNC + ( + /* returns */ ub4, OCI_SUCCESS, + /* context */ OCI_IPC_NOTIFY, oci_ctx + ) + + OCI_Subscription* sub = (OCI_Subscription*)oci_ctx; - OCI_CALL_DECLARE_CONTEXT(TRUE) + ub4 type = 0; OCI_NOT_USED(paylen) OCI_NOT_USED(payload) OCI_NOT_USED(mode) OCI_NOT_USED(subscrhp) - OCI_CHECK(NULL == sub, OCI_SUCCESS) - - OCI_CALL_CONTEXT_SET_FROM_ERR(sub->err) + CHECK_PTR(OCI_IPC_VOID, sub) - OCI_EventReset(&sub->event); + CHECK(EventReset(&sub->event)) #if OCI_VERSION_COMPILE >= OCI_10_2 /* get database that generated the notification */ - OCI_GetStringAttribute(sub->con, desc, OCI_DTYPE_CHDES, OCI_ATTR_CHDES_DBNAME, &sub->event.dbname, &sub->event.dbname_size); + CHECK(StringGetAttribute(sub->con, desc, OCI_DTYPE_CHDES, OCI_ATTR_CHDES_DBNAME, + &sub->event.dbname, &sub->event.dbname_size)) /* get notification type */ - OCI_GET_ATTRIB(OCI_DTYPE_CHDES, OCI_ATTR_CHDES_NFYTYPE, desc, &type, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_CHDES, OCI_ATTR_CHDES_NFYTYPE, + desc, &type, NULL, + sub->err + ) switch(type) { @@ -309,7 +335,12 @@ ub4 OCI_ProcNotifyChanges /* get collection of modified tables */ - OCI_GET_ATTRIB(OCI_DTYPE_CHDES, OCI_ATTR_CHDES_TABLE_CHANGES, desc, &tables, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_CHDES, OCI_ATTR_CHDES_TABLE_CHANGES, + desc, &tables, NULL, + sub->err + ) if (tables) { @@ -321,7 +352,7 @@ ub4 OCI_ProcNotifyChanges /* get number of tables in the collection */ - OCI_EXEC(OCICollSize(sub->env, sub->err, tables, &nb_tables)) + CHECK_OCI(sub->err, OCICollSize, sub->env, sub->err, tables, &nb_tables) for (sb4 i = 0; i < nb_tables; i++) { @@ -341,15 +372,28 @@ ub4 OCI_ProcNotifyChanges /* get table element */ - OCI_EXEC(OCICollGetElem(sub->env, sub->err, tables, i, &tbl_exist, (dvoid**) (dvoid*) &tbl_elem, (dvoid**) &tbl_ind)) + CHECK_OCI + ( + sub->err, + OCICollGetElem, + sub->env, sub->err, tables, i, &tbl_exist, + (dvoid**) (dvoid*) &tbl_elem, (dvoid**) &tbl_ind + ) /* get table name */ - OCI_GetStringAttribute(sub->con, *tbl_elem, OCI_DTYPE_TABLE_CHDES, OCI_ATTR_CHDES_TABLE_NAME, &sub->event.objname, &sub->event.objname_size); + CHECK(StringGetAttribute(sub->con, *tbl_elem, OCI_DTYPE_TABLE_CHDES, + OCI_ATTR_CHDES_TABLE_NAME, &sub->event.objname, + &sub->event.objname_size)) /* get table modification type */ - OCI_GET_ATTRIB(OCI_DTYPE_TABLE_CHDES, OCI_ATTR_CHDES_TABLE_OPFLAGS, *tbl_elem, &sub->event.op, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_TABLE_CHDES, OCI_ATTR_CHDES_TABLE_OPFLAGS, + *tbl_elem, &sub->event.op, NULL, + sub->err + ) sub->event.op = sub->event.op & (~OCI_OPCODE_ALLROWS); sub->event.op = sub->event.op & (~OCI_OPCODE_ALLOPS); @@ -362,7 +406,12 @@ ub4 OCI_ProcNotifyChanges /* get collection of modified rows */ - OCI_GET_ATTRIB(OCI_DTYPE_TABLE_CHDES, OCI_ATTR_CHDES_TABLE_ROW_CHANGES, *tbl_elem, &rows, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_TABLE_CHDES, OCI_ATTR_CHDES_TABLE_ROW_CHANGES, + *tbl_elem, &rows, NULL, + sub->err + ) if (rows) { @@ -372,7 +421,13 @@ ub4 OCI_ProcNotifyChanges /* get number of rows */ - OCI_EXEC(OCICollSize(sub->env, sub->err, rows, &nb_rows)) + CHECK_OCI + ( + sub->err, + OCICollSize, + sub->env, sub->err, + rows, &nb_rows + ) for (sb4 j = 0; j < nb_rows; j++) { @@ -385,18 +440,28 @@ ub4 OCI_ProcNotifyChanges /* get row element */ - OCI_EXEC + CHECK_OCI ( - OCICollGetElem(sub->env, sub->err, rows, j, &row_exist, (dvoid**) (dvoid*) &row_elem, (dvoid**) &row_ind) + sub->err, + OCICollGetElem, + sub->env, sub->err, rows, j, &row_exist, + (dvoid**) (dvoid*) &row_elem, (dvoid**) &row_ind ) /* get rowid */ - OCI_GetStringAttribute(sub->con, *row_elem, OCI_DTYPE_ROW_CHDES, OCI_ATTR_CHDES_ROW_ROWID, &sub->event.rowid, &sub->event.rowid_size); + CHECK(StringGetAttribute(sub->con, *row_elem, OCI_DTYPE_ROW_CHDES, + OCI_ATTR_CHDES_ROW_ROWID, &sub->event.rowid, + &sub->event.rowid_size)) /* get opcode */ - - OCI_GET_ATTRIB(OCI_DTYPE_ROW_CHDES, OCI_ATTR_CHDES_ROW_OPFLAGS, *row_elem, &sub->event.op, NULL) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_ROW_CHDES, OCI_ATTR_CHDES_ROW_OPFLAGS, + *row_elem, &sub->event.op, NULL, + sub->err + ) sub->handler(&sub->event); } @@ -415,23 +480,24 @@ ub4 OCI_ProcNotifyChanges sub->handler(&sub->event); } + SET_RETVAL(OCI_SUCCESS) + #else - OCI_NOT_USED(ctx) OCI_NOT_USED(desc) OCI_NOT_USED(subscrhp) OCI_NOT_USED(type) #endif - return OCI_SUCCESS; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ProcFailOver + * ProcFailOver * --------------------------------------------------------------------------------------------- */ -sb4 OCI_ProcFailOver +sb4 CallbackFailOver ( dvoid *svchp, dvoid *envhp, @@ -440,101 +506,142 @@ sb4 OCI_ProcFailOver ub4 fo_event ) { - OCI_Connection *cn = (OCI_Connection *) fo_ctx; - sb4 ret = OCI_FOC_OK; + ENTER_FUNC + ( + /* returns */ sb4, OCI_FOC_OK, + /* context */ OCI_IPC_CONNECTION, fo_ctx + ) + + OCI_Connection* con = (OCI_Connection*)fo_ctx; OCI_NOT_USED(envhp) OCI_NOT_USED(svchp) - if (cn && cn->taf_handler) - { - ret = (sb4) cn->taf_handler(cn, fo_type, fo_event); - } + CHECK_PTR(OCI_IPC_CONNECTION, con) - return ret; + CHECK_NULL(con->taf_handler) + + SET_RETVAL((sb4)con->taf_handler(con, fo_type, fo_event)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_ProcHAEventInvoke +* ProcHAEventInvoke * --------------------------------------------------------------------------------------------- */ -void OCI_ProcHAEventInvoke +void ProcHAEventInvoke ( OCI_Connection *con, HAEventParams * ha_params ) { - OCI_Timestamp *tmsp = NULL; + ENTER_VOID + ( + /* context */ OCI_IPC_CONNECTION, con + ) + + OCI_Timestamp* tmsp = NULL; + + CHECK_PTR(OCI_IPC_CONNECTION, con) - if (con && (con->svr == ha_params->srvhp)) + if (NULL != con && con->svr == ha_params->srvhp) { - tmsp = OCI_TimestampInit(NULL, tmsp, ha_params->dthp, OCI_TIMESTAMP); + tmsp = TimestampInitialize(NULL, tmsp, ha_params->dthp, OCI_TIMESTAMP); - OCILib.ha_handler(con, (unsigned int)ha_params->source, (unsigned int)ha_params->event, tmsp); + CHECK_NULL(tmsp) + + Env.ha_handler(con, (unsigned int)ha_params->source, (unsigned int)ha_params->event, tmsp); } - if (tmsp) + if (NULL != tmsp) { tmsp->hstate = OCI_OBJECT_FETCHED_DIRTY; - OCI_TimestampFree(tmsp); - } + TimestampFree(tmsp); + } + + EXIT_VOID() } /* --------------------------------------------------------------------------------------------- * - * OCI_ProcHAEvent + * ProcHAEvent * --------------------------------------------------------------------------------------------- */ -void OCI_ProcHAEvent +void CallbackHAEvent ( - dvoid *evtctx, - dvoid *eventptr + dvoid *evtctx, + dvoid *eventptr ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_VOID + ( + /* context */ OCI_IPC_VOID, &Env + ) - OCI_NOT_USED(evtctx) + CHECK_PTR(OCI_IPC_VOID, evtctx) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!OCILib.ha_handler) - { - return; - } + CHECK_PTR(OCI_IPC_VOID, Env.ha_handler) - if (OCILib.version_runtime >= OCI_10_2) - { + if (Env.version_runtime >= OCI_10_2) + { HAEventParams params; memset(¶ms, 0, sizeof(params)); - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_HA_SRVFIRST, (OCIEvent *)eventptr, ¶ms.srvhp, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_HA_SRVFIRST, + (OCIEvent *)eventptr, ¶ms.srvhp, NULL, + Env.err + ) - while (OCI_STATUS && params.srvhp) - { + while (params.srvhp) + { params.dthp = NULL; params.event = OCI_HA_STATUS_DOWN; params.source = OCI_HA_SOURCE_INSTANCE; /* get event timestamp */ - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_HA_TIMESTAMP, params.srvhp, ¶ms.dthp, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_HA_TIMESTAMP, + params.srvhp, ¶ms.dthp, NULL, + Env.err + ) /* get status */ - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_HA_STATUS, params.srvhp, ¶ms.event, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_HA_STATUS, + params.srvhp, ¶ms.event, NULL, + Env.err + ) /* get source */ - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_HA_SOURCE, params.srvhp, ¶ms.source, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_HA_SOURCE, + params.srvhp, ¶ms.source, NULL, + Env.err + ) /* notify all related connections */ - if (OCI_STATUS) - { - OCI_ListForEachWithParam(OCILib.cons, ¶ms, (POCI_LIST_FOR_EACH_WITH_PARAM)OCI_ProcHAEventInvoke); - } - - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_HA_SRVNEXT, (OCIEvent *)eventptr, ¶ms.srvhp, NULL) + ListForEachWithParam(Env.cons, ¶ms, (POCI_LIST_FOR_EACH_WITH_PARAM) ProcHAEventInvoke); + + /* get next server */ + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_HA_SRVNEXT, + eventptr, ¶ms.srvhp, NULL, + Env.err + ) } } @@ -544,4 +651,5 @@ void OCI_ProcHAEvent #endif + EXIT_VOID() } diff --git a/src/callback.h b/src/callback.h new file mode 100644 index 00000000..7181cebe --- /dev/null +++ b/src/callback.h @@ -0,0 +1,86 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_CALLBACK_H_INCLUDED +#define OCILIB_CALLBACK_H_INCLUDED + +#include "types.h" + +sb4 CallbackInBind +( + dvoid *ictxp, + OCIBind *bindp, + ub4 iter, + ub4 index, + dvoid **bufpp, + ub4 *alenp, + ub1 *piecep, + dvoid **indp +); + +sb4 CallbackOutBind +( + dvoid *octxp, + OCIBind *bindp, + ub4 iter, + ub4 index, + dvoid **bufpp, + ub4 **alenp, + ub1 *piecep, + void **indp, + ub2 **rcodep +); + +ub4 CallbackNotifyChanges +( + void *oci_ctx, + OCISubscription *subscrhp, + void *payload, + ub4 paylen, + void *desc, + ub4 mode +); + +ub4 CallbackNotifyMessages +( + void *oci_ctx, + OCISubscription *subscrhp, + void *payload, + ub4 paylen, + void *desc, + ub4 mode +); + +sb4 CallbackFailOver +( + dvoid *svchp, + dvoid *envhp, + dvoid *fo_ctx, + ub4 fo_type, + ub4 fo_event +); + +void CallbackHAEvent +( + dvoid *evtctx, + dvoid *eventptr +); + +#endif /* OCILIB_CALLBACK_H_INCLUDED */ diff --git a/src/collection.c b/src/collection.c index 946333c4..6b213ba9 100644 --- a/src/collection.c +++ b/src/collection.c @@ -18,17 +18,18 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "collection.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "array.h" +#include "element.h" +#include "macros.h" +#include "strings.h" /* --------------------------------------------------------------------------------------------- * - * OCI_CollInit + * CollInit * --------------------------------------------------------------------------------------------- */ -OCI_Coll * OCI_CollInit +OCI_Coll * CollectionInitialize ( OCI_Connection *con, OCI_Coll *coll, @@ -36,93 +37,104 @@ OCI_Coll * OCI_CollInit OCI_TypeInfo *typinf ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Coll*, coll, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_ALLOCATE_DATA(OCI_IPC_COLLECTION, coll, 1); + CHECK_PTR(OCI_IPC_CONNECTION, con) - if (OCI_STATUS) + ALLOC_DATA(OCI_IPC_COLLECTION, coll, 1); + + coll->con = con; + coll->handle = handle; + coll->typinf = typinf; + + if (NULL == coll->handle || (OCI_OBJECT_ALLOCATED_ARRAY == coll->hstate)) { - coll->con = con; - coll->handle = handle; - coll->typinf = typinf; + /* allocates handle for non fetched collection */ - if (!coll->handle || (OCI_OBJECT_ALLOCATED_ARRAY == coll->hstate)) + if (OCI_OBJECT_ALLOCATED_ARRAY != coll->hstate) { - /* allocates handle for non fetched collection */ - - if (OCI_OBJECT_ALLOCATED_ARRAY != coll->hstate) - { - coll->hstate = OCI_OBJECT_ALLOCATED; - } + coll->hstate = OCI_OBJECT_ALLOCATED; + } - OCI_EXEC + CHECK + ( + MemoryAllocateObject ( - OCI_ObjectNew(coll->con->env, coll->con->err, coll->con->cxt, - typinf->colcode, typinf->tdo, (void *) NULL, - OCI_DURATION_SESSION, TRUE, (dvoid **) &coll->handle) + coll->con->env, coll->con->err, coll->con->cxt, + typinf->colcode, typinf->tdo, (void *) NULL, + OCI_DURATION_SESSION, TRUE, (dvoid **) &coll->handle ) - } - else - { - coll->hstate = OCI_OBJECT_FETCHED_CLEAN; - } + ) } - - /* check for failure */ - - if (!OCI_STATUS && coll) + else { - OCI_CollFree(coll); - coll = NULL; + coll->hstate = OCI_OBJECT_FETCHED_CLEAN; } - return coll; -} + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + CollectionFree(coll); + coll = NULL; + } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + SET_RETVAL(coll) + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_CollCreate + * CollCreate * --------------------------------------------------------------------------------------------- */ -OCI_Coll * OCI_API OCI_CollCreate +OCI_Coll * CollectionCreate ( OCI_TypeInfo *typinf ) { - OCI_CALL_ENTER(OCI_Coll *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) + ENTER_FUNC + ( + /* returns */ OCI_Coll*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) - OCI_RETVAL = OCI_CollInit(typinf->con, NULL, NULL, typinf); - OCI_STATUS = (NULL != OCI_RETVAL); + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_EXIT() + SET_RETVAL(CollectionInitialize(typinf->con, NULL, NULL, typinf)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollFree + * CollFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollFree +boolean CollectionFree ( OCI_Coll *coll ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_OBJECT_FETCHED(coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_OBJECT_FETCHED(coll) /* free data element */ if (coll->elem) { coll->elem->hstate = OCI_OBJECT_FETCHED_DIRTY; - OCI_ElemFree(coll->elem); + + ElementFree(coll->elem); + coll->elem = NULL; } @@ -130,433 +142,578 @@ boolean OCI_API OCI_CollFree if ((OCI_OBJECT_ALLOCATED == coll->hstate) || (OCI_OBJECT_ALLOCATED_ARRAY == coll->hstate)) { - OCI_OCIObjectFree(coll->con->env, coll->typinf->con->err, coll->handle, OCI_DEFAULT); + MemoryFreeObject(coll->con->env, coll->typinf->con->err, coll->handle, OCI_DEFAULT); } if (OCI_OBJECT_ALLOCATED_ARRAY != coll->hstate) { - OCI_FREE(coll) + FREE(coll) } - OCI_RETVAL = TRUE; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollArrayCreate + * CollArrayCreate * --------------------------------------------------------------------------------------------- */ -OCI_Coll ** OCI_API OCI_CollArrayCreate +OCI_Coll ** CollectionCreateArray ( OCI_Connection *con, OCI_TypeInfo *typinf, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Coll**, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Coll **, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_COLLECTION, 0, sizeof(OCIColl *), sizeof(OCI_Coll), 0, typinf); - OCI_STATUS = (arr != NULL); + arr = ArrayCreate(con, nbelem, OCI_CDT_COLLECTION, 0, + sizeof(OCIColl*), sizeof(OCI_Coll), 0, typinf); - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Coll **) arr->tab_obj; - } + CHECK_NULL(arr) + + SET_RETVAL((OCI_Coll **) arr->tab_obj) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollArrayFree + * CollArrayFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollArrayFree +boolean CollectionFreeArray ( OCI_Coll **colls ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, colls) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, colls + ) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)colls); + CHECK_PTR(OCI_IPC_ARRAY, colls) - OCI_CALL_EXIT() + SET_RETVAL(ArrayFreeFromHandles((void **)colls)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollAssign + * CollAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollAssign +boolean CollectionAssign ( OCI_Coll *coll, OCI_Coll *coll_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll_src) - OCI_CALL_CHECK_COMPAT(coll->con, coll->typinf->cols[0].libcode == coll_src->typinf->cols[0].libcode) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) - - OCI_EXEC(OCICollAssign(coll->con->env, coll->con->err, coll_src->handle, coll->handle)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_PTR(OCI_IPC_COLLECTION, coll_src) + CHECK_COMPAT(coll->typinf->cols[0].libcode == coll_src->typinf->cols[0].libcode) + + CHECK_OCI + ( + coll->con->err, + OCICollAssign, + coll->con->env, coll->con->err, + coll_src->handle, coll->handle + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetType + * CollGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_CollGetType +unsigned int CollectionGetType ( OCI_Coll *coll ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + + unsigned int type = OCI_UNKNOWN; if (OCI_TYPECODE_TABLE == coll->typinf->colcode) { - OCI_RETVAL = OCI_COLL_NESTED_TABLE; + type = OCI_COLL_NESTED_TABLE; } else if (OCI_TYPECODE_VARRAY == coll->typinf->colcode) { - OCI_RETVAL = OCI_COLL_VARRAY; + type = OCI_COLL_VARRAY; } #if OCI_VERSION_COMPILE >= OCI_12_1 else if (OCI_TYPECODE_ITABLE == coll->typinf->colcode) { - OCI_RETVAL = OCI_COLL_INDEXED_TABLE; + type = OCI_COLL_INDEXED_TABLE; } #endif - OCI_CALL_EXIT() + SET_RETVAL(type) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetMax + * CollGetMax * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_CollGetMax +unsigned int CollectionGetMax ( OCI_Coll *coll ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_RETVAL = (unsigned int) OCICollMax(coll->con->env, coll->handle); + SET_RETVAL((unsigned int) OCICollMax(coll->con->env, coll->handle)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetSize + * CollGetSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_CollGetSize +unsigned int CollectionGetSize ( OCI_Coll *coll ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_COLLECTION, coll + ) + sb4 value = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_EXEC(OCICollSize(coll->con->env, coll->con->err, coll->handle, &value)) + CHECK_OCI + ( + coll->con->err, + OCICollSize, + coll->con->env, coll->con->err, + coll->handle, &value + ) - OCI_RETVAL = (unsigned int)value; + SET_RETVAL((unsigned int)value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollTrim + * CollTrim * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollTrim +boolean CollectionTrim ( - OCI_Coll *coll, - unsigned int nb_elem + OCI_Coll *coll, + unsigned int nb_elem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_BOUND(coll->con, (sb4) nb_elem, (sb4) 0, (sb4) OCI_CollGetSize(coll)); - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) - - OCI_EXEC(OCICollTrim(coll->con->env, coll->con->err, (sb4) nb_elem, coll->handle)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_BOUND((sb4) nb_elem, (sb4) 0, (sb4) CollectionGetSize(coll)); + + CHECK_OCI + ( + coll->con->err, + OCICollTrim, + coll->con->env, coll->con->err, + (sb4) nb_elem, coll->handle + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetElem + * CollGetElem * --------------------------------------------------------------------------------------------- */ -OCI_Elem * OCI_API OCI_CollGetElem +OCI_Elem * CollectionGetElement ( OCI_Coll *coll, unsigned int index ) { - boolean exists = FALSE; - void *data = NULL; - OCIInd *p_ind = NULL; - - OCI_CALL_ENTER(OCI_Elem*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) - - OCI_EXEC(OCICollGetElem(coll->con->env, coll->con->err, coll->handle, (sb4) index-1, &exists, &data, (dvoid **) (dvoid *) &p_ind)) - - if (OCI_STATUS && exists && data) + ENTER_FUNC + ( + /* returns */ OCI_Elem*, NULL, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + + boolean exists = FALSE; + void * data = NULL; + OCIInd* ind = NULL; + + CHECK_OCI + ( + coll->con->err, + OCICollGetElem, + coll->con->env, coll->con->err, coll->handle, + (sb4)index - 1, &exists, &data, + (dvoid**)(dvoid*)&ind + ) + + OCI_Elem* elem = NULL; + + if (exists && NULL != data) { - OCI_RETVAL = coll->elem = OCI_ElemInit(coll->con, coll->elem, data, p_ind, coll->typinf); + elem = coll->elem = ElementInitialize(coll->con, coll->elem, data, ind, coll->typinf); + CHECK_NULL(elem) } - OCI_CALL_EXIT() + SET_RETVAL(elem) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetElem2 + * CollGetElem2 * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollGetElem2 +boolean CollectionGetElement2 ( OCI_Coll *coll, unsigned int index, OCI_Elem *elem ) { - boolean exists = FALSE; - void *data = NULL; - OCIInd *p_ind = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(coll->con, elem->typinf->cols[0].datatype == coll->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) - - OCI_EXEC(OCICollGetElem(coll->con->env, coll->con->err, coll->handle, (sb4) index-1, &exists, &data, (dvoid **) (dvoid *) &p_ind)) - - if (OCI_STATUS && exists && data) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + boolean exists = FALSE; + void *data = NULL; + OCIInd *ind = NULL; + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(elem->typinf->cols[0].datatype == coll->typinf->cols[0].datatype) + + CHECK_OCI + ( + coll->con->err, + OCICollGetElem, + coll->con->env, coll->con->err, + coll->handle, (sb4) index-1, &exists, + &data, (dvoid **) (dvoid *) &ind + ) + + if (exists && NULL != data) { - elem = OCI_ElemInit(coll->con, elem, data, p_ind, coll->typinf); - OCI_STATUS = (NULL != elem); + elem = ElementInitialize(coll->con, elem, data, ind, coll->typinf); + CHECK_NULL(elem) } else { - OCI_STATUS = OCI_ElemSetNullIndicator(elem, OCI_IND_NULL); + CHECK(ElementSetNullIndicator(elem, OCI_IND_NULL)) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollSetElem + * CollSetElem * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollSetElem +boolean CollectionSetElement ( - OCI_Coll *coll, - unsigned int index, - OCI_Elem *elem + OCI_Coll *coll, + unsigned int index, + OCI_Elem *elem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(coll->con, elem->typinf->cols[0].datatype == coll->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) - - OCI_EXEC(OCICollAssignElem(coll->con->env, coll->con->err, (sb4) index-1, elem->handle, elem->pind, coll->handle)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(elem->typinf->cols[0].datatype == coll->typinf->cols[0].datatype) + + CHECK_OCI + ( + coll->con->err, + OCICollAssignElem, + coll->con->env, coll->con->err, + (sb4) index-1, elem->handle, + elem->pind, coll->handle + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollAppend + * CollAppend * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollAppend +boolean CollectionAddElement ( OCI_Coll *coll, OCI_Elem *elem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(coll->con, elem->typinf->cols[0].datatype == coll->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) - - OCI_EXEC(OCICollAppend(coll->con->env, coll->con->err, elem->handle, elem->pind, coll->handle)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(elem->typinf->cols[0].datatype == coll->typinf->cols[0].datatype) + + CHECK_OCI + ( + coll->con->err, + OCICollAppend, + coll->con->env, coll->con->err, + elem->handle, elem->pind, coll->handle + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetTypeInfo + * CollGetTypeInfo * --------------------------------------------------------------------------------------------- */ -OCI_TypeInfo * OCI_API OCI_CollGetTypeInfo +OCI_TypeInfo * CollectionGetTypeInfo ( OCI_Coll *coll ) { - OCI_GET_PROP(OCI_TypeInfo*, NULL, OCI_IPC_COLLECTION, coll, typinf, coll->con, NULL, coll->con->err) + GET_PROP + ( + /* result */ OCI_TypeInfo*, NULL, + /* handle */ OCI_IPC_COLLECTION, coll, + /* member */ typinf + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_CollClear + * CollClear * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollClear +boolean CollectionClear ( OCI_Coll *coll ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) + + CHECK(CollectionTrim(coll, CollectionGetSize(coll))) - OCI_RETVAL = OCI_STATUS = OCI_CollTrim(coll, OCI_CollGetSize(coll)); + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollDeleteElem + * CollDeleteElem * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollDeleteElem +boolean CollectionRemoveElement ( OCI_Coll *coll, unsigned int index ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + + CHECK_PTR(OCI_IPC_COLLECTION, coll) if (OCI_TYPECODE_TABLE == coll->typinf->colcode) { - OCI_EXEC(OCITableDelete(coll->con->env, coll->con->err, (sb4) index-1, coll->handle)) + CHECK_OCI + ( + coll->con->err, + OCITableDelete, + coll->con->env, coll->con->err, + (sb4) index-1, coll->handle + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollGetCount + * CollGetCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_CollGetCount +unsigned int CollectionGetCount ( OCI_Coll *coll ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + sb4 value = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + CHECK_PTR(OCI_IPC_COLLECTION, coll) if (OCI_TYPECODE_TABLE == coll->typinf->colcode) { - OCI_EXEC(OCITableSize(coll->con->env, coll->con->err, coll->handle, &value)) + CHECK_OCI + ( + coll->con->err, + OCITableSize, + coll->con->env, coll->con->err, + coll->handle, &value + ) } else { - OCI_EXEC(OCICollSize(coll->con->env, coll->con->err, coll->handle, &value)) + CHECK_OCI + ( + coll->con->err, + OCICollSize, + coll->con->env, coll->con->err, + coll->handle, &value + ) } - OCI_RETVAL = (unsigned int) value; + SET_RETVAL((unsigned int) value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_CollToText + * CollectionToString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_CollToText +boolean CollectionToString ( OCI_Coll *coll, unsigned int *size, otext *str ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLLECTION, coll + ) + OCI_Error *err = NULL; - boolean quote = TRUE; - unsigned int len = 0; + boolean quote = TRUE; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, size) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + unsigned int len = 0; + unsigned int count = 0; - err = OCI_ErrorGet(TRUE, TRUE); + CHECK_PTR(OCI_IPC_COLLECTION, coll) + CHECK_PTR(OCI_IPC_VOID, size) - if (str) + err = ErrorGet(TRUE, TRUE); + + if (NULL != str) { *str = 0; } - len += OCI_StringAddToBuffer(str, len, coll->typinf->name, (unsigned int) ostrlen(coll->typinf->name), FALSE); - len += OCI_StringAddToBuffer(str, len, OTEXT("("), 1, FALSE); + len += StringAddToBuffer(str, len, coll->typinf->name, + (unsigned int)ostrlen(coll->typinf->name), FALSE); + + len += StringAddToBuffer(str, len, OTEXT("("), 1, FALSE); - const unsigned int n = OCI_CollGetSize(coll); + count = CollectionGetSize(coll); - for (unsigned int i = 1; i <= n && OCI_STATUS; i++) + for (unsigned int i = 1; i <= count; i++) { - OCI_Elem *elem = OCI_CollGetElem(coll, i); + OCI_Elem* elem = CollectionGetElement(coll, i); quote = TRUE; - if (OCI_ElemIsNull(elem)) + if (ElementIsNull(elem)) { - len += OCI_StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); + len += StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); } else { - void *data = NULL; - unsigned int data_size = 0; + void *data = NULL; + unsigned int data_size = 0; const unsigned int data_type = coll->typinf->cols[0].datatype; + otext* tmpbuf = NULL; + switch (data_type) { case OCI_CDT_TEXT: { - data_size = OCIStringSize(OCILib.env, elem->handle); - data = (void *) OCI_ElemGetString(elem); + data_size = OCIStringSize(Env.env, elem->handle); + data = (void*) ElementGetString(elem); break; } case OCI_CDT_NUMERIC: @@ -567,7 +724,7 @@ boolean OCI_API OCI_CollToText } case OCI_CDT_BOOLEAN: { - data = (void *)elem->handle; + data = (void *)elem->handle; quote = FALSE; break; } @@ -583,93 +740,93 @@ boolean OCI_API OCI_CollToText } case OCI_CDT_DATETIME: { - data = (void *) OCI_ElemGetDate(elem); + data = (void*) ElementGetDate(elem); break; } case OCI_CDT_TIMESTAMP: { - data = (void *) OCI_ElemGetTimestamp(elem); + data = (void*) ElementGetTimestamp(elem); break; } case OCI_CDT_INTERVAL: { - data = (void *) OCI_ElemGetInterval(elem); + data = (void*) ElementGetInterval(elem); break; } case OCI_CDT_LOB: { - data = (void *) OCI_ElemGetLob(elem); + data = (void*) ElementGetLob(elem); break; } case OCI_CDT_FILE: { - data = (void *) OCI_ElemGetFile(elem); + data = (void*) ElementGetFile(elem); break; } case OCI_CDT_REF: { - data = (void *) OCI_ElemGetRef(elem); + data = (void*) ElementGetReference(elem); break; } case OCI_CDT_OBJECT: { - data = (void *) OCI_ElemGetObject(elem); + data = (void*) ElementGetObject(elem); quote = FALSE; break; } case OCI_CDT_COLLECTION: { - data = (void *) OCI_ElemGetColl(elem); + data = (void*) ElementGetCollection(elem); quote = FALSE; } } - OCI_STATUS = (NULL != data || OCI_CDT_TEXT == data_type) && (NULL == err || !err->raise); + CHECK(NULL != data || OCI_CDT_TEXT == data_type) + CHECK_ERROR(err) - if (OCI_STATUS) - { - otext *tmpbuf = str; + tmpbuf = str; - if (tmpbuf) - { - tmpbuf += len; - } + if (NULL != tmpbuf) + { + tmpbuf += len; + } - if (data) - { - len += OCI_StringGetFromType(coll->con, &coll->typinf->cols[0], data, data_size, tmpbuf, tmpbuf && size ? *size - len : 0, quote); - } - else - { - len += OCI_StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); - } - OCI_STATUS = (NULL == err || OCI_UNKNOWN == err->type); + if (NULL != data) + { + len += StringGetFromType(coll->con, &coll->typinf->cols[0], data, data_size, tmpbuf, + tmpbuf && size ? *size - len : 0, quote); } + else + { + len += StringAddToBuffer(str, len, OCI_STRING_NULL, + OCI_STRING_NULL_SIZE, FALSE); + } + + CHECK(NULL == err || OCI_UNKNOWN == err->type) } - if (OCI_STATUS && i < n) + if (i < count) { - len += OCI_StringAddToBuffer(str, len, OTEXT(", "), 2, FALSE); + len += StringAddToBuffer(str, len, OTEXT(", "), 2, FALSE); } } - if (OCI_STATUS) - { - len += OCI_StringAddToBuffer(str, len, OTEXT(")"), 1, FALSE); + len += StringAddToBuffer(str, len, OTEXT(")"), 1, FALSE); - *size = len; - } - else - { - *size = 0; + *size = len; - if (str) - { - *str = 0; - } - } + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + *size = 0; - OCI_CALL_EXIT() + if (NULL != str) + { + *str = 0; + } + } + ) } diff --git a/src/collection.h b/src/collection.h new file mode 100644 index 00000000..40258c37 --- /dev/null +++ b/src/collection.h @@ -0,0 +1,137 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_COLLECTION_H_INCLUDED +#define OCILIB_COLLECTION_H_INCLUDED + +#include "types.h" + +OCI_Coll * CollectionInitialize +( + OCI_Connection *con, + OCI_Coll *Coll, + void *handle, + OCI_TypeInfo *typeinf +); + +OCI_Coll* CollectionCreate +( + OCI_TypeInfo* typinf +); + +boolean CollectionFree +( + OCI_Coll* coll +); + +OCI_Coll** CollectionCreateArray +( + OCI_Connection* con, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +boolean CollectionFreeArray +( + OCI_Coll** colls +); + +boolean CollectionAssign +( + OCI_Coll* coll, + OCI_Coll* coll_src +); + +boolean CollectionTrim +( + OCI_Coll * coll, + unsigned int nb_elem +); + +boolean CollectionClear +( + OCI_Coll* coll +); + +unsigned int CollectionGetType +( + OCI_Coll* coll +); + +unsigned int CollectionGetMax +( + OCI_Coll* coll +); + +unsigned int CollectionGetSize +( + OCI_Coll* coll +); + +unsigned int CollectionGetCount +( + OCI_Coll* coll +); + +OCI_Elem* CollectionGetElement +( + OCI_Coll * coll, + unsigned int index +); + +boolean CollectionGetElement2 +( + OCI_Coll * coll, + unsigned int index, + OCI_Elem * elem +); + +boolean CollectionSetElement +( + OCI_Coll * coll, + unsigned int index, + OCI_Elem * elem +); + +boolean CollectionAddElement +( + OCI_Coll* coll, + OCI_Elem* elem +); + +boolean CollectionRemoveElement +( + OCI_Coll * coll, + unsigned int index +); + +OCI_TypeInfo* CollectionGetTypeInfo +( + OCI_Coll* coll +); + +boolean CollectionToString +( + OCI_Coll * coll, + unsigned int* size, + otext * str +); + +#endif /* OCILIB_COLLECTION_H_INCLUDED */ \ No newline at end of file diff --git a/src/column.c b/src/column.c index 609ce33b..54fb52d8 100644 --- a/src/column.c +++ b/src/column.c @@ -18,30 +18,39 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "column.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "connection.h" +#include "macros.h" +#include "object.h" +#include "strings.h" +#include "typeinfo.h" /* --------------------------------------------------------------------------------------------- * -* OCI_ColumnGetAttrInfo +* ColumnGetAttrInfo * --------------------------------------------------------------------------------------------- */ -boolean OCI_ColumnGetAttrInfo +boolean ColumnGetAttributeInfo ( - OCI_Column *col, - unsigned int count, - unsigned int index, - size_t *p_size, - size_t *p_align + OCI_Column *col, + unsigned int count, + unsigned int index, + size_t *p_size, + size_t *p_align ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) + if (index >= count) { *p_size = 0; - - return FALSE; + JUMP_EXIT() } switch (col->datatype) @@ -65,7 +74,7 @@ boolean OCI_ColumnGetAttrInfo } else if (type & OCI_NUM_BIGUINT) { - *p_size = sizeof(big_int); + *p_size = sizeof(big_int); } else if (type & OCI_NUM_DOUBLE) { @@ -87,7 +96,7 @@ boolean OCI_ColumnGetAttrInfo } case OCI_CDT_OBJECT: { - OCI_ObjectGetUserStructSize(col->typinf, p_size, p_align); + ObjectGetUserStructSize(col->typinf, p_size, p_align); break; } default: @@ -98,14 +107,16 @@ boolean OCI_ColumnGetAttrInfo } } - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnDescribe + * ColumnRetrieveInfo * --------------------------------------------------------------------------------------------- */ -boolean OCI_ColumnDescribe +boolean ColumnRetrieveInfo ( OCI_Column *col, OCI_Connection *con, @@ -115,34 +126,47 @@ boolean OCI_ColumnDescribe int ptype ) { - void *param = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ (stmt ? OCI_IPC_STATEMENT : OCI_IPC_CONNECTION), (stmt ? (void*) stmt : (void*) con) + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) + void *param = NULL; - if (stmt) - { - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt); - } - else - { - OCI_CALL_CONTEXT_SET_FROM_CONN(con); - } + CHECK_PTR(OCI_IPC_COLUMN, col) /* get descriptor */ if (OCI_DESC_COLLECTION == ptype) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_COLLECTION_ELEMENT, handle, ¶m, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_COLLECTION_ELEMENT, + handle, ¶m, NULL, + con->err + ) } else { const ub4 htype = (OCI_DESC_RESULTSET == ptype) ? OCI_HTYPE_STMT : OCI_DTYPE_PARAM; - OCI_EXEC(OCIParamGet((dvoid *) handle, htype, con->err, (void**) ¶m, (ub4) index)) + CHECK_OCI + ( + con->err, + OCIParamGet, + (dvoid *) handle, htype, con->err, + (void**) ¶m, (ub4) index + ) } /* sql code */ - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_DATA_TYPE, param, &col->sqlcode, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_DATA_TYPE, + param, &col->sqlcode, NULL, + con->err + ) /* when the column is a record from a PL/SQL table, OCI returns an undocumented SQLT code */ @@ -157,11 +181,21 @@ boolean OCI_ColumnDescribe /* size */ - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_DATA_SIZE, param, &col->size, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_DATA_SIZE, + param, &col->size, NULL, + con->err + ) /* scale */ - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_SCALE, param, &col->scale, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_SCALE, + param, &col->scale, NULL, + con->err + ) /* precision */ @@ -169,7 +203,12 @@ boolean OCI_ColumnDescribe { sb2 prec = 0; - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_PRECISION, param, &prec, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_PRECISION, + param, &prec, NULL, + con->err + ) col->prec = (sb2) prec; } @@ -177,34 +216,54 @@ boolean OCI_ColumnDescribe { ub1 prec = 0; - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_PRECISION, param, &prec, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_PRECISION, + param, &prec, NULL, + con->err + ) col->prec = (sb2) prec; } /* charset form */ - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_CHARSET_FORM, param, &col->csfrm, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_CHARSET_FORM, + param, &col->csfrm, NULL, + con->err + ) /* type of column length for string based column */ #if OCI_VERSION_COMPILE >= OCI_9_2 - if (OCI_ConnectionIsVersionSupported(con, OCI_9_2)) + if (ConnectionIsVersionSupported(con, OCI_9_2)) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_CHAR_USED, param, &col->charused, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_CHAR_USED, + param, &col->charused, NULL, + con->err + ) } /* char size */ if (col->charused) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_CHAR_SIZE, param, &col->charsize, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_CHAR_SIZE, + param, &col->charsize, NULL, + con->err + ) } #endif - if (OCI_ConnectionIsVersionSupported(con, OCI_9_0)) + if (ConnectionIsVersionSupported(con, OCI_9_0)) { /* fractional time precision for timestamps */ @@ -212,25 +271,46 @@ boolean OCI_ColumnDescribe SQLT_TIMESTAMP_TZ == col->sqlcode || SQLT_TIMESTAMP_LTZ == col->sqlcode ) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_FSPRECISION, param, &col->prec, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_FSPRECISION, + param, &col->prec, NULL, + con->err + ) } /* leading and fractional precision for interval */ if (SQLT_INTERVAL_DS == col->sqlcode || SQLT_INTERVAL_YM == col->sqlcode) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_LFPRECISION, param, &col->prec, NULL) - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_FSPRECISION, param, &col->prec2, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_LFPRECISION, + param, &col->prec, NULL, + con->err + ) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_FSPRECISION, + param, &col->prec2, NULL, + con->err + ) } } #if OCI_VERSION_COMPILE >= OCI_12_2 - if (OCI_ConnectionIsVersionSupported(con, OCI_12_2)) + if (ConnectionIsVersionSupported(con, OCI_12_2)) { if (OCI_DESC_RESULTSET == ptype) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_COLLATION_ID, param, &col->collation_id, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_COLLATION_ID, + param, &col->collation_id, NULL, + con->err + ) } } @@ -238,13 +318,18 @@ boolean OCI_ColumnDescribe #if OCI_VERSION_COMPILE >= OCI_12_1 - if (OCI_ConnectionIsVersionSupported(con, OCI_12_1)) + if (ConnectionIsVersionSupported(con, OCI_12_1)) { if (ptype < OCI_DESC_TYPE) { ub8 value = 0; - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_COL_PROPERTIES, param, &value, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_COL_PROPERTIES, + param, &value, NULL, + con->err + ) if (value & OCI_ATTR_COL_PROPERTY_IS_IDENTITY) { @@ -261,7 +346,7 @@ boolean OCI_ColumnDescribe col->props |= OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL; } - #if OCI_VERSION_COMPILE >= OCI_18_1 + #if OCI_VERSION_COMPILE >= OCI_18_1 if (value & OCI_ATTR_COL_PROPERTY_IS_LPART) { @@ -273,7 +358,7 @@ boolean OCI_ColumnDescribe col->props |= OCI_CPF_IS_CONID; } - #endif + #endif } } @@ -283,7 +368,12 @@ boolean OCI_ColumnDescribe if (ptype < OCI_DESC_TYPE) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_IS_NULL, param, &col->nullable, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_IS_NULL, + param, &col->nullable, NULL, + con->err + ) } else { @@ -292,50 +382,49 @@ boolean OCI_ColumnDescribe /* name */ - if (OCI_STATUS) - { - #if defined(OCI_CHARSET_WIDE) - // Ugly workaround for Oracle Bug 9838993 + /* Ugly workaround for Oracle Bug 9838993 */ - if ((OCI_DESC_RESULTSET == ptype) && (OCILib.env_vars[OCI_VARS_WORKAROUND_UTF16_COLUMN_NAME])) - { - OCIParamStruct *param_struct = (OCIParamStruct*) param; + if ((OCI_DESC_RESULTSET == ptype) && (Env.env_vars[OCI_VARS_WORKAROUND_UTF16_COLUMN_NAME])) + { + OCIParamStruct *param_struct = (OCIParamStruct*) param; - if (param_struct && param_struct->column_info && param_struct->column_info->name && (param_struct->column_info->attributes[1] != 0)) - { - size_t char_count = param_struct->column_info->attributes[1]; + if (param_struct && param_struct->column_info && param_struct->column_info->name && + (param_struct->column_info->attributes[1] != 0)) + { + const size_t char_count = param_struct->column_info->attributes[1]; - OCI_ALLOCATE_DATA(OCI_IPC_STRING, col->name, char_count + 1) + ALLOC_DATA(OCI_IPC_STRING, col->name, char_count + 1) - if (OCI_STATUS) - { - OCI_StringAnsiToNative(param_struct->column_info->name, col->name, (int) char_count); - } - } - else - { - OCI_STATUS = FALSE; - } + StringAnsiToNative(param_struct->column_info->name, col->name, (int) char_count); } else + { + CHECK(FALSE) + } + } + else #endif - { - int dbsize = 0; - dbtext *dbstr = NULL; - const ub4 attrname = (OCI_DESC_COLLECTION == ptype) ? OCI_ATTR_TYPE_NAME : OCI_ATTR_NAME; + { + int dbsize = 0; + dbtext *dbstr = NULL; + const ub4 attrname = (OCI_DESC_COLLECTION == ptype) ? OCI_ATTR_TYPE_NAME : OCI_ATTR_NAME; - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, attrname, param, &dbstr, &dbsize) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, attrname, + param, &dbstr, &dbsize, + con->err + ) - if (OCI_STATUS && dbstr) - { - col->name = OCI_StringDuplicateFromOracleString(dbstr, dbcharcount(dbsize)); + if (dbstr) + { + col->name = StringDuplicateFromDBString(dbstr, dbcharcount(dbsize)); - OCI_STATUS = (NULL != col->name); - } + CHECK_NULL(col->name) } } @@ -348,93 +437,112 @@ boolean OCI_ColumnDescribe || SQLT_REC == col->sqlcode || SQLT_TAB == col->sqlcode #endif - ) + ) { - dbtext *dbstr_name = NULL; - dbtext *dbstr_schema = NULL; - dbtext *dbstr_package = NULL; - int dbsize_name = 0; - int dbsize_schema = 0; - int dbsize_package = 0; - - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_TYPE_NAME, param, &dbstr_name, &dbsize_name) - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_SCHEMA_NAME, param, &dbstr_schema, &dbsize_schema) - - #if OCI_VERSION_COMPILE >= OCI_12_1 + dbtext *dbstr_name = NULL; + dbtext *dbstr_schema = NULL; + dbtext *dbstr_package = NULL; + int dbsize_name = 0; + int dbsize_schema = 0; + int dbsize_package = 0; + + otext schema_name[OCI_SIZE_OBJ_NAME + 1] = OTEXT(""); + otext package_name[OCI_SIZE_OBJ_NAME + 1] = OTEXT(""); + otext type_name[OCI_SIZE_OBJ_NAME + 1] = OTEXT(""); + otext full_name[(OCI_SIZE_OBJ_NAME * 3) + 3] = OTEXT(""); + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_TYPE_NAME, + param, &dbstr_name, &dbsize_name, + con->err + ) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_SCHEMA_NAME, + param, &dbstr_schema, &dbsize_schema, + con->err + ) +#if OCI_VERSION_COMPILE >= OCI_12_1 if (SQLT_REC == col->sqlcode || SQLT_TAB == col->sqlcode) { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_PACKAGE_NAME, handle, &dbstr_package, &dbsize_package) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_PACKAGE_NAME, + handle, &dbstr_package, &dbsize_package, + con->err + ) } - #endif +#endif + /* Retrieve correct schema name */ - if (OCI_STATUS) + if (NULL != dbstr_schema && (dbsize_schema > 0)) { - otext schema_name[OCI_SIZE_OBJ_NAME + 1] = OTEXT(""); - otext package_name[OCI_SIZE_OBJ_NAME + 1] = OTEXT(""); - otext type_name[OCI_SIZE_OBJ_NAME + 1] = OTEXT(""); - otext full_name[(OCI_SIZE_OBJ_NAME * 3) + 3] = OTEXT(""); - - /* Retrieve correct schema name */ + StringOracleToNative(dbstr_schema, schema_name, dbcharcount(dbsize_schema)); - if (dbstr_schema && (dbsize_schema > 0)) + if (0 == ostrcasecmp(schema_name, OTEXT("PUBLIC"))) { - OCI_StringOracleToNative(dbstr_schema, schema_name, dbcharcount(dbsize_schema)); - - if (0 == ostrcasecmp(schema_name, OTEXT("PUBLIC"))) - { - schema_name[0] = 0; - } + schema_name[0] = 0; } + } - /* Retrieve correct type name */ - - if (dbstr_package && (dbsize_package > 0)) - { - OCI_StringOracleToNative(dbstr_package, package_name, dbcharcount(dbsize_package)); - } + /* Retrieve correct type name */ - /* Retrieve correct type name */ + if (NULL != dbstr_package && (dbsize_package > 0)) + { + StringOracleToNative(dbstr_package, package_name, dbcharcount(dbsize_package)); + } - if (dbstr_name && (dbsize_name > 0)) - { - OCI_StringOracleToNative(dbstr_name, type_name, dbcharcount(dbsize_name)); - } + /* Retrieve correct type name */ - /* Format full type name respecting case sensitivity if needed in order to not fail type info retrieval.*/ + if (NULL != dbstr_name && (dbsize_name > 0)) + { + StringOracleToNative(dbstr_name, type_name, dbcharcount(dbsize_name)); + } - OCI_StringGetFullTypeName(schema_name, package_name, type_name, NULL, full_name, (sizeof(full_name) / sizeof(otext)) - 1); + /* Format full type name respecting case sensitivity if needed in order to not fail type + * info retrieval.*/ - col->typinf = OCI_TypeInfoGet(con, full_name, OCI_TIF_TYPE); + StringGetFullTypeName(schema_name, package_name, type_name, NULL, full_name, (sizeof(full_name) / sizeof(otext)) - 1); - OCI_STATUS = (NULL != col->typinf); - } + col->typinf = TypeInfoGet(con, full_name, OCI_TIF_TYPE); + CHECK_NULL(col->typinf); } - if (param) - { - OCI_STATUS = (OCI_SUCCESS == OCIDescriptorFree(param, OCI_DTYPE_PARAM) && OCI_STATUS); - } + SET_SUCCESS() - return OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != param) + { + OCIDescriptorFree(param, OCI_DTYPE_PARAM); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnMap + * ColumnMap * --------------------------------------------------------------------------------------------- */ -boolean OCI_ColumnMap +boolean ColumnMapInfo ( OCI_Column *col, OCI_Statement *stmt ) { - const ub2 char_size = (ub2) ( (OCILib.nls_utf8 ) ? OCI_UTF8_BYTES_PER_CHAR : sizeof(otext) ); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLUMN, col + ) - OCI_CHECK(NULL == col, FALSE) + const ub2 char_size = (ub2) ( (Env.nls_utf8 ) ? OCI_UTF8_BYTES_PER_CHAR : sizeof(otext) ); + + CHECK_PTR(OCI_IPC_COLUMN, col) /* map Oracle SQL code to OCILIB types and setup of internal buffer size */ @@ -450,6 +558,7 @@ boolean OCI_ColumnMap { col->datatype = OCI_CDT_NUMERIC; col->libcode = SQLT_INT; + /* set buffer size only if it's not a "returning into" placeholder */ if (0 == col->bufsize) @@ -499,7 +608,7 @@ boolean OCI_ColumnMap break; } - #if OCI_VERSION_COMPILE >= OCI_12_1 +#if OCI_VERSION_COMPILE >= OCI_12_1 case SQLT_BOL: @@ -516,9 +625,9 @@ boolean OCI_ColumnMap break; } - #endif +#endif - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 case SQLT_BFLOAT: case SQLT_IBFLOAT: @@ -535,9 +644,9 @@ boolean OCI_ColumnMap break; } - #endif +#endif - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 case SQLT_BDOUBLE: case SQLT_IBDOUBLE: @@ -554,7 +663,7 @@ boolean OCI_ColumnMap break; } - #endif +#endif case SQLT_DAT: case SQLT_ODT: @@ -689,7 +798,7 @@ boolean OCI_ColumnMap break; } - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 case SQLT_TIMESTAMP: { @@ -732,13 +841,13 @@ boolean OCI_ColumnMap break; } - #endif +#endif - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 case SQLT_PNTY: - #endif +#endif case SQLT_NTY: { @@ -755,7 +864,7 @@ boolean OCI_ColumnMap break; } - #if OCI_VERSION_COMPILE >= OCI_12_1 +#if OCI_VERSION_COMPILE >= OCI_12_1 case SQLT_REC: { @@ -765,7 +874,7 @@ boolean OCI_ColumnMap break; } - #endif +#endif case SQLT_CHR: case SQLT_STR: @@ -785,73 +894,94 @@ boolean OCI_ColumnMap } } - return TRUE; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetName + * ColumnGetName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_ColumnGetName +const otext * ColumnGetName ( OCI_Column *col ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_COLUMN, col, name, NULL, NULL, NULL) + GET_PROP + ( + /* result */ const otext *, NULL, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ name + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetType + * ColumnGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetType +unsigned int ColumnGetType ( OCI_Column *col ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_COLUMN, col, datatype, NULL, NULL, NULL) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ datatype + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetCharsetForm + * ColumnGetCharsetForm * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetCharsetForm +unsigned int ColumnGetCharsetForm ( OCI_Column *col ) { - OCI_CALL_ENTER(unsigned int, OCI_CSF_NONE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_CSF_NONE, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) + + unsigned int charset_form = OCI_CSF_NONE; if (SQLCS_NCHAR == col->csfrm) { - OCI_RETVAL = OCI_CSF_NATIONAL; + charset_form = OCI_CSF_NATIONAL; } else if (SQLCS_IMPLICIT == col->csfrm) { - OCI_RETVAL = OCI_CSF_DEFAULT; + charset_form = OCI_CSF_DEFAULT; } - OCI_CALL_EXIT() + SET_RETVAL(charset_form) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetSize + * ColumnGetSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetSize +unsigned int ColumnGetSize ( OCI_Column *col ) { - OCI_CALL_ENTER(unsigned int, 0) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_COLUMN, col + ) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + CHECK_PTR(OCI_IPC_COLUMN, col) /* Oracle 9i introduced CHAR attribute on string columns to indicate the size of the column is not in bytes (default) but in chars @@ -861,146 +991,196 @@ unsigned int OCI_API OCI_ColumnGetSize - the size is not in char - client does not support the OCI_ATTR_CHAR_SIZE attribute */ - OCI_RETVAL = (col->charused && col->charsize > 0) ? col->charsize : col->size; + SET_RETVAL((col->charused && col->charsize > 0) ? col->charsize : col->size) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetScale + * ColumnGetScale * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ColumnGetScale +int ColumnGetScale ( OCI_Column *col ) { - OCI_GET_PROP(int, 0, OCI_IPC_COLUMN, col, scale, NULL, NULL, NULL) + GET_PROP + ( + /* result */ int, 0, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ scale + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetPrecision + * ColumnGetPrecision * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ColumnGetPrecision +int ColumnGetPrecision ( OCI_Column *col ) { - OCI_CALL_ENTER(int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) - OCI_RETVAL = (OCI_CDT_NUMERIC == col->datatype) ? (int) col->prec : 0; + SET_RETVAL((OCI_CDT_NUMERIC == col->datatype) ? (int) col->prec : 0) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetFractionalPrecision + * ColumnGetFractionalPrecision * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ColumnGetFractionalPrecision +int ColumnGetFractionalPrecision ( OCI_Column *col ) { - OCI_CALL_ENTER(int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) + + int precision = 0; if (OCI_CDT_TIMESTAMP == col->datatype) { - OCI_RETVAL = (int) col->prec; + precision = (int) col->prec; } else if (OCI_CDT_INTERVAL == col->datatype) { - OCI_RETVAL = (int)col->prec2; + precision = (int)col->prec2; } - OCI_CALL_EXIT() + SET_RETVAL(precision) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetLeadingPrecision + * ColumnGetLeadingPrecision * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ColumnGetLeadingPrecision +int ColumnGetLeadingPrecision ( OCI_Column *col ) { - OCI_CALL_ENTER(int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) - OCI_RETVAL = (OCI_CDT_INTERVAL == col->datatype) ? (int) col->prec : 0; - OCI_STATUS = TRUE; + SET_RETVAL((OCI_CDT_INTERVAL == col->datatype) ? (int) col->prec : 0) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetNullable + * ColumnGetNullable * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ColumnGetNullable +boolean ColumnGetNullable ( OCI_Column *col ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) - OCI_RETVAL = (1 == col->nullable); + SET_RETVAL(1 == col->nullable) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetCharUsed + * ColumnGetCharUsed * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ColumnGetCharUsed +boolean ColumnGetCharUsed ( OCI_Column *col ) { - OCI_GET_PROP(boolean, FALSE, OCI_IPC_COLUMN, col, charused, NULL, NULL, NULL) + GET_PROP + ( + /* result */ boolean, FALSE, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ charused + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetPropertyFlags + * ColumnGetPropertyFlags * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetPropertyFlags +unsigned int ColumnGetPropertyFlags ( OCI_Column *col ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_COLUMN, col, props, NULL, NULL, NULL) + GET_PROP + ( + /* result */ unsigned int, 0, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ props + ) } /* --------------------------------------------------------------------------------------------- * * OCI_ColumnGetCollationID * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetCollationID +unsigned int ColumnGetCollationID ( OCI_Column *col ) { - OCI_GET_PROP(unsigned int, OCI_CCI_NONE, OCI_IPC_COLUMN, col, collation_id, NULL, NULL, NULL) + GET_PROP + ( + /* result */ unsigned int, OCI_CCI_NONE, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ collation_id + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetSQLType + * ColumnGetSQLType * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_ColumnGetSQLType +const otext * ColumnGetSqlType ( OCI_Column *col ) { - OCI_CALL_ENTER(const otext*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) + + const otext *type = NULL; /* VARCHAR type will not be returned because Oracle does not make any difference with VARCHAR2. If a column is created with VARCHAR, it is @@ -1011,188 +1191,186 @@ const otext * OCI_API OCI_ColumnGetSQLType { case SQLT_AFC: { - OCI_RETVAL = (SQLCS_NCHAR == col->csfrm) ? OTEXT("NCHAR") : OTEXT("CHAR");; + type = (SQLCS_NCHAR == col->csfrm) ? OTEXT("NCHAR") : OTEXT("CHAR");; break; } case SQLT_AVC: case SQLT_STR: case SQLT_CHR: { - OCI_RETVAL = (SQLCS_NCHAR == col->csfrm) ? OTEXT("NVARCHAR2") : OTEXT("VARCHAR2"); - break; + type = (SQLCS_NCHAR == col->csfrm) ? OTEXT("NVARCHAR2") : OTEXT("VARCHAR2"); + break; } case SQLT_NUM: { - OCI_RETVAL = (SCALE_FLOAT == col->scale && col->prec > 0) ? OTEXT("FLOAT") : OTEXT("NUMBER"); + type = (SCALE_FLOAT == col->scale && col->prec > 0) ? OTEXT("FLOAT") : OTEXT("NUMBER"); break; } case SQLT_INT: { - OCI_RETVAL = OTEXT("INTEGER"); + type = OTEXT("INTEGER"); break; } case SQLT_FLT: { - OCI_RETVAL = OTEXT("FLOAT"); + type = OTEXT("FLOAT"); break; } - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 case SQLT_BFLOAT: case SQLT_IBFLOAT: { - OCI_RETVAL = OTEXT("BINARY FLOAT"); + type = OTEXT("BINARY FLOAT"); break; } case SQLT_BDOUBLE: case SQLT_IBDOUBLE: { - OCI_RETVAL = OTEXT("BINARY DOUBLE"); + type = OTEXT("BINARY DOUBLE"); break; } - #endif +#endif case SQLT_LNG: { - OCI_RETVAL = OTEXT("LONG"); + type = OTEXT("LONG"); break; } case SQLT_DAT: case SQLT_ODT: case SQLT_DATE: { - OCI_RETVAL = OTEXT("DATE"); + type = OTEXT("DATE"); break; } case SQLT_RDD: case SQLT_RID: { - OCI_RETVAL = OTEXT("ROWID"); + type = OTEXT("ROWID"); break; } case SQLT_BIN: { - OCI_RETVAL = OTEXT("RAW"); + type = OTEXT("RAW"); break; } case SQLT_LBI: { - OCI_RETVAL = OTEXT("LONG RAW"); + type = OTEXT("LONG RAW"); break; } case SQLT_RSET: { - OCI_RETVAL = OTEXT("RESULTSET"); + type = OTEXT("RESULTSET"); break; } case SQLT_CUR: { - OCI_RETVAL = OTEXT("CURSOR"); + type = OTEXT("CURSOR"); break; } case SQLT_CLOB: { - OCI_RETVAL = (col->subtype == OCI_NCLOB) ? OTEXT("NCLOB") : OTEXT("CLOB"); + type = (col->subtype == OCI_NCLOB) ? OTEXT("NCLOB") : OTEXT("CLOB"); break; } case SQLT_BLOB: { - OCI_RETVAL = OTEXT("BLOB"); + type = OTEXT("BLOB"); break; } case SQLT_BFILE: { - OCI_RETVAL = OTEXT("BINARY FILE LOB"); + type = OTEXT("BINARY FILE LOB"); break; } case SQLT_CFILE: { - OCI_RETVAL = OTEXT("CFILE"); + type = OTEXT("CFILE"); break; } - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 case SQLT_TIMESTAMP: { - OCI_RETVAL = OTEXT("TIMESTAMP"); + type = OTEXT("TIMESTAMP"); break; } case SQLT_TIMESTAMP_TZ: { - OCI_RETVAL = OTEXT("TIMESTAMP WITH TIME ZONE"); + type = OTEXT("TIMESTAMP WITH TIME ZONE"); break; } case SQLT_TIMESTAMP_LTZ: { - OCI_RETVAL = OTEXT("TIMESTAMP WITH LOCAL TIME ZONE"); + type = OTEXT("TIMESTAMP WITH LOCAL TIME ZONE"); break; } case SQLT_INTERVAL_YM: { - OCI_RETVAL = OTEXT("INTERVAL YEAR TO MONTH"); + type = OTEXT("INTERVAL YEAR TO MONTH"); break; } case SQLT_INTERVAL_DS: { - OCI_RETVAL = OTEXT("INTERVAL DAY TO SECOND"); + type = OTEXT("INTERVAL DAY TO SECOND"); break; } - #endif +#endif case SQLT_REF: { - OCI_RETVAL = OTEXT("REF"); + type = OTEXT("REF"); break; } - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 case SQLT_PNTY: - #endif +#endif case SQLT_NTY: { - OCI_RETVAL = col->typinf ? col->typinf->name : OTEXT("NAMED TYPE"); + type = col->typinf ? col->typinf->name : OTEXT("NAMED TYPE"); break; } - - #if OCI_VERSION_COMPILE >= OCI_12_1 case SQLT_BOL: { - OCI_RETVAL = OTEXT("PL/SQL BOOLEAN"); + type = OTEXT("PL/SQL BOOLEAN"); break; } case SQLT_REC: case SQLT_UNDOCUMENTED_REC: { - OCI_RETVAL = col->typinf ? col->typinf->name : OTEXT("PL/SQL RECORD"); + type = col->typinf ? col->typinf->name : OTEXT("PL/SQL RECORD"); break; } case SQLT_TAB: { - OCI_RETVAL = col->typinf ? col->typinf->name : OTEXT("PL/SQL TABLE INDEX BY"); + type = col->typinf ? col->typinf->name : OTEXT("PL/SQL TABLE INDEX BY"); break; } case SQLT_UNDOCUMENTED_BIN_INTEGER: { - OCI_RETVAL = OTEXT("PL/SQL BINARY INTEGER"); + type = OTEXT("PL/SQL BINARY INTEGER"); break; } case OCI_TYPECODE_PLS_INTEGER: { - OCI_RETVAL = OTEXT("PL/SQL INTEGER"); + type = OTEXT("PL/SQL INTEGER"); break; } @@ -1203,31 +1381,39 @@ const otext * OCI_API OCI_ColumnGetSQLType /* unknown data type ? Should not happen because all data types are supported */ - OCI_RETVAL = OTEXT("?"); + type = OTEXT("?"); } } - OCI_CALL_EXIT() + SET_RETVAL(type) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetFullSQLType + * ColumnGetFullSQLType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetFullSQLType +unsigned int ColumnGetFullSqlType ( OCI_Column *col, otext *buffer, unsigned int len ) { - OCI_CALL_ENTER(unsigned int, 0) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_COLUMN, col + ) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, buffer) + CHECK_PTR(OCI_IPC_COLUMN, col) + CHECK_PTR(OCI_IPC_STRING, buffer) buffer[0] = 0; + unsigned int size = 0; + /* ISO C functions are supposed to be "standard", but we still see specific implementations that make some usage not portable and worse not compatible. MS Windows is implementing string conversion tokens (%s/%ls) of the standard @@ -1241,11 +1427,11 @@ unsigned int OCI_API OCI_ColumnGetFullSQLType case SQLT_AFC: { - #if defined(OCI_CHARSET_WIDE) && !defined(_WINDOWS) - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("%lsCHAR(%i%ls)"), - #else - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("%sCHAR(%i%s)"), - #endif +#if defined(OCI_CHARSET_WIDE) && !defined(_WINDOWS) + size = osprintf(buffer, (int)len, OTEXT("%lsCHAR(%i%ls)"), +#else + size = osprintf(buffer, (int)len, OTEXT("%sCHAR(%i%s)"), +#endif SQLCS_NCHAR == col->csfrm ? OTEXT("N") : OTEXT(""), (int) (col->charused ? col->charsize : col->size), col->charused && SQLCS_NCHAR != col->csfrm ? OTEXT(" CHAR") : OTEXT("")); @@ -1255,215 +1441,214 @@ unsigned int OCI_API OCI_ColumnGetFullSQLType case SQLT_STR: case SQLT_CHR: { - #if defined(OCI_CHARSET_WIDE) && !defined(_WINDOWS) +#if defined(OCI_CHARSET_WIDE) && !defined(_WINDOWS) const otext *fmt = OTEXT("%lsVARCHAR(%i%ls)"); - #else +#else const otext *fmt = OTEXT("%sVARCHAR(%i%s)"); - #endif +#endif - OCI_RETVAL = osprintf(buffer, (int)len, fmt, SQLCS_NCHAR == col->csfrm ? OTEXT("N") : OTEXT(""), - (int) (col->charused ? col->charsize : col->size), - col->charused && SQLCS_NCHAR != col->csfrm ? OTEXT(" CHAR") : OTEXT("")); + size = osprintf(buffer, (int)len, fmt, SQLCS_NCHAR == col->csfrm ? OTEXT("N") : OTEXT(""), + (int) (col->charused ? col->charsize : col->size), + col->charused && SQLCS_NCHAR != col->csfrm ? OTEXT(" CHAR") : OTEXT("")); break; } case SQLT_NUM: { if (SCALE_FLOAT == col->scale && col->prec > 0) { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("FLOAT(%i)"), col->prec); + size = osprintf(buffer, (int)len, OTEXT("FLOAT(%i)"), col->prec); } else if (col->scale > 0 && col->prec > 0) { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("NUMBER(%i,%i)"), (int) col->prec, (int) col->scale); + size = osprintf(buffer, (int)len, OTEXT("NUMBER(%i,%i)"), (int) col->prec, (int) col->scale); } else if (col->prec > 0) { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("NUMBER(%i)"), (int) col->prec); + size = osprintf(buffer, (int)len, OTEXT("NUMBER(%i)"), (int) col->prec); } else { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("NUMBER")); + size = osprintf(buffer, (int)len, OTEXT("NUMBER")); } break; } case SQLT_INT: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("NUMBER")); + size = osprintf(buffer, (int)len, OTEXT("NUMBER")); break; } case SQLT_FLT: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("FLOAT(%i)"), (int) col->prec); + size = osprintf(buffer, (int)len, OTEXT("FLOAT(%i)"), (int) col->prec); break; } - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 case SQLT_BFLOAT: case SQLT_IBFLOAT: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("BINARY FLOAT")); + size = osprintf(buffer, (int)len, OTEXT("BINARY FLOAT")); break; } case SQLT_BDOUBLE: case SQLT_IBDOUBLE: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("BINARY DOUBLE")); + size = osprintf(buffer, (int)len, OTEXT("BINARY DOUBLE")); break; } - #endif +#endif case SQLT_LNG: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("LONG")); + size = osprintf(buffer, (int)len, OTEXT("LONG")); break; } case SQLT_DAT: case SQLT_ODT: case SQLT_DATE: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("DATE")); + size = osprintf(buffer, (int)len, OTEXT("DATE")); break; } case SQLT_RDD: case SQLT_RID: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("ROWID")); + size = osprintf(buffer, (int)len, OTEXT("ROWID")); break; } case SQLT_BIN: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("RAW(%i)"), (int) col->size); + size = osprintf(buffer, (int)len, OTEXT("RAW(%i)"), (int) col->size); break; } case SQLT_LBI: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("LONG RAW(%i)"), (int) col->size); + size = osprintf(buffer, (int)len, OTEXT("LONG RAW(%i)"), (int) col->size); break; } case SQLT_RSET: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("RESULTSET")); + size = osprintf(buffer, (int)len, OTEXT("RESULTSET")); break; } case SQLT_CUR: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("CURSOR")); + size = osprintf(buffer, (int)len, OTEXT("CURSOR")); break; } case SQLT_CLOB: { - OCI_RETVAL = osprintf(buffer, (int)len, (col->subtype == OCI_NCLOB) ? OTEXT("NCLOB") : OTEXT("CLOB")); + size = osprintf(buffer, (int)len, (col->subtype == OCI_NCLOB) ? OTEXT("NCLOB") : OTEXT("CLOB")); break; } case SQLT_BLOB: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("BLOB")); + size = osprintf(buffer, (int)len, OTEXT("BLOB")); break; } case SQLT_BFILE: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("BINARY FILE LOB")); + size = osprintf(buffer, (int)len, OTEXT("BINARY FILE LOB")); break; } case SQLT_CFILE: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("CFILE")); + size = osprintf(buffer, (int)len, OTEXT("CFILE")); break; } - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 case SQLT_TIMESTAMP: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("TIMESTAMP(%i)"), (int) col->prec); + size = osprintf(buffer, (int)len, OTEXT("TIMESTAMP(%i)"), (int) col->prec); break; } case SQLT_TIMESTAMP_TZ: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("TIMESTAMP(%i) WITH TIME ZONE"), (int) col->prec); + size = osprintf(buffer, (int)len, OTEXT("TIMESTAMP(%i) WITH TIME ZONE"), (int) col->prec); break; } case SQLT_TIMESTAMP_LTZ: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("TIMESTAMP(%i) WITH LOCAL TIME ZONE"), (int) col->prec); + size = osprintf(buffer, (int)len, OTEXT("TIMESTAMP(%i) WITH LOCAL TIME ZONE"), (int) col->prec); break; } case SQLT_INTERVAL_YM: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("INTERVAL(%i) YEAR TO MONTH(%i)"), - (int) col->prec, (int) col->prec2); + size = osprintf(buffer, (int)len, OTEXT("INTERVAL(%i) YEAR TO MONTH(%i)"), + (int) col->prec, (int) col->prec2); break; } case SQLT_INTERVAL_DS: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("INTERVAL(%i) DAY TO SECOND(%i)"), - (int) col->prec, (int) col->prec2); + size = osprintf(buffer, (int)len, OTEXT("INTERVAL(%i) DAY TO SECOND(%i)"), + (int) col->prec, (int) col->prec2); break; } - #endif +#endif case SQLT_REF: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("REF")); + size = osprintf(buffer, (int)len, OTEXT("REF")); break; } - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 case SQLT_PNTY: - #endif +#endif case SQLT_NTY: { if (col->typinf) { otext fullname[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); - OCI_StringGetFullTypeName(col->typinf->schema, NULL, col->typinf->name, NULL, fullname, (sizeof(fullname) / sizeof(otext)) - 1); - OCI_RETVAL = osprintf(buffer, (int)len, fullname); + StringGetFullTypeName(col->typinf->schema, NULL, col->typinf->name, NULL, fullname, (sizeof(fullname) / sizeof(otext)) - 1); + size = osprintf(buffer, (int)len, fullname); } else { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("NAMED TYPE")); + size = osprintf(buffer, (int)len, OTEXT("NAMED TYPE")); } break; } - #if OCI_VERSION_COMPILE >= OCI_12_1 case SQLT_BOL: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("PL/SQL BOOLEAN")); + size = osprintf(buffer, (int)len, OTEXT("PL/SQL BOOLEAN")); break; } case SQLT_REC: case SQLT_UNDOCUMENTED_REC: { - OCI_RETVAL = osprintf(buffer, (int)len, col->typinf ? col->typinf->name : OTEXT("PL/SQL RECORD")); + size = osprintf(buffer, (int)len, col->typinf ? col->typinf->name : OTEXT("PL/SQL RECORD")); break; } case SQLT_TAB: { - OCI_RETVAL = osprintf(buffer, (int)len, col->typinf ? col->typinf->name : OTEXT("PL/SQL TABLE INDEX BY")); + size = osprintf(buffer, (int)len, col->typinf ? col->typinf->name : OTEXT("PL/SQL TABLE INDEX BY")); break; } case SQLT_UNDOCUMENTED_BIN_INTEGER: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("PL/SQL BINARY INTEGER")); + size = osprintf(buffer, (int)len, OTEXT("PL/SQL BINARY INTEGER")); break; } case OCI_TYPECODE_PLS_INTEGER: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("PL/SQL INTEGER")); + size = osprintf(buffer, (int)len, OTEXT("PL/SQL INTEGER")); break; } @@ -1471,37 +1656,51 @@ unsigned int OCI_API OCI_ColumnGetFullSQLType default: { - OCI_RETVAL = osprintf(buffer, (int)len, OTEXT("?")); - break; + size = osprintf(buffer, (int)len, OTEXT("?")); + break; } } - OCI_CALL_EXIT() + SET_RETVAL(size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetTypeInfo + * ColumnGetTypeInfo * --------------------------------------------------------------------------------------------- */ -OCI_TypeInfo * OCI_API OCI_ColumnGetTypeInfo +OCI_TypeInfo * ColumnGetTypeInfo ( OCI_Column *col ) { - OCI_GET_PROP(OCI_TypeInfo*, NULL, OCI_IPC_COLUMN, col, typinf, NULL, NULL, NULL) + GET_PROP + ( + /* result */ OCI_TypeInfo*, NULL, + /* handle */ OCI_IPC_COLUMN, col, + /* member */ typinf + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ColumnGetSubType + * ColumnGetSubType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ColumnGetSubType +unsigned int ColumnGetSubType ( OCI_Column *col ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_COLUMN, col) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_COLUMN, col + ) + + CHECK_PTR(OCI_IPC_COLUMN, col) + + int subtype =OCI_UNKNOWN; if (OCI_CDT_LONG == col->datatype || OCI_CDT_LOB == col->datatype || @@ -1510,9 +1709,10 @@ unsigned int OCI_API OCI_ColumnGetSubType OCI_CDT_INTERVAL == col->datatype || OCI_CDT_NUMERIC == col->datatype) { - OCI_RETVAL = col->subtype; + subtype = col->subtype; } - OCI_CALL_EXIT() -} + SET_RETVAL(subtype) + EXIT_FUNC() +} diff --git a/src/column.h b/src/column.h new file mode 100644 index 00000000..3ecfe668 --- /dev/null +++ b/src/column.h @@ -0,0 +1,133 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_COLUMN_H_INCLUDED +#define OCILIB_COLUMN_H_INCLUDED + +#include "types.h" + +boolean ColumnGetAttributeInfo +( + OCI_Column *col, + unsigned int count, + unsigned int index, + size_t *p_size, + size_t *p_align +); + +boolean ColumnRetrieveInfo +( + OCI_Column *col, + OCI_Connection *con, + OCI_Statement *stmt, + void *handle, + int index, + int ptype +); + +boolean ColumnMapInfo +( + OCI_Column *col, + OCI_Statement *stmt +); + +const otext* ColumnGetName +( + OCI_Column* col +); + +unsigned int ColumnGetType +( + OCI_Column* col +); + +unsigned int ColumnGetCharsetForm +( + OCI_Column* col +); + +unsigned int ColumnGetSize +( + OCI_Column* col +); + +int ColumnGetScale +( + OCI_Column* col +); + +int ColumnGetPrecision +( + OCI_Column* col +); + +int ColumnGetFractionalPrecision +( + OCI_Column* col +); + +int ColumnGetLeadingPrecision +( + OCI_Column* col +); + +boolean ColumnGetNullable +( + OCI_Column* col +); + +boolean ColumnGetCharUsed +( + OCI_Column* col +); + +unsigned int ColumnGetPropertyFlags +( + OCI_Column* col +); + +unsigned int ColumnGetCollationID +( + OCI_Column* col +); + +const otext* ColumnGetSqlType +( + OCI_Column* col +); + +unsigned int ColumnGetFullSqlType +( + OCI_Column * col, + otext * buffer, + unsigned int len +); + +OCI_TypeInfo* ColumnGetTypeInfo +( + OCI_Column* col +); + +unsigned int ColumnGetSubType +( + OCI_Column* col +); + +#endif /* OCILIB_COLUMN_H_INCLUDED */ diff --git a/src/connection.c b/src/connection.c index a2888eed..d5a0668e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -18,19 +18,27 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ - -static const unsigned int TraceTypeValues[] = -{ - OCI_TRC_IDENTITY, +#include "connection.h" + +#include "bind.h" +#include "callback.h" +#include "error.h" +#include "format.h" +#include "list.h" +#include "macros.h" +#include "statement.h" +#include "strings.h" +#include "timestamp.h" +#include "transaction.h" +#include "typeinfo.h" + +static const unsigned int TraceTypeValues[] = +{ + OCI_TRC_IDENTITY, OCI_TRC_MODULE, - OCI_TRC_ACTION, - OCI_TRC_DETAIL, - OCI_TRC_OPERATION + OCI_TRC_ACTION, + OCI_TRC_DETAIL, + OCI_TRC_OPERATION }; static const unsigned int TimeoutTypeValues[] = @@ -40,28 +48,38 @@ static const unsigned int TimeoutTypeValues[] = OCI_NTO_CALL }; -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -#define OCI_SET_TRACE(prop) \ - con->trace->prop[0] = 0; \ - if (value) \ - { \ - ostrncat(con->trace->prop, value, osizeof(con->trace->prop)-1); \ - str = con->trace->prop; \ +#define SET_TRACE(prop) \ + \ + con->trace->prop[0] = 0; \ + if (value) \ + { \ + ostrncat(con->trace->prop, value, osizeof(con->trace->prop)-1); \ + str = con->trace->prop; \ } -#define OCI_GET_TRACE(prop) \ - OCI_RETVAL = con->trace->prop[0] ? con->trace->prop : NULL; +#define GET_TRACE(prop) \ + \ + value = con->trace->prop[0] ? con->trace->prop : NULL; /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionDetachSubscriptions + * ConnectionDetachSubscriptions * --------------------------------------------------------------------------------------------- */ -void OCI_ConnectionDetachSubscriptions(OCI_Subscription *sub, OCI_Connection *con) +void ConnectionDetachSubscriptions +( + OCI_Subscription *sub, + OCI_Connection *con +) { - if (sub && (sub->con == con)) + ENTER_VOID + ( + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_NOTIFY, sub) + CHECK_PTR(OCI_IPC_CONNECTION, con) + + if (NULL != sub && (sub->con == con)) { sub->con = NULL; @@ -69,13 +87,15 @@ void OCI_ConnectionDetachSubscriptions(OCI_Subscription *sub, OCI_Connection *co sub->saved_user = ostrdup(con->user); sub->saved_pwd = ostrdup(con->pwd); } + + EXIT_VOID() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionAllocate + * ConnectionAllocate * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_ConnectionAllocate +OCI_Connection * ConnectionAllocate ( OCI_Pool *pool, const otext *db, @@ -84,141 +104,145 @@ OCI_Connection * OCI_ConnectionAllocate unsigned int mode ) { - OCI_Connection *con = NULL; - - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ OCI_Connection*, NULL, + /* context */ (pool ? OCI_IPC_POOL : OCI_IPC_VOID), (pool ? (void*)pool : (void*)&Env) + ) /* create connection object */ - con = OCI_ListAppend(OCILib.cons, sizeof(*con)); - OCI_STATUS = (NULL != con); - - if (OCI_STATUS) - { - con->alloc_handles = (0 == (mode & OCI_SESSION_XA)); - - /* create internal lists */ + OCI_Connection *con = ListAppend(Env.cons, sizeof(*con)); + CHECK_NULL(con) - con->stmts = OCI_ListCreate(OCI_IPC_STATEMENT); + con->alloc_handles = (0 == (mode & OCI_SESSION_XA)); - if (OCI_STATUS) - { - con->tinfs = OCI_ListCreate(OCI_IPC_TYPE_INFO); - OCI_STATUS = (NULL != con->tinfs); - } - - if (OCI_STATUS) - { - con->trsns = OCI_ListCreate(OCI_IPC_TRANSACTION); - OCI_STATUS = (NULL != con->trsns); - } + /* create internal lists */ - /* set attributes */ + con->stmts = ListCreate(OCI_IPC_STATEMENT); + CHECK_NULL(con->stmts) - if (OCI_STATUS) - { - con->mode = mode; - con->pool = pool; - con->sess_tag = NULL; + con->tinfs = ListCreate(OCI_IPC_TYPE_INFO); + CHECK_NULL(con->tinfs) - if (con->pool) - { - con->db = (otext *) db; - con->user = (otext *) user; - con->pwd = (otext *) pwd; + con->trsns = ListCreate(OCI_IPC_TRANSACTION); + CHECK_NULL(con->trsns) - #if OCI_VERSION_COMPILE >= OCI_9_2 + /* set attributes */ - if (OCI_HTYPE_SPOOL == con->pool->htype) - { - con->alloc_handles = FALSE; - } + con->mode = mode; + con->pool = pool; + con->sess_tag = NULL; - #endif + if (NULL != con->pool) + { + con->db = (otext *) db; + con->user = (otext *) user; + con->pwd = (otext *) pwd; - } - else - { - con->db = ostrdup(db ? db : OTEXT("")); - con->user = ostrdup(user ? user : OTEXT("")); - con->pwd = ostrdup(pwd ? pwd : OTEXT("")); - } +#if OCI_VERSION_COMPILE >= OCI_9_2 - #if OCI_VERSION_COMPILE >= OCI_10_1 + if (OCI_HTYPE_SPOOL == con->pool->htype) + { + con->alloc_handles = FALSE; + } - if (con->mode & OCI_SESSION_XA) - { - char dbname[OCI_SIZE_BUFFER+1]; +#endif - memset(dbname, 0, sizeof(dbname)); + } + else + { + con->db = ostrdup(db ? db : OTEXT("")); + con->user = ostrdup(user ? user : OTEXT("")); + con->pwd = ostrdup(pwd ? pwd : OTEXT("")); + } - if (OCI_STRING_VALID(con->db)) - { - OCI_StringNativeToAnsi(con->db, dbname, (int) ostrlen(con->db)); - } +#if OCI_VERSION_COMPILE >= OCI_10_1 - con->env = xaoEnv((OraText *) (dbname[0] ? dbname : NULL )); + if (con->mode & OCI_SESSION_XA) + { + char dbname[OCI_SIZE_BUFFER+1]; - if (NULL == con->env) - { - OCI_ExceptionEnvFromXaString(con->db); - } - } - else + memset(dbname, 0, sizeof(dbname)); - #endif + if (IS_STRING_VALID(con->db)) + { + StringNativeToAnsi(con->db, dbname, (int) ostrlen(con->db)); + } - { - con->env = OCILib.env; - } + con->env = xaoEnv((OraText *) (dbname[0] ? dbname : NULL )); - OCI_STATUS = (NULL != con->env); + if (NULL == con->env) + { + THROW(ExceptionEnvFromXaString, con->db) } + } + else - /* allocate error handle */ +#endif - OCI_STATUS = OCI_STATUS && OCI_HandleAlloc((dvoid *)con->env, (dvoid **)(void *)&con->err, OCI_HTYPE_ERROR); + { + con->env = Env.env; } + /* allocate error handle */ + + CHECK + ( + MemoryAllocHandle + ( + (dvoid *)con->env, + (dvoid **)(void *)&con->err, + OCI_HTYPE_ERROR + ) + ) + /* update internal status */ - if (OCI_STATUS && con) - { - con->cstate = OCI_CONN_ALLOCATED; - } - else if (con) - { - OCI_ConnectionFree(con); - con = NULL; - } + con->cstate = OCI_CONN_ALLOCATED; + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ConnectionFree(con); + con = NULL; + } - return con; + SET_RETVAL(con) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionDeallocate + * ConnectionDeallocate * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionDeallocate +boolean ConnectionDeallocate ( OCI_Connection *con ) { - OCI_CHECK(NULL == con, FALSE) - OCI_CHECK(con->cstate != OCI_CONN_ALLOCATED, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_CON_STATUS(con, OCI_CONN_ALLOCATED) /* close error handle */ - if (con->err) + if (NULL != con->err) { - OCI_HandleFree((dvoid *) con->err, OCI_HTYPE_ERROR); + MemoryFreeHandle((dvoid*)con->err, OCI_HTYPE_ERROR); } /* close server handle (if it had been allocated) in case of login error */ - if ((con->svr) && con->alloc_handles) + if (NULL != con->svr && con->alloc_handles) { - OCI_HandleFree((dvoid *) con->svr, OCI_HTYPE_SERVER); + MemoryFreeHandle((dvoid*)con->svr, OCI_HTYPE_SERVER); } con->cxt = NULL; @@ -226,240 +250,307 @@ boolean OCI_ConnectionDeallocate con->svr = NULL; con->err = NULL; - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionAttach + * ConnectionAttach * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionAttach +boolean ConnectionAttach ( OCI_Connection *con ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CHECK(NULL == con, FALSE) - OCI_CHECK(con->cstate != OCI_CONN_ALLOCATED, FALSE) + dbtext* dbstr = NULL; + int dbsize = -1; - OCI_CALL_CONTEXT_SET_FROM_CONN(con); + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_CON_STATUS(con, OCI_CONN_ALLOCATED) /* allocate server handle for non session pooled connection */ if (con->alloc_handles) { - ub4 cmode = OCI_DEFAULT; - dbtext *dbstr = NULL; - int dbsize = -1; + ub4 cmode = OCI_DEFAULT; - OCI_STATUS = OCI_HandleAlloc((dvoid *) con->env, (dvoid **) (void *) &con->svr, OCI_HTYPE_SERVER); + CHECK(MemoryAllocHandle((dvoid *) con->env, (dvoid **) (void *) &con->svr, OCI_HTYPE_SERVER)) /* attach server handle to service name */ - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0 && con->pool) + if (Env.version_runtime >= OCI_9_0 && con->pool) { - dbstr = OCI_StringGetOracleString(con->pool->name, &dbsize); + dbstr = StringGetDBString(con->pool->name, &dbsize); cmode = OCI_CPOOL; } else - #endif +#endif { - dbstr = OCI_StringGetOracleString(con->db, &dbsize); + dbstr = StringGetDBString(con->db, &dbsize); } - OCI_EXEC(OCIServerAttach(con->svr, con->err, (OraText *)dbstr, (sb4)dbsize, cmode)); - - OCI_StringReleaseOracleString(dbstr); + CHECK_OCI + ( + con->err, + OCIServerAttach, + con->svr, con->err, + (OraText *)dbstr, (sb4)dbsize, cmode + ) } - /* handle errors */ + /* update internal status */ - if (OCI_STATUS) - { - con->cstate = OCI_CONN_ATTACHED; - } + con->cstate = OCI_CONN_ATTACHED; + + SET_SUCCESS() - return OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionDetach + * ConnectionDetach * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionDetach +boolean ConnectionDetach ( OCI_Connection *con ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == con, FALSE) - OCI_CHECK(con->cstate != OCI_CONN_ATTACHED, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_CONTEXT_SET_FROM_CONN(con); + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_CON_STATUS(con, OCI_CONN_ATTACHED) - if (con->alloc_handles && con->svr) + if (con->alloc_handles && NULL != con->svr) { /* detach from the oracle server */ - OCI_EXEC(OCIServerDetach(con->svr, con->err, OCI_DEFAULT)); + CHECK_OCI + ( + con->err, + OCIServerDetach, + con->svr, con->err, OCI_DEFAULT + ) /* close server handle */ - OCI_HandleFree((dvoid *) con->svr, OCI_HTYPE_SERVER); + MemoryFreeHandle((dvoid*)con->svr, OCI_HTYPE_SERVER); con->svr = NULL; } /* update internal status */ - if (OCI_STATUS) - { - con->cstate = OCI_CONN_ALLOCATED; - } + con->cstate = OCI_CONN_ALLOCATED; + + SET_SUCCESS() - return OCI_STATUS; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogonXA + * ConnectionLogonXA * --------------------------------------------------------------------------------------------- */ -void OCI_ConnectionLogonXA +boolean ConnectionLogonXA ( - OCI_Context *ctx, OCI_Connection *con ) { - dbtext *dbstr_user = NULL; - int dbsize_user = 0; - char dbname[OCI_SIZE_BUFFER + 1]; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + dbtext *dbstr_user = NULL; + int dbsize_user = 0; + char dbname[OCI_SIZE_BUFFER + 1]; + + CHECK_PTR(OCI_IPC_CONNECTION, con) memset(dbname, 0, sizeof(dbname)); - if (OCI_STRING_VALID(con->db)) + if (IS_STRING_VALID(con->db)) { - OCI_StringNativeToAnsi(con->db, dbname, (int) ostrlen(con->db)); + StringNativeToAnsi(con->db, dbname, (int) ostrlen(con->db)); } con->cxt = xaoSvcCtx((OraText *) (dbname[0] ? dbname : NULL )); - OCI_STATUS = (NULL != con->cxt); + CHECK_NULL(con->cxt) + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SERVER, + con->cxt, &con->svr, NULL, + con->err + ) + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, + con->cxt, &con->ses, NULL, + con->err + ) - OCI_GET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SERVER, con->cxt, &con->svr, NULL) - OCI_GET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, con->cxt, &con->ses, NULL) - OCI_GET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_USERNAME, con->ses, &dbstr_user, &dbsize_user) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SESSION, OCI_ATTR_USERNAME, + con->ses, &dbstr_user, &dbsize_user, + con->err + ) if (NULL == con->ses) { - OCI_STATUS = FALSE; - OCI_ExceptionConnFromXaString(con->db); + THROW(ExceptionConnFromXaString, con->db) } - if (OCI_STATUS && dbstr_user) + if (dbstr_user) { - OCI_FREE(con->user) + FREE(con->user) - con->user = OCI_StringDuplicateFromOracleString(dbstr_user, dbcharcount(dbsize_user)); + con->user = StringDuplicateFromDBString(dbstr_user, dbcharcount(dbsize_user)); } + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogonRegular + * ConnectionLogonRegular * --------------------------------------------------------------------------------------------- */ -void OCI_ConnectionLogonRegular +boolean ConnectionLogonRegular ( - OCI_Context *ctx, OCI_Connection *con, const otext *new_pwd ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + int dbsize1 = -1; + int dbsize2 = -1; + int dbsize3 = -1; + + dbtext* dbstr1 = NULL; + dbtext* dbstr2 = NULL; + dbtext* dbstr3 = NULL; + + CHECK_PTR(OCI_IPC_CONNECTION, con) + /* allocate session handle */ - OCI_HandleAlloc((dvoid *)con->env, (dvoid **)(void *)&con->ses, OCI_HTYPE_SESSION); + CHECK(MemoryAllocHandle((dvoid *)con->env, (dvoid **)(void *)&con->ses, OCI_HTYPE_SESSION)) /* allocate context handle */ - OCI_HandleAlloc((dvoid *)con->env, (dvoid **)(void *)&con->cxt, OCI_HTYPE_SVCCTX); + CHECK(MemoryAllocHandle((dvoid *)con->env, (dvoid **)(void *)&con->cxt, OCI_HTYPE_SVCCTX)) /* set context server attribute */ - OCI_SET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SERVER, con->cxt, con->svr, sizeof(con->svr)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SERVER, + con->cxt, con->svr, sizeof(con->svr), + con->err + ) /* modify user password if needed */ - if (OCI_STRING_VALID(new_pwd)) + if (IS_STRING_VALID(new_pwd)) { - int dbsize1 = -1; - int dbsize2 = -1; - int dbsize3 = -1; - - dbtext *dbstr1 = NULL; - dbtext *dbstr2 = NULL; - dbtext *dbstr3 = NULL; + dbstr1 = StringGetDBString(con->user, &dbsize1); + dbstr2 = StringGetDBString(con->pwd, &dbsize2); + dbstr3 = StringGetDBString(new_pwd, &dbsize3); - dbstr1 = OCI_StringGetOracleString(con->user, &dbsize1); - dbstr2 = OCI_StringGetOracleString(con->pwd, &dbsize2); - dbstr3 = OCI_StringGetOracleString(new_pwd, &dbsize3); - - OCI_SET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, con->cxt, con->ses, sizeof(con->ses)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, + con->cxt, con->ses, + sizeof(con->ses), + con->err + ) - OCI_EXEC + CHECK_OCI ( - OCIPasswordChange(con->cxt, con->err, (OraText *)dbstr1, (ub4)dbsize1, - (OraText *)dbstr2, (ub4)dbsize2, - (OraText *)dbstr3, (ub4)dbsize3, OCI_AUTH) + con->err, + OCIPasswordChange, + con->cxt, con->err, + (OraText *)dbstr1, (ub4)dbsize1, + (OraText *)dbstr2, (ub4)dbsize2, + (OraText *)dbstr3, (ub4)dbsize3, + OCI_AUTH ) - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); - OCI_StringReleaseOracleString(dbstr3); + /* replace connection password */ - if (OCI_STATUS) - { - OCI_FREE(con->pwd) - con->pwd = ostrdup(new_pwd); - } + FREE(con->pwd) + con->pwd = ostrdup(new_pwd); } else { - int dbsize = -1; - dbtext *dbstr = NULL; + ub4 credt = OCI_CRED_RDBMS; + ub4 mode = con->mode; /* set session login attribute */ - if (OCI_STATUS && OCI_STRING_VALID(con->user)) + if (IS_STRING_VALID(con->user)) { - dbsize = -1; - dbstr = OCI_StringGetOracleString(con->user, &dbsize); - - OCI_SET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_USERNAME, con->ses, dbstr, dbsize); - - OCI_StringReleaseOracleString(dbstr); + dbsize1 = -1; + dbstr1 = StringGetDBString(con->user, &dbsize1); + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SESSION, OCI_ATTR_USERNAME, + con->ses, dbstr1, dbsize1, + con->err + ) } /* set session password attribute */ - if (OCI_STATUS && OCI_STRING_VALID(con->pwd)) + if (IS_STRING_VALID(con->pwd)) { - dbsize = -1; - dbstr = OCI_StringGetOracleString(con->pwd, &dbsize); - - OCI_SET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_PASSWORD, con->ses, dbstr, dbsize); - - OCI_StringReleaseOracleString(dbstr); + dbsize2 = -1; + dbstr2 = StringGetDBString(con->pwd, &dbsize2); + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SESSION, OCI_ATTR_PASSWORD, + con->ses, dbstr2, dbsize2, + con->err + ) } /* set OCILIB driver layer name attribute */ #if OCI_VERSION_COMPILE >= OCI_11_1 - if (OCI_STATUS && (OCILib.version_runtime >= OCI_11_1)) + if (Env.version_runtime >= OCI_11_1) { otext driver_version[OCI_SIZE_FORMAT]; @@ -471,87 +562,106 @@ void OCI_ConnectionLogonRegular OCILIB_MINOR_VERSION, OCILIB_REVISION_VERSION); - dbsize = -1; - dbstr = OCI_StringGetOracleString(driver_version, &dbsize); - - OCI_SET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_DRIVER_NAME, con->ses, dbstr, dbsize); + dbsize3 = -1; + dbstr3 = StringGetDBString(driver_version, &dbsize3); - OCI_StringReleaseOracleString(dbstr); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SESSION, OCI_ATTR_DRIVER_NAME, + con->ses, dbstr3, dbsize3, + con->err + ) } #endif /* start session */ - if (OCI_STATUS) + if (!IS_STRING_VALID(con->user) && !IS_STRING_VALID(con->pwd)) { - ub4 credt = OCI_CRED_RDBMS; - ub4 mode = con->mode; - - if (!OCI_STRING_VALID(con->user) && !OCI_STRING_VALID(con->pwd)) - { - credt = OCI_CRED_EXT; - } + credt = OCI_CRED_EXT; + } #if OCI_VERSION_COMPILE >= OCI_9_2 - /* activate statement cache is the OCI version supports it */ + /* activate statement cache is the OCI version supports it */ - if (OCILib.version_runtime >= OCI_9_2) - { - mode |= OCI_STMT_CACHE; - } + if (Env.version_runtime >= OCI_9_2) + { + mode |= OCI_STMT_CACHE; + } #endif - /* start session */ + /* start session */ - OCI_EXEC(OCISessionBegin(con->cxt, con->err, con->ses, credt, mode)); + CHECK_OCI + ( + con->err, + OCISessionBegin, + con->cxt, con->err, con->ses, + credt, mode + ) - OCI_SET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, con->cxt, con->ses, sizeof(con->ses)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, + con->cxt, con->ses, sizeof(con->ses), + con->err + ) - if (OCI_STATUS) - { - if (!(con->mode & OCI_PRELIM_AUTH)) - { - /* create default transaction object */ + if (!(con->mode & OCI_PRELIM_AUTH)) + { + /* create default transaction object */ - OCI_Transaction *trs = OCI_TransactionCreate(con, 1, OCI_TRANS_READWRITE, NULL); + OCI_Transaction* trs = TransactionCreate(con, 1, OCI_TRANS_READWRITE, NULL); + CHECK_NULL(trs) - if (trs && OCI_SetTransaction(con, trs)) - { - /* start transaction */ + /* start transaction */ - OCI_STATUS = OCI_TransactionStart(trs); - } - } - } - else - { - /* could not start session, must free the session and context handles */ + CHECK(ConnectionSetTransaction(con, trs)) + CHECK(TransactionStart( trs)) + } + } - OCI_HandleFree((dvoid *)con->ses, OCI_HTYPE_SESSION); - OCI_HandleFree((dvoid *)con->cxt, OCI_HTYPE_SVCCTX); + SET_SUCCESS() - con->ses = NULL; - con->cxt = NULL; - } + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + StringReleaseDBString(dbstr3); + + if (FAILURE && NULL != con) + { + /* could not start session, must free the session and context handles */ + + MemoryFreeHandle((dvoid*)con->ses, OCI_HTYPE_SESSION); + MemoryFreeHandle((dvoid*)con->cxt, OCI_HTYPE_SVCCTX); + + con->ses = NULL; + con->cxt = NULL; } - } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogonSessionPool + * ConnectionLogonSessionPool * --------------------------------------------------------------------------------------------- */ -void OCI_ConnectionLogonSessionPool +boolean ConnectionLogonSessionPool ( - OCI_Context *ctx, OCI_Connection *con, const otext *tag ) { - ub4 sess_mode = OCI_SESSGET_SPOOL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + ub4 sess_mode = OCI_SESSGET_SPOOL; boolean found = FALSE; int dbsize = -1; dbtext *dbstr = NULL; @@ -560,63 +670,89 @@ void OCI_ConnectionLogonSessionPool OraText *dbstr_ret = NULL; ub4 dbsize_ret = 0; +#if OCI_VERSION_COMPILE >= OCI_10_2 + if (con->mode & OCI_SESSION_SYSDBA) { sess_mode |= OCI_SESSGET_SYSDBA; } - if (!OCI_STRING_VALID(con->pool->user) && !OCI_STRING_VALID(con->pool->pwd)) +#endif + + if (!IS_STRING_VALID(con->pool->user) && !IS_STRING_VALID(con->pool->pwd)) { sess_mode |= OCI_SESSGET_CREDEXT; } - if (OCI_STRING_VALID(con->pool->name)) + if (IS_STRING_VALID(con->pool->name)) { dbsize = -1; - dbstr = OCI_StringGetOracleString(con->pool->name, &dbsize); + dbstr = StringGetDBString(con->pool->name, &dbsize); } - if (OCI_STRING_VALID(tag)) + if (IS_STRING_VALID(tag)) { dbsize_tag = -1; - dbstr_tag = OCI_StringGetOracleString(tag, &dbsize_tag); + dbstr_tag = StringGetDBString(tag, &dbsize_tag); } - OCI_EXEC + CHECK_OCI ( - OCISessionGet(con->env, con->err, &con->cxt, NULL, - (OraText *)dbstr, (ub4)dbsize, (OraText *)dbstr_tag, dbsize_tag, - (OraText **)&dbstr_ret, &dbsize_ret, &found, sess_mode) + con->err, + OCISessionGet, + con->env, con->err, &con->cxt, NULL, + (OraText *)dbstr, (ub4)dbsize, + (OraText *)dbstr_tag, dbsize_tag, + (OraText **)&dbstr_ret, &dbsize_ret, + &found, sess_mode ) - OCI_StringReleaseOracleString(dbstr); - OCI_StringReleaseOracleString(dbstr_tag); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SERVER, + con->cxt, &con->svr, NULL, + con->err + ) - OCI_GET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SERVER, con->cxt, &con->svr, NULL) - OCI_GET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, con->cxt, &con->ses, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_SESSION, + con->cxt, &con->ses, NULL, + con->err + ) - if (OCI_STATUS && found) + if (found) { - OCI_SetSessionTag(con, tag); + CHECK(ConnectionSetSessionTag(con, tag)) } + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + StringReleaseDBString(dbstr_tag); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogon + * ConnectionLogon * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionLogon +boolean ConnectionLogon ( OCI_Connection *con, const otext *new_pwd, const otext *tag ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == con, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_CONTEXT_SET_FROM_CONN(con); + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE < OCI_9_2 @@ -630,7 +766,7 @@ boolean OCI_ConnectionLogon if (con->mode & OCI_SESSION_XA) { - OCI_ConnectionLogonXA(ctx, con); + CHECK(ConnectionLogonXA(con)) } else @@ -640,56 +776,67 @@ boolean OCI_ConnectionLogon if (con->alloc_handles) { - OCI_ConnectionLogonRegular(ctx, con, new_pwd); + CHECK(ConnectionLogonRegular(con, new_pwd)) } #if OCI_VERSION_COMPILE >= OCI_9_2 - /* 3 - connection from session pool */ + /* 3 - connection from session pool */ - else if (OCILib.version_runtime >= OCI_9_2) + else if (Env.version_runtime >= OCI_9_2) { - OCI_ConnectionLogonSessionPool(ctx, con, tag); + CHECK(ConnectionLogonSessionPool(con, tag)) } #endif - /* check for success */ + /* get server version */ - if (OCI_STATUS) - { - /* get server version */ + ConnectionGetServerVersion(con); + + /* update internal status */ - OCI_GetVersionServer(con); + con->cstate = OCI_CONN_LOGGED; - con->cstate = OCI_CONN_LOGGED; - } + SET_SUCCESS() - return OCI_STATUS; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogoffRegular + * ConnectionLogoffRegular * --------------------------------------------------------------------------------------------- */ -void OCI_ConnectionLogoffRegular +boolean ConnectionLogoffRegular ( - OCI_Context *ctx, OCI_Connection *con ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + /* close any server files not explicitly closed - no check of return code */ - if (con->cxt && con->err && con->ses) + if (NULL != con->cxt && NULL != con->err && NULL != con->ses) { - OCI_EXEC(OCISessionEnd(con->cxt, con->err, con->ses, (ub4)OCI_DEFAULT)); + CHECK_OCI + ( + con->err, + OCISessionEnd, + con->cxt, con->err, con->ses, + (ub4)OCI_DEFAULT + ) /* close session handle */ if (con->ses) { - OCI_HandleFree((dvoid *) con->ses, OCI_HTYPE_SESSION); - + MemoryFreeHandle((dvoid*)con->ses, OCI_HTYPE_SESSION); con->ses = NULL; } @@ -697,78 +844,104 @@ void OCI_ConnectionLogoffRegular if (con->cxt) { - OCI_HandleFree((dvoid *) con->cxt, OCI_HTYPE_SVCCTX); - + MemoryFreeHandle((dvoid*)con->cxt, OCI_HTYPE_SVCCTX); con->cxt = NULL; } - } + } + + SET_SUCCESS() + + EXIT_FUNC() + } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogoffSessionPool + * ConnectionLogoffSessionPool * --------------------------------------------------------------------------------------------- */ -void OCI_ConnectionLogoffSessionPool +boolean ConnectionLogoffSessionPool ( - OCI_Context *ctx, OCI_Connection *con ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + dbtext* dbstr = NULL; + int dbsize = 0; + + CHECK_PTR(OCI_IPC_CONNECTION, con) + /* No explicit transaction object => commit if needed otherwise rollback changes */ if (con->autocom) { - OCI_Commit(con); + ConnectionCommit(con); } else { - OCI_Rollback(con); + ConnectionRollback(con); } #if OCI_VERSION_COMPILE >= OCI_9_2 - if (OCILib.version_runtime >= OCI_9_2) + if (Env.version_runtime >= OCI_9_2) { - dbtext *dbstr = NULL; - int dbsize = 0; - ub4 mode = OCI_DEFAULT; + ub4 mode = OCI_DEFAULT; /* Clear session tag if connection was retrieved from session pool */ - if (con->pool && con->sess_tag && ( OCI_HTYPE_SPOOL == con->pool->htype)) + if (NULL != con->pool && NULL != con->sess_tag && ( OCI_HTYPE_SPOOL == con->pool->htype)) { dbsize = -1; - dbstr = OCI_StringGetOracleString(con->sess_tag, &dbsize); + dbstr = StringGetDBString(con->sess_tag, &dbsize); mode = OCI_SESSRLS_RETAG; } - OCI_EXEC(OCISessionRelease(con->cxt, con->err, (OraText*)dbstr, (ub4)dbsize, mode)); - - OCI_StringReleaseOracleString(dbstr); + CHECK_OCI + ( + con->err, + OCISessionRelease, + con->cxt, con->err, + (OraText*)dbstr, (ub4)dbsize, + mode + ) con->cxt = NULL; con->ses = NULL; con->svr = NULL; } - #endif +#endif + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionLogOff + * ConnectionLogOff * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionLogOff +boolean ConnectionLogOff ( OCI_Connection *con ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == con, FALSE) - OCI_CHECK(con->cstate != OCI_CONN_LOGGED, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_CONTEXT_SET_FROM_CONN(con); + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_CON_STATUS(con, OCI_CONN_LOGGED) /* close opened files */ @@ -779,22 +952,22 @@ boolean OCI_ConnectionLogOff /* dissociate connection from existing subscriptions */ - OCI_ListForEachWithParam(OCILib.subs, con, (POCI_LIST_FOR_EACH_WITH_PARAM) OCI_ConnectionDetachSubscriptions); + ListForEachWithParam(Env.subs, con, (POCI_LIST_FOR_EACH_WITH_PARAM) ConnectionDetachSubscriptions); /* free all statements */ - OCI_ListForEach(con->stmts, (POCI_LIST_FOR_EACH) OCI_StatementClose); - OCI_ListClear(con->stmts); + ListForEach(con->stmts, (POCI_LIST_FOR_EACH)StatementDispose); + ListClear(con->stmts); /* free all type info objects */ - OCI_ListForEach(con->tinfs, (POCI_LIST_FOR_EACH) OCI_TypeInfoClose); - OCI_ListClear(con->tinfs); + ListForEach(con->tinfs, (POCI_LIST_FOR_EACH)TypeInfoDispose); + ListClear(con->tinfs), /* free all transactions */ - OCI_ListForEach(con->trsns, (POCI_LIST_FOR_EACH) OCI_TransactionClose); - OCI_ListClear(con->trsns); + ListForEach(con->trsns, (POCI_LIST_FOR_EACH)TransactionDispose); + ListClear(con->trsns); /* 1 - XA connection */ @@ -812,110 +985,116 @@ boolean OCI_ConnectionLogOff if (con->alloc_handles) { - OCI_ConnectionLogoffRegular(ctx, con); + ConnectionLogoffRegular(con); } #if OCI_VERSION_COMPILE >= OCI_9_2 - /* 3 - connection from session pool */ + /* 3 - connection from session pool */ - else if (OCILib.version_runtime >= OCI_9_0) + else if (Env.version_runtime >= OCI_9_0) { - OCI_ConnectionLogoffSessionPool(ctx, con); + ConnectionLogoffSessionPool(con); } #endif /* update internal status */ - if (OCI_STATUS) - { - con->cstate = OCI_CONN_ATTACHED; - } + con->cstate = OCI_CONN_ATTACHED; + + SET_SUCCESS() - return OCI_STATUS; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionClose + * ConnectionClose * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionClose +boolean ConnectionDispose ( OCI_Connection *con ) { - OCI_Error *err = NULL; - unsigned int i = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CHECK(NULL == con, FALSE) + OCI_Error* err = NULL; + unsigned int i = 0; - /* clear connection reference from current error object */ + CHECK_PTR(OCI_IPC_CONNECTION, con) - err = OCI_ErrorGet(FALSE, FALSE); + /* clear connection reference from current error object */ - if (err && err->con == con) + err = ErrorGet(FALSE, FALSE); + if (NULL != err && err->source_ptr == con) { - err->con = NULL; + err->source_ptr = NULL; } /* clear server output resources */ - OCI_ServerDisableOutput(con); + ConnectionDisableServerOutput(con); /* log off and detach form server */ - OCI_ConnectionLogOff(con); - OCI_ConnectionDetach(con); - OCI_ConnectionDeallocate(con); + ConnectionLogOff(con); + ConnectionDetach(con); + ConnectionDeallocate(con); /* free internal lists */ - OCI_ListFree(con->stmts); - OCI_ListFree(con->trsns); - OCI_ListFree(con->tinfs); + ListFree(con->stmts); + ListFree(con->trsns); + ListFree(con->tinfs); /* free strings */ for (i = 0; i < OCI_FMT_COUNT; i++) { - OCI_FREE(con->formats[i]) + FREE(con->formats[i]) } - OCI_FREE(con->ver_str) - OCI_FREE(con->sess_tag) - OCI_FREE(con->db_name) - OCI_FREE(con->inst_name) - OCI_FREE(con->service_name) - OCI_FREE(con->server_name) - OCI_FREE(con->db_name) - OCI_FREE(con->domain_name) - OCI_FREE(con->trace) + FREE(con->ver_str) + FREE(con->sess_tag) + FREE(con->db_name) + FREE(con->inst_name) + FREE(con->service_name) + FREE(con->server_name) + FREE(con->db_name) + FREE(con->domain_name) + FREE(con->trace) if (!con->pool) { - OCI_FREE(con->db) - OCI_FREE(con->user) - OCI_FREE(con->pwd) + FREE(con->db) + FREE(con->user) + FREE(con->pwd) } - if (con->inst_startup) + if (NULL != con->inst_startup) { - OCI_TimestampFree(con->inst_startup); + TimestampFree(con->inst_startup); } con->stmts = NULL; con->trsns = NULL; con->tinfs = NULL; - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionCreateInternal + * ConnectionCreateInternal * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_ConnectionCreateInternal +OCI_Connection * ConnectionCreateInternal ( OCI_Pool *pool, const otext *db, @@ -925,56 +1104,72 @@ OCI_Connection * OCI_ConnectionCreateInternal const otext *tag ) { + ENTER_FUNC + ( + /* returns */ OCI_Connection*, NULL, + /* context */ (pool ? OCI_IPC_POOL : OCI_IPC_VOID), (pool ? (void*)pool : (void*)&Env) + ) + /* create connection */ - OCI_Connection *con = OCI_ConnectionAllocate(pool, db, user, pwd, mode); + OCI_Connection *con = ConnectionAllocate(pool, db, user, pwd, mode); + CHECK_NULL(con) - if (con) - { - if (!OCI_ConnectionAttach(con) || !OCI_ConnectionLogon(con, NULL, tag)) + CHECK(ConnectionAttach(con)) + CHECK(ConnectionLogon(con, NULL, tag)) + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - OCI_ConnectionFree(con); + ConnectionFree(con); con = NULL; } - } - return con; + SET_RETVAL(con) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionGetMinSupportedVersion + * ConnectionGetMinSupportedVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_ConnectionGetMinSupportedVersion +unsigned int ConnectionGetMinSupportedVersion ( OCI_Connection *con ) { - return (OCILib.version_runtime > con->ver_num) ? con->ver_num : OCILib.version_runtime; + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + + SET_RETVAL((Env.version_runtime > con->ver_num) ? con->ver_num : Env.version_runtime) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionIsVersionSupported + * ConnectionIsVersionSupported * --------------------------------------------------------------------------------------------- */ -boolean OCI_ConnectionIsVersionSupported +boolean ConnectionIsVersionSupported ( OCI_Connection *con, unsigned int version ) { - return OCI_ConnectionGetMinSupportedVersion(con) >= version; + return ConnectionGetMinSupportedVersion(con) >= version; } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionCreate + * ConnectionCreate * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_ConnectionCreate +OCI_Connection * ConnectionCreate ( const otext *db, const otext *user, @@ -982,191 +1177,252 @@ OCI_Connection * OCI_API OCI_ConnectionCreate unsigned int mode ) { - OCI_CALL_ENTER(OCI_Connection *, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_XA_ENABLED(mode) + ENTER_FUNC + ( + /* returns */ OCI_Connection*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_RETVAL = OCI_ConnectionCreateInternal(NULL, db, user, pwd, mode, NULL); - OCI_STATUS = (NULL != OCI_RETVAL); + CHECK_INITIALIZED() + CHECK_XA_ENABLED(mode) - OCI_CALL_EXIT() + SET_RETVAL(ConnectionCreateInternal(NULL, db, user, pwd, mode, NULL)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ConnectionFree + * ConnectionFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ConnectionFree +boolean ConnectionFree ( OCI_Connection *con ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + + ConnectionDispose(con); + ListRemove(Env.cons, con); - OCI_RETVAL = OCI_STATUS = OCI_ConnectionClose(con); + FREE(con) - OCI_ListRemove(OCILib.cons, con); - OCI_FREE(con) + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Commit + * ConnectionCommit * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Commit +boolean ConnectionCommit ( OCI_Connection *con ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_EXEC(OCITransCommit(con->cxt, con->err, (ub4)OCI_DEFAULT)); + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + con->err, + OCITransCommit, + con->cxt, con->err, (ub4)OCI_DEFAULT + ) - OCI_CALL_EXIT() - } + SET_SUCCESS() + + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_Rollback + * ConnectionRollback * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Rollback +boolean ConnectionRollback ( OCI_Connection *con ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_EXEC(OCITransRollback(con->cxt, con->err, (ub4)OCI_DEFAULT)); + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + con->err, + OCITransRollback, + con->cxt, con->err, (ub4)OCI_DEFAULT + ) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetAutoCommit + * ConnectionSetAutoCommit * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetAutoCommit +boolean ConnectionSetAutoCommit ( OCI_Connection *con, boolean enable ) { - OCI_SET_PROP(boolean, OCI_IPC_CONNECTION, con, autocom, enable, con, NULL, con->err) + SET_PROP + ( + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ autocom, boolean, + /* value */ enable + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetAutoCommit + * ConnectionGetAutoCommit * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_GetAutoCommit +boolean ConnectionGetAutoCommit ( OCI_Connection *con ) { - OCI_GET_PROP(boolean, FALSE, OCI_IPC_CONNECTION, con, autocom, con, NULL, con->err) + GET_PROP + ( + /* result */ boolean, FALSE, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ autocom + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IsConnected + * ConnectionIsConnected * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IsConnected +boolean ConnectionIsConnected ( OCI_Connection *con ) { - ub4 status = 0; - ub4 size = (ub4) sizeof(status); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ub4 status = 0; + ub4 size = (ub4) sizeof(status); - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_SERVER_STATUS, con->svr, &status, &size) + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = (status == OCI_SERVER_NORMAL); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_SERVER_STATUS, + con->svr, &status, &size, + con->err + ) + + SET_RETVAL(status == OCI_SERVER_NORMAL) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUserData + * ConnectionGetUserData * --------------------------------------------------------------------------------------------- */ -void * OCI_API OCI_GetUserData +void * ConnectionGetUserData ( OCI_Connection *con ) { - OCI_CALL_ENTER(void*, NULL) - OCI_CALL_CHECK_INITIALIZED() + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_RETVAL = (void*) (con ? con->usrdata : OCILib.usrdata); - - OCI_CALL_EXIT() + CHECK_INITIALIZED() + + SET_RETVAL((void*) (con ? con->usrdata : Env.usrdata)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetSetData + * ConnectionSetSetData * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetUserData +boolean ConnectionSetUserData ( OCI_Connection *con, void *data ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_INITIALIZED() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_INITIALIZED() - if (con) + if (NULL != con) { con->usrdata = data; } else { - OCILib.usrdata = data; + Env.usrdata = data; } - OCI_RETVAL = TRUE; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetSessionTag + * ConnectionSetSessionTag * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetSessionTag +boolean ConnectionSetSessionTag ( OCI_Connection *con, const otext *tag ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_FREE(con->sess_tag) + FREE(con->sess_tag) #if OCI_VERSION_COMPILE >= OCI_9_2 if (tag && con->pool && (OCI_HTYPE_SPOOL == con->pool->htype)) { con->sess_tag = ostrdup(tag); - OCI_STATUS = (NULL != con->sess_tag); + CHECK_NULL(con->sess_tag) } #else @@ -1175,424 +1431,463 @@ boolean OCI_API OCI_SetSessionTag #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetSessionTag + * ConnectionGetSessionTag * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetSessionTag +const otext * ConnectionGetSessionTag ( OCI_Connection *con ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_CONNECTION, con, sess_tag, con, NULL, con->err) + GET_PROP + ( + /* result */ const otext*, NULL, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ sess_tag + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDatabase + * ConnectionGetDatabase * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetDatabase +const otext * ConnectionGetConnectionString ( OCI_Connection *con ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_CONNECTION, con, db, con, NULL, con->err) + GET_PROP + ( + /* result */ const otext*, NULL, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ db + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUserName + * ConnectionGetUserName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetUserName +const otext * ConnectionGetUserName ( OCI_Connection *con ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_CONNECTION, con, user, con, NULL, con->err) + GET_PROP + ( + /* result */ const otext*, NULL, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ user + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetPassword + * ConnectionGetPassword * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetPassword +const otext * ConnectionGetPassword ( OCI_Connection *con ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_CONNECTION, con, pwd, con, NULL, con->err) + GET_PROP + ( + /* result */ const otext*, NULL, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ pwd + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetPassword + * ConnectionSetPassword * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetPassword +boolean ConnectionSetPassword ( OCI_Connection *con, const otext *password ) { - OCI_CALL_ENTER(boolean, FALSE) - - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, password) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - if (OCI_CONN_LOGGED != con->cstate) - { - OCI_STATUS = OCI_ConnectionLogon(con, password, NULL); - } - else - { - int dbsize1 = -1; - int dbsize2 = -1; - int dbsize3 = -1; - - dbtext *dbstr1 = OCI_StringGetOracleString(con->user, &dbsize1); - dbtext *dbstr2 = OCI_StringGetOracleString(con->pwd, &dbsize2); - dbtext *dbstr3 = OCI_StringGetOracleString(password, &dbsize3); - - OCI_EXEC - ( - OCIPasswordChange(con->cxt, con->err, - (OraText *) dbstr1, (ub4) dbsize1, - (OraText *) dbstr2, (ub4) dbsize2, - (OraText *) dbstr3, (ub4) dbsize3, - OCI_DEFAULT) - ) - - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); - OCI_StringReleaseOracleString(dbstr3); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_SetUserPassword - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_SetUserPassword -( - const otext *db, - const otext *user, - const otext *pwd, - const otext *new_pwd -) -{ - OCI_Connection * con = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - - /* let's be sure OCI_Initialize() has been called */ - - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, pwd) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, new_pwd) - - con = OCI_ConnectionAllocate(NULL, db, user, pwd, OCI_AUTH); - - if (con) - { - if (!OCI_ConnectionAttach(con) || !OCI_ConnectionLogon(con, new_pwd, NULL)) - { - OCI_ConnectionFree(con); - con = NULL; - } - } + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_STATUS = (con != NULL); + int dbsize1 = -1; + int dbsize2 = -1; + int dbsize3 = -1; - if (OCI_STATUS) + dbtext* dbstr1 = StringGetDBString(con->user, &dbsize1); + dbtext* dbstr2 = StringGetDBString(con->pwd, &dbsize2); + dbtext* dbstr3 = StringGetDBString(password, &dbsize3); + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, password) + + if (OCI_CONN_LOGGED != con->cstate) + { + CHECK(ConnectionLogon(con, password, NULL)) + } + else { - OCI_ConnectionFree(con); + CHECK_OCI + ( + con->err, + OCIPasswordChange, + con->cxt, con->err, + (OraText *) dbstr1, (ub4) dbsize1, + (OraText *) dbstr2, (ub4) dbsize2, + (OraText *) dbstr3, (ub4) dbsize3, + OCI_DEFAULT + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + StringReleaseDBString(dbstr3); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetSessionMode + * ConnectionGetSessionMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetSessionMode +unsigned int ConnectionGetSessionMode ( OCI_Connection *con ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_CONNECTION, con, mode, con, NULL, con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ mode + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetVersionServer + * ConnectionGetVersionServer * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetVersionServer +const otext * ConnectionGetServerVersion ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + int dbsize = OCI_SIZE_BUFFER * (int)sizeof(dbtext); + dbtext* dbstr = NULL; + + CHECK_PTR(OCI_IPC_CONNECTION, con) /* no version available in preliminary authentication mode */ if (!con->ver_str && (!(con->mode & OCI_PRELIM_AUTH))) { - int dbsize = OCI_SIZE_BUFFER * (int) sizeof(dbtext); - dbtext *dbstr = NULL; - ub4 version = 0; + int ver_maj = 0; + int ver_min = 0; + int ver_rev = 0; - OCI_ALLOCATE_DATA(OCI_IPC_STRING, con->ver_str, OCI_SIZE_BUFFER + 1) + ALLOC_DATA(OCI_IPC_STRING, con->ver_str, OCI_SIZE_BUFFER + 1) - if (OCI_STATUS) - { - dbstr = OCI_StringGetOracleString(con->ver_str, &dbsize); + dbstr = StringGetDBString(con->ver_str, &dbsize); - #if OCI_VERSION_COMPILE >= OCI_18_1 - - if (OCILib.version_runtime >= OCI_18_1) - { - OCI_EXEC(OCIServerRelease2((dvoid *)con->cxt, con->err, (OraText *)dbstr, (ub4)dbsize, (ub1)OCI_HTYPE_SVCCTX, &version, OCI_DEFAULT)) - } - else +#if OCI_VERSION_COMPILE >= OCI_18_1 - #endif - - { - OCI_EXEC(OCIServerVersion((dvoid *)con->cxt, con->err, (OraText *)dbstr, (ub4)dbsize, (ub1)OCI_HTYPE_SVCCTX)) - } + ub4 version = 0; - OCI_StringCopyOracleStringToNativeString(dbstr, con->ver_str, dbcharcount(dbsize)); - OCI_StringReleaseOracleString(dbstr); + if (Env.version_runtime >= OCI_18_1) + { + CHECK_OCI + ( + con->err, + OCIServerRelease2, + (dvoid *)con->cxt, con->err, (OraText *)dbstr, (ub4)dbsize, + (ub1)OCI_HTYPE_SVCCTX, &version, OCI_DEFAULT + ) } + else + +#endif - if (OCI_STATUS) { - int ver_maj = 0, ver_min = 0, ver_rev = 0; + CHECK_OCI + ( + con->err, + OCIServerVersion, + (dvoid *)con->cxt, con->err, + (OraText *)dbstr, (ub4)dbsize, + (ub1)OCI_HTYPE_SVCCTX + ) + } - #if OCI_VERSION_COMPILE >= OCI_18_1 + StringCopyDBStringToNativeString(dbstr, con->ver_str, dbcharcount(dbsize)); - if (OCILib.version_runtime >= OCI_18_1) - { - ver_maj = OCI_SERVER_RELEASE_REL(version); - ver_min = OCI_SERVER_RELEASE_REL_UPD(version); - ver_rev = OCI_SERVER_RELEASE_REL_UPD_REV(version); +#if OCI_VERSION_COMPILE >= OCI_18_1 - con->ver_num = ver_maj * 100 + ver_min * 10 + ver_rev; - } - else + if (Env.version_runtime >= OCI_18_1) + { + ver_maj = OCI_SERVER_RELEASE_REL(version); + ver_min = OCI_SERVER_RELEASE_REL_UPD(version); + ver_rev = OCI_SERVER_RELEASE_REL_UPD_REV(version); - #endif + con->ver_num = ver_maj * 100 + ver_min * 10 + ver_rev; + } + else - { - otext *p = NULL; +#endif - con->ver_str[ocharcount(dbsize)] = 0; + { + otext* p = NULL; + + con->ver_str[ocharcount(dbsize)] = 0; - /* parse server version string to find the version information - **/ + /* parse server version string to find the version information + **/ - for (p = con->ver_str; p && *p; p++) + for (p = con->ver_str; p && *p; p++) + { + if (oisdigit((unsigned char)*p) && + (*(p + (size_t)1) != 0) && + (*(p + (size_t)1) == OTEXT('.') || (*(p + (size_t)2) == OTEXT('.')))) { - if (oisdigit((unsigned char) *p) && - (*(p + (size_t) 1) != 0) && - (*(p + (size_t) 1) == OTEXT('.') || (*(p + (size_t) 2) == OTEXT('.') ))) + if (NB_ARG_VERSION == osscanf(p, OTEXT("%d.%d.%d"), + (int*)&ver_maj, + (int*)&ver_min, + (int*)&ver_rev)) { - if (OCI_NB_ARG_VERSION == osscanf(p, OTEXT("%d.%d.%d"), - (int *) &ver_maj, - (int *) &ver_min, - (int *) &ver_rev)) - { - con->ver_num = ver_maj*100 + ver_min*10 + ver_rev; - } - - break; + con->ver_num = ver_maj * 100 + ver_min * 10 + ver_rev; } + + break; } } } - else - { - OCI_FREE(con->ver_str) - } } - OCI_RETVAL = (const otext*)con->ver_str; + SET_RETVAL((const otext*)con->ver_str) + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); - OCI_CALL_EXIT() + if (FAILURE) + { + FREE(con->ver_str) + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetServerMajorVersion + * ConnectionGetServerMajorVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetServerMajorVersion +unsigned int ConnectionGetServerMajorVersion ( OCI_Connection *con ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) if (OCI_UNKNOWN == con->ver_num) { - OCI_GetVersionServer(con); + ConnectionGetServerVersion(con); } - OCI_RETVAL = (unsigned int) OCI_VER_MAJ(con->ver_num); + SET_RETVAL((unsigned int) OCI_VER_MAJ(con->ver_num)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetServerMinorVersion + * ConnectionGetServerMinorVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetServerMinorVersion +unsigned int ConnectionGetServerMinorVersion ( OCI_Connection *con ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) if (OCI_UNKNOWN == con->ver_num) { - OCI_GetVersionServer(con); + ConnectionGetServerVersion(con); } - OCI_RETVAL = (unsigned int) OCI_VER_MIN(con->ver_num); + SET_RETVAL((unsigned int) OCI_VER_MIN(con->ver_num)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetServerRevisionVersion + * ConnectionGetServerRevisionVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetServerRevisionVersion +unsigned int ConnectionGetServerRevisionVersion ( OCI_Connection *con ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) if (OCI_UNKNOWN == con->ver_num) { - OCI_GetVersionServer(con); + ConnectionGetServerVersion(con); } - OCI_RETVAL = (unsigned int) OCI_VER_REV(con->ver_num); + SET_RETVAL((unsigned int) OCI_VER_REV(con->ver_num)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetTransaction + * ConnectionGetTransaction * --------------------------------------------------------------------------------------------- */ -OCI_Transaction * OCI_API OCI_GetTransaction +OCI_Transaction * ConnectionGetTransaction ( OCI_Connection *con ) { - OCI_GET_PROP(OCI_Transaction*, NULL, OCI_IPC_CONNECTION, con, trs, con, NULL, con->err) + GET_PROP + ( + /* result */ OCI_Transaction*, NULL, + /* handle */ OCI_IPC_CONNECTION, con, + /* member */ trs + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetTransaction + * ConnectionSetTransaction * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetTransaction +boolean ConnectionSetTransaction ( OCI_Connection *con, OCI_Transaction *trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_TRANSACTION, trans) - if (con->trs) + if (NULL != con->trs) { - OCI_STATUS = OCI_TransactionStop(con->trs); + CHECK(TransactionStop( con->trs)) } - OCI_SET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_TRANS, con->cxt, trans->htr, sizeof(trans->htr)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_TRANS, + con->cxt, trans->htr, sizeof(trans->htr), + con->err + ) - if (OCI_STATUS) - { - con->trs = trans; - } + con->trs = trans; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetVersionConnection + * ConnectionGetVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetVersionConnection +unsigned int ConnectionGetVersion ( OCI_Connection *con ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) /* return the minimum supported version */ - - OCI_RETVAL = OCI_ConnectionGetMinSupportedVersion(con); - OCI_CALL_EXIT() + SET_RETVAL(ConnectionGetMinSupportedVersion(con)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Break + * ConnectionBreak * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Break +boolean ConnectionBreak ( OCI_Connection *con ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_EXEC(OCIBreak((dvoid *) con->cxt, con->err)) + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + con->err, + OCIBreak, + (dvoid*)con->cxt, con->err + ) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ServerEnableOutput + * ConnectionServerEnableOutput * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ServerEnableOutput +boolean ConnectionEnableServerOutput ( OCI_Connection *con, unsigned int bufsize, @@ -1600,17 +1895,21 @@ boolean OCI_API OCI_ServerEnableOutput unsigned int lnsize ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) /* initialize the output buffer on server side */ - OCI_ALLOCATE_DATA(OCI_IPC_SERVER_OUPUT, con->svopt, 1) + ALLOC_DATA(OCI_IPC_SERVER_OUPUT, con->svopt, 1) /* allocation internal buffer if needed */ - if (OCI_STATUS && !con->svopt->arrbuf) + if (NULL == con->svopt->arrbuf) { const unsigned int charsize = sizeof(otext); @@ -1620,7 +1919,7 @@ boolean OCI_API OCI_ServerEnableOutput { lnsize = OCI_OUPUT_LSIZE_10G; } - else if (lnsize > OCI_OUPUT_LSIZE) + else if (lnsize > OCI_OUPUT_LSIZE) { lnsize = OCI_OUPUT_LSIZE; } @@ -1630,147 +1929,176 @@ boolean OCI_API OCI_ServerEnableOutput /* allocate internal string (line) array */ - OCI_ALLOCATE_BUFFER(OCI_IPC_STRING, con->svopt->arrbuf, (con->svopt->lnsize + 1) * charsize, con->svopt->arrsize) + ALLOC_BUFFER(OCI_IPC_STRING, con->svopt->arrbuf, (con->svopt->lnsize + 1) * charsize, con->svopt->arrsize) } - if (OCI_STATUS) + if (NULL == con->svopt->stmt) { - if (!con->svopt->stmt) - { - con->svopt->stmt = OCI_StatementCreate(con); - OCI_STATUS = (NULL != con->svopt->stmt); - } - - if (con->svopt->stmt) - { - /* enable server output */ + con->svopt->stmt = StatementCreate(con); + CHECK_NULL(con->svopt->stmt) + } - OCI_STATUS = OCI_Prepare(con->svopt->stmt, OTEXT("BEGIN DBMS_OUTPUT.ENABLE(:n); END;")); + /* enable server output */ - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(con->svopt->stmt, OTEXT(":n"), &bufsize); + CHECK(StatementPrepare(con->svopt->stmt, OTEXT("BEGIN DBMS_OUTPUT.ENABLE(:n); END;"))) + CHECK(StatementBindUnsignedInt(con->svopt->stmt, OTEXT(":n"), &bufsize)) - if (0 == bufsize) - { - OCI_STATUS = OCI_STATUS && OCI_BindSetNull(OCI_GetBind(con->svopt->stmt, 1)); - } + if (0 == bufsize) + { + OCI_Bind* bnd = StatementGetBind(con->svopt->stmt, 1); + CHECK_NULL(bnd); - OCI_STATUS = OCI_STATUS && OCI_Execute(con->svopt->stmt); + CHECK(BindSetNull(bnd)) + } - /* prepare the retrieval statement call */ + CHECK(StatementExecute(con->svopt->stmt)) - if (OCI_STATUS) - { - con->svopt->cursize = con->svopt->arrsize; - } + /* prepare the retrieval statement call */ - OCI_STATUS = OCI_STATUS && OCI_Prepare(con->svopt->stmt, OTEXT("BEGIN DBMS_OUTPUT.GET_LINES(:s, :i); END;")); + con->svopt->cursize = con->svopt->arrsize; - OCI_STATUS = OCI_STATUS && OCI_BindArrayOfStrings(con->svopt->stmt, OTEXT(":s"), - (otext *) con->svopt->arrbuf, - con->svopt->lnsize, - con->svopt->arrsize); + CHECK(StatementPrepare(con->svopt->stmt, OTEXT("BEGIN DBMS_OUTPUT.GET_LINES(:s, :i); END;"))) - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(con->svopt->stmt, OTEXT(":i"), &con->svopt->cursize); - } - } + CHECK + ( + StatementBindArrayOfStrings + ( + con->svopt->stmt, OTEXT(":s"), + (otext *) con->svopt->arrbuf, + con->svopt->lnsize, + con->svopt->arrsize + ) + ) - if (!OCI_STATUS) - { - OCI_ServerDisableOutput(con); - } + CHECK + ( + StatementBindUnsignedInt + ( + con->svopt->stmt, OTEXT(":i"), + &con->svopt->cursize + ) + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ConnectionDisableServerOutput(con); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ServerDisableOutput + * ConnectionServerDisableOutput * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ServerDisableOutput +boolean ConnectionDisableServerOutput ( OCI_Connection *con ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) - if (con->svopt) + if (NULL != con->svopt) { - OCI_STATUS = OCI_ExecuteStmt(con->svopt->stmt, OTEXT("BEGIN DBMS_OUTPUT.DISABLE(); END;")); + StatementExecuteStmt(con->svopt->stmt, OTEXT("BEGIN DBMS_OUTPUT.DISABLE(); END;")); - if (con->svopt->stmt) + if (NULL != con->svopt->stmt) { - OCI_StatementFree(con->svopt->stmt); + StatementFree(con->svopt->stmt); con->svopt->stmt = NULL; } - OCI_FREE(con->svopt->arrbuf) - OCI_FREE(con->svopt) + FREE(con->svopt->arrbuf) + FREE(con->svopt) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ServerGetOutput + * ConnectionServerGetOutput * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_ServerGetOutput +const otext * ConnectionGetServerOutput ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + + const otext *line = NULL; - if (con->svopt) + if (NULL != con->svopt) { if (0 == con->svopt->curpos || con->svopt->curpos >= con->svopt->cursize) { con->svopt->cursize = con->svopt->arrsize; - OCI_STATUS = OCI_Execute(con->svopt->stmt); + + CHECK(StatementExecute(con->svopt->stmt)) + con->svopt->curpos = 0; } - if (OCI_STATUS && (con->svopt->cursize > 0)) + if (con->svopt->cursize > 0) { const unsigned int charsize = sizeof(otext); - OCI_RETVAL = (const otext*)(con->svopt->arrbuf + (size_t)(((con->svopt->lnsize + 1) * charsize) * con->svopt->curpos++)); + line = (const otext*)(con->svopt->arrbuf + (size_t)(((con->svopt->lnsize + 1) * charsize) * con->svopt->curpos++)); } } - OCI_CALL_EXIT() + SET_RETVAL(line) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetTrace + * ConnectionSetTrace * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetTrace +boolean ConnectionSetTrace ( OCI_Connection *con, unsigned int trace, const otext *value ) { - const otext *str = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + dbtext* dbstr = NULL; + int dbsize = 0; + ub4 attrib = OCI_UNKNOWN; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, trace, TraceTypeValues, OTEXT("Trace Type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + const otext* str = NULL; + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(trace, TraceTypeValues, OTEXT("Trace Type")) /* allocate trace info structure only if trace functions are used */ - OCI_ALLOCATE_DATA(OCI_IPC_TRACE_INFO, con->trace, 1) + ALLOC_DATA(OCI_IPC_TRACE_INFO, con->trace, 1) /* set trace properties */ @@ -1780,34 +2108,34 @@ boolean OCI_API OCI_SetTrace { case OCI_TRC_IDENTITY: { - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 attrib = OCI_ATTR_CLIENT_IDENTIFIER; - #endif - OCI_SET_TRACE(identifier) +#endif + SET_TRACE(identifier) break; } case OCI_TRC_MODULE: { - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 attrib = OCI_ATTR_MODULE; - #endif - OCI_SET_TRACE(module) +#endif + SET_TRACE(module) break; } case OCI_TRC_ACTION: { - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 attrib = OCI_ATTR_ACTION; - #endif - OCI_SET_TRACE(action) +#endif + SET_TRACE(action) break; } case OCI_TRC_DETAIL: { - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 attrib = OCI_ATTR_CLIENT_INFO; - #endif - OCI_SET_TRACE(info) +#endif + SET_TRACE(info) break; } case OCI_TRC_OPERATION: @@ -1815,8 +2143,8 @@ boolean OCI_API OCI_SetTrace #if OCI_VERSION_COMPILE >= OCI_12_1 attrib = OCI_ATTR_DBOP; #endif - OCI_SET_TRACE(operation) - break; + SET_TRACE(operation) + break; } } } @@ -1825,43 +2153,52 @@ boolean OCI_API OCI_SetTrace /* On success, we give the value to Oracle to record it in system views */ - if (OCI_STATUS && attrib != OCI_UNKNOWN) + if (attrib != OCI_UNKNOWN) { - dbtext *dbstr = NULL; - int dbsize = 0; - - if (str) + if (NULL != str) { dbsize = -1; - dbstr = OCI_StringGetOracleString(str, &dbsize); + dbstr = StringGetDBString(str, &dbsize); } - OCI_SET_ATTRIB(OCI_HTYPE_SESSION, attrib, con->ses, dbstr, dbsize); - - OCI_StringReleaseOracleString(dbstr); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SESSION, attrib, + con->ses, dbstr, dbsize, + con->err + ) } #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TraceGet + * ConnectionTraceGet * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetTrace +const otext * ConnectionGetTrace ( OCI_Connection *con, unsigned int trace ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, trace, TraceTypeValues, OTEXT("Trace Type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(trace, TraceTypeValues, OTEXT("Trace Type")) + + const otext *value = NULL; if (con->trace) { @@ -1869,403 +2206,500 @@ const otext * OCI_API OCI_GetTrace { case OCI_TRC_IDENTITY: { - OCI_GET_TRACE(identifier) + GET_TRACE(identifier) break; } case OCI_TRC_MODULE: { - OCI_GET_TRACE(module) + GET_TRACE(module) break; } case OCI_TRC_ACTION: { - OCI_GET_TRACE(action) + GET_TRACE(action) break; } case OCI_TRC_DETAIL: { - OCI_GET_TRACE(info) + GET_TRACE(info) break; } case OCI_TRC_OPERATION: { - OCI_GET_TRACE(operation) + GET_TRACE(operation) break; } } } - OCI_CALL_EXIT() + SET_RETVAL(value) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Ping + * ConnectionPing * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Ping +boolean ConnectionPing ( OCI_Connection *con ) { - OCI_CALL_ENTER(boolean , FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (OCILib.version_runtime >= OCI_10_2) + if (Env.version_runtime >= OCI_10_2) { - OCI_EXEC(OCIPing(con->cxt, con->err, (ub4)OCI_DEFAULT)) - - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + con->err, + OCIPing, con->cxt, con->err, + (ub4)OCI_DEFAULT + ) } #endif - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetTimeout + * ConnectionSetTimeout * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetTimeout +boolean ConnectionSetTimeout ( OCI_Connection *con, unsigned int type, unsigned int value ) { - ub4 timeout = value; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(boolean , FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, FALSE, type, TimeoutTypeValues, OTEXT("timeout type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(type, TimeoutTypeValues, OTEXT("timeout type")) + + boolean success = FALSE; #if OCI_VERSION_COMPILE >= OCI_12_1 - if (OCILib.version_runtime >= OCI_12_1) + ub4 timeout = value; + + if (Env.version_runtime >= OCI_12_1) { switch (type) { case OCI_NTO_SEND: { - OCI_SET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_SEND_TIMEOUT, con->svr, &timeout, sizeof(timeout)) - OCI_RETVAL = OCI_STATUS; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SERVER, OCI_ATTR_SEND_TIMEOUT, + con->svr, &timeout, sizeof(timeout), + con->err + ) + success = TRUE; break; } case OCI_NTO_RECEIVE: { - OCI_SET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_RECEIVE_TIMEOUT, con->svr, &timeout, sizeof(timeout)) - OCI_RETVAL = OCI_STATUS; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SERVER, OCI_ATTR_RECEIVE_TIMEOUT, + con->svr, &timeout, sizeof(timeout), + con->err + ) + success = TRUE; break; } - #if OCI_VERSION_COMPILE >= OCI_18_1 + #if OCI_VERSION_COMPILE >= OCI_18_1 case OCI_NTO_CALL: { - if (OCILib.version_runtime >= OCI_18_1) + if (Env.version_runtime >= OCI_18_1) { - OCI_SET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_CALL_TIMEOUT, con->cxt, &timeout, sizeof(timeout)) - OCI_RETVAL = OCI_STATUS; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_CALL_TIMEOUT, + con->cxt, &timeout, sizeof(timeout), + con->err + ) + success = TRUE; } break; } - #endif - + #endif + } } #endif - OCI_CALL_EXIT() -} + SET_RETVAL(success) + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_GetTimeout + * ConnectionGetTimeout * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetTimeout +unsigned int ConnectionGetTimeout ( OCI_Connection *con, unsigned int type ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_CONNECTION, con + ) + ub4 timeout = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, 0, type, TimeoutTypeValues, OTEXT("timeout type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(type, TimeoutTypeValues, OTEXT("timeout type")) #if OCI_VERSION_COMPILE >= OCI_12_1 - if (OCILib.version_runtime >= OCI_12_1) + if (Env.version_runtime >= OCI_12_1) { switch (type) { case OCI_NTO_SEND: { - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_SEND_TIMEOUT, con->svr, &timeout, sizeof(timeout)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SERVER, OCI_ATTR_SEND_TIMEOUT, + con->svr, &timeout, sizeof(timeout), + con->err + ) break; } case OCI_NTO_RECEIVE: { - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_RECEIVE_TIMEOUT, con->svr, &timeout, sizeof(timeout)) - break; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SERVER, OCI_ATTR_RECEIVE_TIMEOUT, + con->svr, &timeout, sizeof(timeout), + con->err + ) + break; } - #if OCI_VERSION_COMPILE >= OCI_18_1 + #if OCI_VERSION_COMPILE >= OCI_18_1 case OCI_NTO_CALL: { - if (OCILib.version_runtime >= OCI_18_3) + if (Env.version_runtime >= OCI_18_3) { - OCI_GET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_CALL_TIMEOUT, con->cxt, &timeout, sizeof(timeout)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_CALL_TIMEOUT, + con->cxt, &timeout, sizeof(timeout), + con->err + ) } break; } - - #endif + + #endif } } #endif - OCI_RETVAL = timeout; + SET_RETVAL(timeout) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDBName + * ConnectionGetDBName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetDBName +const otext * ConnectionGetDatabaseName ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext *, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!con->db_name) + if (NULL == con->db_name) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(con, con->svr, OCI_HTYPE_SERVER, OCI_ATTR_DBNAME, &con->db_name, &size); + + CHECK(StringGetAttribute(con, con->svr, OCI_HTYPE_SERVER, + OCI_ATTR_DBNAME, &con->db_name, &size)) } #endif - OCI_RETVAL = (const otext *) con->db_name; + SET_RETVAL((const otext *) con->db_name) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetInstanceName + * ConnectionGetInstanceName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetInstanceName +const otext * ConnectionGetInstanceName ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!con->inst_name) + if (NULL == con->inst_name) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(con, con->svr, OCI_HTYPE_SERVER, OCI_ATTR_INSTNAME, &con->inst_name, &size); + + CHECK(StringGetAttribute(con, con->svr, OCI_HTYPE_SERVER, + OCI_ATTR_INSTNAME, &con->inst_name, &size)) } #endif - OCI_RETVAL = (const otext *)con->inst_name; + SET_RETVAL((const otext *)con->inst_name) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetServiceName + * ConnectionGetServiceName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetServiceName +const otext * ConnectionGetServiceName ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!con->service_name) + if (NULL == con->service_name) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(con, con->svr, OCI_HTYPE_SERVER, OCI_ATTR_SERVICENAME, &con->service_name, &size); + + CHECK(StringGetAttribute(con, con->svr, OCI_HTYPE_SERVER, + OCI_ATTR_SERVICENAME, &con->service_name, &size)) } #endif - OCI_RETVAL = (const otext *)con->service_name; + SET_RETVAL((const otext *)con->service_name) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetServerName + * ConnectionGetServerName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetServerName +const otext * ConnectionGetServerName ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!con->server_name) + if (NULL == con->server_name) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(con, con->svr, OCI_HTYPE_SERVER, OCI_ATTR_HOSTNAME, &con->server_name, &size); + + CHECK(StringGetAttribute(con, con->svr, OCI_HTYPE_SERVER, + OCI_ATTR_HOSTNAME, &con->server_name, &size)) } #endif - OCI_RETVAL = (const otext *)con->server_name; + SET_RETVAL((const otext *)con->server_name) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDomainName + * ConnectionGetDomainName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetDomainName +const otext * ConnectionGetDomainName ( OCI_Connection *con ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!con->domain_name) + if (NULL == con->domain_name) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(con, con->svr, OCI_HTYPE_SERVER, OCI_ATTR_DBDOMAIN, &con->domain_name, &size); + + CHECK(StringGetAttribute(con, con->svr, OCI_HTYPE_SERVER, + OCI_ATTR_DBDOMAIN, &con->domain_name, &size)) } #endif - OCI_RETVAL = (const otext *)con->domain_name; + SET_RETVAL((const otext *)con->domain_name) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetInstanceStartTime + * ConnectionGetInstanceStartTime * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_API OCI_GetInstanceStartTime +OCI_Timestamp * ConnectionGetInstanceStartTime ( OCI_Connection *con ) { - OCI_CALL_ENTER(OCI_Timestamp*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Timestamp*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (!con->inst_startup) + if (NULL == con->inst_startup) { OCIDateTime *handle = NULL; - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_INSTSTARTTIME, con->svr, &handle, NULL); - con->inst_startup = OCI_TimestampInit(con, NULL, handle, OCI_TIMESTAMP); - OCI_STATUS = OCI_STATUS && (NULL != con->inst_startup); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_INSTSTARTTIME, + con->svr, &handle, NULL, + con->err + ) + + con->inst_startup = TimestampInitialize(con, NULL, handle, OCI_TIMESTAMP); + CHECK_NULL(con->inst_startup) } #endif - OCI_RETVAL = con->inst_startup; + SET_RETVAL(con->inst_startup) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IsTAFCapable + * ConnectionIsTAFCapable * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IsTAFCapable +boolean ConnectionIsTAFCapable ( OCI_Connection *con ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + boolean value = FALSE; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (OCILib.version_runtime >= OCI_10_2) + if (Env.version_runtime >= OCI_10_2) { - OCI_GET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_TAF_ENABLED, con->svr, &value, NULL); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SERVER, OCI_ATTR_TAF_ENABLED, + con->svr, &value, NULL, + con->err + ) } #endif - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetTAFHandler + * ConnectionSetTAFHandler * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetTAFHandler +boolean ConnectionSetTAFHandler ( OCI_Connection *con, POCI_TAF_HANDLER handler ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = OCI_IsTAFCapable(con); + CHECK(ConnectionIsTAFCapable(con)) #if OCI_VERSION_COMPILE >= OCI_10_2 - if (OCI_RETVAL && OCILib.version_runtime >= OCI_10_2) + if (Env.version_runtime >= OCI_10_2) { OCIFocbkStruct fo_struct; @@ -2275,70 +2709,93 @@ boolean OCI_API OCI_SetTAFHandler if (con->taf_handler) { - fo_struct.callback_function = (OCICallbackFailover) OCI_ProcFailOver; + fo_struct.callback_function = (OCICallbackFailover) CallbackFailOver; fo_struct.fo_ctx = (dvoid *) con; } - OCI_SET_ATTRIB(OCI_HTYPE_SERVER, OCI_ATTR_FOCBK, con->svr, &fo_struct, 0); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SERVER, OCI_ATTR_FOCBK, + con->svr, &fo_struct, 0, + con->err + ) } #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetStatementCacheSize + * ConnectionGetStatementCacheSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetStatementCacheSize +unsigned int ConnectionGetStatementCacheSize ( - OCI_Connection *con + OCI_Connection *con ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_CONNECTION, con + ) + ub4 cache_size = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_9_2 - if (OCILib.version_runtime >= OCI_9_2) + if (Env.version_runtime >= OCI_9_2) { - OCI_GET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_STMTCACHESIZE, con->cxt, &cache_size, NULL); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_STMTCACHESIZE, + con->cxt, &cache_size, NULL, + con->err + ) } #endif - OCI_RETVAL = cache_size; + SET_RETVAL(cache_size) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetStatementCacheSize + * ConnectionSetStatementCacheSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetStatementCacheSize +boolean ConnectionSetStatementCacheSize ( - OCI_Connection *con, - unsigned int value + OCI_Connection *con, + unsigned int value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + ub4 cache_size = value; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_9_2 - if (OCILib.version_runtime >= OCI_9_2) + if (Env.version_runtime >= OCI_9_2) { - OCI_SET_ATTRIB(OCI_HTYPE_SVCCTX, OCI_ATTR_STMTCACHESIZE, con->cxt, &cache_size, sizeof(cache_size)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SVCCTX, OCI_ATTR_STMTCACHESIZE, + con->cxt, &cache_size, sizeof(cache_size), + con->err + ) } #else @@ -2347,61 +2804,83 @@ boolean OCI_API OCI_SetStatementCacheSize #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDefaultLobPrefetchSize + * ConnectionGetDefaultLobPrefetchSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetDefaultLobPrefetchSize +unsigned int ConnectionGetDefaultLobPrefetchSize ( OCI_Connection *con ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_CONNECTION, con + ) + ub4 prefetch_size = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_11_1 - if (OCI_ConnectionIsVersionSupported(con, OCI_11_1)) + if (ConnectionIsVersionSupported(con, OCI_11_1)) { - OCI_GET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE, con->ses, &prefetch_size, NULL); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SESSION, OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE, + con->ses, &prefetch_size, NULL, + con->err + ) } #endif - OCI_RETVAL = prefetch_size; + SET_RETVAL(prefetch_size) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetDefaultLobPrefetchSize + * ConnectionSetDefaultLobPrefetchSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetDefaultLobPrefetchSize +boolean ConnectionSetDefaultLobPrefetchSize ( OCI_Connection *con, - unsigned int value + unsigned int value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + ub4 prefetch_size = value; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + boolean success = FALSE; + + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_11_1 - if (OCI_ConnectionIsVersionSupported(con, OCI_11_1)) + if (ConnectionIsVersionSupported(con, OCI_11_1)) { - OCI_SET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE, con->ses, &prefetch_size, sizeof(prefetch_size)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SESSION, OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE, + con->ses, &prefetch_size, sizeof(prefetch_size), + con->err + ) + + success = TRUE; } #else @@ -2410,160 +2889,170 @@ boolean OCI_API OCI_SetDefaultLobPrefetchSize #endif - OCI_RETVAL = OCI_STATUS; + SET_RETVAL(success) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetMaxCursors + * ConnectionGetMaxCursors * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetMaxCursors +unsigned int ConnectionGetMaxCursors ( OCI_Connection *con ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_CONNECTION, con + ) + ub4 max_cursors = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) #if OCI_VERSION_COMPILE >= OCI_12_1 - if (OCI_ConnectionIsVersionSupported(con, OCI_12_1)) + if (ConnectionIsVersionSupported(con, OCI_11_1)) { - OCI_GET_ATTRIB(OCI_HTYPE_SESSION, OCI_ATTR_MAX_OPEN_CURSORS, con->ses, &max_cursors, NULL); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SESSION, OCI_ATTR_MAX_OPEN_CURSORS, + con->ses, &max_cursors, NULL, + con->err + ) } #endif - OCI_RETVAL = max_cursors; + SET_RETVAL(max_cursors) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Immediate + * ConnectionExecuteImmediate * --------------------------------------------------------------------------------------------- */ -boolean OCI_Immediate +boolean ConnectionExecuteImmediate ( OCI_Connection *con, const otext *sql, - ... + va_list args ) { - OCI_Statement *stmt = NULL; - va_list args; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + OCI_Statement *stmt = NULL; - /* First, execute SQL */ + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, sql) - stmt = OCI_StatementCreate(con); - OCI_STATUS = (NULL != stmt); - - if (OCI_STATUS) - { - OCI_STATUS = OCI_ExecuteStmt(stmt, sql); + /* create statement */ - /* get resultset and set up variables */ + stmt = StatementCreate(con); + CHECK_NULL(stmt) - if (OCI_STATUS && (OCI_CST_SELECT == OCI_GetStatementType(stmt))) - { - va_start(args, sql); + /* First, execute SQL */ - OCI_STATUS = OCI_FetchIntoUserVariables(stmt, args); + CHECK(StatementExecuteStmt(stmt, sql)) - va_end(args); - } + /* get resultset and set up variables */ - OCI_StatementFree(stmt); + if (OCI_CST_SELECT == StatementGetStatementType(stmt)) + { + CHECK(StatementFetchIntoUserVariables(stmt, args)) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != stmt) + { + StatementFree(stmt); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ImmediateFmt + * ConnectionExecuteImmediateFmt * --------------------------------------------------------------------------------------------- */ -boolean OCI_ImmediateFmt +boolean ConnectionExecuteImmediateFmt ( OCI_Connection *con, const otext *sql, - ... + va_list args ) { - OCI_Statement *stmt = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + OCI_Statement *stmt = NULL; + otext* sql_fmt = NULL; - stmt = OCI_StatementCreate(con); - OCI_STATUS = (NULL != stmt); + va_list first_pass_args; + va_list second_pass_args; - if (OCI_STATUS) - { - int size = 0; - va_list args; + va_copy(first_pass_args, args); + va_copy(second_pass_args, args); - /* first, get buffer size */ + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, sql) - va_start(args, sql); + /* create statement */ - size = OCI_ParseSqlFmt(stmt, NULL, sql, &args); + stmt = StatementCreate(con); + CHECK_NULL(stmt) - va_end(args); + /* first, get buffer size */ - if (size > 0) - { - /* allocate buffer */ + int size = FormatParseSql(stmt, NULL, sql, &first_pass_args); + CHECK(size > 0) - otext *sql_fmt = NULL; + /* allocate buffer */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - - if (OCI_STATUS) - { - /* format buffer */ + ALLOC_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - va_start(args, sql); + /* format buffer */ - if (OCI_ParseSqlFmt(stmt, sql_fmt, sql, &args) > 0) - { - /* prepare and execute SQL buffer */ + size = FormatParseSql(stmt, sql_fmt, sql, &second_pass_args); + CHECK(size > 0) - OCI_STATUS = OCI_PrepareInternal(stmt, sql_fmt) && OCI_ExecuteInternal(stmt, OCI_DEFAULT); + /* prepare and execute SQL buffer */ - /* get resultset and set up variables */ + CHECK(StatementPrepareInternal(stmt, sql_fmt)) + CHECK(StatementExecuteInternal(stmt, OCI_DEFAULT)) - if (OCI_STATUS && (OCI_CST_SELECT == OCI_GetStatementType(stmt))) - { - OCI_STATUS = OCI_FetchIntoUserVariables(stmt, args); - } - } + /* get resultset and set up variables */ - va_end(args); + if (OCI_CST_SELECT == StatementGetStatementType(stmt)) + { + CHECK(StatementFetchIntoUserVariables(stmt, second_pass_args)) + } - OCI_FREE(sql_fmt) - } - } + SET_SUCCESS() - OCI_StatementFree(stmt); - } + CLEANUP_AND_EXIT_FUNC + ( + va_end(first_pass_args); + va_end(second_pass_args); - OCI_RETVAL = OCI_STATUS; + if (NULL != stmt) + { + StatementFree(stmt); + } - OCI_CALL_EXIT() + FREE(sql_fmt) + ) } - diff --git a/src/connection.h b/src/connection.h new file mode 100644 index 00000000..68aa32d5 --- /dev/null +++ b/src/connection.h @@ -0,0 +1,332 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_CONNECTION_H_INCLUDED +#define OCILIB_CONNECTION_H_INCLUDED + +#include "types.h" + +OCI_Connection * ConnectionCreateInternal +( + OCI_Pool *pool, + const otext *db, + const otext *user, + const otext *pwd, + unsigned int mode, + const otext *tag +); + +OCI_Connection* ConnectionAllocate +( + OCI_Pool * pool, + const otext* db, + const otext* user, + const otext* pwd, + unsigned int mode +); + +boolean ConnectionAttach +( + OCI_Connection* con +); + +boolean ConnectionLogon +( + OCI_Connection* con, + const otext * new_pwd, + const otext * tag +); + +boolean ConnectionDispose +( + OCI_Connection* con +); + +unsigned int ConnectionGetMinSupportedVersion +( + OCI_Connection *con +); + +boolean ConnectionIsVersionSupported +( + OCI_Connection *con, + unsigned int version +); + +OCI_Connection* ConnectionCreate +( + const otext* db, + const otext* user, + const otext* pwd, + unsigned int mode +); + +boolean ConnectionFree +( + OCI_Connection* con +); + +boolean ConnectionCommit +( + OCI_Connection* con +); + +boolean ConnectionRollback +( + OCI_Connection* con +); + +boolean ConnectionSetAutoCommit +( + OCI_Connection* con, + boolean enable +); + +boolean ConnectionGetAutoCommit +( + OCI_Connection* con +); + +boolean ConnectionIsConnected +( + OCI_Connection* con +); + +void* ConnectionGetUserData +( + OCI_Connection* con +); + +boolean ConnectionSetUserData +( + OCI_Connection* con, + void * data +); + +boolean ConnectionSetSessionTag +( + OCI_Connection* con, + const otext * tag +); + +const otext* ConnectionGetSessionTag +( + OCI_Connection* con +); + +const otext* ConnectionGetConnectionString +( + OCI_Connection* con +); + +const otext* ConnectionGetUserName +( + OCI_Connection* con +); + +const otext* ConnectionGetPassword +( + OCI_Connection* con +); + +boolean ConnectionSetPassword +( + OCI_Connection* con, + const otext * password +); + +unsigned int ConnectionGetSessionMode +( + OCI_Connection* con +); + +const otext* ConnectionGetServerVersion +( + OCI_Connection* con +); + +unsigned int ConnectionGetServerMajorVersion +( + OCI_Connection* con +); + +unsigned int ConnectionGetServerMinorVersion +( + OCI_Connection* con +); + +unsigned int ConnectionGetServerRevisionVersion +( + OCI_Connection* con +); + +OCI_Transaction* ConnectionGetTransaction +( + OCI_Connection* con +); + +boolean ConnectionSetTransaction +( + OCI_Connection * con, + OCI_Transaction* trans +); + +unsigned int ConnectionGetVersion +( + OCI_Connection* con +); + +boolean ConnectionBreak +( + OCI_Connection* con +); + +boolean ConnectionEnableServerOutput +( + OCI_Connection* con, + unsigned int bufsize, + unsigned int arrsize, + unsigned int lnsize +); + +boolean ConnectionDisableServerOutput +( + OCI_Connection* con +); + +const otext* ConnectionGetServerOutput +( + OCI_Connection* con +); + +boolean ConnectionSetTrace +( + OCI_Connection* con, + unsigned int trace, + const otext * value +); + +const otext* ConnectionGetTrace +( + OCI_Connection* con, + unsigned int trace +); + +boolean ConnectionPing +( + OCI_Connection* con +); + +boolean ConnectionSetTimeout +( + OCI_Connection* con, + unsigned int type, + unsigned int value +); + +unsigned int ConnectionGetTimeout +( + OCI_Connection* con, + unsigned int type +); + +const otext* ConnectionGetDatabaseName +( + OCI_Connection* con +); + +const otext* ConnectionGetInstanceName +( + OCI_Connection* con +); + +const otext* ConnectionGetServiceName +( + OCI_Connection* con +); + +const otext* ConnectionGetServerName +( + OCI_Connection* con +); + +const otext* ConnectionGetDomainName +( + OCI_Connection* con +); + +OCI_Timestamp* ConnectionGetInstanceStartTime +( + OCI_Connection* con +); + +boolean ConnectionIsTAFCapable +( + OCI_Connection* con +); + +boolean ConnectionSetTAFHandler +( + OCI_Connection * con, + POCI_TAF_HANDLER handler +); + +unsigned int ConnectionGetStatementCacheSize +( + OCI_Connection* con +); + +boolean ConnectionSetStatementCacheSize +( + OCI_Connection* con, + unsigned int value +); + +unsigned int ConnectionGetDefaultLobPrefetchSize +( + OCI_Connection* con +); + +boolean ConnectionSetDefaultLobPrefetchSize +( + OCI_Connection* con, + unsigned int value +); + +unsigned int ConnectionGetMaxCursors +( + OCI_Connection* con +); + +boolean ConnectionExecuteImmediate +( + OCI_Connection* con, + const otext * sql, + va_list args +); + +boolean ConnectionExecuteImmediateFmt +( + OCI_Connection* con, + const otext * sql, + va_list args +); + +#endif /* OCILIB_CONNECTION_H_INCLUDED */ \ No newline at end of file diff --git a/src/database.c b/src/database.c new file mode 100644 index 00000000..1ab4c959 --- /dev/null +++ b/src/database.c @@ -0,0 +1,349 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "database.h" + +#include "array.h" +#include "connection.h" +#include "error.h" +#include "macros.h" +#include "statement.h" +#include "strings.h" +#include "transaction.h" + +/* --------------------------------------------------------------------------------------------- * + * DatabaseStartup + * --------------------------------------------------------------------------------------------- */ + +boolean DatabaseStartup +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int sess_mode, + unsigned int start_mode, + unsigned int start_flag, + const otext *spfile +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + OCI_Connection *con = NULL; + OCI_Statement *stmt = NULL; + +#if OCI_VERSION_COMPILE >= OCI_10_2 + + OCIAdmin* adm = NULL; + + dbtext* dbstr = NULL; + int dbsize = -1; + +#endif + + CHECK_REMOTE_DBS_CONTROL_ENABLED() + +#if OCI_VERSION_COMPILE >= OCI_10_2 + + if (start_mode & OCI_DB_SPM_START) + { + /* connect with preliminary authentication mode */ + + con = ConnectionCreate(db, user, pwd, sess_mode | OCI_PRELIM_AUTH); + CHECK_NULL(con) + + if (IS_STRING_VALID(spfile)) + { + /* allocate administration handle */ + + CHECK(MemoryAllocHandle((dvoid *)Env.env, (dvoid **) (void *) &adm, OCI_HTYPE_ADMIN)) + + /* set client file if provided */ + + dbstr = StringGetDBString(spfile, &dbsize); + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_ADMIN, OCI_ATTR_ADMIN_PFILE, + adm, dbstr, dbsize, + Env.err + ) + } + + /* startup DB */ + + CHECK_OCI + ( + Env.err, + OCIDBStartup, + con->cxt, con->err, + (OCIAdmin *) adm, OCI_DEFAULT, + start_flag + ) + + ConnectionFree(con); + } + + /* connect without preliminary mode */ + + con = ConnectionCreate(db, user, pwd, sess_mode); + CHECK_NULL(con) + + /* alter database */ + + stmt = StatementCreate(con); + CHECK_NULL(stmt) + + /* mount database */ + + if (start_mode & OCI_DB_SPM_MOUNT) + { + CHECK(StatementExecuteStmt(stmt, OTEXT("ALTER DATABASE MOUNT"))) + } + + /* open database */ + + if (start_mode & OCI_DB_SPM_OPEN) + { + CHECK(StatementExecuteStmt(stmt, OTEXT("ALTER DATABASE OPEN"))) + } + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + + if (NULL != stmt) + { + StatementFree(stmt); + } + + if (NULL != con) + { + ConnectionFree(con); + } + + if (NULL != adm) + { + MemoryFreeHandle(Env.err, OCI_HTYPE_ADMIN); + } + ) + +#else + + OCI_NOT_USED(db) + OCI_NOT_USED(user) + OCI_NOT_USED(pwd) + OCI_NOT_USED(sess_mode) + OCI_NOT_USED(start_mode) + OCI_NOT_USED(start_flag) + OCI_NOT_USED(spfile) + OCI_NOT_USED(con) + OCI_NOT_USED(stmt) + + CHECK(FALSE) + + EXIT_FUNC() + +#endif + +} + +/* --------------------------------------------------------------------------------------------- * + * DatabaseShutdown + * --------------------------------------------------------------------------------------------- */ + +boolean DatabaseShutdown +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int sess_mode, + unsigned int shut_mode, + unsigned int shut_flag +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + OCI_Connection *con = NULL; + OCI_Statement *stmt = NULL; + + CHECK_REMOTE_DBS_CONTROL_ENABLED() + +#if OCI_VERSION_COMPILE >= OCI_10_2 + + /* connect to server */ + + con = ConnectionCreate(db, user, pwd, sess_mode); + CHECK_NULL(con) + + /* delete current transaction before the abort */ + + if (NULL != con->trs && (OCI_DB_SDF_ABORT == shut_flag)) + { + TransactionFree(con->trs); + con->trs = NULL; + } + + /* start shutdown */ + + if (shut_mode & OCI_DB_SDM_SHUTDOWN) + { + /* start shutdown process */ + + CHECK_OCI + ( + Env.err, + OCIDBShutdown, + con->cxt, con->err, + (OCIAdmin *) NULL, + shut_flag + ) + } + + /* alter database if we are not in abort mode */ + + if (OCI_DB_SDF_ABORT != shut_flag) + { + stmt = StatementCreate(con); + CHECK_NULL(stmt) + + /* close database */ + + if (shut_mode & OCI_DB_SDM_CLOSE) + { + CHECK(StatementExecuteStmt(stmt, OTEXT("ALTER DATABASE CLOSE NORMAL"))) + } + + /* unmount database */ + + if (shut_mode & OCI_DB_SDM_DISMOUNT) + { + CHECK(StatementExecuteStmt(stmt, OTEXT("ALTER DATABASE DISMOUNT"))) + } + + StatementFree(stmt); + stmt = NULL; + + /* delete current transaction before the shutdown */ + + if (NULL != con->trs) + { + TransactionFree(con->trs); + con->trs = NULL; + } + + /* do the final shutdown if we are not in abort mode */ + + CHECK_OCI + ( + Env.err, + OCIDBShutdown, + con->cxt, con->err, + (OCIAdmin *) 0, + OCI_DBSHUTDOWN_FINAL + ) + + ConnectionFree(con); + con = NULL; + } + + SET_SUCCESS() + +#else + + OCI_NOT_USED(db) + OCI_NOT_USED(user) + OCI_NOT_USED(pwd) + OCI_NOT_USED(sess_mode) + OCI_NOT_USED(shut_mode) + OCI_NOT_USED(shut_flag) + OCI_NOT_USED(con) + +#endif + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != stmt) + { + StatementFree(stmt); + } + + if (NULL != con) + { + ConnectionFree(con); + } + ) +} + +/* --------------------------------------------------------------------------------------------- * + * DatabaseSetUserPassword + * --------------------------------------------------------------------------------------------- */ + +boolean DatabaseSetUserPassword +( + const otext* db, + const otext* user, + const otext* pwd, + const otext* new_pwd +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + OCI_Connection* con = NULL; + + /* let's be sure OCI_Initialize() has been called */ + + CHECK_INITIALIZED() + CHECK_PTR(OCI_IPC_STRING, pwd) + CHECK_PTR(OCI_IPC_STRING, new_pwd) + + /* create a connection in auth mode */ + + con = ConnectionAllocate( NULL, db, user, pwd, OCI_AUTH); + CHECK_NULL(con) + + /* ConnectionLogon() will reset the password */ + + CHECK(ConnectionAttach(con)) + CHECK(ConnectionLogon(con, new_pwd, NULL)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE && NULL != con) + { + ConnectionFree(con); + } + ) +} \ No newline at end of file diff --git a/src/database.h b/src/database.h new file mode 100644 index 00000000..8eb9e4b9 --- /dev/null +++ b/src/database.h @@ -0,0 +1,55 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_DATABASE_H_INCLUDED +#define OCILIB_DATABASE_H_INCLUDED + +#include "types.h" + +boolean DatabaseSetUserPassword +( + const otext* db, + const otext* user, + const otext* pwd, + const otext* new_pwd +); + +boolean DatabaseStartup +( + const otext* db, + const otext* user, + const otext* pwd, + unsigned int sess_mode, + unsigned int start_mode, + unsigned int start_flag, + const otext* spfile +); + +boolean DatabaseShutdown +( + const otext* db, + const otext* user, + const otext* pwd, + unsigned int sess_mode, + unsigned int shut_mode, + unsigned int shut_flag +); + +#endif /* OCILIB_DATABASE_H_INCLUDED */ diff --git a/src/date.c b/src/date.c index 2bf15dd4..b9693e62 100644 --- a/src/date.c +++ b/src/date.c @@ -18,17 +18,18 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "date.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "array.h" +#include "environment.h" +#include "macros.h" +#include "strings.h" /* --------------------------------------------------------------------------------------------- * - * OCI_DateInit + * DateInit * --------------------------------------------------------------------------------------------- */ -OCI_Date * OCI_DateInit +OCI_Date * DateInitialize ( OCI_Connection *con, OCI_Date *date, @@ -37,350 +38,431 @@ OCI_Date * OCI_DateInit boolean ansi ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_ALLOCATE_DATA(OCI_IPC_DATE, date, 1); + ENTER_FUNC + ( + /* returns */ OCI_Date*, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) - if (OCI_STATUS) - { - date->con = con; + ALLOC_DATA(OCI_IPC_DATE, date, 1); - /* get the right error handle */ + date->con = con; - date->err = con ? con->err : OCILib.err; - date->env = con ? con->env : OCILib.env; + /* get the right error handle */ - /* allocate buffer if needed */ + date->err = con ? con->err : Env.err; + date->env = con ? con->env : Env.env; - if (!date->handle && (allocate || ansi)) - { - date->allocated = TRUE; + /* allocate buffer if needed */ - if (allocate) - { - date->hstate = OCI_OBJECT_ALLOCATED; - } + if (NULL == date->handle && (allocate || ansi)) + { + date->allocated = TRUE; - OCI_ALLOCATE_DATA(OCI_IPC_OCIDATE, date->handle, 1); - } - else + if (allocate) { - if (OCI_OBJECT_ALLOCATED_ARRAY != date->hstate) - { - date->hstate = OCI_OBJECT_FETCHED_CLEAN; - } - - date->handle = buffer; + date->hstate = OCI_OBJECT_ALLOCATED; } - /* if the input buffer is an SQLT_DAT buffer, we need to convert it */ - - if (ansi && date->handle && buffer) + ALLOC_DATA(OCI_IPC_OCIDATE, date->handle, 1); + } + else + { + if (OCI_OBJECT_ALLOCATED_ARRAY != date->hstate) { - unsigned char *d = (unsigned char *) buffer; - - date->handle->OCIDateYYYY = (sb2) (((d[0] - 100) * 100) + (d[1] - 100)); - date->handle->OCIDateMM = (ub1) d[2]; - date->handle->OCIDateDD = (ub1) d[3]; - - date->handle->OCIDateTime.OCITimeHH = (ub1) (d[4] - 1); - date->handle->OCIDateTime.OCITimeMI = (ub1) (d[5] - 1); - date->handle->OCIDateTime.OCITimeSS = (ub1) (d[6] - 1); + date->hstate = OCI_OBJECT_FETCHED_CLEAN; } + + date->handle = buffer; } - /* check for failure */ + /* if the input buffer is an SQLT_DAT buffer, we need to convert it */ - if (!OCI_STATUS && date) + if (ansi && NULL != date->handle && NULL != buffer) { - OCI_DateFree(date); - date = NULL; + unsigned char *d = (unsigned char *) buffer; + + date->handle->OCIDateYYYY = (sb2) (((d[0] - 100) * 100) + (d[1] - 100)); + date->handle->OCIDateMM = (ub1) d[2]; + date->handle->OCIDateDD = (ub1) d[3]; + + date->handle->OCIDateTime.OCITimeHH = (ub1) (d[4] - 1); + date->handle->OCIDateTime.OCITimeMI = (ub1) (d[5] - 1); + date->handle->OCIDateTime.OCITimeSS = (ub1) (d[6] - 1); } - return date; -} + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + DateFree(date); + date = NULL; + } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + SET_RETVAL(date) + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_DateCreate + * DateCreate * --------------------------------------------------------------------------------------------- */ -OCI_Date * OCI_API OCI_DateCreate +OCI_Date * DateCreate ( OCI_Connection *con ) { - OCI_CALL_ENTER(OCI_Date*, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Date*, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + + CHECK_INITIALIZED() - OCI_RETVAL = OCI_DateInit(con, NULL, NULL, TRUE, FALSE); - OCI_STATUS = (NULL != OCI_RETVAL); + SET_RETVAL(DateInitialize(con, NULL, NULL, TRUE, FALSE)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateFree + * DateFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateFree +boolean DateFree ( OCI_Date *date ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_OBJECT_FETCHED(date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_OBJECT_FETCHED(date) if (date->allocated) { - OCI_FREE(date->handle) + FREE(date->handle) } if (OCI_OBJECT_ALLOCATED_ARRAY != date->hstate) { - OCI_FREE(date) + FREE(date) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateArrayCreate + * DateArrayCreate * --------------------------------------------------------------------------------------------- */ -OCI_Date ** OCI_API OCI_DateArrayCreate +OCI_Date ** DateCreateArray ( OCI_Connection *con, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Date**, FALSE, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Date **, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_INITIALIZED() - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_DATETIME, 0, sizeof(OCIDate), sizeof(OCI_Date), 0, NULL); - OCI_STATUS = (NULL != arr); + arr = ArrayCreate(con, nbelem, OCI_CDT_DATETIME, 0, + sizeof(OCIDate), sizeof(OCI_Date), 0, NULL); - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Date **) arr->tab_obj; - } + CHECK_NULL(arr) - OCI_CALL_EXIT() + SET_RETVAL((OCI_Date**)arr->tab_obj) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateArrayFree + * DateFreeArray * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateArrayFree +boolean DateFreeArray ( OCI_Date **dates ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, dates) - - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)dates); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_PTR(OCI_IPC_ARRAY, dates) - OCI_CALL_EXIT() + SET_RETVAL(ArrayFreeFromHandles((void**)dates)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateAddDays + * DateAddDays * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateAddDays +boolean DateAddDays ( OCI_Date *date, int nb ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) - - OCI_EXEC(OCIDateAddDays(date->err, date->handle, (sb4)nb, date->handle)) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + CHECK_PTR(OCI_IPC_DATE, date) + + CHECK_OCI + ( + date->err, + OCIDateAddDays, + date->err, date->handle, + (sb4)nb, date->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateAddMonths + * DateAddMonths * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateAddMonths +boolean DateAddMonths ( OCI_Date *date, int nb ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) - OCI_EXEC(OCIDateAddMonths(date->err, date->handle, (sb4) nb, date->handle) ) + CHECK_PTR(OCI_IPC_DATE, date) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + date->err, + OCIDateAddMonths, + date->err, date->handle, + (sb4) nb, date->handle + ) + + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateAssign + * DateAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateAssign +boolean DateAssign ( OCI_Date *date, OCI_Date *date_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date_src) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) - OCI_EXEC(OCIDateAssign(date->err, date_src->handle, date->handle)) + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_DATE, date_src) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + date->err, + OCIDateAssign, + date->err, date_src->handle, + date->handle + ) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateCheck + * DateCheck * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_DateCheck +int DateCheck ( OCI_Date *date ) { + ENTER_FUNC + ( + /* returns */ int, OCI_ERROR, + /* context */ OCI_IPC_DATE, date + ) + uword valid = 0; - OCI_CALL_ENTER(int, valid) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date) - OCI_EXEC(OCIDateCheck(date->err, date->handle, &valid)) - - OCI_RETVAL = (int) valid; + CHECK_OCI + ( + date->err, + OCIDateCheck, + date->err, date->handle, + &valid + ) - OCI_CALL_EXIT() + SET_RETVAL((int) valid) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateCompare + * DateCompare * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_DateCompare +int DateCompare ( OCI_Date *date, OCI_Date *date2 ) { + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_DATE, date + ) + sword value = OCI_ERROR; - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date2) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_DATE, date2) - OCI_EXEC(OCIDateCompare(date->err, date->handle, date2->handle, &value)) + CHECK_OCI + ( + date->err, + OCIDateCompare, + date->err, date->handle, + date2->handle, &value + ) - OCI_RETVAL = (int) value; + SET_RETVAL((int) value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateDaysBetween + * DateDaysBetween * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_DateDaysBetween +int DateDaysBetween ( OCI_Date *date, OCI_Date *date2 ) { + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_DATE, date + ) + sb4 diff = 0; - OCI_CALL_ENTER(int, diff) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date); - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date2); - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date); + CHECK_PTR(OCI_IPC_DATE, date2); - OCI_EXEC(OCIDateDaysBetween(date->err, date->handle, date2->handle, &diff)) + CHECK_OCI + ( + date->err, + OCIDateDaysBetween, + date->err, date->handle, + date2->handle, &diff + ) - OCI_RETVAL = (int) diff; + SET_RETVAL((int) diff) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateFromText + * DateFromString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateFromText +boolean DateFromString ( OCI_Date *date, const otext *str, const otext *fmt ) { - dbtext *dbstr1 = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + dbtext *dbstr1 = NULL; dbtext *dbstr2 = NULL; int dbsize1 = -1; int dbsize2 = -1; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_STRING, str) - if (!OCI_STRING_VALID(fmt)) + if (!IS_STRING_VALID(fmt)) { - fmt = OCI_GetFormat(date->con, OCI_FMT_DATE); + fmt = EnvironmentGetFormat(date->con, OCI_FMT_DATE); + CHECK_NULL(fmt) } - dbstr1 = OCI_StringGetOracleString(str, &dbsize1); - dbstr2 = OCI_StringGetOracleString(fmt, &dbsize2); + dbstr1 = StringGetDBString(str, &dbsize1); + dbstr2 = StringGetDBString(fmt, &dbsize2); - OCI_EXEC + CHECK_OCI ( - OCIDateFromText(date->err, - (oratext *) dbstr1, (ub4) dbsize1, - (oratext *) dbstr2, (ub1) dbsize2, - (oratext *) NULL, (ub4) 0, date->handle) + date->err, + OCIDateFromText, + date->err, + (oratext *) dbstr1, (ub4) dbsize1, + (oratext *) dbstr2, (ub1) dbsize2, + (oratext *) NULL, (ub4) 0, + date->handle ) - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); - - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DateGetDate + * DateGetDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateGetDate +boolean DateGetDate ( OCI_Date *date, int *year, @@ -388,16 +470,20 @@ boolean OCI_API OCI_DateGetDate int *day ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + sb2 yr = 0; ub1 mt = 0; ub1 dy = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, year) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, month) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, day) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_INT, year) + CHECK_PTR(OCI_IPC_INT, month) + CHECK_PTR(OCI_IPC_INT, day) OCIDateGetDate(date->handle, &yr, &mt, &dy); @@ -405,16 +491,16 @@ boolean OCI_API OCI_DateGetDate *month = (int) mt; *day = (int) dy; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateGetTime + * DateGetTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateGetTime +boolean DateGetTime ( OCI_Date *date, int *hour, @@ -422,16 +508,20 @@ boolean OCI_API OCI_DateGetTime int *sec ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + ub1 hr = 0; ub1 mn = 0; ub1 sc = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, hour) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, min) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, sec) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_INT, hour) + CHECK_PTR(OCI_IPC_INT, min) + CHECK_PTR(OCI_IPC_INT, sec) OCIDateGetTime(date->handle, &hr, &mn, &sc); @@ -439,16 +529,16 @@ boolean OCI_API OCI_DateGetTime *min = (int) mn; *sec = (int) sc; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateGetDateTime + * DateGetDateTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateGetDateTime +boolean DateGetDateTime ( OCI_Date *date, int *year, @@ -459,63 +549,85 @@ boolean OCI_API OCI_DateGetDateTime int *sec ) { - return (OCI_DateGetDate(date, year, month, day) && OCI_DateGetTime(date, hour, min, sec)); + return (DateGetDate(date, year, month, day) && DateGetTime(date, hour, min, sec)); } /* --------------------------------------------------------------------------------------------- * - * OCI_DateLastDay + * DateLastDay * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateLastDay +boolean DateLastDay ( OCI_Date *date ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) - OCI_EXEC(OCIDateLastDay(date->err, date->handle, date->handle)) + CHECK_PTR(OCI_IPC_DATE, date) + + CHECK_OCI + ( + date->err, + OCIDateLastDay, + date->err, date->handle, + date->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateNextDay + * DateNextDay * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateNextDay +boolean DateNextDay ( OCI_Date *date, const otext *day ) { - dbtext *dbstr = NULL; - int dbsize = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, day) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + dbtext *dbstr = NULL; + int dbsize = -1; - dbstr = OCI_StringGetOracleString(day, &dbsize); + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_STRING, day) - OCI_EXEC(OCIDateNextDay(date->err, date->handle, (oratext *) dbstr, (ub4) dbsize, date->handle)) + dbstr = StringGetDBString(day, &dbsize); - OCI_StringReleaseOracleString(dbstr); + CHECK_OCI + ( + date->err, + OCIDateNextDay, + date->err, date->handle, + (oratext *) dbstr, (ub4) dbsize, + date->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DateSetDate + * DateSetDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateSetDate +boolean DateSetDate ( OCI_Date *date, int year, @@ -523,22 +635,26 @@ boolean OCI_API OCI_DateSetDate int day ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + CHECK_PTR(OCI_IPC_DATE, date) OCIDateSetDate(date->handle, (sb2) year, (ub1) month, (ub1) day); - OCI_RETVAL = TRUE; + SET_RETVAL(DateCheck(date)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateSetTime + * DateSetTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateSetTime +boolean DateSetTime ( OCI_Date *date, int hour, @@ -546,22 +662,26 @@ boolean OCI_API OCI_DateSetTime int sec ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + CHECK_PTR(OCI_IPC_DATE, date) OCIDateSetTime(date->handle, (ub1) hour, (ub1) min, (ub1) sec); - OCI_RETVAL = TRUE; + SET_RETVAL(DateCheck(date)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateSetDateTime + * DateSetDateTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateSetDateTime +boolean DateSetDateTime ( OCI_Date *date, int year, @@ -572,34 +692,43 @@ boolean OCI_API OCI_DateSetDateTime int sec ) { - return (OCI_DateSetDate(date, year, month, day) && OCI_DateSetTime(date, hour, min, sec)); + return (DateSetDate(date, year, month, day) && DateSetTime(date, hour, min, sec)); } /* --------------------------------------------------------------------------------------------- * - * OCI_DateSysDate + * DateSysDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateSysDate +boolean DateSysDate ( OCI_Date *date ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + CHECK_PTR(OCI_IPC_DATE, date) - OCI_EXEC(OCIDateSysDate(date->err, date->handle)) + CHECK_OCI + ( + date->err, + OCIDateSysDate, + date->err, date->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateToText + * DateToString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateToText +boolean DateToString ( OCI_Date *date, const otext *fmt, @@ -607,107 +736,127 @@ boolean OCI_API OCI_DateToText otext *str ) { - dbtext *dbstr1 = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + dbtext *dbstr1 = NULL; dbtext *dbstr2 = NULL; int dbsize1 = size * (int) sizeof(otext); int dbsize2 = -1; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_STRING, str) /* initialize output buffer in case of OCI failure */ str[0] = 0; - if (!OCI_STRING_VALID(fmt)) + if (!IS_STRING_VALID(fmt)) { - fmt = OCI_GetFormat(date->con, OCI_FMT_DATE); + fmt = EnvironmentGetFormat(date->con, OCI_FMT_DATE); + CHECK_NULL(fmt) } - dbstr1 = OCI_StringGetOracleString(str, &dbsize1); - dbstr2 = OCI_StringGetOracleString(fmt, &dbsize2); + dbstr1 = StringGetDBString(str, &dbsize1); + dbstr2 = StringGetDBString(fmt, &dbsize2); - OCI_EXEC + CHECK_OCI ( - OCIDateToText(date->err, date->handle, (oratext *) dbstr2, - (ub1) dbsize2, (oratext *) NULL, (ub4) 0, - (ub4*) &dbsize1, (oratext *) dbstr1) + date->err, + OCIDateToText, + date->err, date->handle, (oratext *) dbstr2, + (ub1) dbsize2, (oratext *) NULL, (ub4) 0, + (ub4*) &dbsize1, (oratext *) dbstr1 ) - OCI_StringCopyOracleStringToNativeString(dbstr1, str, dbcharcount(dbsize1)); - - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); + StringCopyDBStringToNativeString(dbstr1, str, dbcharcount(dbsize1)); /* set null string terminator */ str[dbcharcount(dbsize1)] = 0; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DateZoneToZone + * DateZoneToZone * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateZoneToZone +boolean DateZoneToZone ( OCI_Date *date, const otext *zone1, const otext *zone2 ) { - dbtext *dbstr1 = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + dbtext *dbstr1 = NULL; dbtext *dbstr2 = NULL; int dbsize1 = -1; int dbsize2 = -1; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, zone1) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, zone2) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) - dbstr1 = OCI_StringGetOracleString(zone1, &dbsize1); - dbstr2 = OCI_StringGetOracleString(zone2, &dbsize2); + CHECK_PTR(OCI_IPC_DATE, date) + CHECK_PTR(OCI_IPC_STRING, zone1) + CHECK_PTR(OCI_IPC_STRING, zone2) - OCI_EXEC + dbstr1 = StringGetDBString(zone1, &dbsize1); + dbstr2 = StringGetDBString(zone2, &dbsize2); + + CHECK_OCI ( - OCIDateZoneToZone(date->err, date->handle, - (oratext *) dbstr1, (ub4) dbsize1, - (oratext *) dbstr2, (ub4) dbsize2, - date->handle) + date->err, + OCIDateZoneToZone, + date->err, date->handle, + (oratext *) dbstr1, (ub4) dbsize1, + (oratext *) dbstr2, (ub4) dbsize2, + date->handle ) - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); - - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DateToCTime + * DateToCTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateToCTime +boolean DateToCTime ( OCI_Date *date, struct tm *ptm, time_t *pt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + time_t time = (time_t) -1; + struct tm t; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + CHECK_PTR(OCI_IPC_DATE, date) memset(&t, 0, sizeof(t)); @@ -725,47 +874,51 @@ boolean OCI_API OCI_DateToCTime time = mktime(&t); - if (ptm) + if (NULL != ptm) { memcpy(ptm, &t, sizeof(t)); } - if (pt) + if (NULL != pt) { *pt = time; } - OCI_RETVAL = (time != (time_t)-1); + SET_RETVAL((time != (time_t)-1)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DateFromCTime + * DateFromCTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DateFromCTime +boolean DateFromCTime ( OCI_Date *date, struct tm *ptm, time_t t ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - OCI_CALL_CONTEXT_SET_FROM_OBJ(date) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DATE, date + ) + + CHECK_PTR(OCI_IPC_DATE, date) - if (!ptm && (t == (time_t) 0)) + if (NULL == ptm && (t == (time_t) 0)) { - OCI_RAISE_EXCEPTION(OCI_ExceptionNullPointer(OCI_IPC_TM)) + THROW(ExceptionNullPointer, OCI_IPC_TM) } - if (!ptm) + if (NULL == ptm) { ptm = localtime(&t); } - if (ptm) + if (NULL != ptm) { date->handle->OCIDateYYYY = (sb2) ptm->tm_year + 1900; date->handle->OCIDateMM = (ub1) ptm->tm_mon + 1; @@ -777,10 +930,10 @@ boolean OCI_API OCI_DateFromCTime } else { - OCI_RAISE_EXCEPTION(OCI_ExceptionNullPointer(OCI_IPC_TM)) + THROW(ExceptionNullPointer, OCI_IPC_TM) } - OCI_RETVAL = TRUE; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/date.h b/src/date.h new file mode 100644 index 00000000..057a5e2a --- /dev/null +++ b/src/date.h @@ -0,0 +1,197 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_DATE_H_INCLUDED +#define OCILIB_DATE_H_INCLUDED + +#include "types.h" + +OCI_Date * DateInitialize +( + OCI_Connection *con, + OCI_Date *date, + OCIDate *buffer, + boolean allocate, + boolean ansi +); + +OCI_Date * DateCreate +( + OCI_Connection *con +); + +boolean DateFree +( + OCI_Date* date +); + +OCI_Date ** DateCreateArray +( + OCI_Connection *con, + unsigned int nbelem +); + +boolean DateFreeArray +( + OCI_Date** dates +); + +boolean DateAddDays +( + OCI_Date* date, + int nb +); + +boolean DateAddMonths +( + OCI_Date* date, + int nb +); + +boolean DateAssign +( + OCI_Date* date, + OCI_Date* date_src +); + +int DateCheck +( + OCI_Date* date +); + +int DateCompare +( + OCI_Date* date, + OCI_Date* date2 +); + +int DateDaysBetween +( + OCI_Date* date, + OCI_Date* date2 +); + +boolean DateFromString +( + OCI_Date * date, + const otext* str, + const otext* fmt +); + +boolean DateToString +( + OCI_Date * date, + const otext* fmt, + int size, + otext * str +); + +boolean DateGetDate +( + OCI_Date* date, + int * year, + int * month, + int * day +); + +boolean DateGetTime +( + OCI_Date* date, + int * hour, + int * min, + int * sec +); + +boolean DateGetDateTime +( + OCI_Date* date, + int * year, + int * month, + int * day, + int * hour, + int * min, + int * sec +); + +boolean DateLastDay +( + OCI_Date* date +); + +boolean DateNextDay +( + OCI_Date * date, + const otext* day +); + +boolean DateSetDate +( + OCI_Date* date, + int year, + int month, + int day +); + +boolean DateSetTime +( + OCI_Date* date, + int hour, + int min, + int sec +); + +boolean DateSetDateTime +( + OCI_Date* date, + int year, + int month, + int day, + int hour, + int min, + int sec +); + +boolean DateSysDate +( + OCI_Date* date +); + +boolean DateZoneToZone +( + OCI_Date * date, + const otext* zone1, + const otext* zone2 +); + +boolean DateToCTime +( + OCI_Date * date, + struct tm* ptm, + time_t * pt +); + +boolean DateFromCTime +( + OCI_Date * date, + struct tm* ptm, + time_t t +); + +#endif /* OCILIB_DATE_H_INCLUDED */ diff --git a/src/define.c b/src/define.c index daf31c52..5c8dcc3c 100644 --- a/src/define.c +++ b/src/define.c @@ -18,71 +18,85 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "define.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "connection.h" +#include "hash.h" +#include "macros.h" +#include "number.h" /* --------------------------------------------------------------------------------------------- * - * OCI_GetDefine + * DefineGet * --------------------------------------------------------------------------------------------- */ -OCI_Define * OCI_GetDefine +OCI_Define * DefineGet ( OCI_Resultset *rs, unsigned int index ) { - OCI_Define * def = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Define*, NULL, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + + OCI_Define *def = NULL; if ((OCI_DESCRIBE_ONLY != rs->stmt->exec_mode) && (OCI_PARSE_ONLY != rs->stmt->exec_mode)) { def = &rs->defs[index-1]; } - return def; + SET_RETVAL(def) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDefineIndex + * DefineGetIndex * --------------------------------------------------------------------------------------------- */ -int OCI_GetDefineIndex +int DefineGetIndex ( OCI_Resultset *rs, const otext *name ) { - OCI_HashEntry *he = NULL; - int index = -1; + ENTER_FUNC + ( + /* returns */ int, -1, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) - if (!rs->map) + if (NULL == rs->map) { /* create the map at the first call to save time and memory when it's not needed */ - rs->map = OCI_HashCreate(OCI_HASH_DEFAULT_SIZE, OCI_HASH_INTEGER); + rs->map = HashCreate(OCI_HASH_DEFAULT_SIZE, OCI_HASH_INTEGER); + CHECK_NULL(rs->map) - if (rs->map) + for (ub4 i = 0; i < rs->nb_defs; i++) { - for (ub4 i = 0; i < rs->nb_defs; i++) - { - OCI_HashAddInt(rs->map, rs->defs[i].col.name, (int)(i + 1)); - } + CHECK(HashAddInt(rs->map, rs->defs[i].col.name, (int)(i + 1))) } } /* check out we got our map object */ - OCI_CHECK(NULL == rs->map, -1); + int index = -1; - he = OCI_HashLookup(rs->map, name, FALSE); + OCI_HashEntry *he = HashLookup(rs->map, name, FALSE); - while (he) + while (NULL != he) { /* no more entries or key matched => so we got it ! */ - if (!he->next || 0 == ostrcasecmp(he->key, name)) + if (NULL == he->next || 0 == ostrcasecmp(he->key, name)) { index = he->values->value.num; break; @@ -93,24 +107,32 @@ int OCI_GetDefineIndex if (index < 0) { - OCI_ExceptionItemNotFound(rs->stmt->con, rs->stmt, name, OCI_IPC_COLUMN); + THROW(ExceptionItemNotFound, name, OCI_IPC_COLUMN) } - return index; + SET_RETVAL(index) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DefineGetData + * DefineGetData * --------------------------------------------------------------------------------------------- */ -void * OCI_DefineGetData +void * DefineGetData ( OCI_Define *def ) { - OCI_CHECK(NULL == def, NULL); - OCI_CHECK(NULL == def->rs, NULL); - OCI_CHECK(def->rs->row_cur < 1, NULL); + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_DEFINE, def + ) + + CHECK_PTR(OCI_IPC_DEFINE, def) + + void* data = NULL; switch (def->col.datatype) { @@ -126,32 +148,43 @@ void * OCI_DefineGetData { /* handle based types */ - return def->buf.data[def->rs->row_cur-1]; + data = def->buf.data[def->rs->row_cur-1]; + break; } default: { /* scalar types */ - return (((ub1 *) (def->buf.data)) + (size_t) (def->col.bufsize * (def->rs->row_cur-1))); + data = (((ub1 *) (def->buf.data)) + (size_t) (def->col.bufsize * (def->rs->row_cur-1))); } } + + SET_RETVAL(data) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DefineIsDataNotNull + * DefineIsDataNotNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_DefineIsDataNotNull +boolean DefineIsDataNotNull ( OCI_Define *def ) { - boolean res = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEFINE, def + ) - if (def && def->rs->row_cur > 0) - { - OCIInd ind = OCI_IND_NULL; + CHECK_PTR(OCI_IPC_DEFINE, def) + + OCIInd ind = OCI_IND_NULL; + if (def->rs->row_cur > 0) + { if (SQLT_NTY == def->col.sqlcode) { ind = *(OCIInd *)def->buf.obj_inds[def->rs->row_cur - 1]; @@ -160,19 +193,18 @@ boolean OCI_DefineIsDataNotNull { ind = def->buf.inds[def->rs->row_cur - 1]; } - - res = (ind != OCI_IND_NULL); } - return res; -} + SET_RETVAL(ind != OCI_IND_NULL) + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_DefineGetNumber + * DefineGetNumber * --------------------------------------------------------------------------------------------- */ -boolean OCI_DefineGetNumber +boolean DefineGetNumber ( OCI_Resultset *rs, unsigned int index, @@ -180,136 +212,161 @@ boolean OCI_DefineGetNumber uword type ) { - OCI_Define *def = NULL; - boolean res = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + OCI_Define* def = NULL; - def = OCI_GetDefine(rs, index); + CHECK_PTR(OCI_IPC_RESULTSET, rs) - if (OCI_DefineIsDataNotNull(def)) + def = DefineGet(rs, index); + CHECK_NULL(def) + + if (DefineIsDataNotNull(def)) { - void *data = OCI_DefineGetData(def); + void* data = DefineGetData(def); switch (def->col.datatype) { case OCI_CDT_NUMERIC: { - res = OCI_TranslateNumericValue(rs->stmt->con, data, def->col.subtype, value, type); + CHECK(NumberTranslateValue(rs->stmt->con, data, + def->col.subtype, value, + type)) break; } case OCI_CDT_TEXT: { - res = OCI_NumberFromString(rs->stmt->con, value, type, (const otext *) data, NULL); + CHECK(NumberFromStringInternal(rs->stmt->con, value, type, + (const otext*)data, NULL)) break; } } } - return res; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DefineAlloc + * DefineAlloc * --------------------------------------------------------------------------------------------- */ -boolean OCI_DefineAlloc +boolean DefineAlloc ( OCI_Define *def ) { - ub4 i; - - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEFINE, def + ) - OCI_CHECK(NULL == def, FALSE) + ub4 i; - OCI_CALL_CONTEXT_SET_FROM_STMT(def->rs->stmt) + CHECK_PTR(OCI_IPC_DEFINE, def) /* Allocate indicators */ - OCI_ALLOCATE_DATA(OCI_IPC_INDICATOR_ARRAY, def->buf.inds, def->buf.count); + ALLOC_DATA(OCI_IPC_INDICATOR_ARRAY, def->buf.inds, def->buf.count) if (SQLT_NTY == def->col.sqlcode) { - OCI_ALLOCATE_DATA(OCI_IPC_INDICATOR_ARRAY, def->buf.obj_inds, def->buf.count); + ALLOC_DATA(OCI_IPC_INDICATOR_ARRAY, def->buf.obj_inds, def->buf.count) } /* Allocate row data sizes array */ - OCI_ALLOCATE_BUFFER(OCI_IPC_LEN_ARRAY, def->buf.lens, def->buf.sizelen, def->buf.count) + ALLOC_BUFFER(OCI_IPC_LEN_ARRAY, def->buf.lens, def->buf.sizelen, def->buf.count) /* initialize length array with buffer default size. But, Oracle uses different sizes for static fetch and callback fetch....*/ - if (OCI_STATUS) - { - /* Allocate buffer array */ + /* Allocate buffer array */ - const ub4 bufsize = (ub4)(OCI_CDT_LONG == def->col.datatype ? sizeof(OCI_Long *) : def->col.bufsize); + const ub4 bufsize = (ub4)(OCI_CDT_LONG == def->col.datatype ? sizeof(OCI_Long *) : def->col.bufsize); - OCI_ALLOCATE_BUFFER(OCI_IPC_BUFF_ARRAY, def->buf.data, bufsize, def->buf.count) + ALLOC_BUFFER(OCI_IPC_BUFF_ARRAY, def->buf.data, bufsize, def->buf.count) - /* Allocate buffer length array */ + /* Allocate buffer length array */ - for (i = 0; i < def->buf.count; i++) + for (i = 0; i < def->buf.count; i++) + { + if (def->buf.sizelen == (int) sizeof(ub2)) { - if (def->buf.sizelen == (int) sizeof(ub2)) - { - OCI_ARRAY_SET_AT(def->buf.lens, ub2, i, def->col.bufsize) - } - else if (def->buf.sizelen == (int) sizeof(ub4)) - { - OCI_ARRAY_SET_AT(def->buf.lens, ub4, i, def->col.bufsize) - } + ARRAY_SET_AT(def->buf.lens, ub2, i, def->col.bufsize) + } + else if (def->buf.sizelen == (int) sizeof(ub4)) + { + ARRAY_SET_AT(def->buf.lens, ub4, i, def->col.bufsize) } } /* Allocate descriptor for cursor, lob and file, interval and timestamp */ - if (OCI_STATUS && OCI_UNKNOWN != def->col.handletype) + if (OCI_UNKNOWN != def->col.handletype) { if (OCI_CDT_CURSOR == def->col.datatype) { - for (i = 0; (i < def->buf.count) && OCI_STATUS; i++) + for (i = 0; i < def->buf.count; i++) { - OCI_STATUS = OCI_HandleAlloc((dvoid *)def->rs->stmt->con->env, (dvoid **) &(def->buf.data[i]), (ub4) def->col.handletype); + CHECK(MemoryAllocHandle((dvoid *)def->rs->stmt->con->env, + (dvoid **) &(def->buf.data[i]), + (ub4) def->col.handletype)) } } else { - OCI_STATUS = OCI_DescriptorArrayAlloc((dvoid *)def->rs->stmt->con->env, (dvoid **)def->buf.data, (ub4)def->col.handletype, (ub4)def->buf.count); + CHECK(MemoryAllocDescriptorArray((dvoid *)def->rs->stmt->con->env, + (dvoid **)def->buf.data, (ub4)def->col.handletype, + (ub4)def->buf.count)) - if (OCI_STATUS && (OCI_CDT_LOB == def->col.datatype)) + if (OCI_CDT_LOB == def->col.datatype) { ub4 empty = 0; - for (i = 0; (i < def->buf.count) && OCI_STATUS; i++) + for (i = 0; i < def->buf.count; i++) { - OCI_SET_ATTRIB(def->col.handletype, OCI_ATTR_LOBEMPTY, def->buf.data[i], &empty, sizeof(empty)) + CHECK_ATTRIB_SET + ( + def->col.handletype, OCI_ATTR_LOBEMPTY, + def->buf.data[i], &empty, sizeof(empty), + def->rs->stmt->con->err + ) } } } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DefineDef + * DefineDef * --------------------------------------------------------------------------------------------- */ -boolean OCI_DefineDef +boolean DefineDef ( OCI_Define *def, ub4 position ) { - ub2 mode = OCI_DEFAULT; - - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEFINE, def + ) - OCI_CHECK(NULL == def, FALSE) + ub2 mode = OCI_DEFAULT; - OCI_CALL_CONTEXT_SET_FROM_STMT(def->rs->stmt) + CHECK_PTR(OCI_IPC_DEFINE, def) /*check define mode for long columns */ @@ -320,36 +377,36 @@ boolean OCI_DefineDef /* oracle defining */ - OCI_EXEC + CHECK_OCI ( - OCIDefineByPos( - def->rs->stmt->stmt, - (OCIDefine **) &def->buf.handle, - def->rs->stmt->con->err, - position, - (void *) def->buf.data, - (sb4 ) def->col.bufsize, - (ub2 ) def->col.libcode, - (void *) def->buf.inds, - (ub2 *) def->buf.lens, - (ub2 *) NULL, - (ub4 ) mode - ) + def->rs->stmt->con->err, + OCIDefineByPos, + def->rs->stmt->stmt, + (OCIDefine **) &def->buf.handle, + def->rs->stmt->con->err, + position, + (void *) def->buf.data, + (sb4 ) def->col.bufsize, + (ub2 ) def->col.libcode, + (void *) def->buf.inds, + (ub2 *) def->buf.lens, + (ub2 *) NULL, + (ub4 ) mode ) if (SQLT_NTY == def->col.sqlcode || SQLT_REF == def->col.sqlcode) { - OCI_EXEC + CHECK_OCI ( - OCIDefineObject( - (OCIDefine *)def->buf.handle, - def->rs->stmt->con->err, - def->col.typinf->tdo, - (void **) def->buf.data, - (ub4 *) NULL, - (void **) def->buf.obj_inds, - (ub4 *) NULL - ) + def->rs->stmt->con->err, + OCIDefineObject, + (OCIDefine *)def->buf.handle, + def->rs->stmt->con->err, + def->col.typinf->tdo, + (void **) def->buf.data, + (ub4 *) NULL, + (void **) def->buf.obj_inds, + (ub4 *) NULL ) } @@ -359,27 +416,39 @@ boolean OCI_DefineDef ((OCI_CDT_LONG == def->col.datatype) && (OCI_BLONG != def->col.subtype))) { - if ((SQLCS_NCHAR == def->col.csfrm) || OCILib.nls_utf8) + if ((SQLCS_NCHAR == def->col.csfrm) || Env.nls_utf8) { ub1 csfrm = SQLCS_NCHAR; - OCI_SET_ATTRIB(OCI_HTYPE_DEFINE, OCI_ATTR_CHARSET_FORM, def->buf.handle, &csfrm, sizeof(csfrm)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DEFINE, OCI_ATTR_CHARSET_FORM, + def->buf.handle, &csfrm, sizeof(csfrm), + def->rs->stmt->con->err + ) } } #if OCI_VERSION_COMPILE >= OCI_11_1 - if (OCI_ConnectionIsVersionSupported(def->rs->stmt->con, OCI_11_1)) + if (ConnectionIsVersionSupported(def->rs->stmt->con, OCI_11_1)) { if (OCI_CDT_LOB == def->col.datatype) { ub2 value = 1; - OCI_SET_ATTRIB(OCI_HTYPE_DEFINE, OCI_ATTR_LOBPREFETCH_LENGTH, def->buf.handle, &value, sizeof(value)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DEFINE, OCI_ATTR_LOBPREFETCH_LENGTH, + def->buf.handle, &value, sizeof(value), + def->rs->stmt->con->err + ) } } #endif - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } diff --git a/src/define.h b/src/define.h new file mode 100644 index 00000000..6a86f61e --- /dev/null +++ b/src/define.h @@ -0,0 +1,67 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_DEFINES_H_INCLUDED +#define OCILIB_DEFINES_H_INCLUDED + +#include "types.h" + +OCI_Define* DefineGet +( + OCI_Resultset* rs, + unsigned int index +); + +int DefineGetIndex +( + OCI_Resultset* rs, + const otext * name +); + +void* DefineGetData +( + OCI_Define* def +); + +boolean DefineIsDataNotNull +( + OCI_Define* def +); + +boolean DefineGetNumber +( + OCI_Resultset* rs, + unsigned int index, + void * value, + uword type +); + +boolean DefineAlloc +( + OCI_Define* def +); + +boolean DefineDef +( + OCI_Define* def, + ub4 position +); + +#endif /* OCILIB_DEFINES_H_INCLUDED */ diff --git a/src/defs.h b/src/defs.h new file mode 100644 index 00000000..d0a59bbf --- /dev/null +++ b/src/defs.h @@ -0,0 +1,431 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_DEFS_H_INCLUDED +#define OCILIB_DEFS_H_INCLUDED + +#include "ocilib_config.h" + +#include "import.h" + +/* ********************************************************************************************* * + ORACLE VERSION DETECTION + * ********************************************************************************************* */ + +#ifdef OCI_IMPORT_RUNTIME + +/* for runtime loading, set compile time version to the highest minimum + version needed by OCILIB encapsulation of OCI */ + +#define OCI_VERSION_COMPILE OCI_19_5 + +/* set runtime version to unknown, it will be guessed from symbols loading */ + +#define OCI_VERSION_RUNTIME OCI_UNKNOWN + +#else + + #if defined(OCI_MAJOR_VERSION) + +#define OCI_VERSION_COMPILE OCI_VER_MAKE(OCI_MAJOR_VERSION, OCI_MINOR_VERSION, 0) + + #if OCI_VERSION_COMPILE == OCI_VER_MAKE(18, 0, 0) + +/* Oracle headers not updated for Windows 18.3 release ! */ + #undef OCI_VERSION_COMPILE + +#define OCI_VERSION_COMPILE OCI_18_3 + + #endif + + #elif defined(OCI_FNCODE_SODAOPERKEYSSET) /* = OCI_18_3 */ + +#define OCI_VERSION_COMPILE OCI_18_3 + + #elif defined(OCI_FNCODE_SERVERRELEASE2) /* = OCI_18_1 */ + +#define OCI_VERSION_COMPILE OCI_18_1 + + #elif defined(OCI_FNCODE_LOBGETCHUNKSIZE) /* = OCI_12_2 */ + +#define OCI_VERSION_COMPILE OCI_12_2 + + #elif defined(OCI_FNCODE_BINDBYPOS2) /* = OCI_12_1 */ + +#define OCI_VERSION_COMPILE OCI_12_1 + + #elif defined(OCI_FNCODE_LOBGETCONTENTTYPE) /* = OCI_11_2 */ + +#define OCI_VERSION_COMPILE OCI_11_2 + + #elif defined(OCI_FNCODE_LOBGETOPT) /* = OCI_11_1 */ + +#define OCI_VERSION_COMPILE OCI_11_1 + + #elif defined(OCI_FNCODE_DBSHUTDOWN) /* = OCI_10_2 */ + +#define OCI_VERSION_COMPILE OCI_10_2 + + #elif defined(OCI_FNCODE_LOBREAD2) /* = OCI_10_1 */ + +#define OCI_VERSION_COMPILE OCI_10_1 + + #elif defined(OCI_FNCODE_STMTPREPARE2) /* = OCI_9_2 */ + +#define OCI_VERSION_COMPILE OCI_9_2 + + #elif defined(OCI_FNCODE_CPOOLCREATE) /* = OCI_9_0 */ + +#define OCI_VERSION_COMPILE OCI_9_0 + + #elif defined(OCIThreadHandle) /* = OCI_8_1 */ + +#define OCI_VERSION_COMPILE OCI_8_1 + + #elif defined(OCIEnv) /* = OCI_8_0 */ + +#define OCI_VERSION_COMPILE OCI_8_0 + + #else /* OCI_UNKNOWN */ + +#define OCI_VERSION_COMPILE OCI_UNKNOWN + + #endif + +#define OCI_VERSION_RUNTIME OCI_VERSION_COMPILE + +#endif + +/* tries to enable Oracle 10g support for lobs > 4Go */ + +#if defined(OCI_BIG_UINT_ENABLED) && defined(ORAXB8_DEFINED) + +#define OCI_LOB2_API_ENABLED + +#endif + +/* ********************************************************************************************* * + CHARSET AND STRING TYPES DETECTION + * ********************************************************************************************* */ + +/* otext is public character types for all string types + We need to handle as well an internal oracle string type because : + + - wchar_t is not the same type on all platforms (that is such a pain !), + - OCI, in Unicode mode, uses Fixed length UTF16 encoding (2 bytes) + + So, dbtext was added to represent internal oracle string type. + + The following checks find out the real types and size of dbtext +*/ + +#if defined (OCI_CHARSET_ANSI) + +typedef otext dbtext; + +#else + +typedef unsigned short dbtext; + +#endif + +/* ********************************************************************************************* * + INTERNAL CONSTANTS + * ********************************************************************************************* */ + +/* --------------------------------------------------------------------------------------------- * + * Default environment mode + * --------------------------------------------------------------------------------------------- */ + +#ifdef OCI_CHARSET_WIDE + +#define OCI_ENV_MODE OCI_UTF16 + +#else + +#define OCI_ENV_MODE OCI_DEFAULT + +#endif + +/* --------------------------------------------------------------------------------------------- * + * Internal Pointer Codes + * --------------------------------------------------------------------------------------------- */ + +/* -- external C pointers ---- */ + +#define OCI_IPC_ORACLE (-1) +#define OCI_IPC_BOOLEAN 0 +#define OCI_IPC_VOID 1 +#define OCI_IPC_SHORT 2 +#define OCI_IPC_INT 3 +#define OCI_IPC_BIGINT 4 +#define OCI_IPC_DOUBLE 5 +#define OCI_IPC_FLOAT 6 +#define OCI_IPC_STRING 7 +#define OCI_IPC_PROC 8 + +/* internal OCILIB handles - */ + +#define OCI_IPC_ERROR 9 + +/* ---- Internal pointers ----- */ + +#define OCI_IPC_LIST 41 +#define OCI_IPC_LIST_ITEM 42 +#define OCI_IPC_BIND_ARRAY 43 +#define OCI_IPC_DEFINE 44 +#define OCI_IPC_DEFINE_ARRAY 45 +#define OCI_IPC_HASHENTRY 46 +#define OCI_IPC_HASHENTRY_ARRAY 47 +#define OCI_IPC_HASHVALUE 48 +#define OCI_IPC_THREADKEY 49 +#define OCI_IPC_OCIDATE 50 +#define OCI_IPC_TM 51 +#define OCI_IPC_RESULTSET_ARRAY 52 +#define OCI_IPC_PLS_SIZE_ARRAY 53 +#define OCI_IPC_PLS_RCODE_ARRAY 54 +#define OCI_IPC_SERVER_OUPUT 55 +#define OCI_IPC_INDICATOR_ARRAY 56 +#define OCI_IPC_LEN_ARRAY 57 +#define OCI_IPC_BUFF_ARRAY 58 +#define OCI_IPC_LONG_BUFFER 59 +#define OCI_IPC_TRACE_INFO 60 +#define OCI_IPC_DP_COL_ARRAY 61 +#define OCI_IPC_BATCH_ERRORS 62 +#define OCI_IPC_STATEMENT_ARRAY 63 + +#define OCI_IPC_COUNT (OCI_IPC_STATEMENT_ARRAY + 2) + +/* --------------------------------------------------------------------------------------------- * + * Oracle conditional features + * --------------------------------------------------------------------------------------------- */ + +#define OCI_FEATURE_WIDE_USERDATA 1 +#define OCI_FEATURE_TIMESTAMP 2 +#define OCI_FEATURE_DIRPATH_DATE_CACHE 3 +#define OCI_FEATURE_STATEMENT_CACHING 4 +#define OCI_FEATURE_SCROLLABLE_CURSOR 5 +#define OCI_FEATURE_DATABASE_NOTIFY 6 +#define OCI_FEATURE_REMOTE_DBS_CONTROL 7 +#define OCI_FEATURE_HIGH_AVAILABILITY 8 +#define OCI_FEATURE_XA 9 +#define OCI_FEATURE_EXTENDED_PLSQLTYPES 10 + +#define OCI_FEATURE_COUNT OCI_FEATURE_EXTENDED_PLSQLTYPES + +/* --------------------------------------------------------------------------------------------- * + * handle types + * --------------------------------------------------------------------------------------------- */ + +#define OCI_HDLE_HANDLE 1 +#define OCI_HDLE_DESCRIPTOR 2 +#define OCI_HDLE_OBJECT 3 + +#define OCI_HDLE_COUNT OCI_HDLE_OBJECT + +/* --------------------------------------------------------------------------------------------- * + * statement status + * --------------------------------------------------------------------------------------------- */ + +#define OCI_STMT_CLOSED 1 +#define OCI_STMT_PARSED 2 +#define OCI_STMT_PREPARED 4 +#define OCI_STMT_DESCRIBED 8 +#define OCI_STMT_EXECUTED 16 + +#define OCI_STMT_STATES_COUNT 5 + +/* --------------------------------------------------------------------------------------------- * + * connection states + * --------------------------------------------------------------------------------------------- */ + +#define OCI_CONN_ALLOCATED 1 +#define OCI_CONN_ATTACHED 2 +#define OCI_CONN_LOGGED 3 + +/* --------------------------------------------------------------------------------------------- * + * objects status + * --------------------------------------------------------------------------------------------- */ + +#define OCI_OBJECT_ALLOCATED 1 +#define OCI_OBJECT_FETCHED_CLEAN 2 +#define OCI_OBJECT_FETCHED_DIRTY 3 +#define OCI_OBJECT_ALLOCATED_ARRAY 4 +#define OCI_OBJECT_ALLOCATED_BIND_STMT 5 + +/* --------------------------------------------------------------------------------------------- * + * bind type + * --------------------------------------------------------------------------------------------- */ + +#define OCI_BIND_INPUT 1 +#define OCI_BIND_OUTPUT 2 + +/* --------------------------------------------------------------------------------------------- * + * Type of schema describing + * --------------------------------------------------------------------------------------------- */ + +#define OCI_DESC_RESULTSET 1 +#define OCI_DESC_TABLE 2 +#define OCI_DESC_TYPE 3 +#define OCI_DESC_COLLECTION 4 + +/* --------------------------------------------------------------------------------------------- * + * Direct path object status + * --------------------------------------------------------------------------------------------- */ + +#define OCI_DPS_NOT_PREPARED 1 +#define OCI_DPS_PREPARED 2 +#define OCI_DPS_CONVERTED 3 +#define OCI_DPS_TERMINATED 4 + +#define OCI_DPS_COUNT OCI_DPS_TERMINATED + +/* --------------------------------------------------------------------------------------------- * + * internal statement fetch direction + * --------------------------------------------------------------------------------------------- */ + +#define OCI_SFD_NEXT 0x02 +#define OCI_SFD_FIRST 0x04 +#define OCI_SFD_LAST 0x08 +#define OCI_SFD_PREV 0x10 + +/* --------------------------------------------------------------------------------------------- * + * internal direct path column types + * --------------------------------------------------------------------------------------------- */ + +#define OCI_DDT_TEXT 1 +#define OCI_DDT_BINARY 2 +#define OCI_DDT_NUMBER 3 +#define OCI_DDT_OTHERS 4 + +/* --------------------------------------------------------------------------------------------- * + * output buffer server line size + * --------------------------------------------------------------------------------------------- */ + +#define OCI_OUPUT_LSIZE 255 +#define OCI_OUPUT_LSIZE_10G 32767 + +/* --------------------------------------------------------------------------------------------- * +* Undocumented OCI SQL TYPES +* --------------------------------------------------------------------------------------------- */ + +#define SQLT_UNDOCUMENTED_REC 245 +#define SQLT_UNDOCUMENTED_BIN_INTEGER 265 + +/* --------------------------------------------------------------------------------------------- * + * Unicode constants + * --------------------------------------------------------------------------------------------- */ + +/* OCI unicode flag */ + +#ifndef OCI_UTF16ID + +#define OCI_UTF16ID OCI_UCS2ID + +#endif + +#define OCI_UTF8_BYTES_PER_CHAR 4 +#define OCI_SIZE_TMP_CVT 128 + +#ifdef _WINDOWS + +#define OCI_CVT_CHAR 1 + +#else + +#define OCI_CVT_CHAR 0 + +#endif + +#define OCI_SQLCMD_COUNT 239 + +#define OCI_FMT_COUNT 6 + +#define OCI_BIND_ARRAY_GROWTH_FACTOR 128 + +#define OCI_DEF_ALIGN sizeof(void *) + +#define ROUNDUP(amount, align) \ + \ + (((unsigned long)(amount)+((align)-1))&~((align)-1)) + +#define osizeof(s) (sizeof(s) / sizeof(otext)) + +#define ocharcount(l) ((l) / sizeof(otext)) +#define dbcharcount(l) ((l) / sizeof(dbtext)) + +#define OCI_ERR_AQ_LISTEN_TIMEOUT 25254 +#define OCI_ERR_AQ_DEQUEUE_TIMEOUT 25228 +#define OCI_ERR_SUB_BUG_OCI_UTF16 24915 + +#define OCI_DEFAUT_STMT_CACHE_SIZE 20 + +#define WCHAR_2_BYTES 0xFFFF +#define WCHAR_4_BYTES 0x7FFFFFFF + +#define SCALE_FLOAT (-127) + +#define OCI_VARS_COUNT 1 + +#define OCI_VARS_TRUE_VALUE "TRUE" + +#define OCI_VARS_WORKAROUND_UTF16_COLUMN_NAME 0 + +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +/* check OCI status */ + +#define OCI_FAILURE(res) ((res) != OCI_SUCCESS) +#define OCI_SUCCESSFUL(res) ((res) == OCI_SUCCESS) + +/* indicator and nullity handlers */ + +#define OCI_IND(exp) (sb2) ((exp) ? 0 : -1) + +#define OCI_NOT_USED(p) (p) = (p); + +#define NB_ARG_VERSION 3 + +#define LIB_THREADED (Env.env_mode & OCI_ENV_THREADED) + +#define IS_PLSQL_STMT(type) \ + \ + ((OCI_CST_BEGIN == (type)) || \ + (OCI_CST_DECLARE == (type)) || \ + (OCI_CST_CALL == (type))) + +#define IS_OCI_NUMBER(type, subtype) \ + \ + (OCI_CDT_NUMERIC == (type) && OCI_NUM_NUMBER == (subtype)) + +#define IS_OCILIB_OBJECT(type, subtype) \ + \ + ( (IS_OCI_NUMBER(type, subtype)) || \ + (OCI_CDT_TEXT != (type) && \ + OCI_CDT_RAW != (type) && \ + OCI_CDT_BOOLEAN != (type))) + +#endif /* OCILIB_DEFS_H_INCLUDED */ diff --git a/src/dequeue.c b/src/dequeue.c index 4bb7ffdc..6f4a97d3 100644 --- a/src/dequeue.c +++ b/src/dequeue.c @@ -18,239 +18,274 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "dequeue.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "agent.h" +#include "callback.h" +#include "macros.h" +#include "memory.h" +#include "message.h" +#include "object.h" +#include "strings.h" -static const unsigned int NavigationModeValues[] = { OCI_ADN_FIRST_MSG, OCI_ADN_NEXT_MSG, OCI_ADN_NEXT_TRANSACTION }; -static const unsigned int VisibilityModeValues[] = { OCI_AMV_IMMEDIATE, OCI_AMV_ON_COMMIT }; -static const unsigned int DequeueModeValues[] = { OCI_ADM_BROWSE, OCI_ADM_LOCKED, OCI_ADM_REMOVE, OCI_ADM_REMOVE_NODATA }; +static const unsigned int NavigationModeValues[] = +{ + OCI_ADN_FIRST_MSG, + OCI_ADN_NEXT_MSG, + OCI_ADN_NEXT_TRANSACTION +}; + +static const unsigned int VisibilityModeValues[] = +{ + OCI_AMV_IMMEDIATE, + OCI_AMV_ON_COMMIT +}; -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int DequeueModeValues[]= +{ + OCI_ADM_BROWSE, + OCI_ADM_LOCKED, + OCI_ADM_REMOVE, + OCI_ADM_REMOVE_NODATA +}; /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueCreate + * DequeueCreate * --------------------------------------------------------------------------------------------- */ -OCI_Dequeue * OCI_API OCI_DequeueCreate +OCI_Dequeue * DequeueCreate ( OCI_TypeInfo *typinf, const otext *name ) { - OCI_Dequeue *dequeue = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Dequeue*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) + + OCI_Dequeue* dequeue = NULL; - OCI_CALL_ENTER(OCI_Dequeue*, dequeue) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + CHECK_PTR(OCI_IPC_STRING, name) /* allocate dequeue structure */ - OCI_ALLOCATE_DATA(OCI_IPC_DEQUEUE, dequeue, 1) + ALLOC_DATA(OCI_IPC_DEQUEUE, dequeue, 1) - if (OCI_STATUS) - { - dequeue->typinf = typinf; - dequeue->name = ostrdup(name); + dequeue->typinf = typinf; + dequeue->name = ostrdup(name); - /* allocate dequeue options descriptor */ + /* allocate dequeue options descriptor */ - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)dequeue->typinf->con->env, (dvoid **)&dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS); + CHECK(MemoryAllocDescriptor((dvoid *)dequeue->typinf->con->env, + (dvoid **)&dequeue->opth, + OCI_DTYPE_AQDEQ_OPTIONS)) - /* create local message for OCI_DequeueGet() */ + /* create local message for OCI_DequeueGet() */ - if (OCI_STATUS) + dequeue->msg = MessageCreate(dequeue->typinf); + CHECK_NULL(dequeue->msg) + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - dequeue->msg = OCI_MsgCreate(dequeue->typinf); - OCI_STATUS = (NULL != dequeue->msg); + DequeueFree(dequeue); + dequeue = NULL; } - } - - /* check for failure */ - - if (OCI_STATUS) - { - OCI_RETVAL = dequeue; - } - else if (dequeue) - { - OCI_DequeueFree(dequeue); - } - OCI_CALL_EXIT() + SET_RETVAL(dequeue) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueFree + * DequeueFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueFree +boolean DequeueFree ( OCI_Dequeue *dequeue ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) /* Unsubscribe notification if needed */ - if (dequeue->subhp) + if (NULL != dequeue->subhp) { - OCI_DequeueUnsubscribe(dequeue); + DequeueUnsubscribe(dequeue); } /* free local message */ - if (dequeue->msg) + if (NULL != dequeue->msg) { - OCI_MsgFree(dequeue->msg); + MessageFree(dequeue->msg); } /* free local agent */ - if (dequeue->agent) + if (NULL != dequeue->agent) { - OCI_AgentFree(dequeue->agent); + AgentFree(dequeue->agent); } /* free OCI descriptor */ - OCI_DescriptorFree((dvoid *) dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS); + MemoryFreeDescriptor((dvoid*)dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS); /* free data */ - OCI_FREE(dequeue->name) - OCI_FREE(dequeue->pattern) - OCI_FREE(dequeue->consumer) - OCI_FREE(dequeue->agent_list) - OCI_FREE(dequeue) + FREE(dequeue->name) + FREE(dequeue->pattern) + FREE(dequeue->consumer) + FREE(dequeue->agent_list) + FREE(dequeue) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueListen + * DequeueListen * --------------------------------------------------------------------------------------------- */ -OCI_Agent * OCI_API OCI_DequeueListen +OCI_Agent * DequeueListen ( OCI_Dequeue *dequeue, int timeout ) { - OCIAQAgent *handle = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Agent*, NULL, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) - OCI_CALL_ENTER(OCI_Agent*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) /* listen only if OCI_DequeueSetAgentList has been called */ - if (dequeue->agent_list) - { - sword ret = OCI_SUCCESS; - sb4 code = OCI_SUCCESS; + CHECK_NULL(dequeue->agent_list) - ret = OCIAQListen(dequeue->typinf->con->cxt, dequeue->typinf->con->err, - dequeue->agent_list, (ub4) dequeue->agent_count, - (sb4) timeout, &handle, OCI_DEFAULT); + sword ret = OCI_SUCCESS; + sb4 code = OCI_SUCCESS; - /* check returned error code */ + OCIAQAgent *handle = NULL; - if (OCI_ERROR == ret) - { - OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, - (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, - (ub4) OCI_HTYPE_ERROR); + ret = OCIAQListen(dequeue->typinf->con->cxt, dequeue->typinf->con->err, + dequeue->agent_list, (ub4) dequeue->agent_count, + (sb4) timeout, &handle, OCI_DEFAULT); - /* raise error only if the call has not been timed out */ + /* check returned error code */ - if (OCI_ERR_AQ_LISTEN_TIMEOUT != code) - { - OCI_RAISE_EXCEPTION(OCI_ExceptionOCI(dequeue->typinf->con->err, dequeue->typinf->con, NULL, FALSE)) - } - } + if (OCI_ERROR == ret) + { + OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, + (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, + (ub4) OCI_HTYPE_ERROR); - /* initialize local agent object */ + /* raise error only if the call has not been timed out */ - if (OCI_STATUS && handle && OCI_SUCCESSFUL(ret)) + if (OCI_ERR_AQ_LISTEN_TIMEOUT != code) { - OCI_RETVAL = dequeue->agent = OCI_AgentInit(dequeue->typinf->con, dequeue->agent, handle, NULL, NULL); + THROW(ExceptionOCI, dequeue->typinf->con->err, ret) } } - OCI_CALL_EXIT() + /* initialize local agent object */ + + OCI_Agent* agent = NULL; + + if (NULL != handle && OCI_SUCCESSFUL(ret)) + { + dequeue->agent= AgentInitialize(dequeue->typinf->con, + dequeue->agent, handle, + NULL, NULL); + + CHECK_NULL(dequeue->agent) + + agent = dequeue->agent; + } + + SET_RETVAL(agent) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGet + * DequeueGetMessage * --------------------------------------------------------------------------------------------- */ -OCI_Msg * OCI_API OCI_DequeueGet +OCI_Msg * DequeueGetMessage ( OCI_Dequeue *dequeue ) { - sword ret = OCI_SUCCESS; - void *p_ind = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Msg*, NULL, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) - OCI_CALL_ENTER(OCI_Msg*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + sword ret = OCI_SUCCESS; + void *p_ind = NULL; - /* reset message */ + int dbsize = -1; + dbtext* dbstr = NULL; - OCI_STATUS = OCI_MsgReset(dequeue->msg); + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - if (OCI_STATUS) - { - int dbsize = -1; - dbtext *dbstr = OCI_StringGetOracleString(dequeue->name, &dbsize); + /* reset message */ - if (OCI_UNKNOWN == dequeue->typinf->typecode) - { - p_ind = &dequeue->msg->ind; - } + CHECK(MessageReset(dequeue->msg)) - /* dequeue message */ + /* dequeue message */ - ret = OCIAQDeq(dequeue->typinf->con->cxt, dequeue->typinf->con->err, - (OraText *) dbstr, dequeue->opth, dequeue->msg->proph, - dequeue->typinf->tdo, &dequeue->msg->payload, - (void **) &p_ind, &dequeue->msg->id, OCI_DEFAULT); + StringGetDBString(dequeue->name, &dbsize); - OCI_StringReleaseOracleString(dbstr); + if (OCI_UNKNOWN == dequeue->typinf->typecode) + { + p_ind = &dequeue->msg->ind; + } - /* check returned error code */ + ret = OCIAQDeq(dequeue->typinf->con->cxt, dequeue->typinf->con->err, + (OraText *) dbstr, dequeue->opth, dequeue->msg->proph, + dequeue->typinf->tdo, &dequeue->msg->payload, + (void **) &p_ind, &dequeue->msg->id, OCI_DEFAULT); - if (OCI_ERROR == ret) - { - sb4 code = 0; + /* check returned error code */ - OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, - (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, - (ub4) OCI_HTYPE_ERROR); + if (OCI_ERROR == ret) + { + sb4 code = 0; - /* raise error only if the call has not been timed out */ + OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, + (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, + (ub4) OCI_HTYPE_ERROR); - if (OCI_ERR_AQ_DEQUEUE_TIMEOUT != code) - { - OCI_RAISE_EXCEPTION(OCI_ExceptionOCI(dequeue->typinf->con->err, dequeue->typinf->con, NULL, FALSE)) - } + /* raise error only if the call has not been timed out */ + + if (OCI_ERR_AQ_DEQUEUE_TIMEOUT != code) + { + THROW(ExceptionOCI, dequeue->typinf->con->err, ret) } } /* reset message */ - if (OCI_STATUS && OCI_SUCCESSFUL(ret)) + OCI_Msg* msg = NULL; + + if (OCI_SUCCESSFUL(ret)) { /* get payload */ @@ -260,142 +295,180 @@ OCI_Msg * OCI_API OCI_DequeueGet { dequeue->msg->ind = *(OCIInd *) p_ind; - dequeue->msg->obj = OCI_ObjectInit(dequeue->typinf->con, - (OCI_Object *) dequeue->msg->obj, - dequeue->msg->payload, dequeue->typinf, - NULL, -1, TRUE); + dequeue->msg->obj = ObjectInitialize + ( + dequeue->typinf->con, (OCI_Object*)dequeue->msg->obj, + dequeue->msg->payload, dequeue->typinf, NULL, -1, TRUE + ); - OCI_STATUS = (NULL != dequeue->msg->obj); + CHECK_NULL(dequeue->msg->obj) + + msg = dequeue->msg; } } } - /* on success return internal message handle */ + SET_RETVAL(msg) - if (OCI_STATUS && OCI_SUCCESSFUL(ret)) - { - OCI_RETVAL = dequeue->msg; - } - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetConsumerName + * DequeueGetConsumerName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_DequeueGetConsumer +const otext * DequeueGetConsumer ( OCI_Dequeue *dequeue ) { - OCI_CALL_ENTER(const otext*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - if (!dequeue->consumer) + if (NULL == dequeue->consumer) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(dequeue->typinf->con, dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS, - OCI_ATTR_CONSUMER_NAME, &dequeue->consumer, &size); + + CHECK(StringGetAttribute(dequeue->typinf->con, dequeue->opth, + OCI_DTYPE_AQDEQ_OPTIONS, + OCI_ATTR_CONSUMER_NAME, + &dequeue->consumer, &size)) } - - OCI_RETVAL = dequeue->consumer; - OCI_CALL_EXIT() + SET_RETVAL(dequeue->consumer) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetConsumerName + * DequeueSetConsumerName * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetConsumer +boolean DequeueSetConsumer ( OCI_Dequeue *dequeue, const otext *consumer ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) + + CHECK(StringSetAttribute(dequeue->typinf->con, dequeue->opth, + OCI_DTYPE_AQDEQ_OPTIONS, + OCI_ATTR_CONSUMER_NAME, + &dequeue->consumer, consumer)) - OCI_RETVAL = OCI_STATUS = OCI_SetStringAttribute(dequeue->typinf->con, dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS, - OCI_ATTR_CONSUMER_NAME, &dequeue->consumer, consumer); - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetCorrelation + * DequeueGetCorrelation * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_DequeueGetCorrelation +const otext * DequeueGetCorrelation ( OCI_Dequeue *dequeue ) { - OCI_CALL_ENTER(const otext*, NULL) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - if (!dequeue->pattern) + if (NULL == dequeue->pattern) { unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(dequeue->typinf->con, dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS, - OCI_ATTR_CORRELATION, &dequeue->pattern, &size); + + CHECK(StringGetAttribute(dequeue->typinf->con, dequeue->opth, + OCI_DTYPE_AQDEQ_OPTIONS, + OCI_ATTR_CORRELATION, + &dequeue->pattern, &size)) } - - OCI_RETVAL = dequeue->pattern; - OCI_CALL_EXIT() + SET_RETVAL(dequeue->pattern) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetCorrelation + * DequeueSetCorrelation * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetCorrelation +boolean DequeueSetCorrelation ( OCI_Dequeue *dequeue, const otext *pattern ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) - OCI_RETVAL = OCI_STATUS = OCI_SetStringAttribute(dequeue->typinf->con, dequeue->opth, OCI_DTYPE_AQDEQ_OPTIONS, - OCI_ATTR_CORRELATION, &dequeue->pattern, pattern); + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_EXIT() + CHECK(StringSetAttribute(dequeue->typinf->con, dequeue->opth, + OCI_DTYPE_AQDEQ_OPTIONS, + OCI_ATTR_CORRELATION, + &dequeue->pattern, pattern)) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetRelativeMsgID + * DequeueGetRelativeMsgID * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueGetRelativeMsgID +boolean DequeueGetRelativeMsgID ( OCI_Dequeue *dequeue, void *id, unsigned int *len ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + OCIRaw *value = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, id) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, len) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) + CHECK_PTR(OCI_IPC_VOID, id) + CHECK_PTR(OCI_IPC_VOID, len) *len = 0; - OCI_GET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MSGID, dequeue->opth, &value, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MSGID, + dequeue->opth, &value, NULL, + dequeue->typinf->con->err + ) - if (OCI_STATUS && value) + if (NULL != value) { const ub4 raw_len = OCIRawSize(dequeue->typinf->con->env, value); @@ -407,296 +480,393 @@ boolean OCI_API OCI_DequeueGetRelativeMsgID memcpy(id, OCIRawPtr(dequeue->typinf->con->env, value), (size_t) (*len)); } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetRelativeMsgID + * DequeueSetRelativeMsgID * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetRelativeMsgID +boolean DequeueSetRelativeMsgID ( - OCI_Dequeue *dequeue, - const void *id, - unsigned int len + OCI_Dequeue *dequeue, + const void *id, + unsigned int len ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + OCIRaw *value = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_EXEC(OCIRawAssignBytes(dequeue->typinf->con->env, dequeue->typinf->con->err, (ub1*) id, (ub4) len, (OCIRaw **) &value)) + CHECK_OCI + ( + dequeue->typinf->con->err, + OCIRawAssignBytes, + dequeue->typinf->con->env, dequeue->typinf->con->err, + (ub1*) id, (ub4) len, (OCIRaw **) &value + ) - OCI_SET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MSGID, dequeue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MSGID, + dequeue->opth, &value, 0, + dequeue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetVisibility + * DequeueGetVisibility * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DequeueGetVisibility +unsigned int DequeueGetVisibility ( OCI_Dequeue *dequeue ) { + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + ub4 value = OCI_UNKNOWN; - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_GET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_VISIBILITY, dequeue->opth, &value, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_VISIBILITY, + dequeue->opth, &value, NULL, + dequeue->typinf->con->err + ) - OCI_RETVAL = (unsigned int)value; + SET_RETVAL((unsigned int)value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetVisibility + * DequeueSetVisibility * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetVisibility +boolean DequeueSetVisibility ( OCI_Dequeue *dequeue, unsigned int visibility ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + ub4 value = (ub4) visibility; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, visibility, VisibilityModeValues, OTEXT("Visibility Mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) + CHECK_ENUM_VALUE(visibility, VisibilityModeValues, OTEXT("Visibility Mode")) - OCI_SET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_VISIBILITY, dequeue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_VISIBILITY, + dequeue->opth, &value, 0, + dequeue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetMode + * DequeueGetMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DequeueGetMode +unsigned int DequeueGetMode ( OCI_Dequeue *dequeue ) { + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + ub4 value = OCI_UNKNOWN; - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_GET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MODE, dequeue->opth, &value, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MODE, + dequeue->opth, &value, NULL, + dequeue->typinf->con->err + ) - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetMode + * DequeueSetMode * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetMode +boolean DequeueSetMode ( OCI_Dequeue *dequeue, unsigned int mode ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + ub4 value = (ub4) mode; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, mode, DequeueModeValues, OTEXT("Dequeue Mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) + CHECK_ENUM_VALUE(mode, DequeueModeValues, OTEXT("Dequeue Mode")) - OCI_SET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MODE, dequeue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_DEQ_MODE, + dequeue->opth, &value, 0, + dequeue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetNavigation + * DequeueGetNavigation * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DequeueGetNavigation +unsigned int DequeueGetNavigation ( OCI_Dequeue *dequeue ) { + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + ub4 value = OCI_UNKNOWN; - OCI_CALL_ENTER(unsigned int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_GET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_NAVIGATION, dequeue->opth, &value, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_NAVIGATION, + dequeue->opth, &value, NULL, + dequeue->typinf->con->err + ) - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetNavigation + * DequeueSetNavigation * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetNavigation +boolean DequeueSetNavigation ( OCI_Dequeue *dequeue, unsigned int position ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + ub4 value = (ub4) position; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, position, NavigationModeValues, OTEXT("Navigation Mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) + CHECK_ENUM_VALUE(position, NavigationModeValues, OTEXT("Navigation Mode")) - OCI_SET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_NAVIGATION, dequeue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_NAVIGATION, + dequeue->opth, &value, 0, + dequeue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueGetWaitTime + * DequeueGetWaitTime * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_DequeueGetWaitTime +int DequeueGetWaitTime ( OCI_Dequeue *dequeue ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + sb4 value = 0; - OCI_CALL_ENTER(unsigned int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_GET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_WAIT, dequeue->opth, &value, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_WAIT, + dequeue->opth, &value, NULL, + dequeue->typinf->con->err + ) - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetWaitTime + * DequeueSetWaitTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetWaitTime +boolean DequeueSetWaitTime ( OCI_Dequeue *dequeue, int timeout ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + sb4 value = (ub4) timeout; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_SET_ATTRIB(OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_WAIT, dequeue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQDEQ_OPTIONS, OCI_ATTR_WAIT, + dequeue->opth, &value, 0, + dequeue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSetAgentList + * DequeueSetAgentList * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSetAgentList +boolean DequeueSetAgentList ( OCI_Dequeue *dequeue, OCI_Agent **consumers, unsigned int count ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + + CHECK_PTR(OCI_IPC_ENQUEUE, dequeue) - OCI_FREE(dequeue->agent_list) + FREE(dequeue->agent_list) - if (consumers && (count > 0)) + if (NULL != consumers && count > 0) { - OCI_ALLOCATE_DATA(OCI_IPC_ARRAY, dequeue->agent_list, count) + ALLOC_DATA(OCI_IPC_ARRAY, dequeue->agent_list, count) - if (OCI_STATUS) + for (unsigned int i = 0; i < count; i++) { - for (unsigned int i = 0; i < count; i++) - { - dequeue->agent_list[i] = consumers[i]->handle; - } - - dequeue->agent_count = (ub4)count; + dequeue->agent_list[i] = consumers[i]->handle; } + + dequeue->agent_count = (ub4)count; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueSubscribe + * DequeueSubscribe * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueSubscribe +boolean DequeueSubscribe ( - OCI_Dequeue *dequeue, - unsigned int port, - unsigned int timeout, - POCI_NOTIFY_AQ callback + OCI_Dequeue *dequeue, + unsigned int port, + unsigned int timeout, + POCI_NOTIFY_AQ callback ) { - ub4 oci_namespace = OCI_SUBSCR_NAMESPACE_AQ; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) #if OCI_VERSION_COMPILE >= OCI_10_2 - ub4 oci_port = (ub4) port; - ub4 oci_timeout = (ub4) timeout; - ub4 oci_protocol = OCI_SUBSCR_PROTO_OCI; - ub4 oci_msgpres = OCI_SUBSCR_PRES_DEFAULT; + ub4 oci_port = (ub4) port; + ub4 oci_timeout = (ub4) timeout; + ub4 oci_protocol = OCI_SUBSCR_PROTO_OCI; + ub4 oci_msgpres = OCI_SUBSCR_PRES_DEFAULT; #endif + ub4 oci_namespace = OCI_SUBSCR_NAMESPACE_AQ; + OCI_Connection *con = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_DATABASE_NOTIFY_ENABLED() - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + dbtext* dbstr = NULL; + int dbsize = -1; + + CHECK_DATABASE_NOTIFY_ENABLED() + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) con = dequeue->typinf->con; /* clear any previous subscription */ - OCI_DequeueUnsubscribe(dequeue); + CHECK(DequeueUnsubscribe(dequeue)) /* allocate subscription handle */ - OCI_STATUS = OCI_HandleAlloc(con->env, (dvoid **) (void *) &dequeue->subhp, OCI_HTYPE_SUBSCRIPTION); + CHECK(MemoryAllocHandle(con->env, + (dvoid **) (void *) &dequeue->subhp, + OCI_HTYPE_SUBSCRIPTION)) #if OCI_VERSION_COMPILE >= OCI_10_2 @@ -704,23 +874,43 @@ boolean OCI_API OCI_DequeueSubscribe if (oci_port > 0) { - OCI_GET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_PORTNO, dequeue->subhp, &oci_port, sizeof(oci_port)) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_PORTNO, + dequeue->subhp, &oci_port, sizeof(oci_port), + dequeue->typinf->con->err + ) } /* set timeout */ if (oci_timeout > 0) { - OCI_GET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_TIMEOUT, dequeue->subhp, &oci_timeout, sizeof(oci_timeout)) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_TIMEOUT, + dequeue->subhp, &oci_timeout, sizeof(oci_timeout), + dequeue->typinf->con->err + ) } /* set protocol */ - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_RECPTPROTO, dequeue->subhp, &oci_protocol, sizeof(oci_protocol)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_RECPTPROTO, + dequeue->subhp, &oci_protocol, sizeof(oci_protocol), + dequeue->typinf->con->err + ) /* set presentation */ - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_RECPTPRES, dequeue->subhp, &oci_msgpres, sizeof(oci_msgpres)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_RECPTPRES, + dequeue->subhp, &oci_msgpres, sizeof(oci_msgpres), + dequeue->typinf->con->err + ) #else @@ -731,24 +921,22 @@ boolean OCI_API OCI_DequeueSubscribe /* set name */ - if (dequeue->name) + if (NULL != dequeue->name) { /* for AQ subscription, the name should be "[schema.]queue[:consumer]" */ otext buffer[OCI_SIZE_BUFFER] = OTEXT(""); - otext *str = NULL; - size_t max_chars = sizeof(buffer) / sizeof(otext) - 1; + otext *str = NULL; - dbtext *dbstr = NULL; - int dbsize = -1; + size_t max_chars = sizeof(buffer) / sizeof(otext) - 1; ostrncat(buffer, dequeue->name, max_chars); if (dequeue->consumer) { max_chars -= ostrlen(dequeue->name); - ostrncat(buffer, OTEXT(":"), max_chars); + ostrncat(buffer, OTEXT(":"), max_chars); max_chars -= (size_t)1; ostrncat(buffer, dequeue->consumer, max_chars); @@ -761,36 +949,54 @@ boolean OCI_API OCI_DequeueSubscribe *str = (otext) otoupper(*str); } - dbstr = OCI_StringGetOracleString(buffer, &dbsize); + dbstr = StringGetDBString(buffer, &dbsize); - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAME, dequeue->subhp, dbstr, dbsize) - - OCI_StringReleaseOracleString(dbstr); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAME, + dequeue->subhp, dbstr, dbsize, + dequeue->typinf->con->err + ) } /* set namespace */ - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAMESPACE, dequeue->subhp, &oci_namespace, oci_namespace) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAMESPACE, + dequeue->subhp, &oci_namespace, oci_namespace, + dequeue->typinf->con->err + ) /* set context pointer to dequeue structure */ - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CTX, dequeue->subhp, dequeue, 0) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CTX, + dequeue->subhp, dequeue, 0, + dequeue->typinf->con->err + ) /* On MSVC, casting a function pointer to a data pointer generates a warning. As there is no other to way to do regarding the OCI API, let's disable this warning just the time to set the callback attribute to the dequeue handle */ - #ifdef _MSC_VER - #pragma warning(disable: 4054) - #endif +#ifdef _MSC_VER + #pragma warning(disable: 4054) +#endif /* internal callback handler */ - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CALLBACK, dequeue->subhp, OCI_ProcNotifyMessages, 0) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CALLBACK, + dequeue->subhp, CallbackNotifyMessages, 0, + dequeue->typinf->con->err + ) - #ifdef _MSC_VER - #pragma warning(default: 4054) - #endif +#ifdef _MSC_VER + #pragma warning(default: 4054) +#endif /* set callback */ @@ -798,54 +1004,67 @@ boolean OCI_API OCI_DequeueSubscribe /* all attributes set, let's register the subscription ! */ - OCI_EXEC(OCISubscriptionRegister(con->cxt, &dequeue->subhp, (ub2) 1, con->err,(ub4) OCI_DEFAULT)) + CHECK_OCI + ( + dequeue->typinf->con->err, + OCISubscriptionRegister, + con->cxt, &dequeue->subhp, (ub2) 1, + con->err,(ub4) OCI_DEFAULT + ) - if (!OCI_STATUS) - { - /* clear subscription on failure */ + SET_SUCCESS() - OCI_DequeueUnsubscribe(dequeue); - } - - OCI_RETVAL = OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); - OCI_CALL_EXIT() + if (FAILURE && NULL != dequeue) + { + DequeueUnsubscribe(dequeue); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DequeueUnsubscribe + * DequeueUnsubscribe * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DequeueUnsubscribe +boolean DequeueUnsubscribe ( OCI_Dequeue *dequeue ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_DATABASE_NOTIFY_ENABLED() - OCI_CALL_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) - OCI_CALL_CONTEXT_SET_FROM_CONN(dequeue->typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DEQUEUE, dequeue + ) + + CHECK_DATABASE_NOTIFY_ENABLED() + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) dequeue->callback = NULL; - if (dequeue->subhp) + if (NULL != dequeue->subhp) { /* unregister the subscription */ - OCI_EXEC + CHECK_OCI ( - OCISubscriptionUnRegister(dequeue->typinf->con->cxt, dequeue->subhp, - dequeue->typinf->con->err,(ub4) OCI_DEFAULT) + dequeue->typinf->con->err, + OCISubscriptionUnRegister, + dequeue->typinf->con->cxt, dequeue->subhp, + dequeue->typinf->con->err,(ub4) OCI_DEFAULT ) /* free OCI handle */ - OCI_HandleFree((dvoid *) dequeue->subhp, OCI_HTYPE_SUBSCRIPTION); + MemoryFreeHandle((dvoid *) dequeue->subhp, OCI_HTYPE_SUBSCRIPTION); dequeue->subhp = NULL; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/dequeue.h b/src/dequeue.h new file mode 100644 index 00000000..c5921103 --- /dev/null +++ b/src/dequeue.h @@ -0,0 +1,148 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_DEQUEUE_H_INCLUDED +#define OCILIB_DEQUEUE_H_INCLUDED + +#include "types.h" + +OCI_Dequeue * DequeueCreate +( + OCI_TypeInfo *typinf, + const otext *name +); + +boolean DequeueFree +( + OCI_Dequeue *dequeue +); + +OCI_Agent * DequeueListen +( + OCI_Dequeue *dequeue, + int timeout +); + +OCI_Msg * DequeueGetMessage +( + OCI_Dequeue *dequeue +); + +const otext * DequeueGetConsumer +( + OCI_Dequeue *dequeue +); + +boolean DequeueSetConsumer +( + OCI_Dequeue *dequeue, + const otext *consumer +); + +const otext * DequeueGetCorrelation +( + OCI_Dequeue *dequeue +); + +boolean DequeueSetCorrelation +( + OCI_Dequeue *dequeue, + const otext *pattern +); + +boolean DequeueGetRelativeMsgID +( + OCI_Dequeue *dequeue, + void *id, + unsigned int *len +); + +boolean DequeueSetRelativeMsgID +( + OCI_Dequeue *dequeue, + const void *id, + unsigned int len +); + +unsigned int DequeueGetVisibility +( + OCI_Dequeue *dequeue +); + +boolean DequeueSetVisibility +( + OCI_Dequeue *dequeue, + unsigned int visibility +); + +unsigned int DequeueGetMode +( + OCI_Dequeue *dequeue +); + +boolean DequeueSetMode +( + OCI_Dequeue *dequeue, + unsigned int mode +); + +unsigned int DequeueGetNavigation +( + OCI_Dequeue *dequeue +); + +boolean DequeueSetNavigation +( + OCI_Dequeue *dequeue, + unsigned int position +); + +int DequeueGetWaitTime +( + OCI_Dequeue *dequeue +); + +boolean DequeueSetWaitTime +( + OCI_Dequeue *dequeue, + int timeout +); + +boolean DequeueSetAgentList +( + OCI_Dequeue *dequeue, + OCI_Agent **consumers, + unsigned int count +); + +boolean DequeueSubscribe +( + OCI_Dequeue *dequeue, + unsigned int port, + unsigned int timeout, + POCI_NOTIFY_AQ callback +); + +boolean DequeueUnsubscribe +( + OCI_Dequeue *dequeue +); + +#endif /* OCILIB_DEQUEUE_H_INCLUDED */ diff --git a/src/dirpath.c b/src/dirpath.c index af6ffaab..1ad600c3 100644 --- a/src/dirpath.c +++ b/src/dirpath.c @@ -18,39 +18,42 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "dirpath.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "strings.h" -static const unsigned int ConversionModeValues[] = { OCI_DCM_DEFAULT, OCI_DCM_FORCE }; - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int ConversionModeValues[] = +{ + OCI_DCM_DEFAULT, + OCI_DCM_FORCE +}; /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetArray + * DirPathSetArray * --------------------------------------------------------------------------------------------- */ -boolean OCI_DirPathSetArray +boolean DirPathSetArray ( OCI_DirPath *dp, - ub4 row_from + ub4 row_from ) { - ub1 *data = NULL; - ub4 size = 0; - ub1 flag = 0; - ub2 col = 0; - ub4 row = 0; - - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == dp, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + ub1 *data = NULL; + ub4 size = 0; + ub1 flag = 0; + ub2 col = 0; + ub4 row = 0; - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) /* reset the number of entries et */ @@ -58,9 +61,9 @@ boolean OCI_DirPathSetArray /* set entries */ - for (row = row_from; (row < dp->nb_cur) && OCI_STATUS; row++) + for (row = row_from; row < dp->nb_cur; row++) { - for (col = 0; (col < dp->nb_cols) && OCI_STATUS; col++) + for (col = 0; col < dp->nb_cols; col++) { OCI_DirPathColumn *dpcol = &(dp->cols[col]); @@ -79,39 +82,45 @@ boolean OCI_DirPathSetArray /* set entry value */ - OCI_EXEC(OCIDirPathColArrayEntrySet(dp->arr, dp->con->err, (ub4) dp->nb_entries, - (ub2) (col), (ub1*) data, (ub4) size, flag)) + CHECK_OCI + ( + dp->con->err, + OCIDirPathColArrayEntrySet, + dp->arr, dp->con->err, (ub4) dp->nb_entries, + (ub2) (col), (ub1*) data, (ub4) size, flag + ) } /* increment number of item set */ - - if (OCI_STATUS) - { - dp->nb_entries++; - } + dp->nb_entries++; } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPahArrayToStream + * DirPahArrayToStream * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_DirPathArrayToStream +unsigned int DirPathArrayToStream ( OCI_DirPath *dp, - ub4 row_from + ub4 row_from ) { - unsigned int res = OCI_DPR_COMPLETE; - sword ret = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_DPR_ERROR, + /* context */ OCI_IPC_DIRPATH, dp + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) + sword ret = OCI_SUCCESS; - OCI_CHECK(NULL == dp, OCI_DPR_ERROR) + unsigned int status = OCI_DPR_ERROR; - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) /* convert the array to a stream */ @@ -121,31 +130,31 @@ unsigned int OCI_DirPathArrayToStream { case OCI_SUCCESS: { - res = OCI_DPR_COMPLETE; + status = OCI_DPR_COMPLETE; dp->status = OCI_DPS_CONVERTED; break; } case OCI_ERROR: { - res = OCI_DPR_ERROR; + status = OCI_DPR_ERROR; /* only raise the exception if we're not in force mode */ if (OCI_DCM_DEFAULT == dp->cvt_mode) { - OCI_ExceptionOCI(dp->con->err, dp->con, NULL, FALSE); + THROW(ExceptionOCI, dp->con->err, ret) } break; } case OCI_CONTINUE: { + status = OCI_DPR_FULL; dp->status = OCI_DPS_CONVERTED; - res = OCI_DPR_FULL; break; } case OCI_NEED_DATA: { - res = OCI_DPR_PARTIAL; + status = OCI_DPR_PARTIAL; break; } } @@ -158,17 +167,27 @@ unsigned int OCI_DirPathArrayToStream size = sizeof(err_col); - OCI_GET_ATTRIB(OCI_HTYPE_DIRPATH_COLUMN_ARRAY, OCI_ATTR_COL_COUNT, dp->arr, &err_col, &size) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DIRPATH_COLUMN_ARRAY, OCI_ATTR_COL_COUNT, + dp->arr, &err_col, &size, + dp->con->err + ) size = sizeof(err_row); - OCI_GET_ATTRIB(OCI_HTYPE_DIRPATH_COLUMN_ARRAY, OCI_ATTR_ROW_COUNT, dp->arr, &err_row, &size) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DIRPATH_COLUMN_ARRAY, OCI_ATTR_ROW_COUNT, + dp->arr, &err_row, &size, + dp->con->err + ) /* update converted rows so far */ dp->nb_converted += err_row; /* record errors index on real error */ - if (OCI_DPR_ERROR == res) + if (OCI_DPR_ERROR == status) { dp->err_rows[dp->nb_err] = row_from + err_row; dp->err_cols[dp->nb_err] = err_col; @@ -183,23 +202,33 @@ unsigned int OCI_DirPathArrayToStream dp->nb_converted += dp->nb_entries; } - return res; + SET_RETVAL(status) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPahArrayToStream + * DirPahArrayToStream * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_DirPathLoadStream(OCI_DirPath *dp) -{ - unsigned int res = OCI_DPR_COMPLETE; - sword ret = OCI_SUCCESS; - ub4 nb_loaded = 0; - ub4 size = sizeof(nb_loaded); +unsigned int DirPathLoadStream +( + OCI_DirPath *dp +) +{ + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_DPR_ERROR, + /* context */ OCI_IPC_DIRPATH, dp + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) + sword ret = OCI_SUCCESS; + ub4 nb_loaded = 0; + ub4 size = sizeof(nb_loaded); - OCI_CHECK(NULL == dp, OCI_DPR_ERROR) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + + unsigned int status = OCI_DPR_ERROR; /* load the stream */ @@ -209,32 +238,36 @@ unsigned int OCI_DirPathLoadStream(OCI_DirPath *dp) { case OCI_SUCCESS: { - res = OCI_DPR_COMPLETE; - dp->status = OCI_DPS_PREPARED; + status = OCI_DPR_COMPLETE; + dp->status = OCI_DPS_PREPARED; break; } case OCI_ERROR: { - res = OCI_DPR_ERROR; - - OCI_ExceptionOCI(dp->con->err, dp->con, NULL, FALSE); + status = OCI_DPR_ERROR; + THROW(ExceptionOCI, dp->con->err, ret) break; } case OCI_NO_DATA: { - res = OCI_DPR_EMPTY; + status = OCI_DPR_EMPTY; break; } case OCI_NEED_DATA: { - res = OCI_DPR_PARTIAL; + status = OCI_DPR_PARTIAL; break; } } /* retrieve the number of rows loaded so far */ - OCI_GET_ATTRIB(OCI_HTYPE_DIRPATH_STREAM, OCI_ATTR_ROW_COUNT, dp->strm, &nb_loaded, &size) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DIRPATH_STREAM, OCI_ATTR_ROW_COUNT, + dp->strm, &nb_loaded, &size, + dp->con->err + ) dp->nb_loaded += nb_loaded; dp->nb_processed += nb_loaded; @@ -248,18 +281,16 @@ unsigned int OCI_DirPathLoadStream(OCI_DirPath *dp) dp->nb_err++; } - return res; -} + SET_RETVAL(status) -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathCreate + * DirPathCreate * --------------------------------------------------------------------------------------------- */ -OCI_DirPath * OCI_API OCI_DirPathCreate +OCI_DirPath * DirPathCreate ( OCI_TypeInfo *typinf, const otext *partition, @@ -267,148 +298,181 @@ OCI_DirPath * OCI_API OCI_DirPathCreate unsigned int nb_rows ) { - OCI_DirPath *dp = NULL; - - OCI_CALL_ENTER(OCI_DirPath*, dp) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CHECK_COMPAT(typinf->con, typinf->type != OCI_TIF_TYPE) - OCI_CALL_CHECK_BOUND(typinf->con, nb_cols, 1, typinf->nb_cols) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) - - /* allocate direct path structure */ - - OCI_ALLOCATE_DATA(OCI_IPC_DIRPATH, dp, 1) + ENTER_FUNC + ( + /* returns */ OCI_DirPath*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) - if (OCI_STATUS) - { - dbtext *dbstr = NULL; - int dbsize = -1; + dbtext* dbstr1 = NULL; + dbtext* dbstr2 = NULL; + dbtext* dbstr3 = NULL; - dp->con = typinf->con; - dp->status = OCI_DPS_NOT_PREPARED; - dp->cvt_mode = OCI_DCM_DEFAULT; - dp->res_conv = OCI_DPR_EMPTY; - dp->res_load = OCI_DPR_EMPTY; - dp->typinf = typinf; - dp->nb_rows = (ub2)nb_rows; - dp->nb_cols = (ub2)nb_cols; - dp->nb_cur = (ub2)dp->nb_rows; + int dbsize1 = -1; + int dbsize2 = -1; + int dbsize3 = -1; - /* allocates direct context handle */ + OCI_DirPath* dp = NULL; - OCI_STATUS = OCI_HandleAlloc((dvoid *)dp->con->env, (dvoid **) (void *) &dp->ctx, OCI_HTYPE_DIRPATH_CTX); + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + CHECK_COMPAT(typinf->type != OCI_TIF_TYPE) + CHECK_BOUND(nb_cols, 1, typinf->nb_cols) - /* set table name attribute */ + /* allocate direct path structure */ - if (OCI_STATUS) - { - dbsize = -1; - dbstr = OCI_StringGetOracleString(dp->typinf->name, &dbsize); + ALLOC_DATA(OCI_IPC_DIRPATH, dp, 1) - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_NAME, dp->ctx, dbstr, dbsize) + dp->con = typinf->con; + dp->status = OCI_DPS_NOT_PREPARED; + dp->cvt_mode = OCI_DCM_DEFAULT; + dp->res_conv = OCI_DPR_EMPTY; + dp->res_load = OCI_DPR_EMPTY; + dp->typinf = typinf; + dp->nb_rows = (ub2)nb_rows; + dp->nb_cols = (ub2)nb_cols; + dp->nb_cur = (ub2)dp->nb_rows; - OCI_StringReleaseOracleString(dbstr); - } + /* allocates direct context handle */ - /* set schema name attribute */ + CHECK + ( + MemoryAllocHandle + ( + (dvoid *) dp->con->env, + (dvoid **) (void *) &dp->ctx, + OCI_HTYPE_DIRPATH_CTX + ) + ) - if (OCI_STATUS && OCI_STRING_VALID(dp->typinf->schema)) - { - dbsize = -1; - dbstr = OCI_StringGetOracleString(dp->typinf->schema, &dbsize); + /* set table name attribute */ - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_SCHEMA_NAME, dp->ctx, dbstr, dbsize) + dbstr1 = StringGetDBString(dp->typinf->name, &dbsize1); - OCI_StringReleaseOracleString(dbstr); - } + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_NAME, + dp->ctx, dbstr1, dbsize1, + typinf->con->err + ) - /* set partition name attribute */ + /* set schema name attribute */ - if (OCI_STATUS && OCI_STRING_VALID(partition)) - { - dbsize = -1; - dbstr = OCI_StringGetOracleString(partition, &dbsize); + if (IS_STRING_VALID(dp->typinf->schema)) + { + dbstr2 = StringGetDBString(dp->typinf->schema, &dbsize2); + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_SCHEMA_NAME, + dp->ctx, dbstr2, dbsize2, + typinf->con->err + ) + } - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_SUB_NAME, dp->ctx, dbstr, dbsize) + /* set partition name attribute */ - OCI_StringReleaseOracleString(dbstr); - } + if (IS_STRING_VALID(partition)) + { + dbstr3 = StringGetDBString(partition, &dbsize3); + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_SUB_NAME, + dp->ctx, dbstr3, dbsize3, + typinf->con->err + ) + } - if (OCILib.version_runtime >= OCI_9_0) - { - ub4 num_rows = dp->nb_rows; + if (Env.version_runtime >= OCI_9_0) + { + ub4 num_rows = dp->nb_rows; - /* set array size attribute */ + /* set array size attribute */ - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_NUM_ROWS, dp->ctx, &num_rows, sizeof(num_rows)) - } + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_NUM_ROWS, + dp->ctx, &num_rows, sizeof(num_rows), + typinf->con->err + ) + } - /* set columns count attribute */ + /* set columns count attribute */ - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_NUM_COLS, dp->ctx, &dp->nb_cols, sizeof(dp->nb_cols)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_NUM_COLS, + dp->ctx, &dp->nb_cols, sizeof(dp->nb_cols), + typinf->con->err + ) - /* allocating the column array */ + /* allocating the column array */ - OCI_ALLOCATE_DATA(OCI_IPC_DP_COL_ARRAY, dp->cols, dp->nb_cols) - } + ALLOC_DATA(OCI_IPC_DP_COL_ARRAY, dp->cols, dp->nb_cols) - /* handle errors */ + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + StringReleaseDBString(dbstr3); - if (OCI_STATUS) - { - OCI_RETVAL = dp; - } - else if (dp) - { - OCI_DirPathFree(dp); - } + if (FAILURE) + { + DirPathFree(dp); + dp = NULL; + } - OCI_CALL_EXIT() + SET_RETVAL(dp) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathFree + * DirPathFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathFree +boolean DirPathFree ( OCI_DirPath *dp ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + ub2 i = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) for (i = 0; i < dp->nb_cols; i++) { - OCI_FREE(dp->cols[i].data) - OCI_FREE(dp->cols[i].lens) - OCI_FREE(dp->cols[i].flags) - OCI_FREE(dp->cols[i].format) + FREE(dp->cols[i].data) + FREE(dp->cols[i].lens) + FREE(dp->cols[i].flags) + FREE(dp->cols[i].format) } - OCI_FREE(dp->cols) - OCI_FREE(dp->err_cols) - OCI_FREE(dp->err_rows) + FREE(dp->cols) + FREE(dp->err_cols) + FREE(dp->err_rows) - OCI_HandleFree(dp->strm, OCI_HTYPE_DIRPATH_STREAM); - OCI_HandleFree(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY); - OCI_HandleFree(dp->ctx, OCI_HTYPE_DIRPATH_CTX); + MemoryFreeHandle(dp->strm, OCI_HTYPE_DIRPATH_STREAM); + MemoryFreeHandle(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY); + MemoryFreeHandle(dp->ctx, OCI_HTYPE_DIRPATH_CTX); - OCI_FREE(dp) + FREE(dp) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetColumn + * DirPathSetColumn * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetColumn +boolean DirPathSetColumn ( OCI_DirPath *dp, unsigned int index, @@ -417,21 +481,27 @@ boolean OCI_API OCI_DirPathSetColumn const otext *format ) { - OCI_DirPathColumn *dpcol = NULL; - OCI_Column *col = NULL; - OCIParam *hattr = NULL; - OCIParam *hlist = NULL; - dbtext *dbstr = NULL; - int dbsize = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + OCI_DirPathColumn *dpcol = NULL; + OCI_Column *col = NULL; + OCIParam *hattr = NULL; + OCIParam *hlist = NULL; + dbtext *dbstr1 = NULL; + int dbsize1 = -1; + dbtext *dbstr2 = NULL; + int dbsize2 = -1; ub2 i = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CHECK_BOUND(dp->con, index, 1, dp->nb_cols) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) + CHECK_PTR(OCI_IPC_STRING, name) + CHECK_BOUND(index, 1, dp->nb_cols) /* check if column exists */ @@ -447,255 +517,312 @@ boolean OCI_API OCI_DirPathSetColumn if (i >= dp->typinf->nb_cols) { - OCI_RAISE_EXCEPTION(OCI_ExceptionDirPathColNotFound(dp, name, dp->typinf->name)) + THROW(ExceptionDirPathColNotFound, name, dp->typinf->name) } /* set column information */ - if (OCI_STATUS) - { - col = &dp->typinf->cols[i]; - dpcol = &dp->cols[index-1]; + col = &dp->typinf->cols[i]; + dpcol = &dp->cols[index-1]; - /* default column attributes */ + /* default column attributes */ - dpcol->maxsize = (ub2) maxsize; - dpcol->bufsize = (ub2) maxsize + 1; - dpcol->sqlcode = SQLT_CHR; - dpcol->type = OCI_DDT_TEXT; - dpcol->index = i; - dpcol->format_size = 0; + dpcol->maxsize = (ub2) maxsize; + dpcol->bufsize = (ub2) maxsize + 1; + dpcol->sqlcode = SQLT_CHR; + dpcol->type = OCI_DDT_TEXT; + dpcol->index = i; + dpcol->format_size = 0; - switch (col->datatype) + switch (col->datatype) + { + case OCI_CDT_TEXT: { - case OCI_CDT_TEXT: + dpcol->maxsize *= sizeof(otext); + dpcol->bufsize *= sizeof(otext); + + if (Env.nls_utf8) { - dpcol->maxsize *= sizeof(otext); - dpcol->bufsize *= sizeof(otext); - - if (OCILib.nls_utf8) - { - dpcol->bufsize *= OCI_UTF8_BYTES_PER_CHAR; - } - break; + dpcol->bufsize *= OCI_UTF8_BYTES_PER_CHAR; } - case OCI_CDT_NUMERIC: + break; + } + case OCI_CDT_NUMERIC: + { + if (IS_STRING_VALID(format)) { - if (OCI_STRING_VALID(format)) - { - dpcol->format = ostrdup(format); - dpcol->format_size = (ub4) ostrlen(format); - dpcol->type = OCI_DDT_NUMBER; - dpcol->sqlcode = SQLT_NUM; - dpcol->bufsize = sizeof(OCINumber); - dpcol->maxsize = sizeof(OCINumber); - } - else - { - dpcol->type = OCI_DDT_OTHERS; - } - break; + dpcol->format = ostrdup(format); + dpcol->format_size = (ub4) ostrlen(format); + dpcol->type = OCI_DDT_NUMBER; + dpcol->sqlcode = SQLT_NUM; + dpcol->bufsize = sizeof(OCINumber); + dpcol->maxsize = sizeof(OCINumber); } - case OCI_CDT_DATETIME: - case OCI_CDT_TIMESTAMP: - case OCI_CDT_INTERVAL: + else { dpcol->type = OCI_DDT_OTHERS; - - if (OCI_STRING_VALID(format)) - { - dpcol->format = ostrdup(format); - dpcol->format_size = (ub4) ostrlen(format); - dpcol->maxsize = (ub2) max(dpcol->format_size, maxsize); - dpcol->bufsize *= sizeof(otext); - } - break; } - case OCI_CDT_LOB: - { - if (OCI_BLOB == col->subtype) - { - dpcol->type = OCI_DDT_BINARY; - dpcol->sqlcode = SQLT_BIN; - } - break; - } - case OCI_CDT_LONG: + break; + } + case OCI_CDT_DATETIME: + case OCI_CDT_TIMESTAMP: + case OCI_CDT_INTERVAL: + { + dpcol->type = OCI_DDT_OTHERS; + + if (IS_STRING_VALID(format)) { - if (OCI_BLONG == col->subtype) - { - dpcol->type = OCI_DDT_BINARY; - dpcol->sqlcode = SQLT_BIN; - } - break; + dpcol->format = ostrdup(format); + dpcol->format_size = (ub4) ostrlen(format); + dpcol->maxsize = (ub2) max(dpcol->format_size, maxsize); + dpcol->bufsize *= sizeof(otext); } - case OCI_CDT_RAW: + break; + } + case OCI_CDT_LOB: + { + if (OCI_BLOB == col->subtype) { dpcol->type = OCI_DDT_BINARY; dpcol->sqlcode = SQLT_BIN; - break; } - default: + break; + } + case OCI_CDT_LONG: + { + if (OCI_BLONG == col->subtype) { - OCI_RAISE_EXCEPTION(OCI_ExceptionDatatypeNotSupported(dp->con, NULL, col->libcode)) + dpcol->type = OCI_DDT_BINARY; + dpcol->sqlcode = SQLT_BIN; } + break; + } + case OCI_CDT_RAW: + { + dpcol->type = OCI_DDT_BINARY; + dpcol->sqlcode = SQLT_BIN; + break; + } + default: + { + THROW(ExceptionDatatypeNotSupported, col->libcode) } } - /* if supported data type, set direct path column attributes */ - - if (OCI_STATUS) - { - /* get column parameter list handle */ + /* get column parameter list handle */ - OCI_GET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_LIST_COLUMNS, dp->ctx, &hlist, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_LIST_COLUMNS, + dp->ctx, &hlist, NULL, + dp->typinf->con->err + ) - /* get column attribute handle */ + /* get column attribute handle */ - OCI_EXEC(OCIParamGet((dvoid *) hlist, OCI_DTYPE_PARAM, dp->con->err, (dvoid** ) (dvoid *) &hattr, (ub4) index)) + CHECK_OCI + ( + dp->typinf->con->err, + OCIParamGet, + (dvoid *) hlist, OCI_DTYPE_PARAM, + dp->con->err, + (dvoid** ) (dvoid *) &hattr, + (ub4) index + ) - /* set column name */ + /* set column name */ - if (OCI_STATUS) - { - dbsize = -1; - dbstr = OCI_StringGetOracleString(name, &dbsize); + dbstr1 = StringGetDBString(name, &dbsize1); - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_NAME, hattr, dbstr, dbsize) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_NAME, + hattr, dbstr1, dbsize1, + dp->typinf->con->err + ) - OCI_StringReleaseOracleString(dbstr); - } + /* set column type */ - /* set column type */ + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_DATA_TYPE, + hattr, &dpcol->sqlcode, sizeof(dpcol->sqlcode), + dp->typinf->con->err + ) - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_DATA_TYPE, hattr, &dpcol->sqlcode, sizeof(dpcol->sqlcode)) + /* set column size */ - /* set column size */ + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_DATA_SIZE, + hattr, &dpcol->maxsize, sizeof(dpcol->maxsize), + dp->typinf->con->err + ) - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_DATA_SIZE, hattr, &dpcol->maxsize, sizeof(dpcol->maxsize)) + /* set column precision */ - /* set column precision */ + if (col->prec != 0) + { + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_PRECISION, + hattr, &col->prec, sizeof(col->prec), + dp->typinf->con->err + ) + } - if (col->prec != 0) - { - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_PRECISION, hattr, &col->prec, sizeof(col->prec)) - } + /* set column scale */ - /* set column scale */ + if (col->scale != 0) + { + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_SCALE, + hattr, &col->scale, sizeof(col->scale), + dp->typinf->con->err + ) + } - if (col->scale != 0) - { - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_SCALE, hattr, &col->scale, sizeof(col->scale)) - } + /* set column date/time format attribute */ - /* set column date/time format attribute */ + if (dpcol->format && dpcol->format[0] && (OCI_DDT_NUMBER != dpcol->type)) + { + dbstr2 = StringGetDBString(dpcol->format, &dbsize2); + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_DATEFORMAT, + hattr, dbstr2, dbsize2, + dp->typinf->con->err + ) + } - if (OCI_STATUS && dpcol->format && dpcol->format[0] && (OCI_DDT_NUMBER != dpcol->type)) - { - dbsize = -1; - dbstr = OCI_StringGetOracleString(dpcol->format, &dbsize); + /* setup Unicode mode for Unicode user data */ - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_DATEFORMAT, hattr, dbstr, dbsize) + if (OCI_DDT_TEXT == dpcol->type && OCI_CHAR_WIDE == Env.charset) + { + ub2 csid = OCI_UTF16ID; + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_PARAM, OCI_ATTR_CHARSET_ID, + hattr, &csid, sizeof(csid), + dp->typinf->con->err + ) + } - OCI_StringReleaseOracleString(dbstr); - } + SET_SUCCESS() - /* setup Unicode mode for Unicode user data */ + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); - if (OCI_DDT_TEXT == dpcol->type && OCI_CHAR_WIDE == OCILib.charset) + if (NULL != hattr) { - ub2 csid = OCI_UTF16ID; - - OCI_SET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_CHARSET_ID, hattr, &csid, sizeof(csid)) + OCIDescriptorFree(hattr, OCI_DTYPE_PARAM); } - - /* free param handle */ - - OCIDescriptorFree(hattr, OCI_DTYPE_PARAM); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathPrepare + * DirPathPrepare * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathPrepare +boolean DirPathPrepare ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + ub4 num_rows = 0; + ub4 size = sizeof(num_rows); + + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) /* prepare direct path operation */ - OCI_EXEC(OCIDirPathPrepare(dp->ctx, dp->con->cxt, dp->con->err)) + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathPrepare, + dp->ctx, dp->con->cxt, + dp->con->err + ) /* allocate column array handle */ - OCI_STATUS = OCI_STATUS && OCI_HandleAlloc((dvoid *)dp->ctx, (dvoid **)(void *)&dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY); + CHECK + ( + MemoryAllocHandle + ( + (dvoid *)dp->ctx, + (dvoid **)(void *)&dp->arr, + OCI_HTYPE_DIRPATH_COLUMN_ARRAY + ) + ) /* allocate stream handle */ - OCI_STATUS = OCI_STATUS && OCI_HandleAlloc((dvoid *)dp->ctx, (dvoid **)(void *)&dp->strm, OCI_HTYPE_DIRPATH_STREAM); + CHECK + ( + MemoryAllocHandle + ( + (dvoid *)dp->ctx, + (dvoid **)(void *)&dp->strm, + OCI_HTYPE_DIRPATH_STREAM + ) + ) /* check the number of rows allocated */ - if (OCI_STATUS) - { - ub4 num_rows = 0; - ub4 size = sizeof(num_rows); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DIRPATH_COLUMN_ARRAY, OCI_ATTR_NUM_ROWS, + dp->arr, &num_rows, &size, + dp->typinf->con->err + ) - OCI_GET_ATTRIB(OCI_HTYPE_DIRPATH_COLUMN_ARRAY, OCI_ATTR_NUM_ROWS, dp->arr, &num_rows, &size) - - dp->nb_cur = (ub2) num_rows; - dp->nb_rows = (ub2) num_rows; - } + dp->nb_cur = (ub2) num_rows; + dp->nb_rows = (ub2) num_rows; /* allocate array of errs rows */ - OCI_ALLOCATE_DATA(OCI_IPC_BUFF_ARRAY, dp->err_rows, dp->nb_cur) - + ALLOC_DATA(OCI_IPC_BUFF_ARRAY, dp->err_rows, dp->nb_cur) /* allocate array of errs cols */ - OCI_ALLOCATE_DATA(OCI_IPC_BUFF_ARRAY, dp->err_cols, dp->nb_cur) + ALLOC_DATA(OCI_IPC_BUFF_ARRAY, dp->err_cols, dp->nb_cur) /* now, we need to allocate internal buffers */ - if (OCI_STATUS) + for (ub2 i = 0; i < dp->nb_cols; i++) { - for (ub2 i = 0; i < dp->nb_cols && OCI_STATUS; i++) - { - OCI_DirPathColumn *col = &dp->cols[i]; + OCI_DirPathColumn *col = &dp->cols[i]; - OCI_ALLOCATE_BUFFER(OCI_IPC_BUFF_ARRAY, col->data, col->bufsize, dp->nb_cur) - OCI_ALLOCATE_BUFFER(OCI_IPC_BUFF_ARRAY, col->lens, sizeof(ub4), dp->nb_cur) - OCI_ALLOCATE_BUFFER(OCI_IPC_BUFF_ARRAY, col->flags, sizeof(ub1), dp->nb_cur) - } + ALLOC_BUFFER(OCI_IPC_BUFF_ARRAY, col->data, col->bufsize, dp->nb_cur) + ALLOC_BUFFER(OCI_IPC_BUFF_ARRAY, col->lens, sizeof(ub4), dp->nb_cur) + ALLOC_BUFFER(OCI_IPC_BUFF_ARRAY, col->flags, sizeof(ub1), dp->nb_cur) } - if (OCI_STATUS) - { - dp->status = OCI_DPS_PREPARED; - } + dp->status = OCI_DPS_PREPARED; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetEntry + * DirPathSetEntry * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetEntry +boolean DirPathSetEntry ( OCI_DirPath *dp, unsigned int row, @@ -705,153 +832,170 @@ boolean OCI_API OCI_DirPathSetEntry boolean complete ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + OCI_DirPathColumn *dpcol = NULL; ub1 flag = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CHECK_BOUND(dp->con, index, 1, dp->nb_cols) - OCI_CALL_CHECK_BOUND(dp->con, row, 1, dp->nb_cur) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) + CHECK_BOUND(index, 1, dp->nb_cols) + CHECK_BOUND(row, 1, dp->nb_cur) dpcol = &dp->cols[index-1]; - OCI_STATUS = (NULL != dpcol); + CHECK_NULL(dpcol) + + /* check size */ - if (OCI_STATUS) + if (size > dpcol->maxsize) { - /* check size */ + size = (unsigned int) dpcol->maxsize; + } - if (size > dpcol->maxsize) - { - size = (unsigned int) dpcol->maxsize; - } + /* setup column flag */ - /* setup column flag */ + if (!value) + { + flag = OCI_DIRPATH_COL_NULL; + size = 0; + } + else if (complete) + { + flag = OCI_DIRPATH_COL_COMPLETE; + } + else + { + flag = OCI_DIRPATH_COL_PARTIAL; + } - if (!value) - { - flag = OCI_DIRPATH_COL_NULL; - size = 0; - } - else if (complete) - { - flag = OCI_DIRPATH_COL_COMPLETE; - } - else - { - flag = OCI_DIRPATH_COL_PARTIAL; - } + /* Process only if data is not null */ - /* Process only if data is not null */ + if (NULL != value) + { + /* for character based column, parameter size was the number of characters */ - if (value) + if (SQLT_CHR == dpcol->sqlcode) { - /* for character based column, parameter size was the number of characters */ - - if (SQLT_CHR == dpcol->sqlcode) - { - size *= (unsigned int) sizeof(otext); - } + size *= (unsigned int) sizeof(otext); + } - /* get internal data cell */ + /* get internal data cell */ - ub1 *data = ((ub1 *) dpcol->data) + (size_t) ((row-1) * dpcol->bufsize); + ub1 *data = ((ub1 *) dpcol->data) + (size_t) ((row-1) * dpcol->bufsize); - /* we weed to pack the buffer if wchar_t is 4 bytes */ + /* we weed to pack the buffer if wchar_t is 4 bytes */ - if (OCI_DDT_TEXT == dpcol->type && OCILib.use_wide_char_conv) - { - size = ocharcount(size); - OCI_StringUTF32ToUTF16(value, data, size); - } - else if (OCI_DDT_OTHERS == dpcol->type && OCI_CHAR_WIDE == OCILib.charset) - { - /* input Unicode numeric values causes oracle conversion error. - so, let's convert them to ANSI */ + if (OCI_DDT_TEXT == dpcol->type && Env.use_wide_char_conv) + { + size = ocharcount(size); + StringUTF32ToUTF16(value, data, size); + } + else if (OCI_DDT_OTHERS == dpcol->type && OCI_CHAR_WIDE == Env.charset) + { + /* input Unicode numeric values causes oracle conversion error. + so, let's convert them to ANSI */ - size = ocharcount(size); - OCI_StringNativeToAnsi(value, data, size); - } - else if (OCI_DDT_NUMBER == dpcol->type) - { - /* if a format was provided for a numeric column, we convert the input - buffer to a OCINumber */ + size = ocharcount(size); + StringNativeToAnsi(value, data, size); + } + else if (OCI_DDT_NUMBER == dpcol->type) + { + /* if a format was provided for a numeric column, we convert the input + buffer to a OCINumber */ - OCINumber *num = (OCINumber *) data; + OCINumber *num = (OCINumber *) data; - OCI_STATUS = OCI_NumberFromString(dp->con, num, OCI_NUM_NUMBER, (otext *)value, dpcol->format); + CHECK(NumberFromStringInternal(dp->con, num, OCI_NUM_NUMBER, + (otext *)value, dpcol->format)) - if (OCI_STATUS) - { - size = (unsigned int) num->OCINumberPart[0]; - } - } - else - { - memcpy(data, value, (size_t) size); - } + size = (unsigned int) num->OCINumberPart[0]; + } + else + { + memcpy(data, value, (size_t) size); } - - dpcol->lens[row-1] = size; - dpcol->flags[row-1] = flag; } - OCI_RETVAL = OCI_STATUS; + dpcol->lens[row-1] = size; + dpcol->flags[row-1] = flag; + + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathReset + * DirPathReset * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathReset +boolean DirPathReset ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + CHECK_PTR(OCI_IPC_DIRPATH, dp) /* reset conversion and loading variables */ - dp->nb_processed = 0; - dp->nb_converted = 0; - dp->nb_err = 0; - dp->idx_err_row = 0; - dp->idx_err_col = 0; + dp->nb_processed = 0; + dp->nb_converted = 0; + dp->nb_err = 0; + dp->idx_err_row = 0; + dp->idx_err_col = 0; /* reset array */ - OCI_EXEC(OCIDirPathColArrayReset(dp->arr, dp->con->err)) + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathColArrayReset, + dp->arr, dp->con->err + ) /* reset stream */ - OCI_EXEC(OCIDirPathStreamReset(dp->strm, dp->con->err)) + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathStreamReset, + dp->strm, dp->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathConvert + * DirPathConvert * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathConvert +unsigned int DirPathConvert ( OCI_DirPath *dp ) { + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_DPR_ERROR, + /* context */ OCI_IPC_DIRPATH, dp + ) + ub4 row_from = 0; - OCI_CALL_ENTER(unsigned int, OCI_DPR_ERROR) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) /* reset the number of processed rows */ @@ -869,7 +1013,12 @@ unsigned int OCI_API OCI_DirPathConvert if (OCI_DPR_FULL == dp->res_conv) { - OCI_EXEC(OCIDirPathStreamReset(dp->strm, dp->con->err)) + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathStreamReset, + dp->strm, dp->con->err + ) } /* reset conversion status back to default error value */ @@ -878,331 +1027,415 @@ unsigned int OCI_API OCI_DirPathConvert /* set array values */ - if (OCI_STATUS && OCI_DirPathSetArray(dp, row_from)) - { - /* try to convert values from array into stream */ + CHECK(DirPathSetArray(dp, row_from)) - dp->res_conv = OCI_DirPathArrayToStream(dp, row_from); + /* try to convert values from array into stream */ - /* in case of conversion error, continue conversion in force mode - other return from conversion */ + dp->res_conv = DirPathArrayToStream(dp, row_from); - if (OCI_DCM_FORCE == dp->cvt_mode && OCI_DPR_ERROR == dp->res_conv) - { - /* perform conversion until all non erred rows are converted */ + /* in case of conversion error, continue conversion in force mode + other return from conversion */ - while (OCI_STATUS && (OCI_DPR_ERROR == dp->res_conv) && (dp->nb_err <= dp->nb_cur)) - { - /* start from the row that follows the last erred row */ + if (OCI_DCM_FORCE == dp->cvt_mode && OCI_DPR_ERROR == dp->res_conv) + { + /* perform conversion until all non erred rows are converted */ - row_from = dp->err_rows[dp->nb_err - 1] + 1; + while (OCI_DPR_ERROR == dp->res_conv && dp->nb_err <= dp->nb_cur) + { + /* start from the row that follows the last erred row */ - /* set values again */ + row_from = dp->err_rows[dp->nb_err - 1] + 1; - OCI_STATUS = OCI_DirPathSetArray(dp, row_from); + /* set values again */ - if (OCI_STATUS) - { - /* perform conversion again */ + CHECK(DirPathSetArray(dp, row_from)) - dp->res_conv = OCI_DirPathArrayToStream(dp, row_from); - } - } + /* perform conversion again */ + + dp->res_conv = DirPathArrayToStream(dp, row_from); } } dp->nb_processed = dp->nb_converted; - OCI_STATUS = OCI_STATUS && (OCI_DPR_COMPLETE == dp->res_conv); - OCI_RETVAL = dp->res_conv; + SET_RETVAL(dp->res_conv) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathLoad + * DirPathLoad * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathLoad +unsigned int DirPathLoad ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(unsigned int, OCI_DPR_ERROR) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_CONVERTED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_DPR_ERROR, + /* context */ OCI_IPC_DIRPATH, dp + ) + + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_CONVERTED) /* reset the number of processed rows */ dp->nb_processed = 0; - /* reset errors variables as OCI_DirPathLoad() is not re-entrant */ + /* reset errors variables as OCI_DirPathLoad() is not re-entrant */ - dp->nb_err = 0; - dp->idx_err_col = 0; - dp->idx_err_row = 0; - dp->res_load = OCI_DPR_COMPLETE; + dp->nb_err = 0; + dp->idx_err_col = 0; + dp->idx_err_row = 0; + dp->res_load = OCI_DPR_COMPLETE; /* load the stream */ - dp->res_load = OCI_DirPathLoadStream(dp); + dp->res_load = DirPathLoadStream(dp); /* continue to load the stream while it returns an error */ while (OCI_DPR_ERROR == dp->res_load) { - dp->res_load = OCI_DirPathLoadStream(dp); + dp->res_load = DirPathLoadStream(dp); } - OCI_STATUS = OCI_STATUS && (OCI_DPR_COMPLETE == dp->res_load); - OCI_RETVAL = dp->res_load; + SET_RETVAL(dp->res_load) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathFinish + * DirPathFinish * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathFinish +boolean DirPathFinish ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) - OCI_EXEC(OCIDirPathFinish(dp->ctx, dp->con->err)) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - if (OCI_STATUS) - { - dp->status = OCI_DPS_TERMINATED; - } + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathFinish, + dp->ctx, dp->con->err + ) + + dp->status = OCI_DPS_TERMINATED; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathAbort + * DirPathAbort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathAbort +boolean DirPathAbort ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) - OCI_EXEC(OCIDirPathAbort(dp->ctx, dp->con->err)) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - if (OCI_STATUS) - { - dp->status = OCI_DPS_TERMINATED; - } + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathAbort, + dp->ctx, dp->con->err + ) + + dp->status = OCI_DPS_TERMINATED; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSave + * DirPathSave * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSave +boolean DirPathSave ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) - - OCI_EXEC(OCIDirPathDataSave(dp->ctx, dp->con->err, OCI_DIRPATH_DATASAVE_SAVEONLY)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) + + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathDataSave, + dp->ctx, dp->con->err, + OCI_DIRPATH_DATASAVE_SAVEONLY + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathFlushRow + * DirPathFlushRow * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathFlushRow +boolean DirPathFlushRow ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_EXEC(OCIDirPathFlushRow(dp->ctx, dp->con->err)) + CHECK_OCI + ( + dp->typinf->con->err, + OCIDirPathFlushRow, + dp->ctx, dp->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetCurrentRows + * DirPathSetCurrentRows * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetCurrentRows +boolean DirPathSetCurrentRows ( OCI_DirPath *dp, unsigned int nb_rows ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) - OCI_CALL_CHECK_BOUND(dp->con, nb_rows, 1, dp->nb_rows) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_PREPARED) + CHECK_BOUND(nb_rows, 1, dp->nb_rows) dp->nb_cur = (ub2) nb_rows; - OCI_RETVAL = TRUE; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathGetCurrentRows + * DirPathGetCurrentRows * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathGetCurrentRows +unsigned int DirPathGetCurrentRows ( OCI_DirPath *dp ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_DIRPATH, dp, nb_cur, dp->con, NULL, dp->con->err) + GET_PROP + ( + /* result */ unsigned int, 0, + /* handle */ OCI_IPC_DIRPATH, dp, + /* member */ nb_cur + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathGetMaxRows + * DirPathGetMaxRows * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathGetMaxRows +unsigned int DirPathGetMaxRows ( OCI_DirPath *dp ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_DIRPATH, dp, nb_rows, dp->con, NULL, dp->con->err) + GET_PROP + ( + /* result */ unsigned int, 0, + /* handle */ OCI_IPC_DIRPATH, dp, + /* member */ nb_rows + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetDateFormat + * DirPathSetDateFormat * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetDateFormat +boolean DirPathSetDateFormat ( OCI_DirPath *dp, const otext *format ) { - dbtext *dbstr = NULL; - int dbsize = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + dbtext *dbstr = NULL; + int dbsize = -1; - dbsize = -1; - dbstr = OCI_StringGetOracleString(format, &dbsize); + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DATEFORMAT, dp->ctx, dbstr, dbsize) + dbstr = StringGetDBString(format, &dbsize); - OCI_StringReleaseOracleString(dbstr); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DATEFORMAT, + dp->ctx, dbstr, dbsize, + dp->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetParallel + * DirPathSetParallel * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetParallel +boolean DirPathSetParallel ( OCI_DirPath *dp, boolean value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + ub1 enabled = (ub1) value; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_PARALLEL, dp->ctx, &enabled, sizeof(enabled)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_PARALLEL, + dp->ctx, &enabled, sizeof(enabled), + dp->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetNoLog + * DirPathSetNoLog * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetNoLog +boolean DirPathSetNoLog ( OCI_DirPath *dp, boolean value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + ub1 nolog = (ub1) value; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_NOLOG, dp->ctx, &nolog, sizeof(nolog)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_NOLOG, + dp->ctx, &nolog, sizeof(nolog), + dp->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetCacheSize + * DirPathSetCacheSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetCacheSize +boolean DirPathSetCacheSize ( OCI_DirPath *dp, unsigned int size ) { - ub4 cache_size = size; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + ub4 cache_size = size; boolean enabled = FALSE; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) #if OCI_VERSION_COMPILE >= OCI_9_2 - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_DCACHE_SIZE, dp->ctx, &cache_size, sizeof(cache_size)) - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_DCACHE_DISABLE, dp->ctx, &enabled, sizeof(enabled)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_DCACHE_SIZE, + dp->ctx, &cache_size, sizeof(cache_size), + dp->typinf->con->err + ) + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_DIRPATH_DCACHE_DISABLE, + dp->ctx, &enabled, sizeof(enabled), + dp->typinf->con->err + ) #else @@ -1211,120 +1444,149 @@ boolean OCI_API OCI_DirPathSetCacheSize #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetBufferSize + * DirPathSetBufferSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetBufferSize +boolean DirPathSetBufferSize ( OCI_DirPath *dp, unsigned int size ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + ub4 bufsize = (ub4) size; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_SET_ATTRIB(OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_BUF_SIZE, dp->ctx, &bufsize, sizeof(bufsize)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DIRPATH_CTX, OCI_ATTR_BUF_SIZE, + dp->ctx, &bufsize, sizeof(bufsize), + dp->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathSetConvertMode + * DirPathSetConvertMode * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DirPathSetConvertMode +boolean DirPathSetConvertMode ( OCI_DirPath *dp, unsigned int mode ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) - OCI_CALL_CHECK_ENUM_VALUE(dp->con, NULL, mode, ConversionModeValues, OTEXT("Conversion mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_DIRPATH, dp + ) + + CHECK_PTR(OCI_IPC_DIRPATH, dp) + CHECK_DIRPATH_STATUS(dp, OCI_DPS_NOT_PREPARED) + CHECK_ENUM_VALUE(mode, ConversionModeValues, OTEXT("Conversion mode")) dp->cvt_mode = (ub2)mode; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathGetRowCount + * DirPathGetRowCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathGetRowCount +unsigned int DirPathGetRowCount ( OCI_DirPath *dp ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_DIRPATH, dp, nb_loaded, dp->con, NULL, dp->con->err) + GET_PROP + ( + /* result */ unsigned int, 0, + /* handle */ OCI_IPC_DIRPATH, dp, + /* member */ nb_loaded + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathGetAffectedRows + * DirPathGetAffectedRows * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathGetAffectedRows +unsigned int DirPathGetAffectedRows ( OCI_DirPath *dp ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_DIRPATH, dp, nb_processed, dp->con, NULL, dp->con->err) + GET_PROP + ( + /* result */ unsigned int, 0, + /* handle */ OCI_IPC_DIRPATH, dp, + /* member */ nb_processed + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathGetErrorColumn + * DirPathGetErrorColumn * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathGetErrorColumn +unsigned int DirPathGetErrorColumn ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_DIRPATH, dp + ) - if (dp->idx_err_col < dp->nb_err) - { - OCI_RETVAL = (unsigned int) dp->err_cols[dp->idx_err_col++] + 1; - } + CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_EXIT() + CHECK(dp->idx_err_col < dp->nb_err) + + SET_RETVAL((unsigned int) dp->err_cols[dp->idx_err_col++] + 1) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DirPathGetErrorRow + * DirPathGetErrorRow * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_DirPathGetErrorRow +unsigned int DirPathGetErrorRow ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - OCI_CALL_CONTEXT_SET_FROM_CONN(dp->con) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_DIRPATH, dp + ) - if (dp->idx_err_row < dp->nb_err) - { - OCI_RETVAL = (unsigned int) dp->err_rows[dp->idx_err_row++] + 1; - } + CHECK_PTR(OCI_IPC_DIRPATH, dp) + + CHECK(dp->idx_err_row < dp->nb_err) + + SET_RETVAL((unsigned int) dp->err_rows[dp->idx_err_row++] + 1) - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/dirpath.h b/src/dirpath.h new file mode 100644 index 00000000..962e54da --- /dev/null +++ b/src/dirpath.h @@ -0,0 +1,170 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_DIRPATH_H_INCLUDED +#define OCILIB_DIRPATH_H_INCLUDED + +#include "types.h" + +OCI_DirPath * DirPathCreate +( + OCI_TypeInfo *typinf, + const otext *partition, + unsigned int nb_cols, + unsigned int nb_rows +); + +boolean DirPathFree +( + OCI_DirPath *dp +); + +boolean DirPathSetColumn +( + OCI_DirPath *dp, + unsigned int index, + const otext *name, + unsigned int maxsize, + const otext *format +); + +boolean DirPathPrepare +( + OCI_DirPath *dp +); + +boolean DirPathSetEntry +( + OCI_DirPath *dp, + unsigned int row, + unsigned int index, + void *value, + unsigned int size, + boolean complete +); + +boolean DirPathReset +( + OCI_DirPath *dp +); + +unsigned int DirPathConvert +( + OCI_DirPath *dp +); + +unsigned int DirPathLoad +( + OCI_DirPath *dp +); + +boolean DirPathFinish +( + OCI_DirPath *dp +); + +boolean DirPathAbort +( + OCI_DirPath *dp +); + +boolean DirPathSave +( + OCI_DirPath *dp +); + +boolean DirPathFlushRow +( + OCI_DirPath *dp +); + +boolean DirPathSetCurrentRows +( + OCI_DirPath *dp, + unsigned int nb_rows +); + +unsigned int DirPathGetCurrentRows +( + OCI_DirPath *dp +); + +unsigned int DirPathGetMaxRows +( + OCI_DirPath* dp +); + +boolean DirPathSetDateFormat +( + OCI_DirPath *dp, + const otext *format +); + +boolean DirPathSetParallel +( + OCI_DirPath *dp, + boolean value +); + +boolean DirPathSetNoLog +( + OCI_DirPath *dp, + boolean value +); + +boolean DirPathSetCacheSize +( + OCI_DirPath *dp, + unsigned int size +); + +boolean DirPathSetBufferSize +( + OCI_DirPath *dp, + unsigned int size +); + +boolean DirPathSetConvertMode +( + OCI_DirPath *dp, + unsigned int mode +); + +unsigned int DirPathGetRowCount +( + OCI_DirPath *dp +); + +unsigned int DirPathGetAffectedRows +( + OCI_DirPath *dp +); + +unsigned int DirPathGetErrorColumn +( + OCI_DirPath *dp +); + +unsigned int DirPathGetErrorRow +( + OCI_DirPath *dp +); + +#endif /* OCILIB_DIRPATH_H_INCLUDED */ diff --git a/src/element.c b/src/element.c index a87dac93..04dad2bf 100644 --- a/src/element.c +++ b/src/element.c @@ -18,123 +18,147 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -#define OCI_ELEM_SET_VALUE(elemtype, type, func_init, func_assign) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) \ - OCI_CALL_CHECK_COMPAT((elem)->con, (elemtype) == (elem)->typinf->cols[0].datatype)\ - OCI_CALL_CONTEXT_SET_FROM_CONN((elem)->con) \ - \ - if (!value) \ - { \ - OCI_STATUS = OCI_ElemSetNull(elem); \ - } \ - else \ - { \ - if (!(elem)->obj) \ - { \ - (elem)->obj = func_init; \ - } \ - \ - if ((elem)->obj) \ - { \ - OCI_STATUS = func_assign; \ - \ - if (OCI_STATUS) \ - { \ - OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL); \ - (elem)->handle = ((type) (elem)->obj)->handle; \ - } \ - } \ - } \ - \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() - -#define OCI_ELEM_GET_VALUE(elemtype, type, func) \ - \ - OCI_CALL_ENTER(type, NULL) \ - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) \ - OCI_CALL_CHECK_COMPAT((elem)->con, (elemtype) == (elem)->typinf->cols[0].datatype)\ - OCI_CALL_CONTEXT_SET_FROM_CONN((elem)->con) \ - \ - if (OCI_IND_NULL != *(elem)->pind) \ - { \ - if (!(elem)->init) \ - { \ - (elem)->obj = OCI_RETVAL = func; \ - \ - (elem)->init = (NULL != OCI_RETVAL); \ - } \ - else \ - { \ - OCI_RETVAL = (type) (elem)->obj; \ - } \ - \ - OCI_STATUS = (elem)->init; \ - } \ - \ - OCI_CALL_EXIT() - - -#define OCI_ELEM_GET_NUMBER(elem, number_type, type, value) \ - \ - OCI_CALL_ENTER(type, value) \ - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) \ - OCI_CALL_CHECK_COMPAT((elem)->con, OCI_CDT_NUMERIC == (elem)->typinf->cols[0].datatype) \ - OCI_CALL_CONTEXT_SET_FROM_CONN((elem)->con) \ - \ - OCI_STATUS = OCI_ElemGetNumberInternal(elem, (void *) (&OCI_RETVAL), \ - (uword) (number_type)); \ - \ - OCI_CALL_EXIT() - -#define OCI_ELEM_SET_NUMBER(elem, value, number_type) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) \ - OCI_CALL_CHECK_COMPAT((elem)->con, OCI_CDT_NUMERIC == (elem)->typinf->cols[0].datatype) \ - OCI_CALL_CONTEXT_SET_FROM_CONN((elem)->con) \ - \ - OCI_RETVAL = OCI_STATUS = OCI_ElemSetNumberInternal(elem, (void *) &(value), \ - (uword) (number_type)); \ - \ - OCI_CALL_EXIT() - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "element.h" + +#include "collection.h" +#include "date.h" +#include "exception.h" +#include "file.h" +#include "helpers.h" +#include "interval.h" +#include "lob.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "strings.h" +#include "timestamp.h" + +#define ELEM_SET_VALUE(elemtype, type, func_init, func_assign) \ + \ + ENTER_FUNC(boolean, TRUE, OCI_IPC_ELEMENT, elem) \ + \ + CHECK_PTR(OCI_IPC_ELEMENT, elem) \ + CHECK_COMPAT((elemtype) == (elem)->typinf->cols[0].datatype) \ + \ + if (NULL == value) \ + { \ + CHECK(ElementSetNull(elem)) \ + } \ + else \ + { \ + if (!(elem)->obj) \ + { \ + (elem)->obj = func_init; \ + CHECK_NULL((elem)->obj) \ + } \ + \ + CHECK(func_assign) \ + \ + CHECK(ElementSetNullIndicator(elem, OCI_IND_NOTNULL)) \ + (elem)->handle = ((type) (elem)->obj)->handle; \ + } \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() + +#define ELEM_GET_VALUE(elemtype, type, func) \ + \ + ENTER_FUNC(type, NULL, OCI_IPC_ELEMENT, elem) \ + \ + CHECK_PTR(OCI_IPC_ELEMENT, elem) \ + CHECK_COMPAT((elemtype) == (elem)->typinf->cols[0].datatype) \ + \ + type tmp = NULL; \ + \ + if (OCI_IND_NULL != *(elem)->pind) \ + { \ + if (!(elem)->init) \ + { \ + (elem)->obj = func; \ + CHECK_NULL((elem)->obj) \ + tmp = (elem)->obj; \ + } \ + else \ + { \ + tmp = (type) (elem)->obj; \ + } \ + } \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +#define ELEM_GET_NUMBER(elem, number_type, type, value) \ + \ + ENTER_FUNC(type, value, OCI_IPC_ELEMENT, elem) \ + \ + CHECK_PTR(OCI_IPC_ELEMENT, elem) \ + CHECK_COMPAT(OCI_CDT_NUMERIC == (elem)->typinf->cols[0].datatype) \ + \ + type tmp = value; \ + \ + CHECK(ElemGetNumberInternal(elem, (void *) &tmp, (uword) (number_type))) \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +#define ELEM_SET_NUMBER(elem, value, number_type) \ + \ + ENTER_FUNC(boolean, FALSE, OCI_IPC_ELEMENT, elem) \ + \ + CHECK_PTR(OCI_IPC_ELEMENT, elem) \ + CHECK_COMPAT(OCI_CDT_NUMERIC == (elem)->typinf->cols[0].datatype) \ + \ + CHECK(ElementSetNumberInternal(elem, (void *) &(value), (uword) (number_type))) \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() /* --------------------------------------------------------------------------------------------- * -* OCI_ElemFreeAllocatedData +* ElemFreeAllocatedData * --------------------------------------------------------------------------------------------- */ -void OCI_ElemFreeAllocatedData +boolean ElemFreeAllocatedData ( OCI_Elem *elem ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + if (elem->alloc && elem->handle) { switch (elem->typinf->cols[0].datatype) { - case OCI_CDT_TEXT: - OCI_StringFreeStringPtr(elem->con->env, (OCIString **) &elem->handle, elem->con->err); - break; - default: - OCI_FREE(elem->handle) + case OCI_CDT_TEXT: + StringFreeStringPtr(elem->con->env, (OCIString**)&elem->handle, elem->con->err); + break; + default: + FREE(elem->handle) break; } } + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemInit + * ElementInitialize * --------------------------------------------------------------------------------------------- */ -OCI_Elem * OCI_ElemInit +OCI_Elem * ElementInitialize ( OCI_Connection *con, OCI_Elem *elem, @@ -143,226 +167,251 @@ OCI_Elem * OCI_ElemInit OCI_TypeInfo *typinf ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_ALLOCATE_DATA(OCI_IPC_ELEMENT, elem, 1); - - if (OCI_STATUS) - { - elem->con = con; - - // Free previously allocated data before reassign new one - OCI_ElemFreeAllocatedData(elem); - - // Reset members - elem->ind = OCI_IND_NULL; - elem->typinf = typinf; - elem->handle = handle; - elem->init = FALSE; - elem->alloc = FALSE; - elem->hstate = handle ? OCI_OBJECT_FETCHED_CLEAN : OCI_OBJECT_ALLOCATED; - - switch (elem->typinf->cols[0].datatype) + ENTER_FUNC + ( + /* returns */ OCI_Elem*, elem, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + + ALLOC_DATA(OCI_IPC_ELEMENT, elem, 1); + + elem->con = con; + + /* Free previously allocated data before reassign new one */ + ElemFreeAllocatedData(elem); + + /* Reset members */ + elem->ind = OCI_IND_NULL; + elem->typinf = typinf; + elem->handle = handle; + elem->init = FALSE; + elem->alloc = FALSE; + elem->hstate = handle ? OCI_OBJECT_FETCHED_CLEAN : OCI_OBJECT_ALLOCATED; + + switch (elem->typinf->cols[0].datatype) + { + case OCI_CDT_NUMERIC: { - case OCI_CDT_NUMERIC: + if (!elem->handle) { - if (!elem->handle) - { - OCI_ALLOCATE_BUFFER(OCI_IPC_VOID, elem->handle, elem->typinf->cols[0].size, 1) - elem->alloc = TRUE; - } - break; - } - case OCI_CDT_BOOLEAN: - { - if (!elem->handle) - { - OCI_ALLOCATE_BUFFER(OCI_IPC_VOID, elem->handle, sizeof(boolean), 1) - elem->alloc = TRUE; - } - break; - } - case OCI_CDT_TEXT: - case OCI_CDT_TIMESTAMP: - case OCI_CDT_INTERVAL: - case OCI_CDT_RAW: - case OCI_CDT_LOB: - case OCI_CDT_FILE: - case OCI_CDT_REF: - { - if (elem->handle) - { - elem->handle = * (void **) handle; - } - break; + ALLOC_BUFFER(OCI_IPC_VOID, elem->handle, elem->typinf->cols[0].size, 1) + elem->alloc = TRUE; } + break; } - - if (pind) + case OCI_CDT_BOOLEAN: { - elem->pind = pind; - elem->ind = *elem->pind; + if (!elem->handle) + { + ALLOC_BUFFER(OCI_IPC_VOID, elem->handle, sizeof(boolean), 1) + elem->alloc = TRUE; + } + break; } - else + case OCI_CDT_TEXT: + case OCI_CDT_TIMESTAMP: + case OCI_CDT_INTERVAL: + case OCI_CDT_RAW: + case OCI_CDT_LOB: + case OCI_CDT_FILE: + case OCI_CDT_REF: { - elem->pind = &elem->ind; + if (elem->handle) + { + elem->handle = * (void **) handle; + } + break; } } - /* check for failure */ - - if (!OCI_STATUS && elem) + if (NULL != pind) { - OCI_ElemFree(elem); - elem = NULL; + elem->pind = pind; + elem->ind = *elem->pind; } + else + { + elem->pind = &elem->ind; + } + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ElementFree(elem); + elem = NULL; + } - return elem; + SET_RETVAL(elem) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetNullIndicator + * ElementSetNullIndicator * --------------------------------------------------------------------------------------------- */ -boolean OCI_ElemSetNullIndicator +boolean ElementSetNullIndicator ( OCI_Elem *elem, OCIInd value ) { - boolean set = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (!elem->pind) - { - return FALSE; - } + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + CHECK_NULL(elem->pind) + + boolean done = FALSE; if (OCI_CDT_OBJECT == elem->typinf->cols[0].datatype) { - OCI_Object *obj = (OCI_Object*) elem->obj; + OCI_Object* obj = (OCI_Object*)elem->obj; if (obj) { elem->pind = obj->tab_ind; - set = TRUE; + done = TRUE; } else { value = OCI_IND_NULL; } - } - - if (!set) + + if (!done) { *elem->pind = value; } - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetNumberInternal + * ElementSetNumberInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_ElemSetNumberInternal +boolean ElementSetNumberInternal ( OCI_Elem *elem, void *value, uword flag ) { - OCI_Column *col = &elem->typinf->cols[0]; - const boolean res = OCI_TranslateNumericValue(elem->typinf->con, value, flag, - elem->handle, col->subtype); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (res) - { - OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL); - } + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + CHECK(NumberTranslateValue(elem->typinf->con, value, flag, elem->handle, + elem->typinf->cols[0].subtype)) - return res; + CHECK(ElementSetNullIndicator(elem, OCI_IND_NOTNULL)) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetNumberInternal + * ElemGetNumberInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_ElemGetNumberInternal +boolean ElemGetNumberInternal ( OCI_Elem *elem, void *value, uword flag ) { - boolean res = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) - OCI_CHECK(NULL == elem, FALSE) - OCI_CHECK(NULL == value, FALSE) + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_PTR(OCI_IPC_VOID, value) - if (OCI_ElemIsNull(elem)) - { - res = TRUE; - } - else if (OCI_CDT_NUMERIC == elem->typinf->cols[0].datatype) - { - OCI_Column *col = &elem->typinf->cols[0]; - res = OCI_TranslateNumericValue(elem->typinf->con, elem->handle, col->subtype, value, flag); - } - else if (OCI_CDT_TEXT == elem->typinf->cols[0].datatype) - { - res = OCI_NumberFromString(elem->con, value, flag, OCI_ElemGetString(elem), NULL); - } - else + if (!ElementIsNull(elem)) { - OCI_ExceptionTypeNotCompatible(elem->con); - res = FALSE; + if (OCI_CDT_NUMERIC == elem->typinf->cols[0].datatype) + { + CHECK(NumberTranslateValue(elem->typinf->con, elem->handle, + elem->typinf->cols[0].subtype, + value, flag)) + } + else if (OCI_CDT_TEXT == elem->typinf->cols[0].datatype) + { + CHECK(NumberFromStringInternal(elem->con, value, flag, + ElementGetString(elem), NULL)) + } + else + { + THROW_NO_ARGS(ExceptionTypeNotCompatible) + } } - return res; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_ElemCreate + * ElementCreate * --------------------------------------------------------------------------------------------- */ -OCI_Elem * OCI_API OCI_ElemCreate +OCI_Elem * ElementCreate ( OCI_TypeInfo *typinf ) { - OCI_CALL_ENTER(OCI_Elem*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + ENTER_FUNC + ( + /* returns */ OCI_Elem*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) + + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_RETVAL = OCI_ElemInit(typinf->con, NULL, NULL, (OCIInd *)NULL, typinf); - OCI_STATUS = (NULL != OCI_RETVAL); - - OCI_CALL_EXIT() + SET_RETVAL(ElementInitialize(typinf->con, NULL, NULL, (OCIInd*)NULL, typinf)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemFree + * ElementFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemFree +boolean ElementFree ( OCI_Elem *elem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_OBJECT_FETCHED(elem) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_OBJECT_FETCHED(elem) /* if the element has sub-objects that have been fetched, we need to free these objects */ - if (elem->obj) + if (NULL != elem->obj) { OCI_Datatype * data = (OCI_Datatype *) elem->obj; @@ -371,640 +420,687 @@ boolean OCI_API OCI_ElemFree data->hstate = OCI_OBJECT_FETCHED_DIRTY; } - OCI_FreeObjectFromType(elem->obj, elem->typinf->cols[0].datatype); + FreeObjectFromType(elem->obj, elem->typinf->cols[0].datatype); } - OCI_ElemFreeAllocatedData(elem); + ElemFreeAllocatedData(elem); - OCI_FREE(elem->tmpbuf) - OCI_FREE(elem) + FREE(elem->tmpbuf) + FREE(elem) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetBoolean + * ElementGetBoolean * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemGetBoolean +boolean ElementGetBoolean ( OCI_Elem *elem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_BOOLEAN == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (!OCI_ElemIsNull(elem)) - { - boolean *data = (boolean *)elem->handle; + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_BOOLEAN == elem->typinf->cols[0].datatype) - if (data) - { - OCI_RETVAL = *data; - } - } + CHECK(!ElementIsNull(elem)) - OCI_CALL_EXIT() + SET_RETVAL(elem->handle ? *((boolean*)elem->handle) : FALSE) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetNumber + * ElementGetNumber * --------------------------------------------------------------------------------------------- */ -OCI_Number * OCI_API OCI_ElemGetNumber +OCI_Number * ElementGetNumber ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_NUMERIC, OCI_Number *, - OCI_NumberInit(elem->con, (OCI_Number *) elem->obj, (OCINumber *) elem->handle) + NumberInitialize(elem->con, (OCI_Number *) elem->obj, (OCINumber *) elem->handle) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetShort + * ElementGetShort * --------------------------------------------------------------------------------------------- */ -short OCI_API OCI_ElemGetShort +short ElementGetShort ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_SHORT, short, 0) + ELEM_GET_NUMBER(elem, OCI_NUM_SHORT, short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetUnsignedShort + * ElementGetUnsignedShort * --------------------------------------------------------------------------------------------- */ -unsigned short OCI_API OCI_ElemGetUnsignedShort +unsigned short ElementGetUnsignedShort ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_USHORT, unsigned short, 0) + ELEM_GET_NUMBER(elem, OCI_NUM_USHORT, unsigned short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetInt + * ElemGetInt * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ElemGetInt +int ElemGetInt ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_INT, int, 0) + ELEM_GET_NUMBER(elem, OCI_NUM_INT, int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetUnsignedInt + * ElementGetUnsignedInt * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ElemGetUnsignedInt +unsigned int ElementGetUnsignedInt ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_UINT, unsigned int, 0) + ELEM_GET_NUMBER(elem, OCI_NUM_UINT, unsigned int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetBigInt + * ElementGetBigInt * --------------------------------------------------------------------------------------------- */ -big_int OCI_API OCI_ElemGetBigInt +big_int ElementGetBigInt ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_BIGINT, big_int, 0) + ELEM_GET_NUMBER(elem, OCI_NUM_BIGINT, big_int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetUnsignedBigInt + * ElementGetUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_ElemGetUnsignedBigInt +big_uint ElementGetUnsignedBigInt ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_BIGUINT, big_uint, 0) + ELEM_GET_NUMBER(elem, OCI_NUM_BIGUINT, big_uint, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetDouble + * ElementGetDouble * --------------------------------------------------------------------------------------------- */ -double OCI_API OCI_ElemGetDouble +double ElementGetDouble ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_DOUBLE, double, 0.0) + ELEM_GET_NUMBER(elem, OCI_NUM_DOUBLE, double, 0.0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetFloat + * ElemGetFloat * --------------------------------------------------------------------------------------------- */ -float OCI_API OCI_ElemGetFloat +float ElementGetFloat ( OCI_Elem *elem ) { - OCI_ELEM_GET_NUMBER(elem, OCI_NUM_FLOAT, float, 0.0f) + ELEM_GET_NUMBER(elem, OCI_NUM_FLOAT, float, 0.0f) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetString + * ElemGetString * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_ElemGetString +const otext * ElementGetString ( OCI_Elem *elem ) { - OCI_CALL_ENTER(otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_TEXT == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (elem->handle) - { - OCI_RETVAL = OCI_StringFromStringPtr(elem->con->env, (OCIString *) elem->handle, &elem->tmpbuf, &elem->tmpsize); - } + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_TEXT == elem->typinf->cols[0].datatype) + + CHECK_NULL(elem->handle) + + SET_RETVAL(StringFromStringPtr(elem->con->env, + (OCIString*)elem->handle, + &elem->tmpbuf, &elem->tmpsize)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetRaw + * ElemGetRaw * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ElemGetRaw +unsigned int ElementGetRaw ( OCI_Elem *elem, void *value, unsigned int len ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_RAW == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (elem->handle) - { - OCIRaw *raw = (OCIRaw *) elem->handle; - const ub4 raw_len = OCIRawSize(elem->con->env, raw); + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_RAW == elem->typinf->cols[0].datatype) - if (len > raw_len) - { - len = raw_len; - } + CHECK_NULL(elem->handle) - memcpy(value, OCIRawPtr(elem->con->env, raw), (size_t) len); - - OCI_RETVAL = raw_len; + OCIRaw *raw = (OCIRaw *) elem->handle; + const ub4 raw_len = OCIRawSize(elem->con->env, raw); + + if (len > raw_len) + { + len = raw_len; } - OCI_CALL_EXIT() + memcpy(value, OCIRawPtr(elem->con->env, raw), (size_t) len); + + SET_RETVAL(raw_len) + + EXIT_FUNC() } /* -------------------------------------------------------------------------------------------- * * OCI_ElemGetRawSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ElemGetRawSize +unsigned int ElementGetRawSize ( - OCI_Elem *elem + OCI_Elem *elem ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_RAW == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (elem->handle) - { - OCIRaw *raw = (OCIRaw *)elem->handle; - OCI_RETVAL = OCIRawSize(elem->con->env, raw); - } + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_RAW == elem->typinf->cols[0].datatype) + + CHECK_NULL(elem->handle) - OCI_CALL_EXIT() + SET_RETVAL(OCIRawSize(elem->con->env, (OCIRaw*)elem->handle)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetDate + * ElemGetDate * --------------------------------------------------------------------------------------------- */ -OCI_Date * OCI_API OCI_ElemGetDate +OCI_Date * ElementGetDate ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_DATETIME, OCI_Date *, - OCI_DateInit(elem->con, (OCI_Date *) elem->obj, (OCIDate *) elem->handle, FALSE, FALSE) + DateInitialize(elem->con, (OCI_Date *) elem->obj, (OCIDate *) elem->handle, FALSE, FALSE) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetTimestamp + * ElemGetTimestamp * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_API OCI_ElemGetTimestamp +OCI_Timestamp * ElementGetTimestamp ( OCI_Elem *elem ) { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_TIMESTAMP, OCI_Timestamp *, - OCI_TimestampInit(elem->con, (OCI_Timestamp *) elem->obj, (OCIDateTime *) elem->handle, elem->typinf->cols[0].subtype) + TimestampInitialize(elem->con, (OCI_Timestamp *) elem->obj, + (OCIDateTime *) elem->handle, + elem->typinf->cols[0].subtype) ) #else - OCI_CALL_ENTER( OCI_Timestamp *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ OCI_Timestamp *, NULL, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetInterval + * ElemGetInterval * --------------------------------------------------------------------------------------------- */ -OCI_Interval * OCI_API OCI_ElemGetInterval +OCI_Interval * ElementGetInterval ( OCI_Elem *elem ) { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_INTERVAL, OCI_Interval *, - OCI_IntervalInit(elem->con, (OCI_Interval *) elem->obj, (OCIInterval *) elem->handle, elem->typinf->cols[0].subtype) + IntervalInitialize(elem->con, (OCI_Interval *) elem->obj, + (OCIInterval *) elem->handle, + elem->typinf->cols[0].subtype) ) #else - OCI_CALL_ENTER( OCI_Interval *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ struct OCI_Interval *, NULL, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetLob + * ElemGetLob * --------------------------------------------------------------------------------------------- */ -OCI_Lob * OCI_API OCI_ElemGetLob +OCI_Lob * ElementGetLob ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( - OCI_CDT_LOB, + OCI_CDT_LOB, OCI_Lob*, - OCI_LobInit(elem->con, (OCI_Lob *) elem->obj, (OCILobLocator *) elem->handle, elem->typinf->cols[0].subtype) + LobInitialize(elem->con, (OCI_Lob *) elem->obj, + (OCILobLocator *) elem->handle, + elem->typinf->cols[0].subtype) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetFile + * ElemGetFile * --------------------------------------------------------------------------------------------- */ -OCI_File * OCI_API OCI_ElemGetFile +OCI_File * ElementGetFile ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_FILE, OCI_File*, - OCI_FileInit(elem->con, (OCI_File *) elem->obj, (OCILobLocator *) elem->handle, elem->typinf->cols[0].subtype) + FileInitialize(elem->con, (OCI_File *) elem->obj, + (OCILobLocator *) elem->handle, + elem->typinf->cols[0].subtype) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetRef + * ElementGetReference * --------------------------------------------------------------------------------------------- */ -OCI_Ref * OCI_API OCI_ElemGetRef +OCI_Ref * ElementGetReference ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_REF, OCI_Ref*, - OCI_RefInit(elem->con, elem->typinf->cols[0].typinf, (OCI_Ref *) elem->obj, (OCIRef *) elem->handle) + ReferenceInitialize(elem->con, elem->typinf->cols[0].typinf, + (OCI_Ref *) elem->obj, (OCIRef *) elem->handle) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetObject + * ElemGetObject * --------------------------------------------------------------------------------------------- */ -OCI_Object * OCI_API OCI_ElemGetObject +OCI_Object * ElementGetObject ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_OBJECT, OCI_Object*, - OCI_ObjectInit(elem->con, (OCI_Object *) elem->obj, elem->handle, elem->typinf->cols[0].typinf, NULL, -1, TRUE) + ObjectInitialize(elem->con, (OCI_Object *) elem->obj, elem->handle, + elem->typinf->cols[0].typinf, NULL, -1, TRUE) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemGetColl + * ElemGetColl * --------------------------------------------------------------------------------------------- */ -OCI_Coll * OCI_API OCI_ElemGetColl +OCI_Coll * ElementGetCollection ( OCI_Elem *elem ) { - OCI_ELEM_GET_VALUE + ELEM_GET_VALUE ( OCI_CDT_COLLECTION, OCI_Coll*, - OCI_CollInit(elem->con, (OCI_Coll *) elem->obj, (OCIColl *) elem->handle, elem->typinf->cols[0].typinf) + CollectionInitialize(elem->con, (OCI_Coll *) elem->obj, + (OCIColl *) elem->handle, + elem->typinf->cols[0].typinf) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetBoolean + * ElemSetBoolean * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetBoolean +boolean ElementSetBoolean ( OCI_Elem *elem, boolean value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_BOOLEAN == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_BOOLEAN == elem->typinf->cols[0].datatype) - if (elem->handle) + if (NULL != elem->handle) { boolean *data = (boolean *) elem->handle; - + *data = value; - - OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL); + + CHECK(ElementSetNullIndicator(elem, OCI_IND_NOTNULL)) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetNumber + * ElementSetNumber * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetNumber +boolean ElementSetNumber ( OCI_Elem *elem, OCI_Number *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_NUMERIC, OCI_Number*, - OCI_NumberInit(elem->con, (OCI_Number *) elem->obj, (OCINumber *) elem->handle), - OCI_NumberAssign((OCI_Number *) elem->obj, value) + NumberInitialize(elem->con, (OCI_Number *) elem->obj, (OCINumber *) elem->handle), + NumberAssign((OCI_Number *) elem->obj, value) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetShort + * ElemSetShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetShort +boolean ElementSetShort ( OCI_Elem *elem, short value ) { - OCI_ELEM_SET_NUMBER(elem,value, OCI_NUM_SHORT) + ELEM_SET_NUMBER(elem,value, OCI_NUM_SHORT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetUnsignedShort + * ElemSetUnsignedShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetUnsignedShort +boolean ElementSetUnsignedShort ( OCI_Elem *elem, unsigned short value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_USHORT) + ELEM_SET_NUMBER(elem, value, OCI_NUM_USHORT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetInt + * ElemSetInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetInt +boolean ElementSetInt ( OCI_Elem *elem, int value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_INT) + ELEM_SET_NUMBER(elem, value, OCI_NUM_INT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetUnsignedInt + * ElemSetUnsignedInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetUnsignedInt +boolean ElementSetUnsignedInt ( OCI_Elem *elem, unsigned int value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_UINT) + ELEM_SET_NUMBER(elem, value, OCI_NUM_UINT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetBigInt + * ElemSetBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetBigInt +boolean ElementSetBigInt ( OCI_Elem *elem, big_int value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_BIGINT) + ELEM_SET_NUMBER(elem, value, OCI_NUM_BIGINT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetUnsignedBigInt + * ElemSetUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetUnsignedBigInt +boolean ElementSetUnsignedBigInt ( OCI_Elem *elem, big_uint value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_BIGUINT) + ELEM_SET_NUMBER(elem, value, OCI_NUM_BIGUINT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetDouble + * ElemSetDouble * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetDouble +boolean ElementSetDouble ( OCI_Elem *elem, double value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_DOUBLE) + ELEM_SET_NUMBER(elem, value, OCI_NUM_DOUBLE) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetFloat + * ElemSetFloat * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetFloat +boolean ElementSetFloat ( OCI_Elem *elem, float value ) { - OCI_ELEM_SET_NUMBER(elem, value, OCI_NUM_FLOAT) + ELEM_SET_NUMBER(elem, value, OCI_NUM_FLOAT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetString + * ElemSetString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetString +boolean ElementSetString ( OCI_Elem *elem, const otext *value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_TEXT == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_TEXT == elem->typinf->cols[0].datatype) - if (!value) + if (NULL == value) { - OCI_STATUS = OCI_ElemSetNull(elem); + CHECK(ElementSetNull(elem)) } else { elem->alloc = (elem->alloc || elem->handle == NULL); - OCI_STATUS = OCI_StringToStringPtr(elem->con->env, (OCIString **) &elem->handle, elem->con->err, value); + CHECK(StringToStringPtr(elem->con->env, + (OCIString **) &elem->handle, + elem->con->err, value)) - if (OCI_STATUS) - { - OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL); - } + CHECK(ElementSetNullIndicator(elem, OCI_IND_NOTNULL)) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetRaw + * ElemSetRaw * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetRaw +boolean ElementSetRaw ( OCI_Elem *elem, void * value, unsigned int len ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CHECK_COMPAT(elem->con, OCI_CDT_TEXT == elem->typinf->cols[0].datatype) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + CHECK_COMPAT(OCI_CDT_TEXT == elem->typinf->cols[0].datatype) - if (!value) + if (NULL == value) { - OCI_STATUS = OCI_ElemSetNull(elem); + CHECK(ElementSetNull(elem)) } else { - OCI_EXEC(OCIRawAssignBytes(elem->con->env, elem->con->err, (ub1*) value, len, (OCIRaw **) &elem->handle)) - - if (OCI_STATUS) - { - OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL); - } + CHECK_OCI + ( + elem->con->err, + OCIRawAssignBytes, + elem->con->env, elem->con->err, + (ub1*) value, len, (OCIRaw **) &elem->handle + ) + + CHECK(ElementSetNullIndicator(elem, OCI_IND_NOTNULL)) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetDate + * ElemSetDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetDate +boolean ElementSetDate ( OCI_Elem *elem, OCI_Date *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_DATETIME, OCI_Date*, - OCI_DateInit(elem->con, (OCI_Date *) elem->obj, (OCIDate *) elem->handle, TRUE, FALSE), - OCI_DateAssign((OCI_Date *) elem->obj, value) + DateInitialize(elem->con, (OCI_Date *) elem->obj, + (OCIDate *) elem->handle, TRUE, FALSE), + DateAssign((OCI_Date *) elem->obj, value) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetTimestamp + * ElemSetTimestamp * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetTimestamp +boolean ElementSetTimestamp ( OCI_Elem *elem, OCI_Timestamp *value @@ -1012,28 +1108,36 @@ boolean OCI_API OCI_ElemSetTimestamp { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( - OCI_CDT_TIMESTAMP, + OCI_CDT_TIMESTAMP, OCI_Timestamp*, - OCI_TimestampInit(elem->con, (OCI_Timestamp *) elem->obj, (OCIDateTime *) elem->handle, elem->typinf->cols[0].subtype), - OCI_TimestampAssign((OCI_Timestamp *) elem->obj, value) + TimestampInitialize(elem->con, (OCI_Timestamp *) elem->obj, + (OCIDateTime *) elem->handle, + elem->typinf->cols[0].subtype), + TimestampAssign((OCI_Timestamp *) elem->obj, value) ) #else - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetInterval + * ElemSetInterval * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetInterval +boolean ElementSetInterval ( OCI_Elem *elem, OCI_Interval *value @@ -1042,153 +1146,165 @@ boolean OCI_API OCI_ElemSetInterval #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_ELEM_SET_VALUE - ( + ELEM_SET_VALUE + ( OCI_CDT_INTERVAL, OCI_Interval*, - OCI_IntervalInit(elem->con, (OCI_Interval *) elem->obj, (OCIInterval *) elem->handle, elem->typinf->cols[0].subtype), - OCI_IntervalAssign((OCI_Interval *) elem->obj, value) + IntervalInitialize(elem->con, (OCI_Interval *) elem->obj, + (OCIInterval *) elem->handle, + elem->typinf->cols[0].subtype), + IntervalAssign((OCI_Interval *) elem->obj, value) ) #else - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) + + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetColl + * ElemSetColl * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetColl +boolean ElementSetCollection ( OCI_Elem *elem, OCI_Coll *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_COLLECTION, OCI_Coll*, - OCI_CollInit(elem->con, (OCI_Coll *) elem->obj, (OCIColl *) elem->handle, elem->typinf->cols[0].typinf), - OCI_CollAssign((OCI_Coll *) elem->obj, value) + CollectionInitialize(elem->con, (OCI_Coll *) elem->obj, (OCIColl *) elem->handle, + elem->typinf->cols[0].typinf), + CollectionAssign((OCI_Coll *) elem->obj, value) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetObject + * ElemSetObject * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetObject +boolean ElementSetObject ( OCI_Elem *elem, OCI_Object *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_OBJECT, OCI_Object*, - OCI_ObjectInit(elem->con, (OCI_Object *) elem->obj, elem->handle, elem->typinf->cols[0].typinf, NULL, -1, TRUE), - OCI_ObjectAssign((OCI_Object *) elem->obj, value) + ObjectInitialize(elem->con, (OCI_Object *) elem->obj, elem->handle, + elem->typinf->cols[0].typinf, NULL, -1, TRUE), + ObjectAssign((OCI_Object *) elem->obj, value) ) - } +} /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetLob + * ElemSetLob * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetLob +boolean ElementSetLob ( OCI_Elem *elem, OCI_Lob *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_LOB, OCI_Lob*, - OCI_LobInit(elem->con, (OCI_Lob *) elem->obj, (OCILobLocator *) elem->handle, elem->typinf->cols[0].subtype), - OCI_LobAssign((OCI_Lob *) elem->obj, value) + LobInitialize(elem->con, (OCI_Lob *) elem->obj, + (OCILobLocator *) elem->handle, + elem->typinf->cols[0].subtype), + LobAssign((OCI_Lob *) elem->obj, value) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetFile + * ElemSetFile * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetFile +boolean ElementSetFile ( OCI_Elem *elem, OCI_File *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_FILE, OCI_File*, - OCI_FileInit(elem->con, (OCI_File *) elem->obj, (OCILobLocator *) elem->handle, elem->typinf->cols[0].subtype), - OCI_FileAssign((OCI_File *) elem->obj, value) + FileInitialize(elem->con, (OCI_File *) elem->obj, + (OCILobLocator *) elem->handle, + elem->typinf->cols[0].subtype), + FileAssign((OCI_File *) elem->obj, value) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetRef + * ElementSetReference * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetRef +boolean ElementSetReference ( OCI_Elem *elem, OCI_Ref *value ) { - OCI_ELEM_SET_VALUE + ELEM_SET_VALUE ( OCI_CDT_REF, OCI_Ref*, - OCI_RefInit(elem->con, elem->typinf->cols[0].typinf, (OCI_Ref *) elem->obj, (OCIRef *) elem->handle), - OCI_RefAssign((OCI_Ref *) elem->obj, value) + ReferenceInitialize(elem->con, elem->typinf->cols[0].typinf, + (OCI_Ref *) elem->obj, (OCIRef *) elem->handle), + ReferenceAssign((OCI_Ref *) elem->obj, value) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemIsNull + * ElemIsNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemIsNull +boolean ElementIsNull ( OCI_Elem *elem ) { - OCI_CALL_ENTER(boolean, TRUE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ELEMENT, elem + ) - if (elem->pind) - { - OCI_RETVAL = (OCI_IND_NULL == *elem->pind); - } + CHECK_PTR(OCI_IPC_ELEMENT, elem) + + CHECK_NULL(elem->pind) + + SET_RETVAL(OCI_IND_NULL == *elem->pind) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ElemSetNull + * ElementSetNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ElemSetNull +boolean ElementSetNull ( OCI_Elem *elem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ELEMENT, elem) - OCI_CALL_CONTEXT_SET_FROM_CONN(elem->con) - - OCI_RETVAL = OCI_STATUS = OCI_ElemSetNullIndicator(elem, OCI_IND_NULL); - - OCI_CALL_EXIT() + return ElementSetNullIndicator(elem, OCI_IND_NULL); } diff --git a/src/element.h b/src/element.h new file mode 100644 index 00000000..ea4f0305 --- /dev/null +++ b/src/element.h @@ -0,0 +1,288 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_ELEMENT_H_INCLUDED +#define OCILIB_ELEMENT_H_INCLUDED + +#include "types.h" + +OCI_Elem* ElementInitialize +( + OCI_Connection* con, + OCI_Elem * elem, + void * handle, + OCIInd * pind, + OCI_TypeInfo * typinf +); + +boolean ElementSetNullIndicator +( + OCI_Elem* elem, + OCIInd value +); + +OCI_Elem* ElementCreate +( + OCI_TypeInfo* typinf +); + +boolean ElementFree +( + OCI_Elem* elem +); + +boolean ElementGetBoolean +( + OCI_Elem* elem +); + +OCI_Number* ElementGetNumber +( + OCI_Elem* elem +); + +short ElementGetShort +( + OCI_Elem* elem +); + +unsigned short ElementGetUnsignedShort +( + OCI_Elem* elem +); + +int ElemGetInt +( + OCI_Elem* elem +); + +unsigned int ElementGetUnsignedInt +( + OCI_Elem* elem +); + +big_int ElementGetBigInt +( + OCI_Elem* elem +); + +big_uint ElementGetUnsignedBigInt +( + OCI_Elem* elem +); + +double ElementGetDouble +( + OCI_Elem* elem +); + +float ElementGetFloat +( + OCI_Elem* elem +); + +const otext* ElementGetString +( + OCI_Elem* elem +); + +unsigned int ElementGetRaw +( + OCI_Elem * elem, + void * value, + unsigned int len +); + +unsigned int ElementGetRawSize +( + OCI_Elem* elem +); + +OCI_Date* ElementGetDate +( + OCI_Elem* elem +); + +OCI_Timestamp* ElementGetTimestamp +( + OCI_Elem* elem +); + +OCI_Interval* ElementGetInterval +( + OCI_Elem* elem +); + +OCI_Lob* ElementGetLob +( + OCI_Elem* elem +); + +OCI_File* ElementGetFile +( + OCI_Elem* elem +); + +OCI_Ref* ElementGetReference +( + OCI_Elem* elem +); + +OCI_Object* ElementGetObject +( + OCI_Elem* elem +); + +OCI_Coll* ElementGetCollection +( + OCI_Elem* elem +); + +boolean ElementSetBoolean +( + OCI_Elem* elem, + boolean value +); + +boolean ElementSetNumber +( + OCI_Elem * elem, + OCI_Number* value +); + +boolean ElementSetShort +( + OCI_Elem* elem, + short value +); + +boolean ElementSetUnsignedShort +( + OCI_Elem * elem, + unsigned short value +); + +boolean ElementSetInt +( + OCI_Elem* elem, + int value +); + +boolean ElementSetUnsignedInt +( + OCI_Elem * elem, + unsigned int value +); + +boolean ElementSetBigInt +( + OCI_Elem* elem, + big_int value +); + +boolean ElementSetUnsignedBigInt +( + OCI_Elem* elem, + big_uint value +); + +boolean ElementSetDouble +( + OCI_Elem* elem, + double value +); + +boolean ElementSetFloat +( + OCI_Elem* elem, + float value +); + +boolean ElementSetString +( + OCI_Elem * elem, + const otext* value +); + +boolean ElementSetRaw +( + OCI_Elem * elem, + void * value, + unsigned int len +); + +boolean ElementSetDate +( + OCI_Elem* elem, + OCI_Date* value +); + +boolean ElementSetTimestamp +( + OCI_Elem * elem, + OCI_Timestamp* value +); + +boolean ElementSetInterval +( + OCI_Elem * elem, + OCI_Interval* value +); + +boolean ElementSetCollection +( + OCI_Elem* elem, + OCI_Coll* value +); + +boolean ElementSetObject +( + OCI_Elem * elem, + OCI_Object* value +); + +boolean ElementSetLob +( + OCI_Elem* elem, + OCI_Lob * value +); + +boolean ElementSetFile +( + OCI_Elem* elem, + OCI_File* value +); + +boolean ElementSetReference +( + OCI_Elem* elem, + OCI_Ref * value +); +boolean ElementIsNull +( + OCI_Elem* elem +); + +boolean ElementSetNull +( + OCI_Elem* elem +); + +#endif /* OCILIB_ELEMENT_H_INCLUDED */ diff --git a/src/enqueue.c b/src/enqueue.c index c7c042ff..bbd5694d 100644 --- a/src/enqueue.c +++ b/src/enqueue.c @@ -18,111 +18,125 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "enqueue.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "macros.h" +#include "memory.h" +#include "strings.h" -static const unsigned int VisibilityModeValues[] = { OCI_AMV_IMMEDIATE, OCI_AMV_ON_COMMIT }; -static const unsigned int EnqueueModeValues[] = { OCI_ASD_BEFORE, OCI_ASD_TOP }; +static const unsigned int VisibilityModeValues[] = +{ + OCI_AMV_IMMEDIATE, + OCI_AMV_ON_COMMIT +}; -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int EnqueueModeValues[] = +{ + OCI_ASD_BEFORE, + OCI_ASD_TOP +}; /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueCreate + * EnqueueCreate * --------------------------------------------------------------------------------------------- */ -OCI_Enqueue * OCI_API OCI_EnqueueCreate +OCI_Enqueue * EnqueueCreate ( OCI_TypeInfo *typinf, const otext *name ) { - OCI_Enqueue *enqueue = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Enqueue*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) - OCI_CALL_ENTER(OCI_Enqueue*, enqueue) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) + OCI_Enqueue* enqueue = NULL; - /* allocate enqueue structure */ + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + CHECK_PTR(OCI_IPC_STRING, name) - OCI_ALLOCATE_DATA(OCI_IPC_ENQUEUE, enqueue, 1) + /* allocate enqueue structure */ - if (OCI_STATUS) - { - enqueue->typinf = typinf; - enqueue->name = ostrdup(name); + ALLOC_DATA(OCI_IPC_ENQUEUE, enqueue, 1) - /* allocate enqueue options descriptor */ + enqueue->typinf = typinf; + enqueue->name = ostrdup(name); - OCI_STATUS = OCI_DescriptorAlloc((dvoid * ) enqueue->typinf->con->env, (dvoid **) &enqueue->opth, OCI_DTYPE_AQENQ_OPTIONS); - } + /* allocate enqueue options descriptor */ - /* check for failure */ + CHECK(MemoryAllocDescriptor((dvoid * )enqueue->typinf->con->env, + (dvoid **) &enqueue->opth, + OCI_DTYPE_AQENQ_OPTIONS)) - if (OCI_STATUS) - { - OCI_RETVAL = enqueue; - } - else if (enqueue) - { - OCI_EnqueueFree(enqueue); - } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + EnqueueFree(enqueue); + enqueue = NULL; + } - OCI_CALL_EXIT() + SET_RETVAL(enqueue) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueFree + * EnqueueFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnqueueFree +boolean EnqueueFree ( OCI_Enqueue *enqueue ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) /* free OCI descriptor */ - OCI_DescriptorFree((dvoid *) enqueue->opth, OCI_DTYPE_AQENQ_OPTIONS); + MemoryFreeDescriptor((dvoid *) enqueue->opth, OCI_DTYPE_AQENQ_OPTIONS); - OCI_FREE(enqueue->name) - OCI_FREE(enqueue) + FREE(enqueue->name) + FREE(enqueue) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueuePut + * EnqueuePut * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnqueuePut +boolean EnqueuePut ( OCI_Enqueue *enqueue, OCI_Msg *msg ) { - dbtext *dbstr = NULL; - int dbsize = -1; - void *payload = NULL; - void *ind = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CHECK_COMPAT(enqueue->typinf->con, enqueue->typinf->tdo == msg->typinf->tdo) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + dbtext *dbstr = NULL; + int dbsize = -1; + void *payload = NULL; + void *ind = NULL; - dbstr = OCI_StringGetOracleString(enqueue->name, &dbsize); + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) + CHECK_PTR(OCI_IPC_MSG, msg) + CHECK_COMPAT(enqueue->typinf->tdo == msg->typinf->tdo) + + dbstr = StringGetDBString(enqueue->name, &dbsize); /* get payload */ @@ -142,134 +156,180 @@ boolean OCI_API OCI_EnqueuePut /* enqueue message */ - OCI_EXEC + CHECK_OCI ( - OCIAQEnq(enqueue->typinf->con->cxt, enqueue->typinf->con->err, - (OraText *) dbstr, enqueue->opth, msg->proph, enqueue->typinf->tdo, - &payload, &ind, NULL, OCI_DEFAULT); + enqueue->typinf->con->err, + OCIAQEnq, + enqueue->typinf->con->cxt, enqueue->typinf->con->err, + (OraText *) dbstr, enqueue->opth, msg->proph, + enqueue->typinf->tdo, &payload, &ind, NULL, OCI_DEFAULT ) - OCI_StringReleaseOracleString(dbstr); - - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueGetVisibility + * EnqueueGetVisibility * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_EnqueueGetVisibility +unsigned int EnqueueGetVisibility ( OCI_Enqueue *enqueue ) { + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + ub4 ret = OCI_UNKNOWN; - OCI_CALL_ENTER(unsigned int, ret) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_VISIBILITY, + enqueue->opth, &ret, NULL, + enqueue->typinf->con->err + ) - OCI_GET_ATTRIB(OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_VISIBILITY, enqueue->opth, &ret, NULL) - - OCI_RETVAL = ret; - - OCI_CALL_EXIT() + SET_RETVAL(ret) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueSetVisibility + * EnqueueSetVisibility * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnqueueSetVisibility +boolean EnqueueSetVisibility ( OCI_Enqueue *enqueue, unsigned int visibility ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + ub4 value = (ub4) visibility; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, visibility, VisibilityModeValues, OTEXT("Visibility Mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) + CHECK_ENUM_VALUE(visibility, VisibilityModeValues, OTEXT("Visibility Mode")) - OCI_SET_ATTRIB(OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_VISIBILITY, enqueue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_VISIBILITY, + enqueue->opth, &value, 0, + enqueue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueGetSequenceDeviation + * EnqueueGetSequenceDeviation * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_EnqueueGetSequenceDeviation +unsigned int EnqueueGetSequenceDeviation ( OCI_Enqueue *enqueue ) { + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + ub4 ret = OCI_UNKNOWN; - OCI_CALL_ENTER(unsigned int, ret) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_GET_ATTRIB(OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_SEQUENCE_DEVIATION, enqueue->opth, &ret, NULL) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_SEQUENCE_DEVIATION, + enqueue->opth, &ret, NULL, enqueue->typinf->con->err + ) - OCI_RETVAL = (unsigned int) ret; + SET_RETVAL((unsigned int) ret) - OCI_CALL_EXIT(); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueSetDeviation + * EnqueueSetDeviation * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnqueueSetSequenceDeviation +boolean EnqueueSetSequenceDeviation ( OCI_Enqueue *enqueue, unsigned int sequence ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + ub4 value = (ub4) sequence; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, sequence, EnqueueModeValues, OTEXT("Sequence Deviation")) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) + CHECK_ENUM_VALUE(sequence, EnqueueModeValues, OTEXT("Sequence Deviation")) - OCI_SET_ATTRIB(OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_SEQUENCE_DEVIATION, enqueue->opth, &value, 0) + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_SEQUENCE_DEVIATION, + enqueue->opth, &value, 0, enqueue->typinf->con->err + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueSetRelativeMsgID + * EnqueueSetRelativeMsgID * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnqueueGetRelativeMsgID +boolean EnqueueGetRelativeMsgID ( OCI_Enqueue *enqueue, void *id, unsigned int *len ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + OCIRaw *value = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, id); - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, len); - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) + CHECK_PTR(OCI_IPC_VOID, id); + CHECK_PTR(OCI_IPC_VOID, len); + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_RELATIVE_MSGID, + enqueue->opth, &value, NULL, + enqueue->typinf->con->err + ) - OCI_GET_ATTRIB(OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_RELATIVE_MSGID, enqueue->opth, &value, NULL) - - if (OCI_STATUS && value) + if (NULL != value) { const ub4 raw_len = OCIRawSize(enqueue->typinf->con->env, value); @@ -285,32 +345,48 @@ boolean OCI_API OCI_EnqueueGetRelativeMsgID *len = 0; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_EnqueueSetRelativeMsgID + * EnqueueSetRelativeMsgID * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnqueueSetRelativeMsgID +boolean EnqueueSetRelativeMsgID ( - OCI_Enqueue *enqueue, - const void *id, - unsigned int len + OCI_Enqueue *enqueue, + const void *id, + unsigned int len ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ENQUEUE, enqueue + ) + OCIRaw *value = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) - OCI_CALL_CONTEXT_SET_FROM_CONN(enqueue->typinf->con) + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) + + CHECK_OCI + ( + enqueue->typinf->con->err, + OCIRawAssignBytes, + enqueue->typinf->con->env, enqueue->typinf->con->err, + (ub1*) id, (ub4) len, (OCIRaw **) &value + ) + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_RELATIVE_MSGID, + enqueue->opth, &value, 0, + enqueue->typinf->con->err + ) - OCI_EXEC(OCIRawAssignBytes(enqueue->typinf->con->env, enqueue->typinf->con->err, (ub1*) id, (ub4) len, (OCIRaw **) &value)) - OCI_SET_ATTRIB(OCI_DTYPE_AQENQ_OPTIONS, OCI_ATTR_RELATIVE_MSGID, enqueue->opth, &value, 0) - - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/enqueue.h b/src/enqueue.h new file mode 100644 index 00000000..70d05fb4 --- /dev/null +++ b/src/enqueue.h @@ -0,0 +1,79 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_ENQUEUE_H_INCLUDED +#define OCILIB_ENQUEUE_H_INCLUDED + +#include "types.h" + +OCI_Enqueue * EnqueueCreate +( + OCI_TypeInfo *typinf, + const otext *name +); + +boolean EnqueueFree +( + OCI_Enqueue *enqueue +); + +boolean EnqueuePut +( + OCI_Enqueue *enqueue, + OCI_Msg *msg +); + +unsigned int EnqueueGetVisibility +( + OCI_Enqueue *enqueue +); + +boolean EnqueueSetVisibility +( + OCI_Enqueue *enqueue, + unsigned int visibility +); + +unsigned int EnqueueGetSequenceDeviation +( + OCI_Enqueue *enqueue +); + +boolean EnqueueSetSequenceDeviation +( + OCI_Enqueue *enqueue, + unsigned int sequence +); + +boolean EnqueueGetRelativeMsgID +( + OCI_Enqueue *enqueue, + void *id, + unsigned int *len +); + +boolean EnqueueSetRelativeMsgID +( + OCI_Enqueue *enqueue, + const void *id, + unsigned int len +); + +#endif /* OCILIB_ENQUEUE_H_INCLUDED */ diff --git a/src/library.c b/src/environment.c similarity index 56% rename from src/library.c rename to src/environment.c index b50074d3..0654e4e3 100644 --- a/src/library.c +++ b/src/environment.c @@ -18,20 +18,27 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * INTERNAL VARIABLES - * ********************************************************************************************* */ - -OCI_Library OCILib; +#include "environment.h" + +#include "array.h" +#include "callback.h" +#include "connection.h" +#include "error.h" +#include "hash.h" +#include "list.h" +#include "macros.h" +#include "mutex.h" +#include "pool.h" +#include "subscription.h" +#include "threadkey.h" + +OCI_Environment Env; const char * EnvironmentVarNames[OCI_VARS_COUNT] = { VAR_OCILIB_WORKAROUND_UTF16_COLUMN_NAME }; - const OCI_SQLCmdInfo SQLCmds[OCI_SQLCMD_COUNT] = { {OCI_UNKNOWN , OTEXT("UNKNOWN") }, @@ -505,249 +512,66 @@ OCISUBSCRIPTIONUNREGISTER OCISubscriptionUnRegister = NULL; OCIAQENQ OCIAQEnq = NULL; OCIAQDEQ OCIAQDeq = NULL; OCIAQLISTEN OCIAQListen = NULL; -XAOSVCCTX xaoSvcCtx = NULL; -XAOENV xaoEnv = NULL; OCILOBGETCONTENTTYPE OCILobGetContentType = NULL; OCISTMTGETNEXTRESULT OCIStmtGetNextResult = NULL; OCISERVERRELEASE2 OCIServerRelease2 = NULL; OCISODAOPERKEYSSET OCISodaOperKeysSet = NULL; -#ifdef ORAXB8_DEFINED +XAOSVCCTX xaoSvcCtx = NULL; +XAOENV xaoEnv = NULL; -OCILOBCOPY2 OCILobCopy2 = NULL; -OCILOBERASE2 OCILobErase2 = NULL; -OCILOBGETLENGTH2 OCILobGetLength2 = NULL; -OCILOBLOADFROMFILE2 OCILobLoadFromFile2 = NULL; -OCILOBREAD2 OCILobRead2 = NULL; -OCILOBTRIM2 OCILobTrim2 = NULL; -OCILOBWRITE2 OCILobWrite2 = NULL; -OCILOBWRITEAPPEND2 OCILobWriteAppend2 = NULL; + #ifdef ORAXB8_DEFINED -#endif /* ORAXB8_DEFINED */ +OCILOBCOPY2 OCILobCopy2 = NULL; +OCILOBERASE2 OCILobErase2 = NULL; +OCILOBGETLENGTH2 OCILobGetLength2 = NULL; +OCILOBLOADFROMFILE2 OCILobLoadFromFile2 = NULL; +OCILOBREAD2 OCILobRead2 = NULL; +OCILOBTRIM2 OCILobTrim2 = NULL; +OCILOBWRITE2 OCILobWrite2 = NULL; +OCILOBWRITEAPPEND2 OCILobWriteAppend2 = NULL; -#endif /* OCI_IMPORT_RUNTIME */ + #endif /* ORAXB8_DEFINED */ -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#endif /* OCI_IMPORT_RUNTIME */ /* --------------------------------------------------------------------------------------------- * - * OCI_ExternalSubTypeToSQLType + * EnvironmentFreeErrors * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_ExternalSubTypeToSQLType -( - unsigned int type, - unsigned int subtype -) +void EnvironmentFreeError(OCI_Error *err) { - unsigned int res = OCI_UNKNOWN; - - switch (type) + if (err != Env.lib_err) { - case OCI_CDT_TIMESTAMP: - { - switch (subtype) - { - case OCI_TIMESTAMP: - res = SQLT_TIMESTAMP; - break; - case OCI_TIMESTAMP_TZ: - res = SQLT_TIMESTAMP_TZ; - break; - case OCI_TIMESTAMP_LTZ: - res = SQLT_TIMESTAMP_LTZ; - break; - } - break; - } - case OCI_CDT_INTERVAL: - { - switch (subtype) - { - case OCI_INTERVAL_YM: - res = SQLT_INTERVAL_YM; - break; - case OCI_INTERVAL_DS: - res = SQLT_INTERVAL_DS; - break; - } - break; - } - case OCI_CDT_LOB: - { - switch (subtype) - { - case OCI_CLOB: - case OCI_NCLOB: - res = SQLT_CLOB; - break; - case OCI_BLOB: - res = SQLT_BLOB; - break; - } - break; - } - case OCI_CDT_FILE: - { - switch (subtype) - { - case OCI_CFILE: - res = SQLT_CFILE; - break; - case OCI_BFILE: - res = SQLT_BFILE; - break; - } - break; - } - case OCI_CDT_LONG: - { - switch (subtype) - { - case OCI_CLONG: - res = SQLT_LNG; - break; - case OCI_BLONG: - res = SQLT_LBI; - break; - } - break; - } + ErrorFree(err); } - - return res; } /* --------------------------------------------------------------------------------------------- * - * OCI_ExternalSubTypeToHandleType + * KeyMapFree * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_ExternalSubTypeToHandleType +void KeyMapFree ( - unsigned int type, - unsigned int subtype ) { - unsigned int res = OCI_UNKNOWN; - - switch (type) - { - case OCI_CDT_TIMESTAMP: - { - switch (subtype) - { - case OCI_TIMESTAMP: - res = OCI_DTYPE_TIMESTAMP; - break; - case OCI_TIMESTAMP_TZ: - res = OCI_DTYPE_TIMESTAMP_TZ; - break; - case OCI_TIMESTAMP_LTZ: - res = OCI_DTYPE_TIMESTAMP_LTZ; - break; - } - break; - } - case OCI_CDT_INTERVAL: - { - switch (subtype) - { - case OCI_INTERVAL_YM: - res = OCI_DTYPE_INTERVAL_YM; - break; - case OCI_INTERVAL_DS: - res = OCI_DTYPE_INTERVAL_DS; - break; - } - break; - } - } + OCI_HashEntry *e = NULL; + OCI_HashValue *v = NULL; - return res; -} + int nb_err = 0; -/* --------------------------------------------------------------------------------------------- * - * OCI_FreeObjectFromType - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_FreeObjectFromType(void *obj, unsigned int type) -{ - boolean res = FALSE; + unsigned int count = 0; - switch (type) + if (NULL == Env.key_map) { - case OCI_CDT_NUMERIC: - { - res = OCI_NumberFree((OCI_Number *)obj); - break; - } - case OCI_CDT_DATETIME: - { - res = OCI_DateFree((OCI_Date *)obj); - break; - } - case OCI_CDT_LOB: - { - res = OCI_LobFree((OCI_Lob *)obj); - break; - } - case OCI_CDT_FILE: - { - res = OCI_FileFree((OCI_File *)obj); - break; - } - case OCI_CDT_OBJECT: - { - res = OCI_ObjectFree((OCI_Object *)obj); - break; - } - case OCI_CDT_COLLECTION: - { - res = OCI_CollFree((OCI_Coll *)obj); - break; - } - case OCI_CDT_TIMESTAMP: - { - res = OCI_TimestampFree((OCI_Timestamp *)obj); - break; - } - case OCI_CDT_INTERVAL: - { - res = OCI_IntervalFree((OCI_Interval *)obj); - break; - } - case OCI_CDT_REF: - { - res= OCI_RefFree((OCI_Ref *)obj); - break; - } + return; } - return res; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_KeyMapFree - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_KeyMapFree -( - void -) -{ - boolean res = TRUE; - OCI_HashEntry *e = NULL; - OCI_HashValue *v = NULL; - int nb_err = 0; - - OCI_CHECK(NULL == OCILib.key_map, TRUE) - - const unsigned int n = OCI_HashGetSize(OCILib.key_map); + count = HashGetSize(Env.key_map); - for (unsigned int i = 0; i < n; i++) + for (unsigned int i = 0; i < count; i++) { - e = OCI_HashGetEntry(OCILib.key_map, i); + e = HashGetEntry(Env.key_map, i); while (e) { @@ -755,7 +579,7 @@ boolean OCI_KeyMapFree while (v) { - if (!OCI_ThreadKeyFree((OCI_ThreadKey *) (v->value.p_void))) + if (!ThreadKeyFree((OCI_ThreadKey *) (v->value.p_void))) { nb_err++; } @@ -767,111 +591,88 @@ boolean OCI_KeyMapFree } } - res = (OCI_HashFree(OCILib.key_map) && (nb_err == 0)); + HashFree(Env.key_map); - OCILib.key_map = NULL; - - return res; + Env.key_map = NULL; } /* --------------------------------------------------------------------------------------------- * - * OCI_CallEnter - * --------------------------------------------------------------------------------------------- */ - -void OCI_CallEnter -( - OCI_Context *ctx -) -{ - if (ctx && ctx->call_err) - { - if (ctx->call_err->depth == 0 && ctx->call_err->type != OCI_UNKNOWN) - { - OCI_ErrorReset(ctx->call_err); - } - - ctx->call_err->depth++; - } -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_CallExit - * --------------------------------------------------------------------------------------------- */ - -void OCI_CallExit -( - OCI_Context *ctx -) -{ - if (ctx && ctx->call_err) - { - if (ctx->call_err->depth > 0) ctx->call_err->depth--; - - ctx->call_err->raise = (ctx->call_err->depth == 0) && - (ctx->call_err->type != OCI_UNKNOWN) && - (!ctx->call_status || (OCI_ERR_WARNING == ctx->call_err->type && OCILib.warnings_on)); - } -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_GetEnvironmentVariable - * - * @note - * Values are allocated with OCI_MemAlloc() and need to be freed by the caller using OCI_MemFree() + * EnvironmentGetVariable + * + * @note + * Values are allocated with MemoryAlloc() and need to be freed by the caller using MemoryFree() * * --------------------------------------------------------------------------------------------- */ -char * OCI_GetEnvironmentVariable +char * EnvironmentGetVariable ( const char *name ) { - char *value = getenv(name); + ENTER_FUNC + ( + /* returns */ char*, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_PTR(OCI_IPC_STRING, name) - if (value) + char* value = NULL; + char *str = getenv(name); + + if (NULL != str) { - value = ocistrdup(value); + value = ocistrdup(str); } #if defined(_WINDOWS) else { - // Variables set using SetEnvironmentVariable() on Windows are not seen by MSVC implementation of getenv() !! - // Thus, let's check if they can be retrieved using GetEnvironmentVariable() + /* Variables set using SetEnvironmentVariable() on Windows are not seen by MSVC + * implementation of getenv() !! */ + + /* Thus, let's check if they can be retrieved using GetEnvironmentVariable() */ unsigned int size = GetEnvironmentVariableA(name, NULL, 0); if (size > 0) { - value = OCI_MemAlloc(OCI_IPC_STRING, size, 1, TRUE); - size = GetEnvironmentVariableA(name, value, size); + value = MemoryAlloc(OCI_IPC_STRING, size, 1, TRUE); + size = GetEnvironmentVariableA(name, value, size); if (size == 0) { - OCI_MemFree(value); + MemoryFree(value); } } } -#endif +#endif - return value; -} + SET_RETVAL(value) -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_Initialize + * EnvironmentInitialize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Initialize +boolean EnvironmentInitialize ( POCI_ERROR err_handler, const otext *lib_path, unsigned int mode ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + unsigned int i = 0; + + sword ret = OCI_SUCCESS; + ub4 oci_mode = OCI_ENV_MODE | OCI_OBJECT; #ifdef OCI_IMPORT_RUNTIME @@ -882,14 +683,12 @@ boolean OCI_API OCI_Initialize #endif - OCI_CALL_DECLARE_VARIABLES(boolean, FALSE, TRUE) - OCI_CALL_CONTEXT_ENTER(mode) - /* check if it was already initialized */ - if (OCILib.loaded) + if (Env.loaded) { - return TRUE; + SET_SUCCESS() + JUMP_EXIT() } #if defined(OCI_CHARSET_WIDE) && (OCI_VERSION_COMPILE >= OCI_10_2) @@ -900,38 +699,42 @@ boolean OCI_API OCI_Initialize #endif - memset(&OCILib, 0, sizeof(OCI_Library)); + memset(&Env, 0, sizeof(struct OCI_Environment)); - OCILib.error_handler = err_handler; + Env.error_handler = err_handler; - OCILib.version_compile = OCI_VERSION_COMPILE; - OCILib.version_runtime = OCI_VERSION_RUNTIME; + Env.version_compile = OCI_VERSION_COMPILE; + Env.version_runtime = OCI_VERSION_RUNTIME; - OCILib.env_mode = mode; - OCILib.charset = (sizeof(otext) == sizeof(wchar_t)) ? OCI_CHAR_WIDE : OCI_CHAR_ANSI; - OCILib.use_wide_char_conv = (OCILib.charset == OCI_CHAR_WIDE && (WCHAR_MAX == WCHAR_4_BYTES)); + Env.env_mode = mode; + Env.charset = (sizeof(otext) == sizeof(wchar_t)) ? OCI_CHAR_WIDE : OCI_CHAR_ANSI; + Env.use_wide_char_conv = (Env.charset == OCI_CHAR_WIDE && (WCHAR_MAX == WCHAR_4_BYTES)); + + /* create environment error */ + + Env.lib_err = ErrorCreate(); for (i = 0; i < OCI_FMT_COUNT; i++) { - OCILib.formats[i] = ostrdup(FormatDefaultValues[i]); + Env.formats[i] = ostrdup(FormatDefaultValues[i]); } /* load any specific environment variable */ for (i = 0; i < OCI_VARS_COUNT; i++) { - char *value = OCI_GetEnvironmentVariable(EnvironmentVarNames[i]); + char *value = EnvironmentGetVariable(EnvironmentVarNames[i]); - OCILib.env_vars[i] = value && (ocistrcasecmp(value, OCI_VARS_TRUE_VALUE) == 0 || atoi(value) == 1); + Env.env_vars[i] = value && (ocistrcasecmp(value, OCI_VARS_TRUE_VALUE) == 0 || atoi(value) == 1); - OCI_FREE(value); + FREE(value); } /* test for UTF8 environment */ - if (OCI_CHAR_ANSI == OCILib.charset) + if (OCI_CHAR_ANSI == Env.charset) { - char *str = OCI_GetEnvironmentVariable("NLS_LANG"); + char *str = EnvironmentGetVariable("NLS_LANG"); if (str) { @@ -944,9 +747,9 @@ boolean OCI_API OCI_Initialize *ptr = (char) toupper(*ptr); } - OCILib.nls_utf8 = (NULL != strstr(nls_lang, "UTF8")); + Env.nls_utf8 = (NULL != strstr(nls_lang, "UTF8")); - OCI_FREE(str); + FREE(str); } } @@ -954,30 +757,30 @@ boolean OCI_API OCI_Initialize OCI_NOT_USED(lib_path) - #if defined(OCI_BIG_UINT_ENABLED) + #if defined(OCI_BIG_UINT_ENABLED) - OCILib.use_lob_ub8 = TRUE; + Env.use_lob_ub8 = TRUE; - #endif + #endif - #if defined(OCI_STMT_SCROLLABLE_READONLY) + #if defined(OCI_STMT_SCROLLABLE_READONLY) - OCILib.use_scrollable_cursors = TRUE; + Env.use_scrollable_cursors = TRUE; - #endif + #endif #else memset(path, 0, sizeof(path)); - #if defined(OCI_CHARSET_WIDE) + #if defined(OCI_CHARSET_WIDE) if (lib_path && lib_path[0]) { len = wcstombs(path, lib_path, sizeof(path)); } - #else + #else if (lib_path && lib_path[0]) { @@ -986,7 +789,7 @@ boolean OCI_API OCI_Initialize len = strlen(path); } - #endif + #endif if ((len > (size_t) 0) && (len < sizeof(path) -1) && (OCI_CHAR_SLASH != path[len - (size_t) 1])) { @@ -996,9 +799,9 @@ boolean OCI_API OCI_Initialize strncat(path, OCI_DL_ANSI_NAME, sizeof(path) - len - 1); - OCILib.lib_handle = LIB_OPEN(path); + Env.lib_handle = LIB_OPEN(path); - if (OCILib.lib_handle) + if (Env.lib_handle) { /* Now loading all symbols - no check is performed on each function, @@ -1006,571 +809,571 @@ boolean OCI_API OCI_Initialize Oracle and compatible library ... */ - LIB_SYMBOL(OCILib.lib_handle, "OCIEnvCreate", OCIEnvCreate, + LIB_SYMBOL(Env.lib_handle, "OCIEnvCreate", OCIEnvCreate, OCIENVCREATE); - LIB_SYMBOL(OCILib.lib_handle, "OCIServerAttach", OCIServerAttach, + LIB_SYMBOL(Env.lib_handle, "OCIServerAttach", OCIServerAttach, OCISERVERATTACH); - LIB_SYMBOL(OCILib.lib_handle, "OCIServerDetach", OCIServerDetach, + LIB_SYMBOL(Env.lib_handle, "OCIServerDetach", OCIServerDetach, OCISERVERDETACH); - LIB_SYMBOL(OCILib.lib_handle, "OCIHandleAlloc", OCIHandleAlloc, + LIB_SYMBOL(Env.lib_handle, "OCIHandleAlloc", OCIHandleAlloc, OCIHANDLEALLOC); - LIB_SYMBOL(OCILib.lib_handle, "OCIHandleFree", OCIHandleFree, + LIB_SYMBOL(Env.lib_handle, "OCIHandleFree", OCIHandleFree, OCIHANDLEFREE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDescriptorAlloc", OCIDescriptorAlloc, + LIB_SYMBOL(Env.lib_handle, "OCIDescriptorAlloc", OCIDescriptorAlloc, OCIDESCRIPTORALLOC); - LIB_SYMBOL(OCILib.lib_handle, "OCIDescriptorFree", OCIDescriptorFree, + LIB_SYMBOL(Env.lib_handle, "OCIDescriptorFree", OCIDescriptorFree, OCIDESCRIPTORFREE); - LIB_SYMBOL(OCILib.lib_handle, "OCIAttrSet", OCIAttrSet, + LIB_SYMBOL(Env.lib_handle, "OCIAttrSet", OCIAttrSet, OCIATTRSET); - LIB_SYMBOL(OCILib.lib_handle, "OCIAttrGet", OCIAttrGet, + LIB_SYMBOL(Env.lib_handle, "OCIAttrGet", OCIAttrGet, OCIATTRGET); - LIB_SYMBOL(OCILib.lib_handle, "OCIParamSet", OCIParamSet, + LIB_SYMBOL(Env.lib_handle, "OCIParamSet", OCIParamSet, OCIPARAMSET); - LIB_SYMBOL(OCILib.lib_handle, "OCIParamGet", OCIParamGet, + LIB_SYMBOL(Env.lib_handle, "OCIParamGet", OCIParamGet, OCIPARAMGET); - LIB_SYMBOL(OCILib.lib_handle, "OCISessionBegin", OCISessionBegin, + LIB_SYMBOL(Env.lib_handle, "OCISessionBegin", OCISessionBegin, OCISESSIONBEGIN); - LIB_SYMBOL(OCILib.lib_handle, "OCISessionEnd", OCISessionEnd, + LIB_SYMBOL(Env.lib_handle, "OCISessionEnd", OCISessionEnd, OCISESSIONEND); - LIB_SYMBOL(OCILib.lib_handle, "OCIPasswordChange", OCIPasswordChange, + LIB_SYMBOL(Env.lib_handle, "OCIPasswordChange", OCIPasswordChange, OCIPASSWORDCHANGE); - LIB_SYMBOL(OCILib.lib_handle, "OCITransStart", OCITransStart, + LIB_SYMBOL(Env.lib_handle, "OCITransStart", OCITransStart, OCITRANSSTART); - LIB_SYMBOL(OCILib.lib_handle, "OCITransDetach", OCITransDetach, + LIB_SYMBOL(Env.lib_handle, "OCITransDetach", OCITransDetach, OCITRANSDETACH); - LIB_SYMBOL(OCILib.lib_handle, "OCITransPrepare", OCITransPrepare, + LIB_SYMBOL(Env.lib_handle, "OCITransPrepare", OCITransPrepare, OCITRANSPREPARE); - LIB_SYMBOL(OCILib.lib_handle, "OCITransForget", OCITransForget, + LIB_SYMBOL(Env.lib_handle, "OCITransForget", OCITransForget, OCITRANSFORGET); - LIB_SYMBOL(OCILib.lib_handle, "OCITransCommit", OCITransCommit, + LIB_SYMBOL(Env.lib_handle, "OCITransCommit", OCITransCommit, OCITRANSCOMMIT); - LIB_SYMBOL(OCILib.lib_handle, "OCITransRollback", OCITransRollback, + LIB_SYMBOL(Env.lib_handle, "OCITransRollback", OCITransRollback, OCITRANSROLLBACK); - LIB_SYMBOL(OCILib.lib_handle, "OCIErrorGet", OCIErrorGet, + LIB_SYMBOL(Env.lib_handle, "OCIErrorGet", OCIErrorGet, OCIERRORGET); - LIB_SYMBOL(OCILib.lib_handle, "OCIServerVersion", OCIServerVersion, + LIB_SYMBOL(Env.lib_handle, "OCIServerVersion", OCIServerVersion, OCISERVERVERSION); - LIB_SYMBOL(OCILib.lib_handle, "OCIBreak", OCIBreak, + LIB_SYMBOL(Env.lib_handle, "OCIBreak", OCIBreak, OCIBREAK); - LIB_SYMBOL(OCILib.lib_handle, "OCIBindByPos", OCIBindByPos, + LIB_SYMBOL(Env.lib_handle, "OCIBindByPos", OCIBindByPos, OCIBINDBYPOS); - LIB_SYMBOL(OCILib.lib_handle, "OCIBindByName", OCIBindByName, + LIB_SYMBOL(Env.lib_handle, "OCIBindByName", OCIBindByName, OCIBINDBYNAME); - LIB_SYMBOL(OCILib.lib_handle, "OCIBindDynamic", OCIBindDynamic, + LIB_SYMBOL(Env.lib_handle, "OCIBindDynamic", OCIBindDynamic, OCIBINDDYNAMIC); - LIB_SYMBOL(OCILib.lib_handle, "OCIBindObject", OCIBindObject, + LIB_SYMBOL(Env.lib_handle, "OCIBindObject", OCIBindObject, OCIBINDOBJECT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDefineByPos", OCIDefineByPos, + LIB_SYMBOL(Env.lib_handle, "OCIDefineByPos", OCIDefineByPos, OCIDEFINEBYPOS); - LIB_SYMBOL(OCILib.lib_handle, "OCIDefineObject", OCIDefineObject, + LIB_SYMBOL(Env.lib_handle, "OCIDefineObject", OCIDefineObject, OCIDEFINEOBJECT); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtPrepare", OCIStmtPrepare, + LIB_SYMBOL(Env.lib_handle, "OCIStmtPrepare", OCIStmtPrepare, OCISTMTPREPARE); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtExecute", OCIStmtExecute, + LIB_SYMBOL(Env.lib_handle, "OCIStmtExecute", OCIStmtExecute, OCISTMTEXECUTE); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtFetch", OCIStmtFetch, + LIB_SYMBOL(Env.lib_handle, "OCIStmtFetch", OCIStmtFetch, OCISTMTFETCH); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtFetch2", OCIStmtFetch2, + LIB_SYMBOL(Env.lib_handle, "OCIStmtFetch2", OCIStmtFetch2, OCISTMTFETCH2); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtGetPieceInfo", OCIStmtGetPieceInfo, + LIB_SYMBOL(Env.lib_handle, "OCIStmtGetPieceInfo", OCIStmtGetPieceInfo, OCISTMTGETPIECEINFO); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtSetPieceInfo", OCIStmtSetPieceInfo, + LIB_SYMBOL(Env.lib_handle, "OCIStmtSetPieceInfo", OCIStmtSetPieceInfo, OCISTMTSETPIECEINFO); - LIB_SYMBOL(OCILib.lib_handle, "OCILobCreateTemporary", OCILobCreateTemporary, + LIB_SYMBOL(Env.lib_handle, "OCILobCreateTemporary", OCILobCreateTemporary, OCILOBCREATETEMPORARY); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFreeTemporary", OCILobFreeTemporary, + LIB_SYMBOL(Env.lib_handle, "OCILobFreeTemporary", OCILobFreeTemporary, OCILOBFREETEMPORARY); - LIB_SYMBOL(OCILib.lib_handle, "OCILobIsTemporary", OCILobIsTemporary, + LIB_SYMBOL(Env.lib_handle, "OCILobIsTemporary", OCILobIsTemporary, OCILOBISTEMPORARY); - LIB_SYMBOL(OCILib.lib_handle, "OCILobRead", OCILobRead, + LIB_SYMBOL(Env.lib_handle, "OCILobRead", OCILobRead, OCILOBREAD); - LIB_SYMBOL(OCILib.lib_handle, "OCILobWrite", OCILobWrite, + LIB_SYMBOL(Env.lib_handle, "OCILobWrite", OCILobWrite, OCILOBWRITE); - LIB_SYMBOL(OCILib.lib_handle, "OCILobCopy", OCILobCopy, + LIB_SYMBOL(Env.lib_handle, "OCILobCopy", OCILobCopy, OCILOBCOPY); - LIB_SYMBOL(OCILib.lib_handle, "OCILobTrim", OCILobTrim, + LIB_SYMBOL(Env.lib_handle, "OCILobTrim", OCILobTrim, OCILOBTRIM); - LIB_SYMBOL(OCILib.lib_handle, "OCILobErase", OCILobErase, + LIB_SYMBOL(Env.lib_handle, "OCILobErase", OCILobErase, OCILOBERASE); - LIB_SYMBOL(OCILib.lib_handle, "OCILobAppend", OCILobAppend, + LIB_SYMBOL(Env.lib_handle, "OCILobAppend", OCILobAppend, OCILOBAPPEND); - LIB_SYMBOL(OCILib.lib_handle, "OCILobGetLength", OCILobGetLength, + LIB_SYMBOL(Env.lib_handle, "OCILobGetLength", OCILobGetLength, OCILOBGETLENGTH); - LIB_SYMBOL(OCILib.lib_handle, "OCILobGetChunkSize", OCILobGetChunkSize, + LIB_SYMBOL(Env.lib_handle, "OCILobGetChunkSize", OCILobGetChunkSize, OCILOBGETCHUNKSIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCILobOpen", OCILobOpen, + LIB_SYMBOL(Env.lib_handle, "OCILobOpen", OCILobOpen, OCILOBOPEN); - LIB_SYMBOL(OCILib.lib_handle, "OCILobClose", OCILobClose, + LIB_SYMBOL(Env.lib_handle, "OCILobClose", OCILobClose, OCILOBCLOSE); - #ifdef ORAXB8_DEFINED + #ifdef ORAXB8_DEFINED - LIB_SYMBOL(OCILib.lib_handle, "OCILobCopy2", OCILobCopy2, + LIB_SYMBOL(Env.lib_handle, "OCILobCopy2", OCILobCopy2, OCILOBCOPY2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobErase2", OCILobErase2, + LIB_SYMBOL(Env.lib_handle, "OCILobErase2", OCILobErase2, OCILOBERASE2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobGetLength2", OCILobGetLength2, + LIB_SYMBOL(Env.lib_handle, "OCILobGetLength2", OCILobGetLength2, OCILOBGETLENGTH2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobLoadFromFile2", OCILobLoadFromFile2, + LIB_SYMBOL(Env.lib_handle, "OCILobLoadFromFile2", OCILobLoadFromFile2, OCILOBLOADFROMFILE2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobRead2", OCILobRead2, + LIB_SYMBOL(Env.lib_handle, "OCILobRead2", OCILobRead2, OCILOBREAD2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobTrim2", OCILobTrim2, + LIB_SYMBOL(Env.lib_handle, "OCILobTrim2", OCILobTrim2, OCILOBTRIM2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobWrite2", OCILobWrite2, + LIB_SYMBOL(Env.lib_handle, "OCILobWrite2", OCILobWrite2, OCILOBWRITE2); - LIB_SYMBOL(OCILib.lib_handle, "OCILobWriteAppend2", OCILobWriteAppend2, + LIB_SYMBOL(Env.lib_handle, "OCILobWriteAppend2", OCILobWriteAppend2, OCILOBWRITEAPPEND2); - #endif + #endif - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileOpen", OCILobFileOpen, + LIB_SYMBOL(Env.lib_handle, "OCILobFileOpen", OCILobFileOpen, OCILOBFILEOPEN); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileClose", OCILobFileClose, + LIB_SYMBOL(Env.lib_handle, "OCILobFileClose", OCILobFileClose, OCILOBFILECLOSE); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileCloseAll", OCILobFileCloseAll, + LIB_SYMBOL(Env.lib_handle, "OCILobFileCloseAll", OCILobFileCloseAll, OCILOBFILECLOSEALL); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileIsOpen", OCILobFileIsOpen, + LIB_SYMBOL(Env.lib_handle, "OCILobFileIsOpen", OCILobFileIsOpen, OCILOBFILEISOPEN); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileExists", OCILobFileExists, + LIB_SYMBOL(Env.lib_handle, "OCILobFileExists", OCILobFileExists, OCILOBFILEEXISTS); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileGetName", OCILobFileGetName, + LIB_SYMBOL(Env.lib_handle, "OCILobFileGetName", OCILobFileGetName, OCILOBFIELGETNAME); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFileSetName", OCILobFileSetName, + LIB_SYMBOL(Env.lib_handle, "OCILobFileSetName", OCILobFileSetName, OCILOBFILESETNAME); - LIB_SYMBOL(OCILib.lib_handle, "OCILobLoadFromFile", OCILobLoadFromFile, + LIB_SYMBOL(Env.lib_handle, "OCILobLoadFromFile", OCILobLoadFromFile, OCILOBLOADFROMFILE); - LIB_SYMBOL(OCILib.lib_handle, "OCILobWriteAppend", OCILobWriteAppend, + LIB_SYMBOL(Env.lib_handle, "OCILobWriteAppend", OCILobWriteAppend, OCILOBWRITEAPPEND); - LIB_SYMBOL(OCILib.lib_handle, "OCILobIsEqual", OCILobIsEqual, + LIB_SYMBOL(Env.lib_handle, "OCILobIsEqual", OCILobIsEqual, OCILOBISEQUAL); - LIB_SYMBOL(OCILib.lib_handle, "OCILobAssign", OCILobAssign, + LIB_SYMBOL(Env.lib_handle, "OCILobAssign", OCILobAssign, OCILOBASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCILobLocatorAssign", OCILobLocatorAssign, + LIB_SYMBOL(Env.lib_handle, "OCILobLocatorAssign", OCILobLocatorAssign, OCILOBLOCATORASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCILobFlushBuffer", OCILobFlushBuffer, + LIB_SYMBOL(Env.lib_handle, "OCILobFlushBuffer", OCILobFlushBuffer, OCILOBFLUSHBUFFER); - LIB_SYMBOL(OCILib.lib_handle, "OCILobGetStorageLimit", OCILobGetStorageLimit, + LIB_SYMBOL(Env.lib_handle, "OCILobGetStorageLimit", OCILobGetStorageLimit, OCILOBGETSTORAGELIMIT); - LIB_SYMBOL(OCILib.lib_handle, "OCILobEnableBuffering", OCILobEnableBuffering, + LIB_SYMBOL(Env.lib_handle, "OCILobEnableBuffering", OCILobEnableBuffering, OCILOBENABLEBUFFERING); - LIB_SYMBOL(OCILib.lib_handle, "OCILobDisableBuffering", OCILobDisableBuffering, + LIB_SYMBOL(Env.lib_handle, "OCILobDisableBuffering", OCILobDisableBuffering, OCILOBDISABLEBUFFERING); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateAssign", OCIDateAssign, + LIB_SYMBOL(Env.lib_handle, "OCIDateAssign", OCIDateAssign, OCIDATEASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateToText", OCIDateToText, + LIB_SYMBOL(Env.lib_handle, "OCIDateToText", OCIDateToText, OCIDATETOTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateFromText", OCIDateFromText, + LIB_SYMBOL(Env.lib_handle, "OCIDateFromText", OCIDateFromText, OCIDATEFROMTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateCompare", OCIDateCompare, + LIB_SYMBOL(Env.lib_handle, "OCIDateCompare", OCIDateCompare, OCIDATECOMPARE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateAddMonths", OCIDateAddMonths, + LIB_SYMBOL(Env.lib_handle, "OCIDateAddMonths", OCIDateAddMonths, OCIDATEADDMONTHS); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateAddDays", OCIDateAddDays, + LIB_SYMBOL(Env.lib_handle, "OCIDateAddDays", OCIDateAddDays, OCIDATEADDDAYS); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateLastDay", OCIDateLastDay, + LIB_SYMBOL(Env.lib_handle, "OCIDateLastDay", OCIDateLastDay, OCIDATELASTDAY); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateDaysBetween", OCIDateDaysBetween, + LIB_SYMBOL(Env.lib_handle, "OCIDateDaysBetween", OCIDateDaysBetween, OCIDATEDAYSBETWEEN); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateZoneToZone", OCIDateZoneToZone, + LIB_SYMBOL(Env.lib_handle, "OCIDateZoneToZone", OCIDateZoneToZone, OCIDATEZONETOZONE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateNextDay", OCIDateNextDay, + LIB_SYMBOL(Env.lib_handle, "OCIDateNextDay", OCIDateNextDay, OCIDATENEXTDAY); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateCheck", OCIDateCheck, + LIB_SYMBOL(Env.lib_handle, "OCIDateCheck", OCIDateCheck, OCIDATECHECK); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateSysDate", OCIDateSysDate, + LIB_SYMBOL(Env.lib_handle, "OCIDateSysDate", OCIDateSysDate, OCIDATESYSDATE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDescribeAny", OCIDescribeAny, + LIB_SYMBOL(Env.lib_handle, "OCIDescribeAny", OCIDescribeAny, OCIDESCRIBEANY); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalAssign", OCIIntervalAssign, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalAssign", OCIIntervalAssign, OCIINTERVALASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalCheck", OCIIntervalCheck, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalCheck", OCIIntervalCheck, OCIINTERVALCHECK); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalCompare", OCIIntervalCompare, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalCompare", OCIIntervalCompare, OCIINTERVALCOMPARE); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalFromText", OCIIntervalFromText, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalFromText", OCIIntervalFromText, OCIINTERVALFROMTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalToText", OCIIntervalToText, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalToText", OCIIntervalToText, OCIINTERVALTOTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalFromTZ", OCIIntervalFromTZ, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalFromTZ", OCIIntervalFromTZ, OCIINTERVALFROMTZ); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalGetDaySecond", OCIIntervalGetDaySecond, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalGetDaySecond", OCIIntervalGetDaySecond, OCIINTERVALGETDAYSECOND); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalGetYearMonth", OCIIntervalGetYearMonth, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalGetYearMonth", OCIIntervalGetYearMonth, OCIINTERVALGETYEARMONTH); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalSetDaySecond", OCIIntervalSetDaySecond, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalSetDaySecond", OCIIntervalSetDaySecond, OCIINTERVALSETDAYSECOND); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalSetYearMonth", OCIIntervalSetYearMonth, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalSetYearMonth", OCIIntervalSetYearMonth, OCIINTERVALSETYEARMONTH); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalSubtract", OCIIntervalSubtract, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalSubtract", OCIIntervalSubtract, OCIINTERVALSUBTRACT); - LIB_SYMBOL(OCILib.lib_handle, "OCIIntervalAdd", OCIIntervalAdd, + LIB_SYMBOL(Env.lib_handle, "OCIIntervalAdd", OCIIntervalAdd, OCIINTERVALADD); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeAssign", OCIDateTimeAssign, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeAssign", OCIDateTimeAssign, OCIDATETIMEASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeCheck", OCIDateTimeCheck, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeCheck", OCIDateTimeCheck, OCIDATETIMECHECK); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeCompare", OCIDateTimeCompare, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeCompare", OCIDateTimeCompare, OCIDATETIMECOMPARE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeConstruct", OCIDateTimeConstruct, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeConstruct", OCIDateTimeConstruct, OCIDATETIMECONSTRUCT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeConvert", OCIDateTimeConvert, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeConvert", OCIDateTimeConvert, OCIDATETIMECONVERT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeFromArray", OCIDateTimeFromArray, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeFromArray", OCIDateTimeFromArray, OCIDATETIMEFROMARRAY); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeToArray", OCIDateTimeToArray, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeToArray", OCIDateTimeToArray, OCIDATETIMETOARRAY); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeFromText", OCIDateTimeFromText, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeFromText", OCIDateTimeFromText, OCIDATETIMEFROMTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeToText", OCIDateTimeToText, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeToText", OCIDateTimeToText, OCIDATETIMETOTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeGetDate", OCIDateTimeGetDate, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeGetDate", OCIDateTimeGetDate, OCIDATETIMEGETDATE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeGetTime", OCIDateTimeGetTime, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeGetTime", OCIDateTimeGetTime, OCIDATETIMEGETTIME); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeGetTimeZoneName", OCIDateTimeGetTimeZoneName, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeGetTimeZoneName", OCIDateTimeGetTimeZoneName, OCIDATETIMEGETTIMEZONENAME); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeGetTimeZoneOffset", OCIDateTimeGetTimeZoneOffset, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeGetTimeZoneOffset", OCIDateTimeGetTimeZoneOffset, OCIDATETIMEGETTIMEZONEOFFSET); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeIntervalAdd", OCIDateTimeIntervalAdd, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeIntervalAdd", OCIDateTimeIntervalAdd, OCIDATETIMEINTERVALADD); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeIntervalSub", OCIDateTimeIntervalSub, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeIntervalSub", OCIDateTimeIntervalSub, OCIDATETIMEINTERVALSUB); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeSubtract", OCIDateTimeSubtract, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeSubtract", OCIDateTimeSubtract, OCIDATETIMESUBTRACT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDateTimeSysTimeStamp", OCIDateTimeSysTimeStamp, + LIB_SYMBOL(Env.lib_handle, "OCIDateTimeSysTimeStamp", OCIDateTimeSysTimeStamp, OCIDATETIMESYSTIMESTAMP); - LIB_SYMBOL(OCILib.lib_handle, "OCITypeByRef", OCITypeByRef, + LIB_SYMBOL(Env.lib_handle, "OCITypeByRef", OCITypeByRef, OCITYPEBYREF); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberToInt", OCINumberToInt, + LIB_SYMBOL(Env.lib_handle, "OCINumberToInt", OCINumberToInt, OCINUMBERTOINT); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberFromInt", OCINumberFromInt, + LIB_SYMBOL(Env.lib_handle, "OCINumberFromInt", OCINumberFromInt, OCINUMBERFROMINT); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberToReal", OCINumberToReal, + LIB_SYMBOL(Env.lib_handle, "OCINumberToReal", OCINumberToReal, OCINUMBERTOREAL); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberFromReal", OCINumberFromReal, + LIB_SYMBOL(Env.lib_handle, "OCINumberFromReal", OCINumberFromReal, OCINUMBERFROMREAL); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberToText", OCINumberToText, + LIB_SYMBOL(Env.lib_handle, "OCINumberToText", OCINumberToText, OCINUMBERTOTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberFromText", OCINumberFromText, + LIB_SYMBOL(Env.lib_handle, "OCINumberFromText", OCINumberFromText, OCINUMBERFROMTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberAssign", OCINumberAssign, + LIB_SYMBOL(Env.lib_handle, "OCINumberAssign", OCINumberAssign, OCINUMBERASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberAdd", OCINumberAdd, + LIB_SYMBOL(Env.lib_handle, "OCINumberAdd", OCINumberAdd, OCINUMBERADD); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberSub", OCINumberSub, + LIB_SYMBOL(Env.lib_handle, "OCINumberSub", OCINumberSub, OCINUMBERSUB); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberMul", OCINumberMul, + LIB_SYMBOL(Env.lib_handle, "OCINumberMul", OCINumberMul, OCINUMBERMUL); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberDiv", OCINumberDiv, + LIB_SYMBOL(Env.lib_handle, "OCINumberDiv", OCINumberDiv, OCINUMBERDIV); - LIB_SYMBOL(OCILib.lib_handle, "OCINumberCmp", OCINumberCmp, + LIB_SYMBOL(Env.lib_handle, "OCINumberCmp", OCINumberCmp, OCINUMBERCMP); - LIB_SYMBOL(OCILib.lib_handle, "OCIStringPtr", OCIStringPtr, + LIB_SYMBOL(Env.lib_handle, "OCIStringPtr", OCIStringPtr, OCISTRINGPTR); - LIB_SYMBOL(OCILib.lib_handle, "OCIStringSize", OCIStringSize, + LIB_SYMBOL(Env.lib_handle, "OCIStringSize", OCIStringSize, OCISTRINGSIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIStringAssignText", OCIStringAssignText, + LIB_SYMBOL(Env.lib_handle, "OCIStringAssignText", OCIStringAssignText, OCISTRINGASSIGNTEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIStringResize", OCIStringResize, + LIB_SYMBOL(Env.lib_handle, "OCIStringResize", OCIStringResize, OCISTRINGRESIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIRawPtr", OCIRawPtr, + LIB_SYMBOL(Env.lib_handle, "OCIRawPtr", OCIRawPtr, OCIRAWPTR); - LIB_SYMBOL(OCILib.lib_handle, "OCIRawAssignBytes", OCIRawAssignBytes, + LIB_SYMBOL(Env.lib_handle, "OCIRawAssignBytes", OCIRawAssignBytes, OCIRAWASSIGNBYTES); - LIB_SYMBOL(OCILib.lib_handle, "OCIRawResize", OCIRawResize, + LIB_SYMBOL(Env.lib_handle, "OCIRawResize", OCIRawResize, OCIRAWRESIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIRawAllocSize", OCIRawAllocSize, + LIB_SYMBOL(Env.lib_handle, "OCIRawAllocSize", OCIRawAllocSize, OCIRAWALLOCSIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIRawSize", OCIRawSize, + LIB_SYMBOL(Env.lib_handle, "OCIRawSize", OCIRawSize, OCIRAWSIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectNew", OCIObjectNew, + LIB_SYMBOL(Env.lib_handle, "OCIObjectNew", OCIObjectNew, OCIOBJECTNEW); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectFree", OCIObjectFree, + LIB_SYMBOL(Env.lib_handle, "OCIObjectFree", OCIObjectFree, OCIOBJECTFREE); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectSetAttr", OCIObjectSetAttr, + LIB_SYMBOL(Env.lib_handle, "OCIObjectSetAttr", OCIObjectSetAttr, OCIOBJECTSETATTR); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectGetAttr", OCIObjectGetAttr, + LIB_SYMBOL(Env.lib_handle, "OCIObjectGetAttr", OCIObjectGetAttr, OCIOBJECTGETATTR); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectPin", OCIObjectPin, + LIB_SYMBOL(Env.lib_handle, "OCIObjectPin", OCIObjectPin, OCIOBJECTPIN); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectUnpin", OCIObjectUnpin, + LIB_SYMBOL(Env.lib_handle, "OCIObjectUnpin", OCIObjectUnpin, OCIOBJECTUNPIN); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectCopy", OCIObjectCopy, + LIB_SYMBOL(Env.lib_handle, "OCIObjectCopy", OCIObjectCopy, OCIOBJECTCOPY); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectGetObjectRef", OCIObjectGetObjectRef, + LIB_SYMBOL(Env.lib_handle, "OCIObjectGetObjectRef", OCIObjectGetObjectRef, OCIOBJECTGETOBJECTREF); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectGetProperty", OCIObjectGetProperty, + LIB_SYMBOL(Env.lib_handle, "OCIObjectGetProperty", OCIObjectGetProperty, OCIOBJECTGETPROPERTY); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectGetInd", OCIObjectGetInd, + LIB_SYMBOL(Env.lib_handle, "OCIObjectGetInd", OCIObjectGetInd, OCIOBJECTGETIND); - LIB_SYMBOL(OCILib.lib_handle, "OCIObjectGetTypeRef", OCIObjectGetTypeRef, - OCIOBJECTGETOBJECTREF); + LIB_SYMBOL(Env.lib_handle, "OCIObjectGetTypeRef", OCIObjectGetTypeRef, + OCIOBJECTGETOBJECTREF); - LIB_SYMBOL(OCILib.lib_handle, "OCIRefAssign", OCIRefAssign, + LIB_SYMBOL(Env.lib_handle, "OCIRefAssign", OCIRefAssign, OCIREFASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCIRefIsNull", OCIRefIsNull, + LIB_SYMBOL(Env.lib_handle, "OCIRefIsNull", OCIRefIsNull, OCIREFISNULL); - LIB_SYMBOL(OCILib.lib_handle, "OCIRefClear", OCIRefClear, + LIB_SYMBOL(Env.lib_handle, "OCIRefClear", OCIRefClear, OCIREFCLEAR); - LIB_SYMBOL(OCILib.lib_handle, "OCIRefToHex", OCIRefToHex, + LIB_SYMBOL(Env.lib_handle, "OCIRefToHex", OCIRefToHex, OCIREFTOHEX); - LIB_SYMBOL(OCILib.lib_handle, "OCIRefHexSize", OCIRefHexSize, + LIB_SYMBOL(Env.lib_handle, "OCIRefHexSize", OCIRefHexSize, OCIREFHEXSIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIArrayDescriptorAlloc", OCIArrayDescriptorAlloc, + LIB_SYMBOL(Env.lib_handle, "OCIArrayDescriptorAlloc", OCIArrayDescriptorAlloc, OCIARRAYDESCRIPTORALLOC); - LIB_SYMBOL(OCILib.lib_handle, "OCIArrayDescriptorFree", OCIArrayDescriptorFree, + LIB_SYMBOL(Env.lib_handle, "OCIArrayDescriptorFree", OCIArrayDescriptorFree, OCIARRAYDESCRIPTORFREE); - LIB_SYMBOL(OCILib.lib_handle, "OCIClientVersion", OCIClientVersion, + LIB_SYMBOL(Env.lib_handle, "OCIClientVersion", OCIClientVersion, OCICLIENTVERSION); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadProcessInit", OCIThreadProcessInit, + LIB_SYMBOL(Env.lib_handle, "OCIThreadProcessInit", OCIThreadProcessInit, OCITHREADPROCESSINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadInit", OCIThreadInit, + LIB_SYMBOL(Env.lib_handle, "OCIThreadInit", OCIThreadInit, OCITHREADINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadTerm", OCIThreadTerm, + LIB_SYMBOL(Env.lib_handle, "OCIThreadTerm", OCIThreadTerm, OCITHREADTERM); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadIdInit", OCIThreadIdInit, + LIB_SYMBOL(Env.lib_handle, "OCIThreadIdInit", OCIThreadIdInit, OCITHREADIDINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadIdDestroy", OCIThreadIdDestroy, + LIB_SYMBOL(Env.lib_handle, "OCIThreadIdDestroy", OCIThreadIdDestroy, OCITHREADIDDESTROY); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadHndInit", OCIThreadHndInit, + LIB_SYMBOL(Env.lib_handle, "OCIThreadHndInit", OCIThreadHndInit, OCITHREADHNDINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadHndDestroy", OCIThreadHndDestroy, + LIB_SYMBOL(Env.lib_handle, "OCIThreadHndDestroy", OCIThreadHndDestroy, OCITHREADHNDDESTROY); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadCreate", OCIThreadCreate, + LIB_SYMBOL(Env.lib_handle, "OCIThreadCreate", OCIThreadCreate, OCITHREADCREATE); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadJoin", OCIThreadJoin, + LIB_SYMBOL(Env.lib_handle, "OCIThreadJoin", OCIThreadJoin, OCITHREADJOIN); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadClose", OCIThreadClose, + LIB_SYMBOL(Env.lib_handle, "OCIThreadClose", OCIThreadClose, OCITHREADCLOSE); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadMutexInit", OCIThreadMutexInit, + LIB_SYMBOL(Env.lib_handle, "OCIThreadMutexInit", OCIThreadMutexInit, OCITHREADMUTEXINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadMutexDestroy", OCIThreadMutexDestroy, + LIB_SYMBOL(Env.lib_handle, "OCIThreadMutexDestroy", OCIThreadMutexDestroy, OCITHREADMUTEXDESTROY); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadMutexAcquire", OCIThreadMutexAcquire, + LIB_SYMBOL(Env.lib_handle, "OCIThreadMutexAcquire", OCIThreadMutexAcquire, OCITHREADMUTEXACQUIRE); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadMutexRelease", OCIThreadMutexRelease, + LIB_SYMBOL(Env.lib_handle, "OCIThreadMutexRelease", OCIThreadMutexRelease, OCITHREADMUTEXRELEASE); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadKeyInit", OCIThreadKeyInit, + LIB_SYMBOL(Env.lib_handle, "OCIThreadKeyInit", OCIThreadKeyInit, OCITHREADKEYINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadKeyDestroy", OCIThreadKeyDestroy, + LIB_SYMBOL(Env.lib_handle, "OCIThreadKeyDestroy", OCIThreadKeyDestroy, OCITHREADKEYDESTROY); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadKeySet", OCIThreadKeySet, + LIB_SYMBOL(Env.lib_handle, "OCIThreadKeySet", OCIThreadKeySet, OCITHREADKEYSET); - LIB_SYMBOL(OCILib.lib_handle, "OCIThreadKeyGet", OCIThreadKeyGet, + LIB_SYMBOL(Env.lib_handle, "OCIThreadKeyGet", OCIThreadKeyGet, OCITHREADKEYGET); - LIB_SYMBOL(OCILib.lib_handle, "OCIConnectionPoolCreate", OCIConnectionPoolCreate, + LIB_SYMBOL(Env.lib_handle, "OCIConnectionPoolCreate", OCIConnectionPoolCreate, OCICONNECTIONPOOLCREATE); - LIB_SYMBOL(OCILib.lib_handle, "OCIConnectionPoolDestroy", OCIConnectionPoolDestroy, + LIB_SYMBOL(Env.lib_handle, "OCIConnectionPoolDestroy", OCIConnectionPoolDestroy, OCICONNECTIONPOOLDESTROY); - LIB_SYMBOL(OCILib.lib_handle, "OCISessionPoolCreate", OCISessionPoolCreate, + LIB_SYMBOL(Env.lib_handle, "OCISessionPoolCreate", OCISessionPoolCreate, OCISESSIONPOOLCREATE); - LIB_SYMBOL(OCILib.lib_handle, "OCISessionPoolDestroy", OCISessionPoolDestroy, + LIB_SYMBOL(Env.lib_handle, "OCISessionPoolDestroy", OCISessionPoolDestroy, OCISESSIONPOOLDESTROY); - LIB_SYMBOL(OCILib.lib_handle, "OCISessionGet", OCISessionGet, + LIB_SYMBOL(Env.lib_handle, "OCISessionGet", OCISessionGet, OCISESSIONGET); - LIB_SYMBOL(OCILib.lib_handle, "OCISessionRelease", OCISessionRelease, + LIB_SYMBOL(Env.lib_handle, "OCISessionRelease", OCISessionRelease, OCISESSIONRELEASE); - LIB_SYMBOL(OCILib.lib_handle, "OCICollSize", OCICollSize, + LIB_SYMBOL(Env.lib_handle, "OCICollSize", OCICollSize, OCICOLLSIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCICollMax", OCICollMax, + LIB_SYMBOL(Env.lib_handle, "OCICollMax", OCICollMax, OCICOLLMAX); - LIB_SYMBOL(OCILib.lib_handle, "OCICollGetElem", OCICollGetElem, + LIB_SYMBOL(Env.lib_handle, "OCICollGetElem", OCICollGetElem, OCICOLLGETITEM); - LIB_SYMBOL(OCILib.lib_handle, "OCICollAssignElem", OCICollAssignElem, + LIB_SYMBOL(Env.lib_handle, "OCICollAssignElem", OCICollAssignElem, OCICOLLASSIGNELEM); - LIB_SYMBOL(OCILib.lib_handle, "OCICollAssign", OCICollAssign, + LIB_SYMBOL(Env.lib_handle, "OCICollAssign", OCICollAssign, OCICOLLASSIGN); - LIB_SYMBOL(OCILib.lib_handle, "OCICollAppend", OCICollAppend, + LIB_SYMBOL(Env.lib_handle, "OCICollAppend", OCICollAppend, OCICOLLAPPEND); - LIB_SYMBOL(OCILib.lib_handle, "OCICollTrim", OCICollTrim, + LIB_SYMBOL(Env.lib_handle, "OCICollTrim", OCICollTrim, OCICOLLTRIM); - LIB_SYMBOL(OCILib.lib_handle, "OCITableDelete", OCITableDelete, + LIB_SYMBOL(Env.lib_handle, "OCITableDelete", OCITableDelete, OCITABLEDELETE); - LIB_SYMBOL(OCILib.lib_handle, "OCITableSize", OCITableSize, + LIB_SYMBOL(Env.lib_handle, "OCITableSize", OCITableSize, OCITABLESIZE); - LIB_SYMBOL(OCILib.lib_handle, "OCIIterCreate", OCIIterCreate, + LIB_SYMBOL(Env.lib_handle, "OCIIterCreate", OCIIterCreate, OCIITERCREATE); - LIB_SYMBOL(OCILib.lib_handle, "OCIIterDelete", OCIIterDelete, + LIB_SYMBOL(Env.lib_handle, "OCIIterDelete", OCIIterDelete, OCIITERDELETE); - LIB_SYMBOL(OCILib.lib_handle, "OCIIterInit", OCIIterInit, + LIB_SYMBOL(Env.lib_handle, "OCIIterInit", OCIIterInit, OCIITERINIT); - LIB_SYMBOL(OCILib.lib_handle, "OCIIterNext", OCIIterNext, + LIB_SYMBOL(Env.lib_handle, "OCIIterNext", OCIIterNext, OCIITERNEXT); - LIB_SYMBOL(OCILib.lib_handle, "OCIIterPrev", OCIIterPrev, + LIB_SYMBOL(Env.lib_handle, "OCIIterPrev", OCIIterPrev, OCIITERPREV); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathAbort", OCIDirPathAbort, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathAbort", OCIDirPathAbort, OCIDIRPATHABORT); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathDataSave", OCIDirPathDataSave, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathDataSave", OCIDirPathDataSave, OCIDIRPATHDATASAVE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathFinish", OCIDirPathFinish, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathFinish", OCIDirPathFinish, OCIDIRPATHFINISH); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathPrepare", OCIDirPathPrepare, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathPrepare", OCIDirPathPrepare, OCIDIRPATHPREPARE); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathLoadStream", OCIDirPathLoadStream, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathLoadStream", OCIDirPathLoadStream, OCIDIRPATHLOADSTREAM); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathColArrayEntrySet", OCIDirPathColArrayEntrySet, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathColArrayEntrySet", OCIDirPathColArrayEntrySet, OCIDIRPATHCOLARRAYENTRYSET); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathColArrayReset", OCIDirPathColArrayReset, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathColArrayReset", OCIDirPathColArrayReset, OCIDIRPATHCOLARRAYRESET); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathColArrayToStream", OCIDirPathColArrayToStream, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathColArrayToStream", OCIDirPathColArrayToStream, OCIDIRPATHCOLARRAYTOSTREAM); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathStreamReset", OCIDirPathStreamReset, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathStreamReset", OCIDirPathStreamReset, OCIDIRPATHSTREAMRESET); - LIB_SYMBOL(OCILib.lib_handle, "OCIDirPathFlushRow", OCIDirPathFlushRow, + LIB_SYMBOL(Env.lib_handle, "OCIDirPathFlushRow", OCIDirPathFlushRow, OCIDIRPATHFLUSHROW); - LIB_SYMBOL(OCILib.lib_handle, "OCICacheFree", OCICacheFree, + LIB_SYMBOL(Env.lib_handle, "OCICacheFree", OCICacheFree, OCICACHEFREE); - LIB_SYMBOL(OCILib.lib_handle, "OCIPing", OCIPing, + LIB_SYMBOL(Env.lib_handle, "OCIPing", OCIPing, OCIPING); - LIB_SYMBOL(OCILib.lib_handle, "OCIDBStartup", OCIDBStartup, + LIB_SYMBOL(Env.lib_handle, "OCIDBStartup", OCIDBStartup, OCIDBSTARTUP); - LIB_SYMBOL(OCILib.lib_handle, "OCIDBShutdown", OCIDBShutdown, + LIB_SYMBOL(Env.lib_handle, "OCIDBShutdown", OCIDBShutdown, OCIDBSHUTDOWN); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtPrepare2", OCIStmtPrepare2, + LIB_SYMBOL(Env.lib_handle, "OCIStmtPrepare2", OCIStmtPrepare2, OCISTMTPREPARE2); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtRelease", OCIStmtRelease, + LIB_SYMBOL(Env.lib_handle, "OCIStmtRelease", OCIStmtRelease, OCISTMTRELEASE); - LIB_SYMBOL(OCILib.lib_handle, "OCISubscriptionRegister", OCISubscriptionRegister, + LIB_SYMBOL(Env.lib_handle, "OCISubscriptionRegister", OCISubscriptionRegister, OCISUBSCRIPTIONREGISTER); - LIB_SYMBOL(OCILib.lib_handle, "OCISubscriptionUnRegister", OCISubscriptionUnRegister, + LIB_SYMBOL(Env.lib_handle, "OCISubscriptionUnRegister", OCISubscriptionUnRegister, OCISUBSCRIPTIONUNREGISTER); - LIB_SYMBOL(OCILib.lib_handle, "OCIAQEnq", OCIAQEnq, + LIB_SYMBOL(Env.lib_handle, "OCIAQEnq", OCIAQEnq, OCIAQENQ); - LIB_SYMBOL(OCILib.lib_handle, "OCIAQDeq", OCIAQDeq, + LIB_SYMBOL(Env.lib_handle, "OCIAQDeq", OCIAQDeq, OCIAQDEQ); - LIB_SYMBOL(OCILib.lib_handle, "OCIAQListen", OCIAQListen, + LIB_SYMBOL(Env.lib_handle, "OCIAQListen", OCIAQListen, OCIAQLISTEN); - LIB_SYMBOL(OCILib.lib_handle, "xaoSvcCtx", xaoSvcCtx, + LIB_SYMBOL(Env.lib_handle, "xaoSvcCtx", xaoSvcCtx, XAOSVCCTX); - LIB_SYMBOL(OCILib.lib_handle, "xaoEnv", xaoEnv, + LIB_SYMBOL(Env.lib_handle, "xaoEnv", xaoEnv, XAOENV); - LIB_SYMBOL(OCILib.lib_handle, "OCILobGetContentType", OCILobGetContentType, + LIB_SYMBOL(Env.lib_handle, "OCILobGetContentType", OCILobGetContentType, OCILOBGETCONTENTTYPE); - LIB_SYMBOL(OCILib.lib_handle, "OCIStmtGetNextResult", OCIStmtGetNextResult, + LIB_SYMBOL(Env.lib_handle, "OCIStmtGetNextResult", OCIStmtGetNextResult, OCISTMTGETNEXTRESULT); - LIB_SYMBOL(OCILib.lib_handle, "OCIServerRelease2", OCIServerRelease2, + LIB_SYMBOL(Env.lib_handle, "OCIServerRelease2", OCIServerRelease2, OCISERVERRELEASE2); - LIB_SYMBOL(OCILib.lib_handle, "OCISodaOperKeysSet", OCISodaOperKeysSet, - OCISODAOPERKEYSSET); + LIB_SYMBOL(Env.lib_handle, "OCISodaOperKeysSet", OCISodaOperKeysSet, + OCISODAOPERKEYSSET); /* API Version checking */ if (OCISodaOperKeysSet) { - OCILib.version_runtime = OCI_18_3; + Env.version_runtime = OCI_18_3; } else if (OCIServerRelease2) { - OCILib.version_runtime = OCI_18_1; + Env.version_runtime = OCI_18_1; } else if (OCIStmtGetNextResult) { - OCILib.version_runtime = OCI_12_1; + Env.version_runtime = OCI_12_1; } else if (OCILobGetContentType) { - OCILib.version_runtime = OCI_11_2; + Env.version_runtime = OCI_11_2; } else if (OCIArrayDescriptorFree) { - OCILib.version_runtime = OCI_11_1; + Env.version_runtime = OCI_11_1; } else if (OCIClientVersion) { - OCILib.version_runtime = OCI_10_2; + Env.version_runtime = OCI_10_2; } else if (OCILobWrite2) { - OCILib.version_runtime = OCI_10_1; + Env.version_runtime = OCI_10_1; } else if (OCIStmtPrepare2) { - OCILib.version_runtime = OCI_9_2; + Env.version_runtime = OCI_9_2; } else if (OCIDateTimeGetTimeZoneName) { - OCILib.version_runtime = OCI_9_0; + Env.version_runtime = OCI_9_0; } else if (OCIThreadCreate) { - OCILib.version_runtime = OCI_8_1; + Env.version_runtime = OCI_8_1; } else if (OCIEnvCreate) { - OCILib.version_runtime = OCI_8_0; + Env.version_runtime = OCI_8_0; } else { - LIB_CLOSE(OCILib.lib_handle); - OCI_RAISE_EXCEPTION(OCI_ExceptionLoadingSymbols()) + LIB_CLOSE(Env.lib_handle); + THROW_NO_ARGS(ExceptionLoadingSymbols) } } else { - OCI_RAISE_EXCEPTION(OCI_ExceptionLoadingSharedLib()) + THROW_NO_ARGS(ExceptionLoadingSharedLib) } - #if defined(OCI_BIG_UINT_ENABLED) + #if defined(OCI_BIG_UINT_ENABLED) - if ((OCILib.version_runtime >= OCI_10_1) && OCILobCopy2) + if ((Env.version_runtime >= OCI_10_1) && OCILobCopy2) { - OCILib.use_lob_ub8 = TRUE; + Env.use_lob_ub8 = TRUE; } - #endif + #endif - #if defined(OCI_STMT_SCROLLABLE_READONLY) + #if defined(OCI_STMT_SCROLLABLE_READONLY) - if ((OCILib.version_runtime >= OCI_9_0) && OCIStmtFetch2) + if ((Env.version_runtime >= OCI_9_0) && OCIStmtFetch2) { - OCILib.use_scrollable_cursors = TRUE; + Env.use_scrollable_cursors = TRUE; } - #endif + #endif #endif @@ -1578,14 +1381,14 @@ boolean OCI_API OCI_Initialize /* Oracle 8i does not support full Unicode mode */ - if (OCILib.version_runtime < OCI_9_0) + if (Env.version_runtime < OCI_9_0) { - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable(NULL, OCI_FEATURE_WIDE_USERDATA)) + THROW(ExceptionNotAvailable, OCI_FEATURE_WIDE_USERDATA) } #endif - /* Initialize OCI environment */ + /* EnvironmentInitialize OCI environment */ if (mode & OCI_ENV_THREADED) { @@ -1599,605 +1402,438 @@ boolean OCI_API OCI_Initialize /* create environment on success */ - OCI_STATUS = OCI_SUCCESSFUL(OCIEnvCreate(&OCILib.env, oci_mode, - (dvoid *) &OCILib, - OCI_MemAllocOracleClient, - OCI_MemReallocOracleClient, - OCI_MemFreeOracleClient, - (size_t) 0, (dvoid **) NULL)); + ret = OCIEnvCreate(&Env.env, oci_mode, + (dvoid *) &Env, + MemoryAllocOracleCallback, + MemoryReallocOracleCallback, + MemoryFreeOracleCallback, + (size_t) 0, (dvoid **) NULL); /* allocate error handle */ - if (OCI_STATUS) + if (OCI_SUCCESSFUL(ret)) { - OCI_STATUS = OCI_HandleAlloc((dvoid *)OCILib.env, (dvoid **) (void *) &OCILib.err, OCI_HTYPE_ERROR); + CHECK + ( + MemoryAllocHandle + ( + (dvoid *)Env.env, + (dvoid **) (void *) &Env.err, + OCI_HTYPE_ERROR + ) + ) } else { - OCI_RAISE_EXCEPTION(OCI_ExceptionOCIEnvironment()) + THROW_NO_ARGS(ExceptionOCIEnvironment) } /* on success, we need to initialize OCIThread object support */ - if (OCI_STATUS) + if (LIB_THREADED) { - if (OCI_LIB_THREADED) - { - OCIThreadProcessInit(); + OCIThreadProcessInit(); - OCI_STATUS = OCI_SUCCESSFUL(OCIThreadInit(OCILib.env, OCILib.err)); + CHECK_OCI + ( + Env.err, + OCIThreadInit, Env.env, Env.err + ) - OCILib.mem_mutex = OCI_MutexCreateInternal(); - OCI_STATUS = (NULL != OCILib.mem_mutex); - } + Env.mem_mutex= MutexCreateInternal(); + CHECK_NULL(Env.mem_mutex) + } - /* create thread key for thread errors */ + /* create thread key for thread errors */ - if (OCI_STATUS) - { - OCILib.key_errs = OCI_ThreadKeyCreateInternal((POCI_THREADKEYDEST) OCI_ErrorFree); - OCI_STATUS = (NULL != OCILib.key_errs); - } + Env.key_errs = ThreadKeyCreateInternal((POCI_THREADKEYDEST)EnvironmentFreeError); + CHECK_NULL(Env.key_errs) - /* allocate connections internal list */ + /* allocate connections internal list */ - if (OCI_STATUS) - { - OCILib.cons = OCI_ListCreate(OCI_IPC_CONNECTION); - OCI_STATUS = (NULL != OCILib.cons); - } + Env.cons = ListCreate(OCI_IPC_CONNECTION); + CHECK_NULL(Env.cons) - /* allocate pools internal list */ + /* allocate pools internal list */ - if (OCI_STATUS) - { - OCILib.pools = OCI_ListCreate(OCI_IPC_POOL); - OCI_STATUS = (NULL != OCILib.pools); - } + Env.pools = ListCreate(OCI_IPC_POOL); + CHECK_NULL(Env.pools) - #if OCI_VERSION_COMPILE >= OCI_10_2 + /* allocate array internal list */ - /* allocate connection pools internal list */ + Env.arrs = ListCreate(OCI_IPC_ARRAY); + CHECK_NULL(Env.arrs) - if (OCI_STATUS) - { - OCILib.subs = OCI_ListCreate(OCI_IPC_NOTIFY); +#if OCI_VERSION_COMPILE >= OCI_10_2 - OCI_STATUS = (NULL != OCILib.subs); - } + /* allocate connection pools internal list */ - #endif + Env.subs = ListCreate(OCI_IPC_NOTIFY); + CHECK_NULL(Env.subs) - if (OCI_STATUS) - { - OCILib.arrs = OCI_ListCreate(OCI_IPC_ARRAY); - OCI_STATUS = (NULL != OCILib.arrs); - } - } +#endif - OCILib.loaded = OCI_RETVAL = OCI_STATUS; + Env.loaded = TRUE; /* test for XA support */ #ifdef _WINDOWS - #if OCI_VERSION_COMPILE >= OCI_10_1 - OCILib.use_xa = (NULL != xaoEnv); - #else - OCILib.use_xa = FALSE; - #endif + #if OCI_VERSION_COMPILE >= OCI_10_1 + Env.use_xa = (NULL != xaoEnv); + #else + Env.use_xa = FALSE; + #endif #else - OCILib.use_xa = TRUE; + Env.use_xa = TRUE; #endif - OCI_CALL_EXIT() + SET_RETVAL(Env.loaded) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Cleanup + * Cleanup * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Cleanup +boolean EnvironmentCleanup ( void ) { - boolean res = TRUE; - unsigned int i = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + boolean success = FALSE; + + unsigned int i = 0; + + /* exit if the environment is not loaded */ + + success = TRUE; + + /* dispose list items */ + + ListForEach(Env.arrs, (POCI_LIST_FOR_EACH)ArrayDispose); + ListForEach(Env.subs, (POCI_LIST_FOR_EACH)SubscriptionDispose); + ListForEach(Env.cons, (POCI_LIST_FOR_EACH)ConnectionDispose); + ListForEach(Env.pools, (POCI_LIST_FOR_EACH)PoolDispose); /* free all arrays */ - OCI_ListForEach(OCILib.arrs, (POCI_LIST_FOR_EACH) OCI_ArrayClose); - OCI_ListClear(OCILib.arrs); + ListClear(Env.arrs); + ListFree(Env.arrs); /* free all subscriptions */ - OCI_ListForEach(OCILib.subs, (POCI_LIST_FOR_EACH) OCI_SubscriptionClose); - OCI_ListClear(OCILib.subs); + ListClear(Env.subs); + ListFree(Env.subs); /* free all connections */ - OCI_ListForEach(OCILib.cons, (POCI_LIST_FOR_EACH) OCI_ConnectionClose); - OCI_ListClear(OCILib.cons); + ListClear(Env.cons); + ListFree(Env.cons); /* free all pools */ - OCI_ListForEach(OCILib.pools, (POCI_LIST_FOR_EACH) OCI_PoolClose); - OCI_ListClear(OCILib.pools); - - /* free objects */ + ListClear(Env.pools); + ListFree(Env.pools); - OCI_KeyMapFree(); + /* free key map */ - OCI_ListFree(OCILib.cons); - OCI_ListFree(OCILib.pools); - OCI_ListFree(OCILib.subs); - OCI_ListFree(OCILib.arrs); + KeyMapFree(); - OCILib.cons = NULL; - OCILib.pools = NULL; - OCILib.subs = NULL; - OCILib.key_map = NULL; + Env.cons = NULL; + Env.pools = NULL; + Env.subs = NULL; + Env.key_map = NULL; for (i = 0; i < OCI_FMT_COUNT; i++) { - OCI_FREE(OCILib.formats[i]) + FREE(Env.formats[i]) } /* finalize OCIThread object support */ - if (OCI_LIB_THREADED) + if (LIB_THREADED) { /* free the memory mutex. We set its reference in the library structure to NULL first otherwise - it would generate an OCI error when calling OCI_HandleAlloc() for freeing the mutex object error handle + it would generate an OCI error when calling MemoryAllocHandle() for freeing the mutex object error handle */ - OCI_Mutex * mutex = OCILib.mem_mutex; + OCI_Mutex * mutex = Env.mem_mutex; - OCILib.mem_mutex = NULL; + Env.mem_mutex = NULL; - if (mutex) + if (NULL != mutex) { - OCI_MutexFree(mutex); + MutexFree(mutex); } - res = OCI_SUCCESSFUL(OCIThreadTerm(OCILib.env, OCILib.err)); + success = OCI_SUCCESSFUL(OCIThreadTerm(Env.env, Env.err)); } /* free error thread key */ - if (OCILib.key_errs) - { - OCI_ThreadKey *key = OCILib.key_errs; - OCI_Error *err = OCI_ErrorGet(FALSE, FALSE); + if (NULL != Env.key_errs) + { + OCI_ThreadKey *key = Env.key_errs; + OCI_Error *err = ErrorGet(FALSE, FALSE); + + Env.key_errs = NULL; - OCILib.key_errs = NULL; + EnvironmentFreeError(err); - OCI_ErrorFree(err); - OCI_ThreadKeySet(key, NULL); - OCI_ThreadKeyFree(key); + ThreadKeySet(key, NULL); + ThreadKeyFree(key); } /* set unloaded flag */ - OCILib.loaded = FALSE; + Env.loaded = FALSE; /* close error handle */ - if (OCILib.err) + if (NULL != Env.err) { - OCI_HandleFree(OCILib.err, OCI_HTYPE_ERROR); + MemoryFreeHandle(Env.err, OCI_HTYPE_ERROR); } - /* close environment handle - => direct OCIHandleFree() because this handle was not allocated - with OCI_HandleAlloc() - */ + /* close environment handle */ - if (OCILib.env) + if (Env.env) { - OCIHandleFree(OCILib.env, OCI_HTYPE_ENV); + OCIHandleFree(Env.env, OCI_HTYPE_ENV); } #ifdef OCI_IMPORT_RUNTIME - if (OCILib.lib_handle) + if (NULL != Env.lib_handle) { - LIB_CLOSE(OCILib.lib_handle); + LIB_CLOSE(Env.lib_handle); } #endif /* checks for non freed handles */ - if (OCILib.nb_hndlp > 0) + if (Env.nb_hndlp > 0) { - OCI_ExceptionUnfreedData(OCI_HDLE_HANDLE, (int) OCILib.nb_hndlp); - res = FALSE; + ExceptionUnfreedData(&call_context, OCI_HDLE_HANDLE, (int) Env.nb_hndlp); + success = FALSE; } /* checks for non freed descriptors */ - if (OCILib.nb_descp > 0) + if (Env.nb_descp > 0) { - OCI_ExceptionUnfreedData(OCI_HDLE_DESCRIPTOR, (int) OCILib.nb_descp); - res = FALSE; + ExceptionUnfreedData(&call_context, OCI_HDLE_DESCRIPTOR, (int) Env.nb_descp); + success = FALSE; } /* checks for non freed objects */ - if (OCILib.nb_objinst > 0) + if (Env.nb_objinst > 0) + { + ExceptionUnfreedData(&call_context, OCI_HDLE_OBJECT, (int) Env.nb_objinst); + success = FALSE; + } + + /* free environment errors */ + + if (NULL != Env.lib_err) { - OCI_ExceptionUnfreedData(OCI_HDLE_OBJECT, (int) OCILib.nb_objinst); - res = FALSE; + ErrorFree(Env.lib_err); } - memset(&OCILib, 0, sizeof(OCILib)); + /* reset environment object */ - return res; + memset(&Env, 0, sizeof(Env)); + + CHECK(TRUE) + + CLEANUP_AND_EXIT_FUNC + ( + SET_RETVAL(success) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetOCICompileVersion + * EnvironmentGetOCICompileVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetOCICompileVersion +unsigned int EnvironmentGetOCICompileVersion ( void ) { - OCI_GET_LIB_PROP(unsigned int, OCI_UNKNOWN, OCILib.version_compile) + GET_LIB_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* value */ Env.version_compile + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetOCIRuntimeVersion + * EnvironmentGetOCIRuntimeVersion * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetOCIRuntimeVersion +unsigned int EnvironmentGetOCIRuntimeVersion ( void ) { - OCI_GET_LIB_PROP(unsigned int, OCI_UNKNOWN, OCILib.version_runtime) + GET_LIB_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* value */ Env.version_runtime + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetImportMode + * EnvironmentGetOCIRuntimeImportMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetImportMode +unsigned int EnvironmentGetOCIRuntimeImportMode ( void ) { - OCI_GET_LIB_PROP(unsigned int, OCI_UNKNOWN, OCI_IMPORT_MODE) + GET_LIB_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* value */ OCI_IMPORT_MODE + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetCharset + * EnvironmentGetCharset * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetCharset +unsigned int EnvironmentGetCharset ( void ) { - OCI_GET_LIB_PROP(unsigned int, OCI_UNKNOWN, OCI_CHAR_TEXT) + GET_LIB_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* value */ OCI_CHAR_TEXT + ) } /* --------------------------------------------------------------------------------------------- * -* OCI_GetAllocatedBytes +* EnvironmentGetAllocatedBytes * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_GetAllocatedBytes +big_uint EnvironmentGetAllocatedBytes ( unsigned int mem_type ) { - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_INITIALIZED() + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_VOID, &Env + ) + + big_uint bytes_count = 0; + + CHECK_INITIALIZED() if (mem_type & OCI_MEM_ORACLE) { - call_retval += OCILib.mem_bytes_oci; + bytes_count += Env.mem_bytes_oci; } if (mem_type & OCI_MEM_OCILIB) { - call_retval += OCILib.mem_bytes_lib; + bytes_count += Env.mem_bytes_lib; } - OCI_CALL_EXIT() + SET_RETVAL(bytes_count) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLastError + * EnvironmentGetLastError * --------------------------------------------------------------------------------------------- */ -OCI_Error * OCI_API OCI_GetLastError +OCI_Error * EnvironmentGetLastError ( void ) { OCI_Error *err = NULL; - if (!OCILib.loaded || OCILib.env_mode & OCI_ENV_CONTEXT) + if (!Env.loaded || Env.env_mode & OCI_ENV_CONTEXT) { - err = OCI_ErrorGet(TRUE, FALSE); + err = ErrorGet(TRUE, FALSE); - if (err && (!err->raise)) + if (NULL != err && OCI_UNKNOWN == err->code) { err = NULL; } + } return err; } /* --------------------------------------------------------------------------------------------- * - * OCI_EnableWarnings + * EnvironmentEnableWarnings * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_EnableWarnings +boolean EnvironmentEnableWarnings ( boolean value ) { - OCI_SET_LIB_PROP(OCILib.warnings_on, value) - } + SET_LIB_PROP + ( + /* member */ Env.warnings_on, + /* value */ value + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_SetErrorHandler + * EnvironmentSetErrorHandler * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetErrorHandler +boolean EnvironmentSetErrorHandler ( POCI_ERROR handler ) { - OCI_SET_LIB_PROP(OCILib.error_handler, handler) + SET_LIB_PROP + ( + /* member */ Env.error_handler, + /* value */ handler + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DatabaseStartup + * EnvironmentSetHAHandler * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_DatabaseStartup +boolean EnvironmentSetHAHandler ( - const otext *db, - const otext *user, - const otext *pwd, - unsigned int sess_mode, - unsigned int start_mode, - unsigned int start_flag, - const otext *spfile + POCI_HA_HANDLER handler ) { - OCI_Connection *con = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REMOTE_DBS_CONTROL_ENABLED() - -#if OCI_VERSION_COMPILE >= OCI_10_2 - - if (start_mode & OCI_DB_SPM_START) - { - OCIAdmin *adm = NULL; - - /* connect with preliminary authentication mode */ - - con = OCI_ConnectionCreate(db, user, pwd, sess_mode | OCI_PRELIM_AUTH); - - OCI_STATUS = (NULL != con); - - if (OCI_STATUS) - { - if (spfile && spfile[0]) - { - dbtext *dbstr = NULL; - int dbsize = -1; - - /* allocate administration handle */ - - OCI_STATUS = OCI_HandleAlloc((dvoid *)OCILib.env, (dvoid **) (void *) &adm, OCI_HTYPE_ADMIN); - - /* set client file if provided */ - - dbstr = OCI_StringGetOracleString(spfile, &dbsize); - - OCI_SET_ATTRIB(OCI_HTYPE_ADMIN, OCI_ATTR_ADMIN_PFILE, adm, dbstr, dbsize) - - OCI_StringReleaseOracleString(dbstr); - } - - /* startup DB */ - - OCI_EXEC(OCIDBStartup(con->cxt, con->err, (OCIAdmin *) adm, OCI_DEFAULT, start_flag)) - - /* release security administration handle */ - - if (adm) - { - OCI_HandleFree(OCILib.err, OCI_HTYPE_ADMIN); - } - - /* disconnect */ - - OCI_ConnectionFree(con); - } - } - - if (OCI_STATUS) - { - /* connect without preliminary mode */ - - con = OCI_ConnectionCreate(db, user, pwd, sess_mode); - - OCI_STATUS = (NULL != con); - - /* alter database */ - - if (OCI_STATUS) - { - OCI_Statement *stmt = OCI_StatementCreate(con); - - /* mount database */ - - if (start_mode & OCI_DB_SPM_MOUNT) - { - OCI_STATUS = OCI_STATUS && OCI_ExecuteStmt(stmt, OTEXT("ALTER DATABASE MOUNT")); - } - - /* open database */ - - if (start_mode & OCI_DB_SPM_OPEN) - { - OCI_STATUS = OCI_STATUS && OCI_ExecuteStmt(stmt, OTEXT("ALTER DATABASE OPEN")); - } - - OCI_StatementFree(stmt); - - /* disconnect */ - - OCI_ConnectionFree(con); - } - } - -#else - - OCI_NOT_USED(db) - OCI_NOT_USED(user) - OCI_NOT_USED(pwd) - OCI_NOT_USED(sess_mode) - OCI_NOT_USED(start_mode) - OCI_NOT_USED(start_flag) - OCI_NOT_USED(spfile) - OCI_NOT_USED(con) - -#endif + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - call_retval = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_DatabaseShutdown - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_DatabaseShutdown -( - const otext *db, - const otext *user, - const otext *pwd, - unsigned int sess_mode, - unsigned int shut_mode, - unsigned int shut_flag -) -{ - OCI_Connection *con = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REMOTE_DBS_CONTROL_ENABLED() - -#if OCI_VERSION_COMPILE >= OCI_10_2 - - /* connect to server */ - - con = OCI_ConnectionCreate(db, user, pwd, sess_mode); - - OCI_STATUS = (NULL != con); - - if (OCI_STATUS) - { - /* delete current transaction before the abort */ - - if (con->trs && (OCI_DB_SDF_ABORT == shut_flag)) - { - OCI_TransactionFree(con->trs); - - con->trs = NULL; - } - - /* start shutdown */ - - if (shut_mode & OCI_DB_SDM_SHUTDOWN) - { - /* start shutdown process */ - - OCI_EXEC(OCIDBShutdown(con->cxt, con->err, (OCIAdmin *) NULL, shut_flag)) - } - - /* alter database if we are not in abort mode */ - - if (OCI_STATUS && (OCI_DB_SDF_ABORT != shut_flag)) - { - OCI_Statement *stmt = OCI_StatementCreate(con); - - /* close database */ - - if (shut_mode & OCI_DB_SDM_CLOSE) - { - OCI_STATUS = OCI_STATUS && OCI_ExecuteStmt(stmt, OTEXT("ALTER DATABASE CLOSE NORMAL")); - } - - /* unmount database */ - - if (shut_mode & OCI_DB_SDM_DISMOUNT) - { - OCI_STATUS = OCI_STATUS && OCI_ExecuteStmt(stmt, OTEXT("ALTER DATABASE DISMOUNT")); - } - - OCI_StatementFree(stmt); - - /* delete current transaction before the shutdown */ - - if (con->trs) - { - OCI_TransactionFree(con->trs); - - con->trs = NULL; - } - - /* do the final shutdown if we are not in abort mode */ - - OCI_EXEC(OCIDBShutdown(con->cxt, con->err, (OCIAdmin *) 0, OCI_DBSHUTDOWN_FINAL)) - } - - /* disconnect */ - - OCI_ConnectionFree(con); - } - -#else - - OCI_NOT_USED(db) - OCI_NOT_USED(user) - OCI_NOT_USED(pwd) - OCI_NOT_USED(sess_mode) - OCI_NOT_USED(shut_mode) - OCI_NOT_USED(shut_flag) - OCI_NOT_USED(con) - -#endif - - call_retval = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_SetHAHandler - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_SetHAHandler -( - POCI_HA_HANDLER handler -) -{ void *callback = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_HIGH_AVAILABILITY_ENABLED() + CHECK_INITIALIZED() + CHECK_HIGH_AVAILABILITY_ENABLED() #if OCI_VERSION_COMPILE >= OCI_10_2 @@ -2205,25 +1841,27 @@ boolean OCI_API OCI_SetHAHandler As there is no other to way to do regarding the OCI API, let's disable this warning just the time to set the callback attribute to the environment handle */ - #ifdef _MSC_VER + #ifdef _MSC_VER #pragma warning(disable: 4054) - #endif + #endif - if (handler) + if (NULL != handler) { - callback = (void*) OCI_ProcHAEvent; + callback = (void*) CallbackHAEvent; } - OCI_SET_ATTRIB(OCI_HTYPE_ENV, OCI_ATTR_EVTCBK, OCILib.env, callback, 0) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_ENV, OCI_ATTR_EVTCBK, + Env.env, callback, 0, + Env.err + ) - if (OCI_STATUS) - { - OCILib.ha_handler = handler; - } + Env.ha_handler = handler; - #ifdef _MSC_VER + #ifdef _MSC_VER #pragma warning(default: 4054) - #endif + #endif #else @@ -2231,63 +1869,73 @@ boolean OCI_API OCI_SetHAHandler #endif - call_retval = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_SetFormat +* EnvironmentSetFormat * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetFormat +boolean EnvironmentSetFormat ( OCI_Connection *con, unsigned int type, const otext *format ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + otext **value = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, FormatTypeValues, OTEXT("Format Type")) + CHECK_INITIALIZED() + CHECK_ENUM_VALUE(type, FormatTypeValues, OTEXT("Format Type")) - value = con ? &con->formats[type - 1] : &OCILib.formats[type - 1]; + value = con ? &con->formats[type - 1] : &Env.formats[type - 1]; - OCI_FREE(*value) + FREE(*value) - *value = ostrdup(format ? format : FormatDefaultValues[type-1]); + *value = ostrdup(format ? format : FormatDefaultValues[type-1]); - call_retval = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_GetFormat +* EnvironmentGetFormat * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetFormat +const otext * EnvironmentGetFormat ( OCI_Connection *con, unsigned int type ) { + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + otext **value = NULL; - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, FormatTypeValues, OTEXT("Format Type")) + CHECK_INITIALIZED() + CHECK_ENUM_VALUE(type, FormatTypeValues, OTEXT("Format Type")) - value = con ? &con->formats[type-1] : &OCILib.formats[type-1]; + value = con ? &con->formats[type-1] : &Env.formats[type-1]; - if (!*value) + if (NULL == *value) { - OCI_SetFormat(con, type, NULL); + CHECK(EnvironmentSetFormat(con, type, NULL)) } - call_retval = *value; + SET_RETVAL(*value) - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/environment.h b/src/environment.h new file mode 100644 index 00000000..6d251b3e --- /dev/null +++ b/src/environment.h @@ -0,0 +1,101 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_ENVIRONMENT_H_INCLUDED +#define OCILIB_ENVIRONMENT_H_INCLUDED + +#include "types.h" + +char* EnvironmentGetVariable +( + const char* name +); + +OCI_Error* EnvironmentGetLastError +( + void +); + +boolean EnvironmentInitialize +( + POCI_ERROR err_handler, + const otext* lib_path, + unsigned int mode +); + +boolean EnvironmentCleanup +( + void +); + +unsigned int EnvironmentGetOCICompileVersion +( + void +); + +unsigned int EnvironmentGetOCIRuntimeVersion +( + void +); + +unsigned int EnvironmentGetOCIRuntimeImportMode +( + void +); + +unsigned int EnvironmentGetCharset +( + void +); + +big_uint EnvironmentGetAllocatedBytes +( + unsigned int mem_type +); + +boolean EnvironmentEnableWarnings +( + boolean value +); + +boolean EnvironmentSetErrorHandler +( + POCI_ERROR handler +); + +boolean EnvironmentSetHAHandler +( + POCI_HA_HANDLER handler +); + +boolean EnvironmentSetFormat +( + OCI_Connection* con, + unsigned int type, + const otext * format +); + +const otext* EnvironmentGetFormat +( + OCI_Connection* con, + unsigned int type +); + +#endif /* OCILIB_ENVIRONMENT_H_INCLUDED */ diff --git a/src/error.c b/src/error.c index 64f720ea..43ff1862 100644 --- a/src/error.c +++ b/src/error.c @@ -18,210 +18,368 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "error.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "macros.h" +#include "strings.h" +#include "threadkey.h" /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorCreate + * ErrorCreate * --------------------------------------------------------------------------------------------- */ -OCI_Error * OCI_ErrorCreate +OCI_Error * ErrorCreate ( - void ) { return (OCI_Error *) calloc(1, sizeof(OCI_Error)); } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorFree + * ErrorFree * --------------------------------------------------------------------------------------------- */ -void OCI_ErrorFree +void ErrorFree ( OCI_Error *err ) { - if (err == &OCILib.lib_err) + if (NULL != err) { - return; - } + if (NULL != err->message) + { + free(err->message); + } + + if (NULL != err->location) + { + free(err->location); + } - if (err) - { free(err); } } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorReset + * ErrorReset * --------------------------------------------------------------------------------------------- */ -void OCI_ErrorReset +void ErrorReset ( OCI_Error *err ) { if (err) { - err->raise = FALSE; - err->active = FALSE; - err->con = NULL; - err->stmt = NULL; - err->sqlcode = 0; - err->libcode = 0; - err->type = 0; - err->str[0] = 0; + err->active = FALSE; + err->source_ptr = NULL; + err->source_type = OCI_UNKNOWN; + err->type = OCI_UNKNOWN; + err->code = 0; + err->row = 0; + + if (NULL != err->message) + { + err->message[0] = 0; + } + + if (NULL != err->location) + { + err->location[0] = 0; + } + } +} + +/* --------------------------------------------------------------------------------------------- * + * ErrorGet + * --------------------------------------------------------------------------------------------- */ + +void ErrorSet +( + OCI_Error *err, + unsigned int type, + int code, + void *source_ptr, + unsigned int source_type, + const char *location, + otext *message, + unsigned int row +) +{ + err->type = type; + err->code = code; + err->source_ptr = source_ptr; + err->source_type = source_type; + err->row = row; + + size_t len = ostrlen(message); + if (err->message_len < len) + { + err->message = realloc(err->message, len + 1); + } + + ostrcpy(err->message, message); + err->message_len = (unsigned int) len; + + len = strlen(location); + if (err->location_len < len) + { + err->location = realloc(err->location, len + 1); } + + StringAnsiToNative(location, err->location, (unsigned int) len); + err->location_len = (unsigned int) len; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGet + * ErrorGet * --------------------------------------------------------------------------------------------- */ -OCI_Error * OCI_ErrorGet +OCI_Error * ErrorGet ( - boolean check, - boolean reset + boolean check_state, + boolean reset_err ) { - OCI_Error *err = NULL; + OCI_Error *err = Env.lib_err; - if (OCILib.loaded && OCI_LIB_THREADED) + if (Env.loaded && LIB_THREADED) { - if (OCI_ThreadKeyGet(OCILib.key_errs, (void **)(dvoid *)&err)) + if (ThreadKeyGet(Env.key_errs, (void **)(dvoid *)&err)) { - if (!err) + if (NULL == err) { - err = OCI_ErrorCreate(); + err = ErrorCreate(); - if (err) + if (NULL != err) { - OCI_ThreadKeySet(OCILib.key_errs, err); + ThreadKeySet(Env.key_errs, err); } } } } - else - { - err = &OCILib.lib_err; - } - if (check && err && err->active) + if (err != NULL && check_state && err->active) { err = NULL; } - // Reset error in case OCI_ENV_CONTEXT is no used - if (reset && err && err->depth == 0 && err->type != OCI_UNKNOWN) + if (err != NULL && reset_err) { - OCI_ErrorReset(err); + ErrorReset(err); } return err; } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetString + * ErrorGetString * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_ErrorGetString +const otext * ErrorGetString ( OCI_Error *err ) { - OCI_CHECK(NULL == err, NULL); + CHECK_FALSE(NULL == err, NULL); - return err->str; + return err->message; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetType + * ErrorGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ErrorGetType +unsigned int ErrorGetType ( OCI_Error *err ) { - OCI_CHECK(NULL == err, OCI_UNKNOWN); + CHECK_FALSE(NULL == err, OCI_UNKNOWN); return err->type; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetOCICode + * ErrorGetOCICode * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ErrorGetOCICode +int ErrorGetOCICode ( OCI_Error *err ) { - OCI_CHECK(NULL == err, OCI_UNKNOWN); + CHECK_FALSE(NULL == err, OCI_UNKNOWN); - return (int) err->sqlcode; + return err->type == OCI_ERR_OCILIB ? 0 : err->code; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetInternalCode + * ErrorGetInternalCode * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ErrorGetInternalCode +int ErrorGetInternalCode ( OCI_Error *err ) { - OCI_CHECK(NULL == err, 0); + CHECK_FALSE(NULL == err, 0); + + return err->type == OCI_ERR_OCILIB ? err->code : 0; +} + +/* --------------------------------------------------------------------------------------------- * + * ErrorGetSource + * --------------------------------------------------------------------------------------------- */ + +void* ErrorGetSource +( + OCI_Error* err +) +{ + CHECK_FALSE(NULL == err, NULL); + + return err->source_ptr; + +} + +/* --------------------------------------------------------------------------------------------- * + * ErrorGetSourceType + * --------------------------------------------------------------------------------------------- */ + +unsigned int ErrorGetSourceType +( + OCI_Error* err +) +{ + CHECK_FALSE(NULL == err, OCI_UNKNOWN); + + return err->source_type; +} + +/* --------------------------------------------------------------------------------------------- * + * ErrorGetLocation + * --------------------------------------------------------------------------------------------- */ + +const otext* ErrorGetLocation +( + OCI_Error* err +) +{ + CHECK_FALSE(NULL == err, NULL); + + return err->location; - return err->libcode; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetConnection + * ErrorGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_ErrorGetConnection +OCI_Connection * ErrorGetConnection ( OCI_Error *err ) { - OCI_CHECK(NULL == err, NULL); + CHECK_FALSE(NULL == err, NULL); + + if (NULL == err->source_ptr) + { + return NULL; + } - return err->con; + switch (err->source_type) + { + case OCI_IPC_TYPE_INFO: + return ((OCI_TypeInfo*)err->source_ptr)->con; + case OCI_IPC_CONNECTION: + return (OCI_Connection*)err->source_ptr; + case OCI_IPC_TRANSACTION: + return ((OCI_Transaction*)err->source_ptr)->con; + case OCI_IPC_STATEMENT: + return ((OCI_Statement*)err->source_ptr)->con; + case OCI_IPC_RESULTSET: + return ((OCI_Resultset*)err->source_ptr)->stmt->con; + case OCI_IPC_DATE: + return ((OCI_Date*)err->source_ptr)->con; + case OCI_IPC_TIMESTAMP: + return ((OCI_Timestamp*)err->source_ptr)->con; + case OCI_IPC_INTERVAL: + return ((OCI_Interval*)err->source_ptr)->con; + case OCI_IPC_LOB: + return ((OCI_Lob*)err->source_ptr)->con; + case OCI_IPC_FILE: + return ((OCI_File*)err->source_ptr)->con; + case OCI_IPC_LONG: + return ((OCI_Long*)err->source_ptr)->stmt->con; + case OCI_IPC_OBJECT: + return ((OCI_Statement*)err->source_ptr)->con; + case OCI_IPC_COLLECTION: + return ((OCI_Coll*)err->source_ptr)->con; + case OCI_IPC_ITERATOR: + return ((OCI_Iter*)err->source_ptr)->coll->con; + case OCI_IPC_ELEMENT: + return ((OCI_Elem*)err->source_ptr)->con; + case OCI_IPC_NUMBER: + return ((OCI_Number*)err->source_ptr)->con; + case OCI_IPC_BIND: + return ((OCI_Bind*)err->source_ptr)->stmt->con; + case OCI_IPC_REF: + return ((OCI_Ref*)err->source_ptr)->con; + case OCI_IPC_DIRPATH: + return ((OCI_DirPath*)err->source_ptr)->con; + case OCI_IPC_MSG: + return ((OCI_Msg*)err->source_ptr)->typinf->con; + case OCI_IPC_ENQUEUE: + return ((OCI_Enqueue*)err->source_ptr)->typinf->con; + case OCI_IPC_DEQUEUE: + return ((OCI_Dequeue*)err->source_ptr)->typinf->con; + case OCI_IPC_AGENT: + return ((OCI_Agent*)err->source_ptr)->con; + } + + return NULL; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetStatement + * ErrorGetStatement * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_API OCI_ErrorGetStatement +OCI_Statement * ErrorGetStatement ( OCI_Error *err ) { - OCI_CHECK(NULL == err, NULL); + CHECK_FALSE(NULL == err, NULL); + + if (NULL == err->source_ptr) + { + return NULL; + } + + switch (err->source_type) + { + case OCI_IPC_STATEMENT: + return (OCI_Statement*) err->source_ptr; + case OCI_IPC_RESULTSET: + return ((OCI_Resultset*)err->source_ptr)->stmt; + case OCI_IPC_BIND: + return ((OCI_Bind*)err->source_ptr)->stmt; + } - return err->stmt; + return NULL; } /* --------------------------------------------------------------------------------------------- * - * OCI_ErrorGetRow + * ErrorGetRow * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ErrorGetRow +unsigned int ErrorGetRow ( OCI_Error *err ) { - OCI_CHECK(NULL == err, 0); + CHECK_FALSE(NULL == err, 0); return err->row; } diff --git a/src/error.h b/src/error.h new file mode 100644 index 00000000..a609604c --- /dev/null +++ b/src/error.h @@ -0,0 +1,107 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_ERROR_H_INCLUDED +#define OCILIB_ERROR_H_INCLUDED + +#include "types.h" + +OCI_Error * ErrorCreate +( +); + +void ErrorFree +( + OCI_Error *err +); + +void ErrorReset +( + OCI_Error *err +); + +void ErrorSet +( + OCI_Error *err, + unsigned int type, + int code, + void *source_ptr, + unsigned int source_type, + const char *location, + otext *message, + unsigned int row); + +OCI_Error * ErrorGet +( + boolean check_state, + boolean reset_err +); + +const otext* ErrorGetString +( + OCI_Error* err +); + +unsigned int ErrorGetType +( + OCI_Error* err +); + +int ErrorGetOCICode +( + OCI_Error* err +); + +int ErrorGetInternalCode +( + OCI_Error* err +); + +void* ErrorGetSource +( + OCI_Error* err +); + +unsigned int ErrorGetSourceType +( + OCI_Error* err +); + +const otext* ErrorGetLocation +( + OCI_Error* err +); + +OCI_Connection* ErrorGetConnection +( + OCI_Error* err +); + +OCI_Statement* ErrorGetStatement +( + OCI_Error* err +); + +unsigned int ErrorGetRow +( + OCI_Error* err +); + +#endif /* OCILIB_ERROR_H_INCLUDED */ diff --git a/src/event.c b/src/event.c index 7bed73ae..7c3552bc 100644 --- a/src/event.c +++ b/src/event.c @@ -18,22 +18,26 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "event.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "macros.h" /* --------------------------------------------------------------------------------------------- * - * OCI_EventReset + * EventReset * --------------------------------------------------------------------------------------------- */ -boolean OCI_EventReset +boolean EventReset ( OCI_Event *event ) { - OCI_CHECK(NULL == event, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_EVENT, event + ) + + CHECK_PTR(OCI_IPC_EVENT, event) event->op = OCI_UNKNOWN; event->type = OCI_UNKNOWN; @@ -53,81 +57,109 @@ boolean OCI_EventReset event->rowid[0] = 0; } - return TRUE; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_EventGetType + * EventGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_EventGetType +unsigned int EventGetType ( OCI_Event *event ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_EVENT, event, type, event->sub->con, NULL, event->sub->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_EVENT, event, + /* member */ type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EventGetOperation + * EventGetOperation * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_EventGetOperation +unsigned int EventGetOperation ( OCI_Event *event ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_EVENT, event, op, event->sub->con, NULL, event->sub->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_EVENT, event, + /* member */ op + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EventGetDatabase + * EventGetDatabase * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_EventGetDatabase +const otext * EventGetDatabase ( OCI_Event *event ) { - OCI_GET_PROP(const otext *, NULL, OCI_IPC_EVENT, event, dbname, event->sub->con, NULL, event->sub->err) + GET_PROP + ( + /* result */ const otext *, NULL, + /* handle */ OCI_IPC_EVENT, event, + /* member */ dbname + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EventGetObject + * EventGetObject * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_EventGetObject +const otext * EventGetObject ( OCI_Event *event ) { - OCI_GET_PROP(const otext *, NULL, OCI_IPC_EVENT, event, objname, event->sub->con, NULL, event->sub->err) + GET_PROP + ( + /* result */ const otext *, NULL, + /* handle */ OCI_IPC_EVENT, event, + /* member */ objname + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EventGetRowid + * EventGetRowid * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_EventGetRowid +const otext * EventGetRowid ( OCI_Event *event ) { - OCI_GET_PROP(const otext *, NULL, OCI_IPC_EVENT, event, rowid, event->sub->con, NULL, event->sub->err) + GET_PROP + ( + /* result */ const otext *, NULL, + /* handle */ OCI_IPC_EVENT, event, + /* member */ rowid + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_EventGetSubscription + * EventGetSubscription * --------------------------------------------------------------------------------------------- */ -OCI_Subscription * OCI_API OCI_EventGetSubscription +OCI_Subscription * EventGetSubscription ( OCI_Event *event ) { - OCI_GET_PROP(OCI_Subscription *, NULL, OCI_IPC_EVENT, event, sub, event->sub->con, NULL, event->sub->err) + GET_PROP + ( + /* result */ OCI_Subscription *, NULL, + /* handle */ OCI_IPC_EVENT, event, + /* member */ sub + ) } diff --git a/src/event.h b/src/event.h new file mode 100644 index 00000000..4736b8f9 --- /dev/null +++ b/src/event.h @@ -0,0 +1,61 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_EVENT_H_INCLUDED +#define OCILIB_EVENT_H_INCLUDED + +#include "types.h" + +boolean EventReset +( + OCI_Event *evt +); + +unsigned int EventGetType +( + OCI_Event * event +); + +unsigned int EventGetOperation +( + OCI_Event * event +); + +const otext * EventGetDatabase +( + OCI_Event * event +); + +const otext * EventGetObject +( + OCI_Event * event +); + +const otext * EventGetRowid +( + OCI_Event * event +); + +OCI_Subscription * EventGetSubscription +( + OCI_Event * event +); + +#endif /* OCILIB_EVENT_H_INCLUDED */ diff --git a/src/exception.c b/src/exception.c index e654b929..4e2afd7f 100644 --- a/src/exception.c +++ b/src/exception.c @@ -18,13 +18,12 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "exception.h" -/* ********************************************************************************************* * - * STRINGS MESSAGES - * ********************************************************************************************* */ +#include "error.h" +#include "strings.h" -static const otext * OCILib_TypeNames[OCI_IPC_COUNT] = +static const otext * TypeNames[OCI_IPC_COUNT] = { OTEXT("Oracle memory"), @@ -97,7 +96,7 @@ static const otext * OCILib_TypeNames[OCI_IPC_COUNT] = #if defined(OCI_CHARSET_WIDE) && !defined(_MSC_VER) -static const otext * OCILib_ErrorMsg[OCI_ERR_COUNT] = +static const otext * ErrorMessages[OCI_ERR_COUNT] = { OTEXT("No error"), OTEXT("OCILIB has not been initialized"), @@ -134,7 +133,7 @@ static const otext * OCILib_ErrorMsg[OCI_ERR_COUNT] = #else -static const otext * OCILib_ErrorMsg[OCI_ERR_COUNT] = +static const otext * ErrorMessages[OCI_ERR_COUNT] = { OTEXT("No error"), OTEXT("OCILIB has not been initialized"), @@ -171,7 +170,7 @@ static const otext * OCILib_ErrorMsg[OCI_ERR_COUNT] = #endif -static const otext * OCILib_OraFeatures[OCI_FEATURE_COUNT] = +static const otext * OracleFeatures[OCI_FEATURE_COUNT] = { OTEXT("Oracle 9.0 support for Unicode data"), OTEXT("Oracle 9.0 Timestamps and Intervals"), @@ -185,13 +184,13 @@ static const otext * OCILib_OraFeatures[OCI_FEATURE_COUNT] = OTEXT("Oracle 12c R1 PL/SQL extended support") }; -typedef struct OCI_StmtStateTable +typedef struct StatementState { - int state; + int state; const otext *name; -} OCI_StmtStateTable; +} StatementState; -static const OCI_StmtStateTable OCILib_StmtStates[OCI_STMT_STATES_COUNT] = +static const StatementState StatementStates[OCI_STMT_STATES_COUNT] = { { OCI_STMT_CLOSED, OTEXT("closed") }, { OCI_STMT_PARSED, OTEXT("parsed") }, @@ -200,7 +199,7 @@ static const OCI_StmtStateTable OCILib_StmtStates[OCI_STMT_STATES_COUNT] = { OCI_STMT_EXECUTED, OTEXT("executed") } }; -static const otext * OCILib_DirPathStates[OCI_DPS_COUNT] = +static const otext * DirPathStates[OCI_DPS_COUNT] = { OTEXT("non prepared"), OTEXT("prepared"), @@ -208,40 +207,79 @@ static const otext * OCILib_DirPathStates[OCI_DPS_COUNT] = OTEXT("terminated") }; -static const otext * OCILib_HandleNames[OCI_HDLE_COUNT] = +static const otext * HandleNames[OCI_HDLE_COUNT] = { OTEXT("OCI handle"), OTEXT("OCI descriptors"), OTEXT("OCI Object handles") }; -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionGetError +#define EXCEPTION_IMPL(err_code, ...) \ + \ + OCI_Error *err = ExceptionGetError(); \ + if (err) \ + { \ + otext message[512]; \ + osprintf(message, osizeof(message) - (size_t)1, \ + ErrorMessages[err_code], __VA_ARGS__); \ + \ + ErrorSet \ + ( \ + err, \ + OCI_ERR_OCILIB, \ + (int)(err_code), \ + ctx->source_ptr, \ + ctx->source_type, \ + ctx->location, \ + message, \ + 0 \ + ); \ + \ + ExceptionCallHandler(err); \ + } \ + + +#define EXCEPTION_IMPL_NO_ARGS(err_code) \ + \ + OCI_Error *err = ExceptionGetError(); \ + if (err) \ + { \ + otext message[512]; \ + osprintf(message, osizeof(message) - (size_t)1, \ + ErrorMessages[err_code]); \ + \ + ErrorSet \ + ( \ + err, \ + OCI_ERR_OCILIB, \ + (int)(err_code), \ + ctx->source_ptr, \ + ctx->source_type, \ + ctx->location, \ + message, \ + 0 \ + ); \ + \ + ExceptionCallHandler(err); \ + } \ + +/* --------------------------------------------------------------------------------------------- * + * ExceptionGetError * --------------------------------------------------------------------------------------------- */ -OCI_Error * OCI_ExceptionGetError +OCI_Error * ExceptionGetError ( void ) { - OCI_Error *err = OCI_ErrorGet(TRUE, FALSE); - - if (err) - { - OCI_ErrorReset(err); - } - return err; + return ErrorGet(TRUE, TRUE); } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionRaise + * ExceptionCallHandler * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionRaise +void ExceptionCallHandler ( OCI_Error *err ) @@ -250,9 +288,9 @@ void OCI_ExceptionRaise { err->active = TRUE; - if (OCILib.error_handler) + if (Env.error_handler) { - OCILib.error_handler(err); + Env.error_handler(err); } err->active = FALSE; @@ -260,892 +298,481 @@ void OCI_ExceptionRaise } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionOCI + * ExceptionOCI * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionOCI +void ExceptionOCI ( - OCIError *p_err, - OCI_Connection *con, - OCI_Statement *stmt, - boolean warning + OCI_Context *ctx, + OCIError * oci_err, + sword call_ret ) { - OCI_Error *err = OCI_ExceptionGetError(); - + OCI_Error *err = ExceptionGetError(); if (err) { - int dbsize = (int) (osizeof(err->str) - (size_t) 1); - dbtext *dbstr = OCI_StringGetOracleString(err->str, &dbsize); + sb4 err_code = 0; + otext buffer[512]; + int err_size = osizeof(buffer); + const boolean warning = OCI_SUCCESS_WITH_INFO == call_ret; - err->type = (warning ? OCI_ERR_WARNING : OCI_ERR_ORACLE); - err->con = con; - err->stmt = stmt; + dbtext * err_msg = StringGetDBString(buffer, &err_size); - /* get oracle description */ + buffer[0] = 0; - OCIErrorGet((dvoid *) p_err, (ub4) 1, (OraText *) NULL, &err->sqlcode, - (OraText *) dbstr, (ub4) dbsize, (ub4) OCI_HTYPE_ERROR); + OCIErrorGet((dvoid *)oci_err, (ub4)1, (OraText *)NULL, &err_code, + (OraText *)err_msg, (ub4)err_size, (ub4)OCI_HTYPE_ERROR); - OCI_StringCopyOracleStringToNativeString(dbstr, err->str, dbcharcount(dbsize)); - OCI_StringReleaseOracleString(dbstr); - } + if (err_code == 0 && err_msg[0] == 0) + { + /* for some OCI call might return an error but OCIErrorGet() not giving more + * information. thus let's provide a message in this case known OCI errors */ + + switch (call_ret) + { + case OCI_SUCCESS: + ostrcpy(buffer, OTEXT("Oracle Client error: OCI_SUCCESS")); + break; + case OCI_SUCCESS_WITH_INFO: + ostrcpy(buffer, OTEXT("Oracle Client error: OCI_SUCCESS_WITH_INFO")); + break; + case OCI_ERROR: + ostrcpy(buffer, OTEXT("Oracle Client error: OCI_ERROR")); + break; + case OCI_INVALID_HANDLE: + ostrcpy(buffer, OTEXT("Oracle Client error: OCI_INVALID_HANDLE")); + break; + case OCI_NEED_DATA: + ostrcpy(buffer, OTEXT("Oracle Client error: OCI_NEED_DATA")); + break; + case OCI_STILL_EXECUTING: + ostrcpy(buffer, OTEXT("Oracle Client error: OCI_STILL_EXECUTING")); + break; + default: + osprintf(buffer, osizeof(buffer) - (size_t)1, + OTEXT("Oracle Client error: OCI error code [%d]"), call_ret); + break; + } + } + + ErrorSet + ( + err, + (warning ? OCI_ERR_WARNING : OCI_ERR_ORACLE), + (int)err_code, + ctx->source_ptr, + ctx->source_type, + ctx->location, + buffer, + 0 + ); - OCI_ExceptionRaise(err); + StringReleaseDBString(err_msg); + + ExceptionCallHandler(err); + } } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionNotInitialized + * ExceptionNotInitialized * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionNotInitialized +void ExceptionNotInitialized ( - void + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_NOT_INITIALIZED; - - ostrncat(err->str, OCILib_ErrorMsg[OCI_ERR_NOT_INITIALIZED], osizeof(err->str) - (size_t) 1); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL_NO_ARGS(OCI_ERR_NOT_INITIALIZED) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionLoadingShareLib + * ExceptionLoadingShareLib * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionLoadingSharedLib +void ExceptionLoadingSharedLib ( - void + OCI_Context* ctx ) { #ifdef OCI_IMPORT_RUNTIME - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_LOADING_SHARED_LIB; - - osprintf(err->str, osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_LOADING_SHARED_LIB], - OCI_DL_NAME); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_LOADING_SHARED_LIB, OCI_DL_NAME) #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionLoadingSymbols + * ExceptionLoadingSymbols * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionLoadingSymbols +void ExceptionLoadingSymbols ( - void + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_LOADING_SYMBOLS; - - ostrncat(err->str, OCILib_ErrorMsg[OCI_ERR_LOADING_SYMBOLS], osizeof(err->str) - (size_t) 1); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL_NO_ARGS(OCI_ERR_LOADING_SYMBOLS) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionNotMultithreaded + * ExceptionNotMultithreaded * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionNotMultithreaded +void ExceptionNotMultithreaded ( - void + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_MULTITHREADED; - - ostrncat(err->str, OCILib_ErrorMsg[OCI_ERR_MULTITHREADED], osizeof(err->str) - (size_t) 1); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL_NO_ARGS(OCI_ERR_MULTITHREADED) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionNullPointer + * ExceptionNullPointer * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionNullPointer +void ExceptionNullPointer ( - int type + OCI_Context* ctx, + int type ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_NULL_POINTER; - - osprintf(err->str, osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_NULL_POINTER], - OCILib_TypeNames[type+1]); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_NULL_POINTER, TypeNames[type + 1]) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionMemory + * ExceptionMemory * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionMemory +void ExceptionMemory ( - int type, - size_t nb_bytes, - OCI_Connection *con, - OCI_Statement *stmt + OCI_Context* ctx, + int type, + size_t nb_bytes ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_MEMORY; - err->con = con; - err->stmt = stmt; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_MEMORY], - OCILib_TypeNames[type+1], - nb_bytes); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_MEMORY, TypeNames[type + 1], nb_bytes) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionNotAvailable + * ExceptionNotAvailable * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionNotAvailable +void ExceptionNotAvailable ( - OCI_Connection *con, - int feature + OCI_Context* ctx, + int feature ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_NOT_AVAILABLE; - err->con = con; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_NOT_AVAILABLE], - OCILib_OraFeatures[feature-1]); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_NOT_AVAILABLE, OracleFeatures[feature - 1]) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionDatatypeNotSupported + * ExceptionDatatypeNotSupported * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionDatatypeNotSupported +void ExceptionDatatypeNotSupported ( - OCI_Connection *con, - OCI_Statement *stmt, - int code + OCI_Context* ctx, + int code ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_DATATYPE_NOT_SUPPORTED; - err->con = con; - err->stmt = stmt; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_DATATYPE_NOT_SUPPORTED], - code); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_DATATYPE_NOT_SUPPORTED, code) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionParsingError + * ExceptionParsingError * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionParsingToken +void ExceptionParsingToken ( - OCI_Connection *con, - OCI_Statement *stmt, - otext token + OCI_Context* ctx, + otext token ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_PARSE_TOKEN; - err->con = con; - err->stmt = stmt; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_PARSE_TOKEN], - token); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_PARSE_TOKEN, token) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionMappingArgument + * ExceptionMappingArgument * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionMappingArgument +void ExceptionMappingArgument ( - OCI_Connection *con, - OCI_Statement *stmt, - int arg + OCI_Context* ctx, + int arg ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_MAP_ARGUMENT; - err->con = con; - err->stmt = stmt; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_MAP_ARGUMENT], - arg); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_MAP_ARGUMENT, arg) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionOutOfBounds + * ExceptionOutOfBounds * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionOutOfBounds +void ExceptionOutOfBounds ( - OCI_Connection *con, - int value + OCI_Context* ctx, + int value ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_OUT_OF_BOUNDS; - err->con = con; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_OUT_OF_BOUNDS], - value); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_OUT_OF_BOUNDS, value) } /* --------------------------------------------------------------------------------------------- * * OCI_ExceptionUnfreedData * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionUnfreedData +void ExceptionUnfreedData ( - int type_elem, - int nb_elem + OCI_Context* ctx, + int type_elem, + int nb_elem ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_UNFREED_DATA; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_UNFREED_DATA], - nb_elem, OCILib_HandleNames[type_elem-1]); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_UNFREED_DATA, nb_elem, HandleNames[type_elem - 1]) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionRuntimeLoading + * ExceptionRuntimeLoading * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionMaxBind +void ExceptionMaxBind ( - OCI_Statement *stmt + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_MAX_BIND; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_MAX_BIND], - OCI_BIND_MAX); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_MAX_BIND, OCI_BIND_MAX) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionAttributeNotFound + * ExceptionAttributeNotFound * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionAttributeNotFound +void ExceptionAttributeNotFound ( - OCI_Connection *con, - const otext *attr + OCI_Context* ctx, + const otext *attr ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_ATTR_NOT_FOUND; - err->con = con; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_ATTR_NOT_FOUND], - attr); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_ATTR_NOT_FOUND, attr) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionMinimumValue + * ExceptionMinimumValue * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionMinimumValue +void ExceptionMinimumValue ( - OCI_Connection *con, - OCI_Statement *stmt, - int min + OCI_Context* ctx, + int min ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_MIN_VALUE; - err->con = con; - err->stmt = stmt; - - osprintf(err->str, osizeof(err->str) - (size_t) 1, OCILib_ErrorMsg[OCI_ERR_MIN_VALUE], min); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_MIN_VALUE, min) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionTypeNotCompatible + * ExceptionTypeNotCompatible * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionTypeNotCompatible +void ExceptionTypeNotCompatible ( - OCI_Connection *con + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_NOT_COMPATIBLE; - err->con = con; - - ostrncat(err->str, OCILib_ErrorMsg[OCI_ERR_NOT_COMPATIBLE], osizeof(err->str) - (size_t) 1); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL_NO_ARGS(OCI_ERR_NOT_COMPATIBLE) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionStatementState + * ExceptionStatementState * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionStatementState +void ExceptionStatementState ( - OCI_Statement *stmt, - int state + OCI_Context* ctx, + int state ) { - OCI_Error *err = OCI_ExceptionGetError(); + int i = 0, index = 0; - if (err) + for (; i < OCI_STMT_STATES_COUNT; i++) { - int index = 0; - - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_STMT_STATE; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - for(int i = 0; i < OCI_STMT_STATES_COUNT; i++) + if (state == StatementStates[i].state) { - if (state == OCILib_StmtStates[i].state) - { - index = i; - break; - } + index = i; + break; } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_STMT_STATE], - OCILib_StmtStates[index].name); } - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_STMT_STATE, StatementStates[index].name) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionStatementNotScrollable + * ExceptionStatementNotScrollable * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionStatementNotScrollable +void ExceptionStatementNotScrollable ( - OCI_Statement *stmt + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_STMT_NOT_SCROLLABLE; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - ostrncat(err->str, OCILib_ErrorMsg[OCI_ERR_STMT_NOT_SCROLLABLE], osizeof(err->str) - (size_t) 1); - - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL_NO_ARGS(OCI_ERR_STMT_NOT_SCROLLABLE) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionBindAlreadyUsed + * ExceptionBindAlreadyUsed * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionBindAlreadyUsed +void ExceptionBindAlreadyUsed ( - OCI_Statement *stmt, - const otext * bind + OCI_Context * ctx, + const otext * bind ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_BIND_ALREADY_USED; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_BIND_ALREADY_USED], - bind); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_BIND_ALREADY_USED, bind) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionBindArraySize + * ExceptionBindArraySize * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionBindArraySize +void ExceptionBindArraySize ( - OCI_Statement *stmt, - unsigned int maxsize, - unsigned int cursize, - unsigned int newsize + OCI_Context* ctx, + unsigned int maxsize, + unsigned int cursize, + unsigned int newsize ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_BIND_ARRAY_SIZE; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_BIND_ARRAY_SIZE], - maxsize, cursize, newsize); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_BIND_ARRAY_SIZE, maxsize, cursize, newsize) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionDirPathColNotFound + * ExceptionDirPathColNotFound * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionDirPathColNotFound +void ExceptionDirPathColNotFound ( - OCI_DirPath *dp, + OCI_Context * ctx, const otext * column, const otext *table ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_COLUMN_NOT_FOUND; - err->stmt = NULL; - - if (dp) - { - err->con = dp->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_COLUMN_NOT_FOUND], - column, - table); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_COLUMN_NOT_FOUND, column, table) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionDirPathState + * ExceptionDirPathState * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionDirPathState +void ExceptionDirPathState ( - OCI_DirPath *dp, + OCI_Context* ctx, int state ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_DIRPATH_STATE; - err->stmt = NULL; - - if (dp) - { - err->con = dp->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_DIRPATH_STATE], - OCILib_DirPathStates[state-1]); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_DIRPATH_STATE, DirPathStates[state - 1]) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionOCIEnvironment + * ExceptionOCIEnvironment * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionOCIEnvironment +void ExceptionOCIEnvironment ( - void + OCI_Context* ctx ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_CREATE_OCI_ENVIRONMENT; - - ostrncat(err->str, OCILib_ErrorMsg[OCI_ERR_CREATE_OCI_ENVIRONMENT], osizeof(err->str) - (size_t) 1); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL_NO_ARGS(OCI_ERR_CREATE_OCI_ENVIRONMENT) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionRebindBadDatatype + * ExceptionRebindBadDatatype * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionRebindBadDatatype +void ExceptionRebindBadDatatype ( - OCI_Statement *stmt, - const otext * bind + OCI_Context * ctx, + const otext * bind ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_REBIND_BAD_DATATYPE; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_REBIND_BAD_DATATYPE], - bind); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_REBIND_BAD_DATATYPE, bind) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExceptionTypeInfoWrongType + * ExceptionTypeInfoWrongType * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionTypeInfoWrongType +void ExceptionTypeInfoWrongType ( - OCI_Connection *con, - const otext * name + OCI_Context * ctx, + const otext * name ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_TYPEINFO_DATATYPE; - err->stmt = NULL; - err->con = con; - - osprintf(err->str, - osizeof(err->str) - (size_t) 1, - OCILib_ErrorMsg[OCI_ERR_TYPEINFO_DATATYPE], - name); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_TYPEINFO_DATATYPE, name) } /* --------------------------------------------------------------------------------------------- * -* OCI_ExceptionItemNotFound +* ExceptionItemNotFound * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionItemNotFound +void ExceptionItemNotFound ( - OCI_Connection *con, - OCI_Statement *stmt, - const otext *name, - unsigned int type + OCI_Context* ctx, + const otext *name, + unsigned int type ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_ITEM_NOT_FOUND; - err->stmt = stmt; - err->con = con; - - osprintf(err->str, - osizeof(err->str) - (size_t)1, - OCILib_ErrorMsg[OCI_ERR_ITEM_NOT_FOUND], - name, type); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_ITEM_NOT_FOUND, name, type) } /* --------------------------------------------------------------------------------------------- * -* OCI_ExceptionArgInvalidValue +* ExceptionArgInvalidValue * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionArgInvalidValue +void ExceptionArgInvalidValue ( - OCI_Connection *con, - OCI_Statement *stmt, - const otext *name, - unsigned int value + OCI_Context* ctx, + const otext *name, + unsigned int value ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_ARG_INVALID_VALUE; - err->stmt = stmt; - err->con = con; - - osprintf(err->str, - osizeof(err->str) - (size_t)1, - OCILib_ErrorMsg[OCI_ERR_ARG_INVALID_VALUE], - name, value); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_ARG_INVALID_VALUE, name, value) } /* --------------------------------------------------------------------------------------------- * -* OCI_ExceptionEnvFromXaString +* ExceptionEnvFromXaString * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionEnvFromXaString +void ExceptionEnvFromXaString ( + OCI_Context* ctx, const otext *value ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_XA_ENV_FROM_STRING; - err->stmt = NULL; - err->con = NULL; - - osprintf(err->str, - osizeof(err->str) - (size_t)1, - OCILib_ErrorMsg[OCI_ERR_XA_ENV_FROM_STRING], - value); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_XA_ENV_FROM_STRING, value) } /* --------------------------------------------------------------------------------------------- * -* OCI_ExceptionConnFromXaString +* ExceptionConnFromXaString * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionConnFromXaString +void ExceptionConnFromXaString ( + OCI_Context* ctx, const otext *value ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_XA_CONN_FROM_STRING; - err->stmt = NULL; - err->con = NULL; - - osprintf(err->str, - osizeof(err->str) - (size_t)1, - OCILib_ErrorMsg[OCI_ERR_XA_CONN_FROM_STRING], - value); - } - - OCI_ExceptionRaise(err); + EXCEPTION_IMPL(OCI_ERR_XA_CONN_FROM_STRING, value) } /* --------------------------------------------------------------------------------------------- * -* OCI_ExceptionExternalBindingNotAllowed +* ExceptionExternalBindingNotAllowed * --------------------------------------------------------------------------------------------- */ -void OCI_ExceptionExternalBindingNotAllowed +void ExceptionExternalBindingNotAllowed ( - OCI_Statement *stmt, - const otext *bind + OCI_Context* ctx, + const otext *bind ) { - OCI_Error *err = OCI_ExceptionGetError(); - - if (err) - { - err->type = OCI_ERR_OCILIB; - err->libcode = OCI_ERR_BIND_EXTERNAL_NOT_ALLOWED; - err->stmt = stmt; - - if (stmt) - { - err->con = stmt->con; - } - - osprintf(err->str, - osizeof(err->str) - (size_t)1, - OCILib_ErrorMsg[OCI_ERR_BIND_EXTERNAL_NOT_ALLOWED], - bind); - } - - OCI_ExceptionRaise(err); - + EXCEPTION_IMPL(OCI_ERR_BIND_EXTERNAL_NOT_ALLOWED, bind) } \ No newline at end of file diff --git a/src/exception.h b/src/exception.h new file mode 100644 index 00000000..dd25ea48 --- /dev/null +++ b/src/exception.h @@ -0,0 +1,217 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_EXCEPTION_H_INCLUDED +#define OCILIB_EXCEPTION_H_INCLUDED + +#include "types.h" + +OCI_Error* ExceptionGetError +( + void +); + +void ExceptionOCI +( + OCI_Context* ctx, + OCIError *oci_err, + sword call_ret +); + +void ExceptionMemory +( + OCI_Context* ctx, + int type, + size_t nb_bytes +); + +void ExceptionNotAvailable +( + OCI_Context* ctx, + int feature +); + +void ExceptionNullPointer +( + OCI_Context* ctx, + int type +); + +void ExceptionDatatypeNotSupported +( + OCI_Context* ctx, + int code +); + +void ExceptionParsingToken +( + OCI_Context* ctx, + otext token +); + +void ExceptionMappingArgument +( + OCI_Context* ctx, + int arg +); + +void ExceptionNotInitialized +( + OCI_Context* ctx +); + +void ExceptionLoadingSharedLib +( + OCI_Context* ctx +); + +void ExceptionLoadingSymbols +( + OCI_Context* ctx +); + +void ExceptionNotMultithreaded +( + OCI_Context* ctx +); + +void ExceptionOutOfBounds +( + OCI_Context* ctx, + int value +); + +void ExceptionUnfreedData +( + OCI_Context* ctx, + int type_elem, + int nb_elem +); + +void ExceptionMaxBind +( + OCI_Context* ctx +); + +void ExceptionAttributeNotFound +( + OCI_Context * ctx, + const otext * attr +); + +void ExceptionMinimumValue +( + OCI_Context* ctx, + int min +); + +void ExceptionTypeNotCompatible +( + OCI_Context* ctx +); + +void ExceptionStatementState +( + OCI_Context* ctx, + int state +); + +void ExceptionStatementNotScrollable +( + OCI_Context* ctx +); + +void ExceptionBindAlreadyUsed +( + OCI_Context * ctx, + const otext * bind +); + +void ExceptionBindArraySize +( + OCI_Context* ctx, + unsigned int maxsize, + unsigned int cursize, + unsigned int newsize +); + +void ExceptionDirPathColNotFound +( + OCI_Context* ctx, + const otext* column, + const otext* table +); + +void ExceptionDirPathState +( + OCI_Context* ctx, + int state +); + +void ExceptionOCIEnvironment +( + OCI_Context* ctx +); + +void ExceptionRebindBadDatatype +( + OCI_Context * ctx, + const otext * bind +); + +void ExceptionTypeInfoWrongType +( + OCI_Context * ctx, + const otext * name +); + +void ExceptionItemNotFound +( + OCI_Context * ctx, + const otext * name, + unsigned int type +); + +void ExceptionArgInvalidValue +( + OCI_Context * ctx, + const otext * name, + unsigned int value +); + +void ExceptionEnvFromXaString +( + OCI_Context* ctx, + const otext* value +); + +void ExceptionConnFromXaString +( + OCI_Context* ctx, + const otext* value +); + +void ExceptionExternalBindingNotAllowed +( + OCI_Context * ctx, + const otext * bind +); + +#endif /* OCILIB_EXCEPTION_H_INCLUDED */ diff --git a/src/file.c b/src/file.c index a6e9efb5..f42e86c7 100644 --- a/src/file.c +++ b/src/file.c @@ -18,24 +18,31 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "file.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "array.h" +#include "macros.h" +#include "memory.h" +#include "strings.h" -static const unsigned int SeekModeValues[] = { OCI_SEEK_SET, OCI_SEEK_END, OCI_SEEK_CUR }; -static const unsigned int FileTypeValues[] = { OCI_CFILE, OCI_BFILE }; +static const unsigned int SeekModeValues[] = +{ + OCI_SEEK_SET, + OCI_SEEK_END, + OCI_SEEK_CUR +}; -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int FileTypeValues[] = +{ + OCI_CFILE, + OCI_BFILE +}; /* --------------------------------------------------------------------------------------------- * - * OCI_FileInit + * FileInit * --------------------------------------------------------------------------------------------- */ -OCI_File * OCI_FileInit +OCI_File * FileInitialize ( OCI_Connection *con, OCI_File *file, @@ -43,341 +50,377 @@ OCI_File * OCI_FileInit ub4 type ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_ALLOCATE_DATA(OCI_IPC_FILE, file, 1); - - if (OCI_STATUS) - { - file->type = type; - file->con = con; - file->handle = handle; - file->offset = 1; + ENTER_FUNC + ( + /* returns */ OCI_File*, file, + /* context */ OCI_IPC_FILE, file + ) - /* reset file info */ + CHECK_PTR(OCI_IPC_CONNECTION, con) - if (file->dir) - { - file->dir[0] = 0; - } + ALLOC_DATA(OCI_IPC_FILE, file, 1) - if (file->name) - { - file->name[0] = 0; - } + file->type = type; + file->con = con; + file->handle = handle; + file->offset = 1; - if (!file->handle) - { - /* allocate handle for non fetched file (local file object) */ + /* reset file info */ - file->hstate = OCI_OBJECT_ALLOCATED; + if (NULL != file->dir) + { + file->dir[0] = 0; + } - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)file->con->env, (dvoid **)(void *)&file->handle, (ub4)OCI_DTYPE_LOB); - } - else if (OCI_OBJECT_ALLOCATED_ARRAY != file->hstate) - { - file->hstate = OCI_OBJECT_FETCHED_CLEAN; - } + if (NULL != file->name) + { + file->name[0] = 0; } - /* check for failure */ + if (NULL == file->handle) + { + /* allocate handle for non fetched file (local file object) */ + + file->hstate = OCI_OBJECT_ALLOCATED; - if (!OCI_STATUS && file) + CHECK(MemoryAllocDescriptor((dvoid *)file->con->env, + (dvoid **)(void *)&file->handle, + (ub4)OCI_DTYPE_LOB)) + } + else if (OCI_OBJECT_ALLOCATED_ARRAY != file->hstate) { - OCI_FileFree(file); - file = NULL; + file->hstate = OCI_OBJECT_FETCHED_CLEAN; } - return file; + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + FileFree(file); + file = NULL; + } + + SET_RETVAL(file) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_FileGetInfo + * FileGetInfo * --------------------------------------------------------------------------------------------- */ -boolean OCI_FileGetInfo +boolean FileGetInfo ( OCI_File *file ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) - OCI_CHECK(NULL == file, FALSE) + dbtext* dbstr1 = NULL; + dbtext* dbstr2 = NULL; - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + int dbsize1 = 0; + int dbsize2 = 0; + + ub2 usize1 = 0; + ub2 usize2 = 0; + + CHECK_PTR(OCI_IPC_FILE, file) /* directory name */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, file->dir, OCI_SIZE_DIRECTORY + 1) + ALLOC_DATA(OCI_IPC_STRING, file->dir, OCI_SIZE_DIRECTORY + 1) - if (OCI_STATUS) - { - file->dir[0] = 0; - } + file->dir[0] = 0; /* file name */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, file->name, OCI_SIZE_FILENAME + 1) - - if (OCI_STATUS) - { - file->name[0] = 0; - } + ALLOC_DATA(OCI_IPC_STRING, file->name, OCI_SIZE_FILENAME + 1) - /* retrieve name */ + file->name[0] = 0; - if (OCI_STATUS) - { - dbtext *dbstr1 = NULL; - dbtext *dbstr2 = NULL; - int dbsize1 = 0; - int dbsize2 = 0; - ub2 usize1 = 0; - ub2 usize2 = 0; + /* retrieve name */ - dbsize1 = (int) OCI_SIZE_DIRECTORY * (int) sizeof(otext); - dbstr1 = OCI_StringGetOracleString(file->dir, &dbsize1); + dbsize1 = (int) OCI_SIZE_DIRECTORY * (int) sizeof(otext); + dbstr1 = StringGetDBString(file->dir, &dbsize1); - dbsize2 = (int) OCI_SIZE_FILENAME * (int) sizeof(otext); - dbstr2 = OCI_StringGetOracleString(file->name, &dbsize1); + dbsize2 = (int) OCI_SIZE_FILENAME * (int) sizeof(otext); + dbstr2 = StringGetDBString(file->name, &dbsize1); - usize1 = (ub2) dbsize1; - usize2 = (ub2) dbsize2; + usize1 = (ub2) dbsize1; + usize2 = (ub2) dbsize2; - OCI_EXEC - ( - OCILobFileGetName(file->con->env, file->con->err, file->handle, - (OraText *) dbstr1, (ub2*) &usize1, - (OraText *) dbstr2, (ub2*) &usize2) - ) + CHECK_OCI + ( + file->con->err, + OCILobFileGetName, + file->con->env, file->con->err, file->handle, + (OraText *) dbstr1, (ub2*) &usize1, + (OraText *) dbstr2, (ub2*) &usize2 + ) - dbsize1 = (int) usize1; - dbsize2 = (int) usize2; + dbsize1 = (int) usize1; + dbsize2 = (int) usize2; - OCI_StringCopyOracleStringToNativeString(dbstr1, file->dir, dbcharcount(dbsize1)); - OCI_StringCopyOracleStringToNativeString(dbstr2, file->name, dbcharcount(dbsize2)); + StringCopyDBStringToNativeString(dbstr1, file->dir, dbcharcount(dbsize1)); + StringCopyDBStringToNativeString(dbstr2, file->name, dbcharcount(dbsize2)); - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); - } + SET_SUCCESS() - return OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_FileCreate + * FileCreate * --------------------------------------------------------------------------------------------- */ -OCI_File * OCI_API OCI_FileCreate +OCI_File * FileCreate ( OCI_Connection *con, unsigned int type ) { - OCI_CALL_ENTER(OCI_File *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, FileTypeValues, OTEXT("File Type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_File*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(type, FileTypeValues, OTEXT("File Type")) - OCI_RETVAL = OCI_FileInit(con, NULL, NULL, type); - OCI_STATUS = (NULL != OCI_RETVAL); + SET_RETVAL(FileInitialize(con, NULL, NULL, type)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileFree + * FileFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileFree +boolean FileFree ( OCI_File *file ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CHECK_OBJECT_FETCHED(file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) - OCI_FREE(file->dir) - OCI_FREE(file->name) + CHECK_PTR(OCI_IPC_FILE, file) + CHECK_OBJECT_FETCHED(file) + + FREE(file->dir) + FREE(file->name) if (OCI_OBJECT_ALLOCATED == file->hstate) { - OCI_DescriptorFree((dvoid *) file->handle, (ub4) OCI_DTYPE_LOB); + MemoryFreeDescriptor((dvoid*)file->handle, (ub4)OCI_DTYPE_LOB); } if (OCI_OBJECT_ALLOCATED_ARRAY != file->hstate) { - OCI_FREE(file) + FREE(file) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileArrayCreate + * FileArrayCreate * --------------------------------------------------------------------------------------------- */ -OCI_File ** OCI_API OCI_FileArrayCreate +OCI_File ** FileCreateArray ( OCI_Connection *con, unsigned int type, unsigned int nbelem ) { - OCI_Array *arr = NULL; + ENTER_FUNC + ( + /* returns */ OCI_File**, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(OCI_File **, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, FileTypeValues, OTEXT("File Type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + OCI_Array* arr = NULL; - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_FILE, type, sizeof(OCILobLocator *), sizeof(OCI_File), OCI_DTYPE_LOB, NULL); - OCI_STATUS = (NULL != arr); + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(type, FileTypeValues, OTEXT("File Type")) - if (arr) - { - OCI_RETVAL = (OCI_File **)arr->tab_obj; - } + arr = ArrayCreate(con, nbelem, OCI_CDT_FILE, type, + sizeof(OCILobLocator*), sizeof(OCI_File), + OCI_DTYPE_LOB, NULL); + + CHECK_NULL(arr) + + SET_RETVAL((OCI_File**)arr->tab_obj) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileArrayFree + * FileArrayFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileArrayFree +boolean FileFreeArray ( OCI_File **files ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, files) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)files); + CHECK_PTR(OCI_IPC_ARRAY, files) - OCI_CALL_EXIT() + SET_RETVAL(ArrayFreeFromHandles((void**)files)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileSeek + * FileSeek * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileSeek +boolean FileSeek ( OCI_File *file, big_uint offset, unsigned int mode ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) + big_uint size = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CHECK_ENUM_VALUE(file->con, NULL, mode, SeekModeValues, OTEXT("Seek Mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + boolean success = FALSE; + + CHECK_PTR(OCI_IPC_FILE, file) + CHECK_ENUM_VALUE(mode, SeekModeValues, OTEXT("Seek Mode")) - size = OCI_FileGetSize(file); + size = FileGetSize(file); switch (mode) { case OCI_SEEK_CUR: { - if ((offset + file->offset - 1) <= size) + if ((offset + file->offset - 1) <= size) { file->offset += offset; - OCI_RETVAL = TRUE; + + success = TRUE; } break; } case OCI_SEEK_SET: { - if (offset <= size) + if (offset <= size) { file->offset = offset + 1; - OCI_RETVAL = TRUE; + + success = TRUE; } break; } case OCI_SEEK_END: { - if (offset <= size) + if (offset <= size) { file->offset = size - offset + 1; - OCI_RETVAL = TRUE; + + success = TRUE; } break; } } - OCI_CALL_EXIT() + SET_RETVAL(success) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileGetOffset + * FileGetOffset * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_FileGetOffset +big_uint FileGetOffset ( OCI_File *file ) { - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_FILE, file + ) + + CHECK_PTR(OCI_IPC_FILE, file) - OCI_RETVAL = file->offset - 1; + SET_RETVAL(file->offset - 1) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileRead + * FileRead * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_FileRead +unsigned int FileRead ( OCI_File *file, void *buffer, unsigned int len ) { - ub4 size_in = 0; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_FILE, file + ) + + ub4 size_in = 0; ub4 size_out = 0; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CHECK_MIN(file->con, NULL, len, 1) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + CHECK_PTR(OCI_IPC_FILE, file) + CHECK_MIN(len, 1) size_out = size_in = len; - OCI_STATUS = TRUE; - #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { ub8 size_char = (ub8) len; ub8 size_byte = (ub8) size_in; - OCI_EXEC + CHECK_OCI ( - OCILobRead2(file->con->cxt, file->con->err, - file->handle, &size_byte, - &size_char, (ub8) file->offset, - buffer, (ub8) size_in, - (ub1) OCI_ONE_PIECE, (dvoid *) NULL, - NULL, (ub2) 0, (ub1) SQLCS_IMPLICIT) + file->con->err, + OCILobRead2, + file->con->cxt, file->con->err, + file->handle, &size_byte, + &size_char, (ub8) file->offset, + buffer, (ub8) size_in, + (ub1) OCI_ONE_PIECE, (dvoid *) NULL, + NULL, (ub2) 0, (ub1) SQLCS_IMPLICIT ) size_out = (ub4) size_byte; @@ -385,62 +428,76 @@ unsigned int OCI_API OCI_FileRead else - #endif +#endif { const ub4 offset = (ub4) file->offset; - OCI_EXEC + CHECK_OCI ( - OCILobRead(file->con->cxt, file->con->err, - file->handle, &size_out, offset, - buffer, size_in, (dvoid *) NULL, - NULL, (ub2) 0, (ub1) SQLCS_IMPLICIT) + file->con->err, + OCILobRead, + file->con->cxt, file->con->err, + file->handle, &size_out, offset, + buffer, size_in, (dvoid *) NULL, + NULL, (ub2) 0, (ub1) SQLCS_IMPLICIT ) } - if (OCI_STATUS) - { - file->offset += (big_uint) size_out; - - OCI_RETVAL = size_out; - } + file->offset += (big_uint) size_out; - OCI_CALL_EXIT() + SET_RETVAL(size_out) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileGetType + * FileGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_FileGetType +unsigned int FileGetType ( OCI_File *file ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_FILE, file, type, file->con, NULL, file->con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_FILE, file, + /* member */ type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_FileGetSize + * FileGetSize * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_FileGetSize +big_uint FileGetSize ( OCI_File *file ) { + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_FILE, file + ) + big_uint size = 0; - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + CHECK_PTR(OCI_IPC_FILE, file) #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { - OCI_EXEC(OCILobGetLength2(file->con->cxt, file->con->err, file->handle, (ub8 *) &size)) + CHECK_OCI + ( + file->con->err, + OCILobGetLength2, + file->con->cxt, file->con->err, + file->handle, (ub8 *) &size + ) } else @@ -449,249 +506,347 @@ big_uint OCI_API OCI_FileGetSize { ub4 size32 = (ub4) size; - OCI_EXEC(OCILobGetLength(file->con->cxt, file->con->err, file->handle, &size32)) + CHECK_OCI + ( + file->con->err, + OCILobGetLength, + file->con->cxt, file->con->err, + file->handle, &size32 + ) size = (big_uint) size32; } - OCI_RETVAL = size; + SET_RETVAL(size) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * * OCI_LobFileExists * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileExists +boolean FileExists ( OCI_File *file ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) + + CHECK_PTR(OCI_IPC_FILE, file) + + boolean exists = FALSE; - OCI_EXEC(OCILobFileExists(file->con->cxt, file->con->err, file->handle, &OCI_RETVAL)) + CHECK_OCI + ( + file->con->err, + OCILobFileExists, file->con->cxt, + file->con->err, file->handle, + &exists + ) + + SET_RETVAL(exists) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileSetName + * FileSetName * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileSetName +boolean FileSetName ( OCI_File *file, const otext *dir, const otext *name ) { - dbtext *dbstr1 = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) + + dbtext *dbstr1 = NULL; dbtext *dbstr2 = NULL; int dbsize1 = -1; int dbsize2 = -1; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + CHECK_PTR(OCI_IPC_FILE, file) - dbstr1 = OCI_StringGetOracleString(dir, &dbsize1); - dbstr2 = OCI_StringGetOracleString(name, &dbsize2); + dbstr1 = StringGetDBString(dir, &dbsize1); + dbstr2 = StringGetDBString(name, &dbsize2); - OCI_EXEC + CHECK_OCI ( - OCILobFileSetName(file->con->env, file->con->err, - &file->handle, - (OraText *) dbstr1, (ub2) dbsize1, - (OraText *) dbstr2, (ub2) dbsize2) + file->con->err, + OCILobFileSetName, + file->con->env, + file->con->err, + &file->handle, + (OraText *) dbstr1, (ub2) dbsize1, + (OraText *) dbstr2, (ub2) dbsize2 ) - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); + CHECK(FileGetInfo(file)) - if (OCI_STATUS) - { - OCI_STATUS = OCI_FileGetInfo(file); - } + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_FileGetDirectory + * FileGetDirectory * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_FileGetDirectory +const otext * FileGetDirectory ( OCI_File *file ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_FILE, file + ) - if (!OCI_STRING_VALID(file->dir)) + CHECK_PTR(OCI_IPC_FILE, file) + + if (!IS_STRING_VALID(file->dir)) { - OCI_STATUS = OCI_FileGetInfo(file); + CHECK(FileGetInfo(file)) } - OCI_RETVAL = file->dir; + SET_RETVAL(file->dir) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileGetName + * FileGetName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_FileGetName +const otext * FileGetName ( OCI_File *file ) { - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ const otext *, NULL, + /* context */ OCI_IPC_FILE, file + ) + + CHECK_PTR(OCI_IPC_FILE, file) - if (!OCI_STRING_VALID(file->name)) + if (!IS_STRING_VALID(file->name)) { - OCI_STATUS = OCI_FileGetInfo(file); + CHECK(FileGetInfo(file)) } - OCI_RETVAL = file->name; - - OCI_CALL_EXIT() + SET_RETVAL(file->name) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileOpen + * FileOpen * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileOpen +boolean FileOpen ( OCI_File *file ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) - OCI_EXEC(OCILobFileOpen(file->con->cxt, file->con->err, file->handle, (ub1) OCI_LOB_READONLY)) + CHECK_PTR(OCI_IPC_FILE, file) - if (OCI_STATUS) - { - file->con->nb_files++; - } + CHECK_OCI + ( + file->con->err, + OCILobFileOpen, + file->con->cxt, file->con->err, + file->handle, (ub1) OCI_LOB_READONLY + ) - OCI_RETVAL = OCI_STATUS; + file->con->nb_files++; - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * * OCI_LobFileIsOpen * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileIsOpen +boolean FileIsOpen ( OCI_File *file ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) + + CHECK_PTR(OCI_IPC_FILE, file) + + boolean is_opened = FALSE; - OCI_EXEC(OCILobFileIsOpen(file->con->cxt, file->con->err, file->handle, &OCI_RETVAL)) - - OCI_CALL_EXIT() + CHECK_OCI + ( + file->con->err, + OCILobFileIsOpen, file->con->cxt, + file->con->err, file->handle, + &is_opened + ) + + SET_RETVAL(is_opened) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileClose + * FileClose * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileClose +boolean FileClose ( OCI_File *file ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) - OCI_EXEC(OCILobFileClose(file->con->cxt, file->con->err, file->handle)) + CHECK_PTR(OCI_IPC_FILE, file) - if (OCI_STATUS) - { - file->con->nb_files--; - } + CHECK_OCI + ( + file->con->err, + OCILobFileClose, + file->con->cxt, file->con->err, + file->handle + ) + + file->con->nb_files--; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileIsEqual + * FileIsEqual * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileIsEqual +boolean FileIsEqual ( OCI_File *file, OCI_File *file2 ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file2) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) + + CHECK_PTR(OCI_IPC_FILE, file) + CHECK_PTR(OCI_IPC_FILE, file2) - OCI_EXEC(OCILobIsEqual(file->con->env, file->handle, file2->handle, &OCI_RETVAL)) + boolean is_equal = FALSE; - OCI_CALL_EXIT() + CHECK_OCI + ( + file->con->err, + OCILobIsEqual, + file->con->env, file->handle, + file2->handle, &is_equal + ) + + SET_RETVAL(is_equal) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FileAssign + * FileAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FileAssign +boolean FileAssign ( OCI_File *file, OCI_File *file_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file_src) - OCI_CALL_CONTEXT_SET_FROM_CONN(file->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_FILE, file + ) + + CHECK_PTR(OCI_IPC_FILE, file) + CHECK_PTR(OCI_IPC_FILE, file_src) if ((OCI_OBJECT_ALLOCATED == file->hstate) || (OCI_OBJECT_ALLOCATED_ARRAY == file->hstate)) { - OCI_EXEC(OCILobLocatorAssign(file->con->cxt, file->con->err, file_src->handle, &file->handle)) + CHECK_OCI + ( + file->con->err, + OCILobLocatorAssign, + file->con->cxt, file->con->err, + file_src->handle, &file->handle + ) } else { - OCI_EXEC(OCILobAssign(file->con->env, file->con->err, file_src->handle, &file->handle)) + CHECK_OCI + ( + file->con->err, + OCILobAssign, + file->con->env, file->con->err, + file_src->handle, &file->handle + ) } - OCI_RETVAL = OCI_STATUS = OCI_STATUS && OCI_FileGetInfo(file); + CHECK(FileGetInfo(file)) + + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_FileGetConnection +* FileGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_FileGetConnection +OCI_Connection * FileGetConnection ( OCI_File *file ) { - OCI_GET_PROP(OCI_Connection *, NULL, OCI_IPC_FILE, file, con, file->con, NULL, file->con->err) + GET_PROP + ( + /* result */ OCI_Connection *, NULL, + /* handle */ OCI_IPC_FILE, file, + /* member */ con + ) } diff --git a/src/file.h b/src/file.h new file mode 100644 index 00000000..2668cbda --- /dev/null +++ b/src/file.h @@ -0,0 +1,145 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_FILE_H_INCLUDED +#define OCILIB_FILE_H_INCLUDED + +#include "types.h" + +OCI_File * FileInitialize +( + OCI_Connection *con, + OCI_File *file, + OCILobLocator *handle, + ub4 type +); + +boolean FileGetInfo +( + OCI_File* file +); + +OCI_File * FileCreate +( + OCI_Connection *con, + unsigned int type +); + +boolean FileFree +( + OCI_File *file +); + +OCI_File ** FileCreateArray +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +boolean FileFreeArray +( + OCI_File **files +); + +boolean FileSeek +( + OCI_File *file, + big_uint offset, + unsigned int mode +); + +big_uint FileGetOffset +( + OCI_File *file +); + +unsigned int FileRead +( + OCI_File *file, + void *buffer, + unsigned int len +); + +unsigned int FileGetType +( + OCI_File *file +); + +big_uint FileGetSize +( + OCI_File *file +); + +boolean FileExists +( + OCI_File *file +); + +boolean FileSetName +( + OCI_File *file, + const otext *dir, + const otext *name +); + +const otext * FileGetDirectory +( + OCI_File *file +); + +const otext * FileGetName +( + OCI_File *file +); + +boolean FileOpen +( + OCI_File *file +); + +boolean FileIsOpen +( + OCI_File *file +); + +boolean FileClose +( + OCI_File *file +); + +boolean FileIsEqual +( + OCI_File *file, + OCI_File *file2 +); + +boolean FileAssign +( + OCI_File *file, + OCI_File *file_src +); + +OCI_Connection* FileGetConnection +( + OCI_File* file +); + +#endif /* OCILIB_FILE_H_INCLUDED */ diff --git a/src/format.c b/src/format.c index 5e8ac967..395fd27f 100644 --- a/src/format.c +++ b/src/format.c @@ -18,17 +18,20 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "format.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "exception.h" +#include "interval.h" +#include "macros.h" +#include "number.h" +#include "reference.h" +#include "timestamp.h" /* --------------------------------------------------------------------------------------------- * - * OCI_ParseSqlFmt + * ParseSqlFmt * --------------------------------------------------------------------------------------------- */ -int OCI_ParseSqlFmt +int FormatParseSql ( OCI_Statement *stmt, otext *buf, @@ -36,13 +39,20 @@ int OCI_ParseSqlFmt va_list *pargs ) { - int size = 0; - int len = 0; - boolean quote = FALSE; - otext *pb = buf; - const otext *pf = format; + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CHECK(NULL == format, 0); + int size = 0; + int len = 0; + boolean quote = FALSE; + otext *pb = buf; + const otext *pf = format; + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, format) for (; *pf; pf++) { @@ -80,7 +90,7 @@ int OCI_ParseSqlFmt { const otext *str = (const otext *) va_arg(*pargs, const otext *); - if (OCI_STRING_VALID(str)) + if (IS_STRING_VALID(str)) { len = (int) ostrlen(str); @@ -123,14 +133,14 @@ int OCI_ParseSqlFmt if (date) { len = osprintf(pb, OCI_SIZE_DATE, - OTEXT("to_date('%02i%02i%04i%02i%02i%02i',") - OTEXT("'DDMMYYYYHH24MISS')"), - date->handle->OCIDateDD, - date->handle->OCIDateMM, - date->handle->OCIDateYYYY, - date->handle->OCIDateTime.OCITimeHH, - date->handle->OCIDateTime.OCITimeMI, - date->handle->OCIDateTime.OCITimeSS); + OTEXT("to_date('%02i%02i%04i%02i%02i%02i',") + OTEXT("'DDMMYYYYHH24MISS')"), + date->handle->OCIDateDD, + date->handle->OCIDateMM, + date->handle->OCIDateYYYY, + date->handle->OCIDateTime.OCITimeHH, + date->handle->OCIDateTime.OCITimeMI, + date->handle->OCIDateTime.OCITimeSS); } else { @@ -154,12 +164,9 @@ int OCI_ParseSqlFmt if (tmsp) { otext str_ff[12]; - int yy, mm, dd, hh, mi, ss, ff; - - yy = mm = dd = mi = hh = ss = ff = 0; + int yy = 0, mm = 0, dd = 0, hh = 0, mi = 0, ss = 0, ff = 0; - OCI_TimestampGetDateTime(tmsp, &yy, &mm, &dd, - &hh, &mi, &ss, &ff); + CHECK(TimestampGetDateTime(tmsp, &yy, &mm, &dd, &hh, &mi, &ss, &ff)) if (ff > 0) { @@ -173,9 +180,9 @@ int OCI_ParseSqlFmt str_ff[2] = 0; len = osprintf(pb, OCI_SIZE_TIMESTAMP, - OTEXT("to_timestamp('%02i%02i%04i%02i%02i%02i%s',") - OTEXT("'DDMMYYYYHH24MISSFF')"), - dd, mm, yy, hh, mi, ss, str_ff); + OTEXT("to_timestamp('%02i%02i%04i%02i%02i%02i%s',") + OTEXT("'DDMMYYYYHH24MISSFF')"), + dd, mm, yy, hh, mi, ss, str_ff); } else { @@ -200,7 +207,7 @@ int OCI_ParseSqlFmt if (itv) { - OCI_IntervalToText(itv, 3, 3, (int) osizeof(temp)- 1, temp); + CHECK(IntervalToString(itv, 3, 3, (int) osizeof(temp)- 1, temp)) len = (int) ostrlen(temp); @@ -296,7 +303,7 @@ int OCI_ParseSqlFmt else if (OTEXT('u') == *pf) { len = (int) osprintf(temp, (int) osizeof(temp) - 1, OTEXT("%hu"), va_arg(*pargs, unsigned int)); - } + } else { len = 0; @@ -330,7 +337,7 @@ int OCI_ParseSqlFmt temp[0] = 0; - OCI_NumberToText(va_arg(*pargs, OCI_Number*), NULL, 128, temp); + CHECK(NumberToString(va_arg(*pargs, OCI_Number*), NULL, 128, temp)) len = (int) ostrlen(temp); if (buf && (len > 0)) @@ -350,7 +357,7 @@ int OCI_ParseSqlFmt if (ref) { - OCI_RefToText(ref, (unsigned int) osizeof(temp) - 1, temp); + CHECK(ReferenceToString( ref, (unsigned int) osizeof(temp) - 1, temp)) len = (int) ostrlen(temp); @@ -373,9 +380,9 @@ int OCI_ParseSqlFmt } default: { - OCI_ExceptionParsingToken(stmt->con, stmt, *pf); + THROW(ExceptionParsingToken, *pf) - return 0; + break; } } @@ -392,5 +399,7 @@ int OCI_ParseSqlFmt *pb = 0; } - return size; + SET_RETVAL(size) + + EXIT_FUNC() } diff --git a/src/format.h b/src/format.h new file mode 100644 index 00000000..0da28f44 --- /dev/null +++ b/src/format.h @@ -0,0 +1,34 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_FORMAT_H_INCLUDED +#define OCILIB_FORMAT_H_INCLUDED + +#include "types.h" + +int FormatParseSql +( + OCI_Statement* stmt, + otext * buffer, + const otext * format, + va_list * pargs +); + +#endif /* OCILIB_FORMAT_H_INCLUDED */ diff --git a/src/handle.c b/src/handle.c index 5527b023..0e09e68d 100644 --- a/src/handle.c +++ b/src/handle.c @@ -18,385 +18,269 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "handle.h" -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ +#include "macros.h" /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetEnvironment + * HandleGetEnvironment * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetEnvironment +const void * HandleGetEnvironment ( - void ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_INITIALIZED() - - OCI_RETVAL = OCILib.env; - - OCI_CALL_EXIT() + GET_LIB_PROP(const void*, NULL, Env.env) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetContext + * HandleGetContext * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetContext +const void * HandleGetContext ( OCI_Connection *con ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - - OCI_RETVAL = con->cxt; - - OCI_CALL_EXIT() + GET_PROP(const void*, NULL, OCI_IPC_CONNECTION, con, cxt) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetServer + * HandleGetServer * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetServer +const void * HandleGetServer ( OCI_Connection *con ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - - OCI_RETVAL = con->svr; - - OCI_CALL_EXIT() - + GET_PROP(const void *, NULL, OCI_IPC_CONNECTION, con, svr) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetError + * HandleGetError * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetError +const void * HandleGetError ( OCI_Connection *con ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - - OCI_RETVAL = con->err; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_CONNECTION, con, err) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetSession + * HandleGetSession * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetSession +const void * HandleGetSession ( OCI_Connection *con ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - - OCI_RETVAL = con->ses; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_CONNECTION, con, ses) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetTransaction + * HandleGetTransaction * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetTransaction +const void * HandleGetTransaction ( OCI_Transaction *trans ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - - OCI_RETVAL = trans->htr; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_TRANSACTION, trans, htr) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetStatement + * HandleGetStatement * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetStatement +const void * HandleGetStatement ( OCI_Statement *stmt ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - - OCI_RETVAL = stmt->stmt; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_STATEMENT, stmt, stmt) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetLob + * HandleGetLob * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetLob +const void * HandleGetLob ( OCI_Lob *lob ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - - OCI_RETVAL = lob->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_LOB, lob, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetFile + * HandleGetFile * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetFile +const void * HandleGetFile ( OCI_File *file ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - - OCI_RETVAL = file->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_FILE, file, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetDate + * HandleGetDate * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetDate +const void * HandleGetDate ( OCI_Date *date ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DATE, date) - - OCI_RETVAL = date->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_DATE, date, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetTimestamp + * HandleGetTimestamp * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetTimestamp +const void * HandleGetTimestamp ( OCI_Timestamp *tmsp ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - - OCI_RETVAL = tmsp->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_TIMESTAMP, tmsp, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetInterval + * HandleGetInterval * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetInterval +const void * HandleGetInterval ( OCI_Interval *itv ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - - OCI_RETVAL = itv->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_INTERVAL, itv, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetObject + * HandleGetObject * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetObject +const void * HandleGetObject ( OCI_Object *obj ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - - OCI_RETVAL = obj->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_OBJECT, obj, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetColl + * HandleGetCollection * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetColl +const void * HandleGetColl ( OCI_Coll *coll ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - - OCI_RETVAL = coll->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_COLLECTION, coll, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetRef + * HandleGetReference * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetRef +const void * HandleGetReference ( OCI_Ref *ref ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - - OCI_RETVAL = ref->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_REF, ref, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetMutex + * HandleGetMutex * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetMutex +const void * HandleGetMutex ( OCI_Mutex *mutex ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_MUTEX, mutex) - - OCI_RETVAL = mutex->handle; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_MUTEX, mutex, handle) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetThreadID + * HandleGetThreadID * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetThreadID +const void * HandleGetThreadID ( OCI_Thread *thread ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_THREAD, thread) - - OCI_RETVAL = thread->id; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_THREAD, thread, id) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetThread + * HandleGetThread * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetThread +const void * HandleGetThread ( OCI_Thread *thread ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_THREAD, thread) - - OCI_RETVAL = thread->handle; - - OCI_CALL_EXIT() - } + GET_PROP(const void *, NULL, OCI_IPC_THREAD, thread, handle) +} /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetDirPathCtx + * HandleGetDirPathCtx * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetDirPathCtx +const void * HandleGetDirPathCtx ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - - OCI_RETVAL = dp->ctx; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_DIRPATH, dp, ctx) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetDirPathColArray + * HandleGetDirPathColArray * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetDirPathColArray +const void * HandleGetDirPathColArray ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - - OCI_RETVAL = dp->arr; - - OCI_CALL_EXIT() - + GET_PROP(const void *, NULL, OCI_IPC_DIRPATH, dp, arr) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetDirPathStream + * HandleGetDirPathStream * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetDirPathStream +const void * HandleGetDirPathStream ( OCI_DirPath *dp ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_DIRPATH, dp) - - OCI_RETVAL = dp->strm; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_DIRPATH, dp, strm) } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleGetSubscription + * HandleGetSubscription * --------------------------------------------------------------------------------------------- */ -const void * OCI_API OCI_HandleGetSubscription +const void * HandleGetSubscription ( OCI_Subscription *sub ) { - OCI_CALL_ENTER(const void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_NOTIFY, sub) - - OCI_RETVAL = sub->subhp; - - OCI_CALL_EXIT() + GET_PROP(const void *, NULL, OCI_IPC_NOTIFY, sub, subhp) } - diff --git a/src/handle.h b/src/handle.h new file mode 100644 index 00000000..7c196fa2 --- /dev/null +++ b/src/handle.h @@ -0,0 +1,136 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_HANDLE_H_INCLUDED +#define OCILIB_HANDLE_H_INCLUDED + +#include "types.h" + +const void * HandleGetEnvironment +( + void +); + +const void * HandleGetContext +( + OCI_Connection *con +); + +const void * HandleGetServer +( + OCI_Connection *con +); + +const void * HandleGetError +( + OCI_Connection *con +); + +const void * HandleGetSession +( + OCI_Connection *con +); + +const void * HandleGetTransaction +( + OCI_Transaction *trans +); + +const void * HandleGetStatement +( + OCI_Statement *stmt +); + +const void * HandleGetLob +( + OCI_Lob *lob +); + +const void * HandleGetFile +( + OCI_File *file +); + +const void * HandleGetDate +( + OCI_Date *date +); + +const void * HandleGetTimestamp +( + OCI_Timestamp *tmsp +); + +const void * HandleGetInterval +( + OCI_Interval *itv +); + +const void * HandleGetObject +( + OCI_Object *obj +); + +const void * HandleGetColl +( + OCI_Coll *coll +); + +const void * HandleGetReference +( + OCI_Ref *ref +); + +const void * HandleGetMutex +( + OCI_Mutex *mutex +); + +const void * HandleGetThreadID +( + OCI_Thread *thread +); + +const void * HandleGetThread +( + OCI_Thread *thread +); + +const void * HandleGetDirPathCtx +( + OCI_DirPath *dp +); + +const void * HandleGetDirPathColArray +( + OCI_DirPath *dp +); + +const void * HandleGetDirPathStream +( + OCI_DirPath *dp +); + +const void * HandleGetSubscription +( + OCI_Subscription *sub +); + +#endif /* OCILIB_HANDLE_H_INCLUDED */ diff --git a/src/hash.c b/src/hash.c index 0dbe2199..0027fac2 100644 --- a/src/hash.c +++ b/src/hash.c @@ -18,34 +18,34 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "hash.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "macros.h" +#include "memory.h" -static const unsigned int HashTypeValues[] = { OCI_HASH_STRING, OCI_HASH_INTEGER, OCI_HASH_POINTER }; - - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int HashTypeValues[] = +{ + OCI_HASH_STRING, + OCI_HASH_INTEGER, + OCI_HASH_POINTER +}; /* --------------------------------------------------------------------------------------------- * - * OCI_HashCompute + * HashCompute * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_HashCompute +unsigned int HashCompute ( OCI_HashTable *table, const otext *str ) { unsigned int h; + otext *p; - OCI_CHECK(NULL == table, 0); - OCI_CHECK(NULL == str, 0); + CHECK_FALSE(NULL == table, 0); + CHECK_FALSE(NULL == str, 0); for(h = 0, p = (otext *) str; (*p) != 0; p++) { @@ -56,10 +56,10 @@ unsigned int OCI_HashCompute } /* --------------------------------------------------------------------------------------------- * -* OCI_HashAdd +* HashAdd * --------------------------------------------------------------------------------------------- */ -boolean OCI_HashAdd +boolean HashAdd ( OCI_HashTable *table, const otext *key, @@ -67,21 +67,29 @@ boolean OCI_HashAdd unsigned int type ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_HASHTABLE, table + ) + OCI_HashEntry * e = NULL; OCI_HashValue * v = NULL, *v1 = NULL, *v2 = NULL; - boolean res = FALSE; - OCI_CHECK(NULL == table, FALSE) - OCI_CHECK(NULL == key, FALSE) - OCI_CHECK(table->type != type, FALSE) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_PTR(OCI_IPC_STRING, key) + CHECK_COMPAT(table->type == type) - e = OCI_HashLookup(table, key, TRUE); + boolean success = FALSE; - if (e) + e = HashLookup(table, key, TRUE); + + if (NULL != e) { - v = (OCI_HashValue *)OCI_MemAlloc(OCI_IPC_HASHVALUE, sizeof(*v), (size_t)1, TRUE); + v = (OCI_HashValue *)MemoryAlloc(OCI_IPC_HASHVALUE, sizeof(*v), + (size_t)1, TRUE); - if (v) + if (NULL != v) { if (OCI_HASH_STRING == table->type && value.p_text) { @@ -98,13 +106,13 @@ boolean OCI_HashAdd v1 = v2 = e->values; - while (v1) + while (NULL != v1) { v2 = v1; v1 = v1->next; } - if (v2) + if (NULL != v2) { v2->next = v; } @@ -113,376 +121,424 @@ boolean OCI_HashAdd e->values = v; } - res = TRUE; + success = TRUE; } } - return res; -} + SET_RETVAL(success) -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_HashCreate + * HashCreate * --------------------------------------------------------------------------------------------- */ -OCI_HashTable * OCI_API OCI_HashCreate +OCI_HashTable * HashCreate ( unsigned int size, unsigned int type ) { - OCI_HashTable *table = NULL; + ENTER_FUNC + ( + /* returns */ OCI_HashTable*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + + OCI_HashTable* table = NULL; - OCI_CALL_ENTER(OCI_HashTable*, table) - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, type, HashTypeValues, OTEXT("Hash type")); + CHECK_ENUM_VALUE(type, HashTypeValues, OTEXT("Hash type")); /* allocate table structure */ - table = (OCI_HashTable *) OCI_MemAlloc(OCI_IPC_HASHTABLE, sizeof(*table), (size_t) 1, TRUE); - OCI_STATUS = (NULL != table); + table = (OCI_HashTable *) MemoryAlloc(OCI_IPC_HASHTABLE, + sizeof(*table), + (size_t) 1, TRUE); + CHECK_NULL(table) /* set up attributes and allocate internal array of hash entry pointers */ - if (OCI_STATUS) - { - table->type = type; - table->size = 0; - table->count = 0; - - table->items = (OCI_HashEntry **) OCI_MemAlloc(OCI_IPC_HASHENTRY_ARRAY, sizeof(*table->items), (size_t) size, TRUE); - OCI_STATUS = (NULL != table->items); - - if (OCI_STATUS) + table->type = type; + table->size = 0; + table->count = 0; + + table->items = (OCI_HashEntry **) MemoryAlloc(OCI_IPC_HASHENTRY_ARRAY, + sizeof(*table->items), + (size_t) size, TRUE); + CHECK_NULL(table->items); + + table->size = size; + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - table->size = size; + HashFree(table); + table = NULL; } - } - - if (OCI_STATUS) - { - OCI_RETVAL = table; - } - else if (table) - { - OCI_HashFree(table); - } - OCI_CALL_EXIT() + SET_RETVAL(table) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_HashFree + * HashFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_HashFree +boolean HashFree ( OCI_HashTable *table ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_HASHTABLE, table + ) + OCI_HashEntry *e1 = NULL, *e2 = NULL; OCI_HashValue *v1 = NULL, *v2 = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_PTR(OCI_IPC_HASHTABLE, table) - if (table->items) + if (NULL != table->items) { for (unsigned int i = 0; i < table->size; i++) { e1 = table->items[i]; - while (e1) + while (NULL != e1) { e2 = e1; e1 = e1->next; v1 = e2->values; - while (v1) + while (NULL != v1) { v2 = v1; v1 = v1->next; if (OCI_HASH_STRING == table->type) { - OCI_FREE(v2->value.p_text) + FREE(v2->value.p_text) } - OCI_FREE(v2) + FREE(v2) } - if (e2->key) + if (NULL != e2->key) { - OCI_FREE(e2->key) + FREE(e2->key) } - if (e2) - { - OCI_FREE(e2) - } + FREE(e2) } } - OCI_FREE(table->items) + FREE(table->items) } - OCI_RETVAL = TRUE; + FREE(table) - OCI_FREE(table) + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetSize + * HashGetSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_HashGetSize +unsigned int HashGetSize ( OCI_HashTable *table ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_HASHTABLE, table + ) - OCI_RETVAL = table->size; + CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_EXIT() + SET_RETVAL(table->size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetType + * HashGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_HashGetType +unsigned int HashGetType ( OCI_HashTable *table ) { - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_HASHTABLE, table + ) + + CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_RETVAL = table->type; + SET_RETVAL(table->type; ) - OCI_CALL_EXIT()} + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetValue + * HashGetValue * --------------------------------------------------------------------------------------------- */ -OCI_HashValue * OCI_API OCI_HashGetValue +OCI_HashValue * HashGetValue ( OCI_HashTable *table, const otext *key ) { - OCI_HashEntry *e = NULL; + ENTER_FUNC + ( + /* returns */ OCI_HashValue*, NULL, + /* context */ OCI_IPC_HASHTABLE, table + ) - OCI_CALL_ENTER(OCI_HashValue*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_PTR(OCI_IPC_HASHTABLE, table) - e = OCI_HashLookup(table, key, FALSE); + OCI_HashEntry* e = HashLookup(table, key, FALSE); + CHECK_NULL(e) - if (e) - { - OCI_RETVAL = e->values; - } + SET_RETVAL(e->values) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetEntry + * HashGetEntry * --------------------------------------------------------------------------------------------- */ -OCI_HashEntry * OCI_API OCI_HashGetEntry +OCI_HashEntry * HashGetEntry ( OCI_HashTable *table, unsigned int index ) { - OCI_CALL_ENTER(OCI_HashEntry*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - - if (index < table->size) - { - OCI_RETVAL = table->items[index]; - } + ENTER_FUNC + ( + /* returns */ OCI_HashEntry*, NULL, + /* context */ OCI_IPC_HASHTABLE, table + ) + + CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_EXIT() + CHECK(index < table->size) + + SET_RETVAL(table->items[index]) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetString + * HashGetString * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_HashGetString +const otext * HashGetString ( OCI_HashTable *table, const otext *key ) { - OCI_HashValue *v = NULL; + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_HASHTABLE, table + ) - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_COMPAT(NULL, table->type == OCI_HASH_STRING) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_COMPAT(table->type == OCI_HASH_STRING) - v = OCI_HashGetValue(table, key); + OCI_HashValue *v = HashGetValue(table, key); + CHECK_NULL(v) - if (v) - { - OCI_RETVAL = v->value.p_text; - } + SET_RETVAL(v->value.p_text) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetInt + * HashGetInt * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_HashGetInt +int HashGetInt ( OCI_HashTable *table, const otext *key ) { - OCI_HashValue *v = NULL; + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_HASHTABLE, table + ) - OCI_CALL_ENTER(int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_COMPAT(NULL, table->type == OCI_HASH_INTEGER) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_COMPAT(table->type == OCI_HASH_INTEGER) - v = OCI_HashGetValue(table, key); + OCI_HashValue * v = HashGetValue(table, key); + CHECK_NULL(v) - if (v) - { - OCI_RETVAL = v->value.num; - } + SET_RETVAL(v->value.num) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashGetPointer + * HashGetPointer * --------------------------------------------------------------------------------------------- */ -void * OCI_API OCI_HashGetPointer +void * HashGetPointer ( OCI_HashTable *table, const otext *key ) { - OCI_HashValue *v = NULL; + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_HASHTABLE, table + ) - OCI_CALL_ENTER(void *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_COMPAT(NULL, table->type == OCI_HASH_POINTER) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_COMPAT(table->type == OCI_HASH_POINTER) - v = OCI_HashGetValue(table, key); + OCI_HashValue *v = HashGetValue(table, key); + CHECK_NULL(v) - if (v) - { - OCI_RETVAL = v->value.p_void; - } + SET_RETVAL(v->value.p_void) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashAddString + * HashAddString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_HashAddString +boolean HashAddString ( OCI_HashTable *table, const otext *key, const otext *value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_HASHTABLE, table + ) + OCI_Variant v; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_COMPAT(NULL, table->type == OCI_HASH_STRING) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_COMPAT(table->type == OCI_HASH_STRING) v.p_text = (otext *) value; - OCI_RETVAL = OCI_STATUS = OCI_HashAdd(table, key, v, OCI_HASH_STRING); + CHECK(HashAdd(table, key, v, OCI_HASH_STRING)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashAddInt + * HashAddInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_HashAddInt +boolean HashAddInt ( OCI_HashTable *table, const otext *key, int value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_HASHTABLE, table + ) + OCI_Variant v; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_COMPAT(NULL, table->type == OCI_HASH_INTEGER) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_COMPAT(table->type == OCI_HASH_INTEGER) v.num = value; - OCI_RETVAL = OCI_STATUS = OCI_HashAdd(table, key, v, OCI_HASH_INTEGER); + CHECK(HashAdd(table, key, v, OCI_HASH_INTEGER)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashAddPointer + * HashAddPointer * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_HashAddPointer +boolean HashAddPointer ( OCI_HashTable *table, const otext *key, void *value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_HASHTABLE, table + ) + OCI_Variant v; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_COMPAT(NULL, table->type == OCI_HASH_POINTER) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_COMPAT(table->type == OCI_HASH_POINTER) v.p_void = value; - OCI_RETVAL = OCI_STATUS = OCI_HashAdd(table, key, v, OCI_HASH_POINTER); + CHECK(HashAdd(table, key, v, OCI_HASH_POINTER)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HashLookup + * HashLookup * --------------------------------------------------------------------------------------------- */ -OCI_HashEntry * OCI_API OCI_HashLookup +OCI_HashEntry * HashLookup ( OCI_HashTable *table, const otext *key, boolean create ) { + ENTER_FUNC + ( + /* returns */ OCI_HashEntry*, NULL, + /* context */ OCI_IPC_HASHTABLE, table + ) + OCI_HashEntry *e = NULL, *e1 = NULL, *e2 = NULL; - OCI_CALL_ENTER(OCI_HashEntry*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_HASHTABLE, table) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, key) + CHECK_PTR(OCI_IPC_HASHTABLE, table) + CHECK_PTR(OCI_IPC_STRING, key) - const unsigned int i = OCI_HashCompute(table, key); + const unsigned int i = HashCompute(table, key); if (i < table->size) { @@ -494,43 +550,42 @@ OCI_HashEntry * OCI_API OCI_HashLookup } } - if (!e && create) + if (NULL == e && create) { - e = (OCI_HashEntry *) OCI_MemAlloc(OCI_IPC_HASHENTRY, sizeof(*e), (size_t) 1, TRUE); - OCI_STATUS = (NULL != e); - - if (OCI_STATUS) - { - e->key = ostrdup(key); + e = (OCI_HashEntry *) MemoryAlloc(OCI_IPC_HASHENTRY, + sizeof(*e), + (size_t) 1, + TRUE); + CHECK_NULL(e) - e1 = e2 = table->items[i]; + e->key = ostrdup(key); - while (e1) - { - e2 = e1; - e1 = e1->next; - } + e1 = e2 = table->items[i]; - if (e2) - { - e2->next = e; - } - else - { - table->items[i] = e; - } + while (NULL != e1) + { + e2 = e1; + e1 = e1->next; + } + + if (NULL != e2) + { + e2->next = e; + } + else + { + table->items[i] = e; } } } - if (OCI_STATUS) - { - OCI_RETVAL = e; - } - else if (e) - { - OCI_FREE(e) - } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE && create) + { + FREE(e) + } - OCI_CALL_EXIT() + SET_RETVAL(e) + ) } diff --git a/src/hash.h b/src/hash.h new file mode 100644 index 00000000..b53e5413 --- /dev/null +++ b/src/hash.h @@ -0,0 +1,105 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_HASH_H_INCLUDED +#define OCILIB_HASH_H_INCLUDED + +#include "types.h" + +OCI_HashTable * HashCreate +( + unsigned int size, + unsigned int type +); + +boolean HashFree +( + OCI_HashTable *table +); + +unsigned int HashGetSize +( + OCI_HashTable *table +); + +unsigned int HashGetType +( + OCI_HashTable *table +); + +boolean HashAddString +( + OCI_HashTable *table, + const otext *key, + const otext *value +); + +const otext * HashGetString +( + OCI_HashTable *table, + const otext *key +); + +boolean HashAddInt +( + OCI_HashTable *table, + const otext *key, + int value +); + +int HashGetInt +( + OCI_HashTable *table, + const otext *key +); + +boolean HashAddPointer +( + OCI_HashTable *table, + const otext *key, + void *value +); + +void * HashGetPointer +( + OCI_HashTable *table, + const otext *key +); + +OCI_HashEntry * HashLookup +( + OCI_HashTable *table, + const otext *key, + boolean create +); + +OCI_HashValue * HashGetValue +( + OCI_HashTable *table, + const otext *key +); + +OCI_HashEntry * HashGetEntry +( + OCI_HashTable *table, + unsigned int index +); + +#endif /* OCILIB_HASH_H_INCLUDED */ diff --git a/src/helpers.c b/src/helpers.c new file mode 100644 index 00000000..c333afe9 --- /dev/null +++ b/src/helpers.c @@ -0,0 +1,231 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "helpers.h" + +#include "collection.h" +#include "date.h" +#include "file.h" +#include "interval.h" +#include "lob.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "timestamp.h" + +/* --------------------------------------------------------------------------------------------- * + * ExternalSubTypeToSQLType + * --------------------------------------------------------------------------------------------- */ + +unsigned int ExternalSubTypeToSQLType +( + unsigned int type, + unsigned int subtype +) +{ + unsigned int res = OCI_UNKNOWN; + + switch (type) + { + case OCI_CDT_TIMESTAMP: + { + switch (subtype) + { + case OCI_TIMESTAMP: + res = SQLT_TIMESTAMP; + break; + case OCI_TIMESTAMP_TZ: + res = SQLT_TIMESTAMP_TZ; + break; + case OCI_TIMESTAMP_LTZ: + res = SQLT_TIMESTAMP_LTZ; + break; + } + break; + } + case OCI_CDT_INTERVAL: + { + switch (subtype) + { + case OCI_INTERVAL_YM: + res = SQLT_INTERVAL_YM; + break; + case OCI_INTERVAL_DS: + res = SQLT_INTERVAL_DS; + break; + } + break; + } + case OCI_CDT_LOB: + { + switch (subtype) + { + case OCI_CLOB: + case OCI_NCLOB: + res = SQLT_CLOB; + break; + case OCI_BLOB: + res = SQLT_BLOB; + break; + } + break; + } + case OCI_CDT_FILE: + { + switch (subtype) + { + case OCI_CFILE: + res = SQLT_CFILE; + break; + case OCI_BFILE: + res = SQLT_BFILE; + break; + } + break; + } + case OCI_CDT_LONG: + { + switch (subtype) + { + case OCI_CLONG: + res = SQLT_LNG; + break; + case OCI_BLONG: + res = SQLT_LBI; + break; + } + break; + } + } + + return res; +} + +/* --------------------------------------------------------------------------------------------- * + * ExternalSubTypeToHandleType + * --------------------------------------------------------------------------------------------- */ + +unsigned int ExternalSubTypeToHandleType +( + unsigned int type, + unsigned int subtype +) +{ + unsigned int res = OCI_UNKNOWN; + + switch (type) + { + case OCI_CDT_TIMESTAMP: + { + switch (subtype) + { + case OCI_TIMESTAMP: + res = OCI_DTYPE_TIMESTAMP; + break; + case OCI_TIMESTAMP_TZ: + res = OCI_DTYPE_TIMESTAMP_TZ; + break; + case OCI_TIMESTAMP_LTZ: + res = OCI_DTYPE_TIMESTAMP_LTZ; + break; + } + break; + } + case OCI_CDT_INTERVAL: + { + switch (subtype) + { + case OCI_INTERVAL_YM: + res = OCI_DTYPE_INTERVAL_YM; + break; + case OCI_INTERVAL_DS: + res = OCI_DTYPE_INTERVAL_DS; + break; + } + break; + } + } + + return res; +} + +/* --------------------------------------------------------------------------------------------- * + * FreeObjectFromType + * --------------------------------------------------------------------------------------------- */ + +boolean FreeObjectFromType +( + void * obj, + unsigned int type +) +{ + boolean res = FALSE; + + switch (type) + { + case OCI_CDT_NUMERIC: + { + res = NumberFree((OCI_Number*)obj); + break; + } + case OCI_CDT_DATETIME: + { + res = DateFree((OCI_Date*)obj); + break; + } + case OCI_CDT_LOB: + { + res = LobFree((OCI_Lob*)obj); + break; + } + case OCI_CDT_FILE: + { + res = FileFree((OCI_File*)obj); + break; + } + case OCI_CDT_OBJECT: + { + res = ObjectFree((OCI_Object*)obj); + break; + } + case OCI_CDT_COLLECTION: + { + res = CollectionFree((OCI_Coll*)obj); + break; + } + case OCI_CDT_TIMESTAMP: + { + res = TimestampFree((OCI_Timestamp*)obj); + break; + } + case OCI_CDT_INTERVAL: + { + res = IntervalFree((OCI_Interval*)obj); + break; + } + case OCI_CDT_REF: + { + res = ReferenceFree((OCI_Ref*)obj); + break; + } + } + + return res; +} diff --git a/src/helpers.h b/src/helpers.h new file mode 100644 index 00000000..655a035f --- /dev/null +++ b/src/helpers.h @@ -0,0 +1,44 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_HELPERS_H_INCLUDED +#define OCILIB_HELPERS_H_INCLUDED + +#include "types.h" + +unsigned int ExternalSubTypeToSQLType +( + unsigned int type, + unsigned int subtype +); + +unsigned int ExternalSubTypeToHandleType +( + unsigned int type, + unsigned int subtype +); + +boolean FreeObjectFromType +( + void * obj, + unsigned int type +); + +#endif /* OCILIB_HELPERS_H_INCLUDED */ diff --git a/src/oci_import.h b/src/import.h similarity index 83% rename from src/oci_import.h rename to src/import.h index d12b0845..2be9022c 100644 --- a/src/oci_import.h +++ b/src/import.h @@ -1,336 +1,335 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OCILIB_OCI_IMPORT_H_INCLUDED -#define OCILIB_OCI_IMPORT_H_INCLUDED - -#ifdef OCI_IMPORT_LINKAGE - -/* this is necessary because some Oracle headers do NOT include C++ checks ! - By example, the file orid.h is not protected ! -*/ - - #ifdef __cplusplus -extern "C" { - #endif /* __cplusplus */ - - #include - #include - #include - - #ifdef __cplusplus -} - #endif - - #ifdef _MSC_VER - #pragma comment(lib, "oci.lib") - #endif - -#else - - #include "oci_loader.h" - #include "oci_api.h" - -/* Setup Oracle shared library name if not provided */ - - #ifndef OCI_DL - #if defined(_WINDOWS) - #define OCI_DL oci.dll - #elif defined(__APPLE__) - #define OCI_DL libclntsh.dylib - #elif defined(__hppa) - #define OCI_DL libclntsh.sl - #else - #define OCI_DL libclntsh.so - #endif - #endif - -/* ANSI string version of Oracle shared lib */ - - #define OCI_DL_ANSI_GET(s) OCI_DL_ANSI_CVT(s) - #define OCI_DL_ANSI_CVT(s) # s - #define OCI_DL_ANSI_NAME OCI_DL_ANSI_GET(OCI_DL) - -/* Meta string version of Oracle shared lib */ - - #define OCI_DL_GET(s) OCI_DL_CVT(s) - #define OCI_DL_CVT(s) OTEXT(# s) - #define OCI_DL_NAME OCI_DL_GET(OCI_DL) - -/* symbol list */ - -extern OCIENVCREATE OCIEnvCreate; -extern OCISERVERATTACH OCIServerAttach; -extern OCISERVERDETACH OCIServerDetach; -extern OCIHANDLEALLOC OCIHandleAlloc; -extern OCIHANDLEFREE OCIHandleFree; -extern OCIDESCRIPTORALLOC OCIDescriptorAlloc; -extern OCIDESCRIPTORFREE OCIDescriptorFree; -extern OCISESSIONBEGIN OCISessionBegin; -extern OCISESSIONEND OCISessionEnd; -extern OCIPASSWORDCHANGE OCIPasswordChange; -extern OCIBINDBYPOS OCIBindByPos; -extern OCIBINDBYNAME OCIBindByName; -extern OCIBINDDYNAMIC OCIBindDynamic; -extern OCIBINDOBJECT OCIBindObject; -extern OCIDEFINEBYPOS OCIDefineByPos; -extern OCIDEFINEOBJECT OCIDefineObject; -extern OCISTMTPREPARE OCIStmtPrepare; -extern OCISTMTEXECUTE OCIStmtExecute; -extern OCISTMTFETCH OCIStmtFetch; -extern OCISTMTFETCH2 OCIStmtFetch2; -extern OCISTMTGETPIECEINFO OCIStmtGetPieceInfo; -extern OCISTMTSETPIECEINFO OCIStmtSetPieceInfo; -extern OCIPARAMGET OCIParamGet; -extern OCIPARAMSET OCIParamSet; -extern OCITRANSSTART OCITransStart; -extern OCITRANSDETACH OCITransDetach; -extern OCITRANSPREPARE OCITransPrepare; -extern OCITRANSFORGET OCITransForget; -extern OCITRANSCOMMIT OCITransCommit; -extern OCITRANSROLLBACK OCITransRollback; -extern OCIERRORGET OCIErrorGet; -extern OCILOBCREATETEMPORARY OCILobCreateTemporary; -extern OCILOBFREETEMPORARY OCILobFreeTemporary; -extern OCILOBISTEMPORARY OCILobIsTemporary; -extern OCILOBAPPEND OCILobAppend; -extern OCILOBCOPY OCILobCopy; -extern OCILOBGETLENGTH OCILobGetLength; -extern OCILOBGETCHUNKSIZE OCILobGetChunkSize; -extern OCILOBREAD OCILobRead; -extern OCILOBWRITE OCILobWrite; -extern OCILOBTRIM OCILobTrim; -extern OCILOBERASE OCILobErase; -extern OCILOBOPEN OCILobOpen; -extern OCILOBCLOSE OCILobClose; -extern OCILOBLOCATORASSIGN OCILobLocatorAssign; -extern OCILOBASSIGN OCILobAssign; -extern OCILOBISEQUAL OCILobIsEqual; -extern OCILOBFLUSHBUFFER OCILobFlushBuffer; -extern OCILOBGETSTORAGELIMIT OCILobGetStorageLimit; -extern OCILOBENABLEBUFFERING OCILobEnableBuffering; -extern OCILOBDISABLEBUFFERING OCILobDisableBuffering; -extern OCILOBFILEOPEN OCILobFileOpen; -extern OCILOBFILECLOSE OCILobFileClose; -extern OCILOBFILECLOSEALL OCILobFileCloseAll; -extern OCILOBFILEISOPEN OCILobFileIsOpen; -extern OCILOBFILEEXISTS OCILobFileExists; -extern OCILOBFIELGETNAME OCILobFileGetName; -extern OCILOBFILESETNAME OCILobFileSetName; -extern OCILOBLOADFROMFILE OCILobLoadFromFile; -extern OCILOBWRITEAPPEND OCILobWriteAppend; -extern OCISERVERVERSION OCIServerVersion; -extern OCIBREAK OCIBreak; -extern OCIATTRGET OCIAttrGet; -extern OCIATTRSET OCIAttrSet; -extern OCIDATEASSIGN OCIDateAssign; -extern OCIDATETOTEXT OCIDateToText; -extern OCIDATEFROMTEXT OCIDateFromText; -extern OCIDATECOMPARE OCIDateCompare; -extern OCIDATEADDMONTHS OCIDateAddMonths; -extern OCIDATEADDDAYS OCIDateAddDays; -extern OCIDATELASTDAY OCIDateLastDay; -extern OCIDATEDAYSBETWEEN OCIDateDaysBetween; -extern OCIDATEZONETOZONE OCIDateZoneToZone; -extern OCIDATENEXTDAY OCIDateNextDay; -extern OCIDATECHECK OCIDateCheck; -extern OCIDATESYSDATE OCIDateSysDate; -extern OCIDESCRIBEANY OCIDescribeAny; -extern OCIINTERVALASSIGN OCIIntervalAssign; -extern OCIINTERVALCHECK OCIIntervalCheck; -extern OCIINTERVALCOMPARE OCIIntervalCompare; -extern OCIINTERVALFROMTEXT OCIIntervalFromText; -extern OCIINTERVALTOTEXT OCIIntervalToText; -extern OCIINTERVALFROMTZ OCIIntervalFromTZ; -extern OCIINTERVALGETDAYSECOND OCIIntervalGetDaySecond; -extern OCIINTERVALGETYEARMONTH OCIIntervalGetYearMonth; -extern OCIINTERVALSETDAYSECOND OCIIntervalSetDaySecond; -extern OCIINTERVALSETYEARMONTH OCIIntervalSetYearMonth; -extern OCIINTERVALSUBTRACT OCIIntervalSubtract; -extern OCIINTERVALADD OCIIntervalAdd; -extern OCIDATETIMEASSIGN OCIDateTimeAssign; -extern OCIDATETIMECHECK OCIDateTimeCheck; -extern OCIDATETIMECOMPARE OCIDateTimeCompare; -extern OCIDATETIMECONSTRUCT OCIDateTimeConstruct; -extern OCIDATETIMECONVERT OCIDateTimeConvert; -extern OCIDATETIMEFROMARRAY OCIDateTimeFromArray; -extern OCIDATETIMETOARRAY OCIDateTimeToArray; -extern OCIDATETIMEFROMTEXT OCIDateTimeFromText; -extern OCIDATETIMETOTEXT OCIDateTimeToText; -extern OCIDATETIMEGETDATE OCIDateTimeGetDate; -extern OCIDATETIMEGETTIME OCIDateTimeGetTime; -extern OCIDATETIMEGETTIMEZONENAME OCIDateTimeGetTimeZoneName; -extern OCIDATETIMEGETTIMEZONEOFFSET OCIDateTimeGetTimeZoneOffset; -extern OCIDATETIMEINTERVALADD OCIDateTimeIntervalAdd; -extern OCIDATETIMEINTERVALSUB OCIDateTimeIntervalSub; -extern OCIDATETIMESUBTRACT OCIDateTimeSubtract; -extern OCIDATETIMESYSTIMESTAMP OCIDateTimeSysTimeStamp; -extern OCIARRAYDESCRIPTORALLOC OCIArrayDescriptorAlloc; -extern OCIARRAYDESCRIPTORFREE OCIArrayDescriptorFree; -extern OCICLIENTVERSION OCIClientVersion; -extern OCITYPEBYREF OCITypeByRef; -extern OCINUMBERTOINT OCINumberToInt; -extern OCINUMBERFROMINT OCINumberFromInt; -extern OCINUMBERTOREAL OCINumberToReal; -extern OCINUMBERFROMREAL OCINumberFromReal; -extern OCINUMBERTOTEXT OCINumberToText; -extern OCINUMBERFROMTEXT OCINumberFromText; -extern OCINUMBERASSIGN OCINumberAssign; -extern OCINUMBERADD OCINumberAdd; -extern OCINUMBERSUB OCINumberSub; -extern OCINUMBERMUL OCINumberMul; -extern OCINUMBERDIV OCINumberDiv; -extern OCINUMBERCMP OCINumberCmp; -extern OCISTRINGPTR OCIStringPtr; -extern OCISTRINGSIZE OCIStringSize; -extern OCISTRINGASSIGNTEXT OCIStringAssignText; -extern OCISTRINGRESIZE OCIStringResize; -extern OCIRAWPTR OCIRawPtr; -extern OCIRAWASSIGNBYTES OCIRawAssignBytes; -extern OCIRAWRESIZE OCIRawResize; -extern OCIRAWALLOCSIZE OCIRawAllocSize; -extern OCIRAWSIZE OCIRawSize; -extern OCIOBJECTNEW OCIObjectNew; -extern OCIOBJECTFREE OCIObjectFree; -extern OCIOBJECTSETATTR OCIObjectSetAttr; -extern OCIOBJECTGETATTR OCIObjectGetAttr; -extern OCIOBJECTPIN OCIObjectPin; -extern OCIOBJECTUNPIN OCIObjectUnpin; -extern OCIOBJECTCOPY OCIObjectCopy; -extern OCIOBJECTGETOBJECTREF OCIObjectGetObjectRef; -extern OCIOBJECTGETTYPEREF OCIObjectGetTypeRef; -extern OCIOBJECTGETPROPERTY OCIObjectGetProperty; -extern OCIOBJECTGETIND OCIObjectGetInd; -extern OCIREFASSIGN OCIRefAssign; -extern OCIREFISNULL OCIRefIsNull; -extern OCIREFCLEAR OCIRefClear; -extern OCIREFTOHEX OCIRefToHex; -extern OCIREFHEXSIZE OCIRefHexSize; -extern OCITHREADPROCESSINIT OCIThreadProcessInit; -extern OCITHREADINIT OCIThreadInit; -extern OCITHREADTERM OCIThreadTerm; -extern OCITHREADIDINIT OCIThreadIdInit; -extern OCITHREADIDDESTROY OCIThreadIdDestroy; -extern OCITHREADHNDINIT OCIThreadHndInit; -extern OCITHREADHNDDESTROY OCIThreadHndDestroy; -extern OCITHREADCREATE OCIThreadCreate; -extern OCITHREADJOIN OCIThreadJoin; -extern OCITHREADCLOSE OCIThreadClose; -extern OCITHREADMUTEXINIT OCIThreadMutexInit; -extern OCITHREADMUTEXDESTROY OCIThreadMutexDestroy; -extern OCITHREADMUTEXACQUIRE OCIThreadMutexAcquire; -extern OCITHREADMUTEXRELEASE OCIThreadMutexRelease; -extern OCITHREADKEYINIT OCIThreadKeyInit; -extern OCITHREADKEYDESTROY OCIThreadKeyDestroy; -extern OCITHREADKEYSET OCIThreadKeySet; -extern OCITHREADKEYGET OCIThreadKeyGet; -extern OCICONNECTIONPOOLCREATE OCIConnectionPoolCreate; -extern OCICONNECTIONPOOLDESTROY OCIConnectionPoolDestroy; -extern OCISESSIONPOOLCREATE OCISessionPoolCreate ; -extern OCISESSIONPOOLDESTROY OCISessionPoolDestroy; -extern OCISESSIONGET OCISessionGet; -extern OCISESSIONRELEASE OCISessionRelease; -extern OCICOLLSIZE OCICollSize; -extern OCICOLLMAX OCICollMax; -extern OCICOLLGETITEM OCICollGetElem; -extern OCICOLLASSIGNELEM OCICollAssignElem; -extern OCICOLLASSIGN OCICollAssign; -extern OCICOLLAPPEND OCICollAppend; -extern OCICOLLTRIM OCICollTrim; -extern OCITABLESIZE OCITableSize; -extern OCITABLEDELETE OCITableDelete; -extern OCIITERCREATE OCIIterCreate; -extern OCIITERDELETE OCIIterDelete; -extern OCIITERINIT OCIIterInit; -extern OCIITERNEXT OCIIterNext; -extern OCIITERPREV OCIIterPrev; -extern OCIDIRPATHABORT OCIDirPathAbort; -extern OCIDIRPATHDATASAVE OCIDirPathDataSave; -extern OCIDIRPATHFINISH OCIDirPathFinish; -extern OCIDIRPATHPREPARE OCIDirPathPrepare; -extern OCIDIRPATHLOADSTREAM OCIDirPathLoadStream; -extern OCIDIRPATHCOLARRAYENTRYSET OCIDirPathColArrayEntrySet; -extern OCIDIRPATHCOLARRAYRESET OCIDirPathColArrayReset; -extern OCIDIRPATHCOLARRAYTOSTREAM OCIDirPathColArrayToStream; -extern OCIDIRPATHSTREAMRESET OCIDirPathStreamReset; -extern OCIDIRPATHFLUSHROW OCIDirPathFlushRow; -extern OCICACHEFREE OCICacheFree; -extern OCIPING OCIPing; -extern OCIAQENQ OCIAQEnq; -extern OCIAQDEQ OCIAQDeq; -extern OCIAQLISTEN OCIAQListen; -extern OCIDBSTARTUP OCIDBStartup; -extern OCIDBSHUTDOWN OCIDBShutdown; -extern OCISTMTPREPARE2 OCIStmtPrepare2; -extern OCISTMTRELEASE OCIStmtRelease; -extern OCISUBSCRIPTIONREGISTER OCISubscriptionRegister; -extern OCISUBSCRIPTIONUNREGISTER OCISubscriptionUnRegister; -extern XAOSVCCTX xaoSvcCtx; -extern XAOENV xaoEnv; -extern OCILOBGETCONTENTTYPE OCILobGetContentType; -extern OCISTMTGETNEXTRESULT OCIStmtGetNextResult; -extern OCISERVERRELEASE2 OCIServerRelease2; -extern OCISODAOPERKEYSSET OCISodaOperKeysSet; - -#ifdef ORAXB8_DEFINED - -extern OCILOBCOPY2 OCILobCopy2; -extern OCILOBERASE2 OCILobErase2; -extern OCILOBGETLENGTH2 OCILobGetLength2; -extern OCILOBLOADFROMFILE2 OCILobLoadFromFile2; -extern OCILOBREAD2 OCILobRead2; -extern OCILOBTRIM2 OCILobTrim2; -extern OCILOBWRITE2 OCILobWrite2; -extern OCILOBWRITEAPPEND2 OCILobWriteAppend2; - -#endif - - #define OCIDateGetTime(date, hour, min, sec) \ - { \ - *(hour) = (date)->OCIDateTime.OCITimeHH; \ - *(min) = (date)->OCIDateTime.OCITimeMI; \ - *(sec) = (date)->OCIDateTime.OCITimeSS; \ - } - - #define OCIDateGetDate(date, year, month, day) \ - { \ - *(year) = (date)->OCIDateYYYY; \ - *(month) = (date)->OCIDateMM; \ - *(day) = (date)->OCIDateDD; \ - } - - #define OCIDateSetTime(date, hour, min, sec) \ - { \ - (date)->OCIDateTime.OCITimeHH = hour; \ - (date)->OCIDateTime.OCITimeMI = min; \ - (date)->OCIDateTime.OCITimeSS = sec; \ - } - - #define OCIDateSetDate(date, year, month, day) \ - { \ - (date)->OCIDateYYYY = year; \ - (date)->OCIDateMM = month; \ - (date)->OCIDateDD = day; \ - } - -#endif - -#endif /* OCILIB_OCI_IMPORT_H_INCLUDED */ - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_OCI_IMPORT_H_INCLUDED +#define OCILIB_OCI_IMPORT_H_INCLUDED + + #ifdef OCI_IMPORT_LINKAGE + +/* this is necessary because some Oracle headers do NOT include C++ checks ! + By example, the file orid.h is not protected ! +*/ + + #ifdef __cplusplus +extern "C" { + #endif /* __cplusplus */ + + #include + #include + #include + + #ifdef __cplusplus +} + #endif + + #ifdef _MSC_VER + #pragma comment(lib, "oci.lib") + #endif + + #else + + #include "loader.h" + #include "oci/api.h" + +/* Setup Oracle shared library name if not provided */ + + #ifndef OCI_DL + #if defined(_WINDOWS) +#define OCI_DL oci.dll + #elif defined(__APPLE__) +#define OCI_DL libclntsh.dylib + #elif defined(__hppa) +#define OCI_DL libclntsh.sl + #else +#define OCI_DL libclntsh.so + #endif + #endif + +/* ANSI string version of Oracle shared lib */ + +#define OCI_DL_ANSI_GET(s) OCI_DL_ANSI_CVT(s) +#define OCI_DL_ANSI_CVT(s) # s +#define OCI_DL_ANSI_NAME OCI_DL_ANSI_GET(OCI_DL) + +/* Meta string version of Oracle shared lib */ + +#define OCI_DL_GET(s) OCI_DL_CVT(s) +#define OCI_DL_CVT(s) OTEXT(# s) +#define OCI_DL_NAME OCI_DL_GET(OCI_DL) + +/* symbol list */ + +extern OCIENVCREATE OCIEnvCreate; +extern OCISERVERATTACH OCIServerAttach; +extern OCISERVERDETACH OCIServerDetach; +extern OCIHANDLEALLOC OCIHandleAlloc; +extern OCIHANDLEFREE OCIHandleFree; +extern OCIDESCRIPTORALLOC OCIDescriptorAlloc; +extern OCIDESCRIPTORFREE OCIDescriptorFree; +extern OCISESSIONBEGIN OCISessionBegin; +extern OCISESSIONEND OCISessionEnd; +extern OCIPASSWORDCHANGE OCIPasswordChange; +extern OCIBINDBYPOS OCIBindByPos; +extern OCIBINDBYNAME OCIBindByName; +extern OCIBINDDYNAMIC OCIBindDynamic; +extern OCIBINDOBJECT OCIBindObject; +extern OCIDEFINEBYPOS OCIDefineByPos; +extern OCIDEFINEOBJECT OCIDefineObject; +extern OCISTMTPREPARE OCIStmtPrepare; +extern OCISTMTEXECUTE OCIStmtExecute; +extern OCISTMTFETCH OCIStmtFetch; +extern OCISTMTFETCH2 OCIStmtFetch2; +extern OCISTMTGETPIECEINFO OCIStmtGetPieceInfo; +extern OCISTMTSETPIECEINFO OCIStmtSetPieceInfo; +extern OCIPARAMGET OCIParamGet; +extern OCIPARAMSET OCIParamSet; +extern OCITRANSSTART OCITransStart; +extern OCITRANSDETACH OCITransDetach; +extern OCITRANSPREPARE OCITransPrepare; +extern OCITRANSFORGET OCITransForget; +extern OCITRANSCOMMIT OCITransCommit; +extern OCITRANSROLLBACK OCITransRollback; +extern OCIERRORGET OCIErrorGet; +extern OCILOBCREATETEMPORARY OCILobCreateTemporary; +extern OCILOBFREETEMPORARY OCILobFreeTemporary; +extern OCILOBISTEMPORARY OCILobIsTemporary; +extern OCILOBAPPEND OCILobAppend; +extern OCILOBCOPY OCILobCopy; +extern OCILOBGETLENGTH OCILobGetLength; +extern OCILOBGETCHUNKSIZE OCILobGetChunkSize; +extern OCILOBREAD OCILobRead; +extern OCILOBWRITE OCILobWrite; +extern OCILOBTRIM OCILobTrim; +extern OCILOBERASE OCILobErase; +extern OCILOBOPEN OCILobOpen; +extern OCILOBCLOSE OCILobClose; +extern OCILOBLOCATORASSIGN OCILobLocatorAssign; +extern OCILOBASSIGN OCILobAssign; +extern OCILOBISEQUAL OCILobIsEqual; +extern OCILOBFLUSHBUFFER OCILobFlushBuffer; +extern OCILOBGETSTORAGELIMIT OCILobGetStorageLimit; +extern OCILOBENABLEBUFFERING OCILobEnableBuffering; +extern OCILOBDISABLEBUFFERING OCILobDisableBuffering; +extern OCILOBFILEOPEN OCILobFileOpen; +extern OCILOBFILECLOSE OCILobFileClose; +extern OCILOBFILECLOSEALL OCILobFileCloseAll; +extern OCILOBFILEISOPEN OCILobFileIsOpen; +extern OCILOBFILEEXISTS OCILobFileExists; +extern OCILOBFIELGETNAME OCILobFileGetName; +extern OCILOBFILESETNAME OCILobFileSetName; +extern OCILOBLOADFROMFILE OCILobLoadFromFile; +extern OCILOBWRITEAPPEND OCILobWriteAppend; +extern OCISERVERVERSION OCIServerVersion; +extern OCIBREAK OCIBreak; +extern OCIATTRGET OCIAttrGet; +extern OCIATTRSET OCIAttrSet; +extern OCIDATEASSIGN OCIDateAssign; +extern OCIDATETOTEXT OCIDateToText; +extern OCIDATEFROMTEXT OCIDateFromText; +extern OCIDATECOMPARE OCIDateCompare; +extern OCIDATEADDMONTHS OCIDateAddMonths; +extern OCIDATEADDDAYS OCIDateAddDays; +extern OCIDATELASTDAY OCIDateLastDay; +extern OCIDATEDAYSBETWEEN OCIDateDaysBetween; +extern OCIDATEZONETOZONE OCIDateZoneToZone; +extern OCIDATENEXTDAY OCIDateNextDay; +extern OCIDATECHECK OCIDateCheck; +extern OCIDATESYSDATE OCIDateSysDate; +extern OCIDESCRIBEANY OCIDescribeAny; +extern OCIINTERVALASSIGN OCIIntervalAssign; +extern OCIINTERVALCHECK OCIIntervalCheck; +extern OCIINTERVALCOMPARE OCIIntervalCompare; +extern OCIINTERVALFROMTEXT OCIIntervalFromText; +extern OCIINTERVALTOTEXT OCIIntervalToText; +extern OCIINTERVALFROMTZ OCIIntervalFromTZ; +extern OCIINTERVALGETDAYSECOND OCIIntervalGetDaySecond; +extern OCIINTERVALGETYEARMONTH OCIIntervalGetYearMonth; +extern OCIINTERVALSETDAYSECOND OCIIntervalSetDaySecond; +extern OCIINTERVALSETYEARMONTH OCIIntervalSetYearMonth; +extern OCIINTERVALSUBTRACT OCIIntervalSubtract; +extern OCIINTERVALADD OCIIntervalAdd; +extern OCIDATETIMEASSIGN OCIDateTimeAssign; +extern OCIDATETIMECHECK OCIDateTimeCheck; +extern OCIDATETIMECOMPARE OCIDateTimeCompare; +extern OCIDATETIMECONSTRUCT OCIDateTimeConstruct; +extern OCIDATETIMECONVERT OCIDateTimeConvert; +extern OCIDATETIMEFROMARRAY OCIDateTimeFromArray; +extern OCIDATETIMETOARRAY OCIDateTimeToArray; +extern OCIDATETIMEFROMTEXT OCIDateTimeFromText; +extern OCIDATETIMETOTEXT OCIDateTimeToText; +extern OCIDATETIMEGETDATE OCIDateTimeGetDate; +extern OCIDATETIMEGETTIME OCIDateTimeGetTime; +extern OCIDATETIMEGETTIMEZONENAME OCIDateTimeGetTimeZoneName; +extern OCIDATETIMEGETTIMEZONEOFFSET OCIDateTimeGetTimeZoneOffset; +extern OCIDATETIMEINTERVALADD OCIDateTimeIntervalAdd; +extern OCIDATETIMEINTERVALSUB OCIDateTimeIntervalSub; +extern OCIDATETIMESUBTRACT OCIDateTimeSubtract; +extern OCIDATETIMESYSTIMESTAMP OCIDateTimeSysTimeStamp; +extern OCIARRAYDESCRIPTORALLOC OCIArrayDescriptorAlloc; +extern OCIARRAYDESCRIPTORFREE OCIArrayDescriptorFree; +extern OCICLIENTVERSION OCIClientVersion; +extern OCITYPEBYREF OCITypeByRef; +extern OCINUMBERTOINT OCINumberToInt; +extern OCINUMBERFROMINT OCINumberFromInt; +extern OCINUMBERTOREAL OCINumberToReal; +extern OCINUMBERFROMREAL OCINumberFromReal; +extern OCINUMBERTOTEXT OCINumberToText; +extern OCINUMBERFROMTEXT OCINumberFromText; +extern OCINUMBERASSIGN OCINumberAssign; +extern OCINUMBERADD OCINumberAdd; +extern OCINUMBERSUB OCINumberSub; +extern OCINUMBERMUL OCINumberMul; +extern OCINUMBERDIV OCINumberDiv; +extern OCINUMBERCMP OCINumberCmp; +extern OCISTRINGPTR OCIStringPtr; +extern OCISTRINGSIZE OCIStringSize; +extern OCISTRINGASSIGNTEXT OCIStringAssignText; +extern OCISTRINGRESIZE OCIStringResize; +extern OCIRAWPTR OCIRawPtr; +extern OCIRAWASSIGNBYTES OCIRawAssignBytes; +extern OCIRAWRESIZE OCIRawResize; +extern OCIRAWALLOCSIZE OCIRawAllocSize; +extern OCIRAWSIZE OCIRawSize; +extern OCIOBJECTNEW OCIObjectNew; +extern OCIOBJECTFREE OCIObjectFree; +extern OCIOBJECTSETATTR OCIObjectSetAttr; +extern OCIOBJECTGETATTR OCIObjectGetAttr; +extern OCIOBJECTPIN OCIObjectPin; +extern OCIOBJECTUNPIN OCIObjectUnpin; +extern OCIOBJECTCOPY OCIObjectCopy; +extern OCIOBJECTGETOBJECTREF OCIObjectGetObjectRef; +extern OCIOBJECTGETTYPEREF OCIObjectGetTypeRef; +extern OCIOBJECTGETPROPERTY OCIObjectGetProperty; +extern OCIOBJECTGETIND OCIObjectGetInd; +extern OCIREFASSIGN OCIRefAssign; +extern OCIREFISNULL OCIRefIsNull; +extern OCIREFCLEAR OCIRefClear; +extern OCIREFTOHEX OCIRefToHex; +extern OCIREFHEXSIZE OCIRefHexSize; +extern OCITHREADPROCESSINIT OCIThreadProcessInit; +extern OCITHREADINIT OCIThreadInit; +extern OCITHREADTERM OCIThreadTerm; +extern OCITHREADIDINIT OCIThreadIdInit; +extern OCITHREADIDDESTROY OCIThreadIdDestroy; +extern OCITHREADHNDINIT OCIThreadHndInit; +extern OCITHREADHNDDESTROY OCIThreadHndDestroy; +extern OCITHREADCREATE OCIThreadCreate; +extern OCITHREADJOIN OCIThreadJoin; +extern OCITHREADCLOSE OCIThreadClose; +extern OCITHREADMUTEXINIT OCIThreadMutexInit; +extern OCITHREADMUTEXDESTROY OCIThreadMutexDestroy; +extern OCITHREADMUTEXACQUIRE OCIThreadMutexAcquire; +extern OCITHREADMUTEXRELEASE OCIThreadMutexRelease; +extern OCITHREADKEYINIT OCIThreadKeyInit; +extern OCITHREADKEYDESTROY OCIThreadKeyDestroy; +extern OCITHREADKEYSET OCIThreadKeySet; +extern OCITHREADKEYGET OCIThreadKeyGet; +extern OCICONNECTIONPOOLCREATE OCIConnectionPoolCreate; +extern OCICONNECTIONPOOLDESTROY OCIConnectionPoolDestroy; +extern OCISESSIONPOOLCREATE OCISessionPoolCreate; +extern OCISESSIONPOOLDESTROY OCISessionPoolDestroy; +extern OCISESSIONGET OCISessionGet; +extern OCISESSIONRELEASE OCISessionRelease; +extern OCICOLLSIZE OCICollSize; +extern OCICOLLMAX OCICollMax; +extern OCICOLLGETITEM OCICollGetElem; +extern OCICOLLASSIGNELEM OCICollAssignElem; +extern OCICOLLASSIGN OCICollAssign; +extern OCICOLLAPPEND OCICollAppend; +extern OCICOLLTRIM OCICollTrim; +extern OCITABLESIZE OCITableSize; +extern OCITABLEDELETE OCITableDelete; +extern OCIITERCREATE OCIIterCreate; +extern OCIITERDELETE OCIIterDelete; +extern OCIITERINIT OCIIterInit; +extern OCIITERNEXT OCIIterNext; +extern OCIITERPREV OCIIterPrev; +extern OCIDIRPATHABORT OCIDirPathAbort; +extern OCIDIRPATHDATASAVE OCIDirPathDataSave; +extern OCIDIRPATHFINISH OCIDirPathFinish; +extern OCIDIRPATHPREPARE OCIDirPathPrepare; +extern OCIDIRPATHLOADSTREAM OCIDirPathLoadStream; +extern OCIDIRPATHCOLARRAYENTRYSET OCIDirPathColArrayEntrySet; +extern OCIDIRPATHCOLARRAYRESET OCIDirPathColArrayReset; +extern OCIDIRPATHCOLARRAYTOSTREAM OCIDirPathColArrayToStream; +extern OCIDIRPATHSTREAMRESET OCIDirPathStreamReset; +extern OCIDIRPATHFLUSHROW OCIDirPathFlushRow; +extern OCICACHEFREE OCICacheFree; +extern OCIPING OCIPing; +extern OCIAQENQ OCIAQEnq; +extern OCIAQDEQ OCIAQDeq; +extern OCIAQLISTEN OCIAQListen; +extern OCIDBSTARTUP OCIDBStartup; +extern OCIDBSHUTDOWN OCIDBShutdown; +extern OCISTMTPREPARE2 OCIStmtPrepare2; +extern OCISTMTRELEASE OCIStmtRelease; +extern OCISUBSCRIPTIONREGISTER OCISubscriptionRegister; +extern OCISUBSCRIPTIONUNREGISTER OCISubscriptionUnRegister; +extern XAOSVCCTX xaoSvcCtx; +extern XAOENV xaoEnv; +extern OCILOBGETCONTENTTYPE OCILobGetContentType; +extern OCISTMTGETNEXTRESULT OCIStmtGetNextResult; +extern OCISERVERRELEASE2 OCIServerRelease2; +extern OCISODAOPERKEYSSET OCISodaOperKeysSet; + + #ifdef ORAXB8_DEFINED + +extern OCILOBCOPY2 OCILobCopy2; +extern OCILOBERASE2 OCILobErase2; +extern OCILOBGETLENGTH2 OCILobGetLength2; +extern OCILOBLOADFROMFILE2 OCILobLoadFromFile2; +extern OCILOBREAD2 OCILobRead2; +extern OCILOBTRIM2 OCILobTrim2; +extern OCILOBWRITE2 OCILobWrite2; +extern OCILOBWRITEAPPEND2 OCILobWriteAppend2; + + #endif + +#define OCIDateGetTime(date, hour, min, sec) \ + { \ + *(hour) = (date)->OCIDateTime.OCITimeHH; \ + *(min) = (date)->OCIDateTime.OCITimeMI; \ + *(sec) = (date)->OCIDateTime.OCITimeSS; \ + } + +#define OCIDateGetDate(date, year, month, day) \ + { \ + *(year) = (date)->OCIDateYYYY; \ + *(month) = (date)->OCIDateMM; \ + *(day) = (date)->OCIDateDD; \ + } + +#define OCIDateSetTime(date, hour, min, sec) \ + { \ + (date)->OCIDateTime.OCITimeHH = hour; \ + (date)->OCIDateTime.OCITimeMI = min; \ + (date)->OCIDateTime.OCITimeSS = sec; \ + } + +#define OCIDateSetDate(date, year, month, day) \ + { \ + (date)->OCIDateYYYY = year; \ + (date)->OCIDateMM = month; \ + (date)->OCIDateDD = day; \ + } + + #endif + +#endif /* OCILIB_OCI_IMPORT_H_INCLUDED */ diff --git a/src/interval.c b/src/interval.c index 7e3a3501..e412400c 100644 --- a/src/interval.c +++ b/src/interval.c @@ -18,25 +18,28 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "interval.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "array.h" +#include "helpers.h" +#include "macros.h" +#include "strings.h" #if OCI_VERSION_COMPILE >= OCI_9_0 -static const unsigned int IntervalTypeValues[] = { OCI_INTERVAL_YM, OCI_INTERVAL_DS }; -#endif -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int IntervalTypeValues[] = +{ + OCI_INTERVAL_YM, + OCI_INTERVAL_DS +}; + +#endif /* --------------------------------------------------------------------------------------------- * - * OCI_Interval functions + * IntervalInit * --------------------------------------------------------------------------------------------- */ -OCI_Interval * OCI_IntervalInit +OCI_Interval * IntervalInitialize ( OCI_Connection *con, OCI_Interval *itv, @@ -44,152 +47,171 @@ OCI_Interval * OCI_IntervalInit ub4 type ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Interval*, itv, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) #if OCI_VERSION_COMPILE >= OCI_9_0 - - OCI_ALLOCATE_DATA(OCI_IPC_INTERVAL, itv, 1); - if (OCI_STATUS) - { - itv->con = con; - itv->handle = buffer; - itv->type = type; + ALLOC_DATA(OCI_IPC_INTERVAL, itv, 1); - /* get the right error handle */ + itv->con = con; + itv->handle = buffer; + itv->type = type; - itv->err = con ? con->err : OCILib.err; - itv->env = con ? con->env : OCILib.env; + /* get the right error handle */ - /* allocate buffer if needed */ + itv->err = con ? con->err : Env.err; + itv->env = con ? con->env : Env.env; - if (!itv->handle || (OCI_OBJECT_ALLOCATED_ARRAY == itv->hstate)) - { - if (OCI_OBJECT_ALLOCATED_ARRAY != itv->hstate) - { - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)itv->env, (dvoid **)(void *)&itv->handle, (ub4)OCI_ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, itv->type)); + /* allocate buffer if needed */ - itv->hstate = OCI_OBJECT_ALLOCATED; - } - } - else + if (NULL == itv->handle || (OCI_OBJECT_ALLOCATED_ARRAY == itv->hstate)) + { + if (OCI_OBJECT_ALLOCATED_ARRAY != itv->hstate) { - itv->hstate = OCI_OBJECT_FETCHED_CLEAN; + CHECK + ( + MemoryAllocDescriptor + ( + (dvoid *)itv->env, (dvoid **)(void *)&itv->handle, + (ub4)ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, itv->type) + ) + ) + + itv->hstate = OCI_OBJECT_ALLOCATED; } } - - /* check for failure */ - - if (!OCI_STATUS && itv) + else { - OCI_IntervalFree(itv); - itv = NULL; + itv->hstate = OCI_OBJECT_FETCHED_CLEAN; } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + IntervalFree(itv); + itv = NULL; + } + + SET_RETVAL(itv) + ) + #else OCI_NOT_USED(con) OCI_NOT_USED(type) OCI_NOT_USED(buffer) -#endif + CHECK(FALSE) - return itv; -} + EXIT_FUNC() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ +#endif +} /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalCreate + * IntervalCreate * --------------------------------------------------------------------------------------------- */ -OCI_Interval * OCI_API OCI_IntervalCreate +OCI_Interval * IntervalCreate ( OCI_Connection *con, unsigned int type ) { - OCI_CALL_ENTER(OCI_Interval*, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_INTERVAL_ENABLED(con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Interval*, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + CHECK_INITIALIZED() + CHECK_INTERVAL_ENABLED(con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, IntervalTypeValues, OTEXT("Interval type")); + CHECK_ENUM_VALUE(type, IntervalTypeValues, OTEXT("Interval type")) #endif - OCI_RETVAL = OCI_IntervalInit(con, NULL, NULL, type); - OCI_STATUS = (NULL != OCI_RETVAL); + SET_RETVAL(IntervalInitialize(con, NULL, NULL, type)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalFree + * IntervalFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalFree +boolean IntervalFree ( OCI_Interval *itv ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_INTERVAL_ENABLED(itv->con) - OCI_CALL_CHECK_OBJECT_FETCHED(itv); - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_INTERVAL_ENABLED(itv->con) + CHECK_OBJECT_FETCHED(itv); if (OCI_OBJECT_ALLOCATED == itv->hstate) { - OCI_DescriptorFree((dvoid *)itv->handle, OCI_ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, itv->type)); + MemoryFreeDescriptor + ( + (dvoid*)itv->handle, + ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, itv->type) + ); } if (OCI_OBJECT_ALLOCATED_ARRAY != itv->hstate) { - OCI_FREE(itv) + FREE(itv) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalArrayCreate + * IntervalArrayCreate * --------------------------------------------------------------------------------------------- */ -OCI_Interval ** OCI_API OCI_IntervalArrayCreate +OCI_Interval ** IntervalCreateArray ( OCI_Connection *con, unsigned int type, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Interval**, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Interval **, NULL) - OCI_CALL_CHECK_INTERVAL_ENABLED(con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_INTERVAL_ENABLED(con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, IntervalTypeValues, OTEXT("Interval type")) + CHECK_ENUM_VALUE(type, IntervalTypeValues, OTEXT("Interval type")) #endif #if OCI_VERSION_COMPILE >= OCI_9_0 - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_INTERVAL, type, - sizeof(OCIInterval *), sizeof(OCI_Interval), - OCI_ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, type), NULL); + arr = ArrayCreate(con, nbelem, OCI_CDT_INTERVAL, type, + sizeof(OCIInterval*), sizeof(OCI_Interval), + ExternalSubTypeToHandleType(OCI_CDT_INTERVAL, type), NULL); - OCI_STATUS = (NULL != arr); + CHECK_NULL(arr) - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Interval **) arr->tab_obj; - } + SET_RETVAL((OCI_Interval**)arr->tab_obj) #else @@ -199,156 +221,209 @@ OCI_Interval ** OCI_API OCI_IntervalArrayCreate #endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalArrayFree + * IntervalArrayFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalArrayFree +boolean IntervalFreeArray ( OCI_Interval **itvs ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, itvs) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_PTR(OCI_IPC_ARRAY, itvs) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)itvs); + SET_RETVAL(ArrayFreeFromHandles((void**)itvs)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalGetType + * IntervalGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_IntervalGetType +unsigned int IntervalGetType ( OCI_Interval *itv ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_INTERVAL, itv, type, itv->con, NULL, itv->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_INTERVAL, itv, + /* member */ type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalAssign + * IntervalAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalAssign +boolean IntervalAssign ( OCI_Interval *itv, OCI_Interval *itv_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv_src) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) - #if OCI_VERSION_COMPILE >= OCI_9_0 + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_INTERVAL, itv_src) - OCI_EXEC(OCIIntervalAssign((dvoid *) itv->env, itv->err, itv_src->handle, itv->handle)) +#if OCI_VERSION_COMPILE >= OCI_9_0 + + CHECK_OCI + ( + itv->err, + OCIIntervalAssign, + (dvoid *) itv->env, itv->err, + itv_src->handle, itv->handle + ) - #endif + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; +#endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalCheck + * IntervalCheck * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_IntervalCheck +int IntervalCheck ( OCI_Interval *itv ) { + ENTER_FUNC + ( + /* returns */ int, OCI_ERROR, + /* context */ OCI_IPC_INTERVAL, itv + ) + ub4 value = (ub4) OCI_ERROR; - - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) - #if OCI_VERSION_COMPILE >= OCI_9_0 + CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_EXEC(OCIIntervalCheck((dvoid *) itv->env, itv->err, itv->handle, &value)) +#if OCI_VERSION_COMPILE >= OCI_9_0 + + CHECK_OCI + ( + itv->err, + OCIIntervalCheck, + (dvoid *) itv->env, itv->err, + itv->handle, &value + ) - #endif +#endif - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalCompare + * IntervalCompare * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_IntervalCompare +int IntervalCompare ( OCI_Interval *itv, OCI_Interval *itv2 ) { + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_INTERVAL, itv + ) + sword value = OCI_ERROR; - - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv2) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) - #if OCI_VERSION_COMPILE >= OCI_9_0 + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_INTERVAL, itv2) - OCI_EXEC(OCIIntervalCompare((dvoid *) itv->env, itv->err, itv->handle, itv2->handle, &value)) +#if OCI_VERSION_COMPILE >= OCI_9_0 - #endif + CHECK_OCI + ( + itv->err, + OCIIntervalCompare, + (dvoid *) itv->env, itv->err, + itv->handle, itv2->handle, + &value + ) - OCI_RETVAL = value; +#endif - OCI_CALL_EXIT() + SET_RETVAL(value) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalFromText + * IntervalFromString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalFromText +boolean IntervalFromString ( - OCI_Interval *itv, + OCI_Interval* itv, const otext * str ) { - dbtext *dbstr = NULL; - int dbsize = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + dbtext *dbstr = NULL; + int dbsize = -1; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_STRING, str) - dbstr = OCI_StringGetOracleString(str, &dbsize); + dbstr = StringGetDBString(str, &dbsize); - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIIntervalFromText((dvoid *) itv->env, itv->err, (OraText *) dbstr, (size_t) dbsize, itv->handle)) + CHECK_OCI + ( + itv->err, + OCIIntervalFromText, + (dvoid *) itv->env, itv->err, + (OraText *) dbstr, (size_t) dbsize, + itv->handle + ) - OCI_StringReleaseOracleString(dbstr); + SET_SUCCESS() #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalToText + * IntervalToString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalToText +boolean IntervalToString ( OCI_Interval *itv, int leading_prec, @@ -357,94 +432,113 @@ boolean OCI_API OCI_IntervalToText otext *str ) { - dbtext *dbstr = NULL; - int dbsize = size * (int) sizeof(otext); - size_t len = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + dbtext *dbstr = NULL; + int dbsize = size * (int) sizeof(otext); + size_t len = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_STRING, str) /* initialize output buffer in case of OCI failure */ str[0] = 0; - dbstr = OCI_StringGetOracleString(str, &dbsize); + dbstr = StringGetDBString(str, &dbsize); len = (size_t) dbsize; #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC + CHECK_OCI ( - OCIIntervalToText((dvoid *) itv->env, itv->err, - (OCIInterval *) itv->handle, - (ub1) leading_prec, (ub1) fraction_prec, - (OraText *) dbstr, (size_t) dbsize, - (size_t *) &len) + itv->err, + OCIIntervalToText, + (dvoid *) itv->env, itv->err, + (OCIInterval *) itv->handle, + (ub1) leading_prec, (ub1) fraction_prec, + (OraText *) dbstr, (size_t) dbsize, + (size_t *) &len ) - #else +#else OCI_NOT_USED(leading_prec) OCI_NOT_USED(fraction_prec) - #endif +#endif dbsize = (int)len; - OCI_StringCopyOracleStringToNativeString(dbstr, str, dbcharcount(dbsize)); - OCI_StringReleaseOracleString(dbstr); + StringCopyDBStringToNativeString(dbstr, str, dbcharcount(dbsize)); /* set null string terminator */ str[dbcharcount(dbsize)] = 0; + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalFromTimeZone + * IntervalFromTimeZone * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalFromTimeZone +boolean IntervalFromTimeZone ( OCI_Interval *itv, const otext * str ) { - dbtext *dbstr = NULL; - int dbsize = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + dbtext *dbstr = NULL; + int dbsize = -1; - dbstr = OCI_StringGetOracleString(str, &dbsize); + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_STRING, str) -#if OCI_VERSION_COMPILE >= OCI_9_0 + dbstr = StringGetDBString(str, &dbsize); - OCI_EXEC(OCIIntervalFromTZ((dvoid *) itv->env, itv->err, (CONST OraText *) dbstr, (size_t) dbsize, itv->handle)) +#if OCI_VERSION_COMPILE >= OCI_9_0 -#endif + CHECK_OCI + ( + itv->err, + OCIIntervalFromTZ, + (dvoid *) itv->env, itv->err, + (CONST OraText *) dbstr, + (size_t) dbsize, itv->handle + ) - OCI_StringReleaseOracleString(dbstr); + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; +#endif - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalGetDaySecond + * IntervalGetDaySecond * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalGetDaySecond +boolean IntervalGetDaySecond ( OCI_Interval *itv, int *day, @@ -454,13 +548,17 @@ boolean OCI_API OCI_IntervalGetDaySecond int *fsec ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, hour) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, min) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, sec) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, fsec) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_INT, hour) + CHECK_PTR(OCI_IPC_INT, min) + CHECK_PTR(OCI_IPC_INT, sec) + CHECK_PTR(OCI_IPC_INT, fsec) *day = 0; *hour = 0; @@ -470,13 +568,17 @@ boolean OCI_API OCI_IntervalGetDaySecond #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC + CHECK_OCI ( - OCIIntervalGetDaySecond((dvoid *) itv->env, itv->err, - (sb4 *) day, (sb4 *) hour, (sb4 *) min, - (sb4 *) sec, (sb4 *) fsec, itv->handle) + itv->err, + OCIIntervalGetDaySecond, + (dvoid *) itv->env, itv->err, + (sb4 *) day, (sb4 *) hour, (sb4 *) min, + (sb4 *) sec, (sb4 *) fsec, itv->handle ) + SET_SUCCESS() + #else OCI_NOT_USED(day) @@ -487,47 +589,56 @@ boolean OCI_API OCI_IntervalGetDaySecond #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalGetYearMonth + * IntervalGetYearMonth * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalGetYearMonth +boolean IntervalGetYearMonth ( OCI_Interval *itv, int *year, int *month ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, year) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, month) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_INT, year) + CHECK_PTR(OCI_IPC_INT, month) *year = 0; *month = 0; #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIIntervalGetYearMonth((dvoid *) itv->env, itv->err, (sb4 *) year, (sb4 *) month, itv->handle)) + CHECK_OCI + ( + itv->err, + OCIIntervalGetYearMonth, + (dvoid *) itv->env, itv->err, + (sb4 *) year, (sb4 *) month, + itv->handle + ) -#endif + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; +#endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalSetDaySecond + * IntervalSetDaySecond * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalSetDaySecond +boolean IntervalSetDaySecond ( OCI_Interval *itv, int day, @@ -537,19 +648,27 @@ boolean OCI_API OCI_IntervalSetDaySecond int fsec ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC + CHECK_OCI ( - OCIIntervalSetDaySecond((dvoid *) itv->env, itv->err, - (sb4) day, (sb4) hour, (sb4) min, - (sb4) sec, (sb4) fsec, itv->handle) + itv->err, + OCIIntervalSetDaySecond, + (dvoid *) itv->env, itv->err, + (sb4) day, (sb4) hour, (sb4) min, + (sb4) sec, (sb4) fsec, itv->handle ) + SET_SUCCESS() + #else OCI_NOT_USED(day) @@ -560,29 +679,39 @@ boolean OCI_API OCI_IntervalSetDaySecond #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalSetYearMonth + * IntervalSetYearMonth * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalSetYearMonth +boolean IntervalSetYearMonth ( OCI_Interval *itv, int year, int month ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIIntervalSetYearMonth((dvoid *) itv->env, itv->err, (sb4) year, (sb4) month, itv->handle)) + CHECK_OCI + ( + itv->err, + OCIIntervalSetYearMonth, + (dvoid *) itv->env, itv->err, + (sb4) year, (sb4) month, itv->handle + ) + + SET_SUCCESS() #else @@ -591,59 +720,77 @@ boolean OCI_API OCI_IntervalSetYearMonth #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalAdd + * IntervalAdd * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalAdd +boolean IntervalAdd ( OCI_Interval *itv, OCI_Interval *itv2 ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv2) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_INTERVAL, itv2) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIIntervalAdd((dvoid *) itv->env, itv->err, itv->handle, itv2->handle, itv->handle)) + CHECK_OCI + ( + itv->err, + OCIIntervalAdd, + (dvoid *) itv->env, itv->err, itv->handle, + itv2->handle, itv->handle + ) -#endif + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; +#endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IntervalSubtract + * IntervalSubtract * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IntervalSubtract +boolean IntervalSubtract ( OCI_Interval *itv, OCI_Interval *itv2 ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv2) - OCI_CALL_CONTEXT_SET_FROM_OBJ(itv) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_INTERVAL, itv + ) + + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_PTR(OCI_IPC_INTERVAL, itv2) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIIntervalSubtract((dvoid *) itv->env, itv->err, itv->handle, itv2->handle, itv->handle)) + CHECK_OCI + ( + itv->err, + OCIIntervalSubtract, + (dvoid *) itv->env, itv->err, itv->handle, + itv2->handle, itv->handle + ) -#endif + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; +#endif - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/interval.h b/src/interval.h new file mode 100644 index 00000000..809ec718 --- /dev/null +++ b/src/interval.h @@ -0,0 +1,146 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_INTERVAL_H_INCLUDED +#define OCILIB_INTERVAL_H_INCLUDED + +#include "types.h" + +OCI_Interval * IntervalInitialize +( + OCI_Connection *con, + OCI_Interval *itv, + OCIInterval *buffer, + ub4 type +); + +OCI_Interval * IntervalCreate +( + OCI_Connection *con, + unsigned int type +); + +boolean IntervalFree +( + OCI_Interval *itv +); + +OCI_Interval ** IntervalCreateArray +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +boolean IntervalFreeArray +( + OCI_Interval **itvs +); + +unsigned int IntervalGetType +( + OCI_Interval *itv +); + +boolean IntervalAssign +( + OCI_Interval *itv, + OCI_Interval *itv_src +); + +int IntervalCheck +( + OCI_Interval *itv +); + +int IntervalCompare +( + OCI_Interval *itv, + OCI_Interval *itv2 +); + +boolean IntervalFromString +( + OCI_Interval *itv, + const otext * str +); + +boolean IntervalToString +( + OCI_Interval *itv, + int leading_prec, + int fraction_prec, + int size, + otext *str +); + +boolean IntervalFromTimeZone +( + OCI_Interval *itv, + const otext * str +); + +boolean IntervalGetDaySecond +( + OCI_Interval *itv, + int *day, + int *hour, + int *min, + int *sec, + int *fsec +); + +boolean IntervalGetYearMonth +( + OCI_Interval *itv, + int *year, + int *month +); + +boolean IntervalSetDaySecond +( + OCI_Interval *itv, + int day, + int hour, + int min, + int sec, + int fsec +); + +boolean IntervalSetYearMonth +( + OCI_Interval *itv, + int year, + int month +); + +boolean IntervalAdd +( + OCI_Interval *itv, + OCI_Interval *itv2 +); + +boolean IntervalSubtract +( + OCI_Interval *itv, + OCI_Interval *itv2 +); + +#endif /* OCILIB_INTERVAL_H_INCLUDED */ diff --git a/src/iterator.c b/src/iterator.c index ce476246..0a485792 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -18,184 +18,225 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "iterator.h" -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ +#include "element.h" +#include "macros.h" /* --------------------------------------------------------------------------------------------- * - * OCI_IterCreate + * IteratorCreate * --------------------------------------------------------------------------------------------- */ -OCI_Iter * OCI_API OCI_IterCreate +OCI_Iter * IteratorCreate ( -OCI_Coll *coll + OCI_Coll *coll ) { - OCI_Iter *iter = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Iter*, NULL, + /* context */ OCI_IPC_COLLECTION, coll + ) - OCI_CALL_ENTER(OCI_Iter*, iter); - OCI_CALL_CHECK_PTR(OCI_IPC_COLLECTION, coll) - OCI_CALL_CONTEXT_SET_FROM_CONN(coll->con) + OCI_Iter* iter = NULL; + + CHECK_PTR(OCI_IPC_COLLECTION, coll) /* allocate iterator structure */ - OCI_ALLOCATE_DATA(OCI_IPC_ITERATOR, iter, 1) + ALLOC_DATA(OCI_IPC_ITERATOR, iter, 1) - if (OCI_STATUS) - { - iter->coll = coll; - iter->eoc = FALSE; - iter->boc = TRUE; - iter->dirty = TRUE; + iter->coll = coll; + iter->eoc = FALSE; + iter->boc = TRUE; + iter->dirty = TRUE; - /* create iterator */ + /* create iterator */ - OCI_EXEC(OCIIterCreate(iter->coll->con->env, iter->coll->con->err, coll->handle, &iter->handle)) + CHECK_OCI + ( + iter->coll->con->err, + OCIIterCreate, + iter->coll->con->env, + iter->coll->con->err, + iter->coll->handle, + &iter->handle + ) - /* create data element */ + /* create data element */ - if (OCI_STATUS) + CHECK_NULL(ElementInitialize(coll->con, iter->elem, NULL, (OCIInd *)NULL, coll->typinf)) + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - iter->elem = OCI_ElemInit(coll->con, iter->elem, NULL, (OCIInd *)NULL, coll->typinf); - OCI_STATUS = (NULL != iter->elem); + IteratorFree(iter); + iter = NULL; } - } - /* check for success */ - - if (OCI_STATUS) - { - OCI_RETVAL = iter; - } - else if (iter) - { - OCI_IterFree(iter); - } - - OCI_CALL_EXIT() + SET_RETVAL(iter) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IterFree + * IteratorFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IterFree +boolean IteratorFree ( OCI_Iter *iter ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ITERATOR, iter) - OCI_CALL_CONTEXT_SET_FROM_CONN(iter->coll->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_ITERATOR, iter + ) + + CHECK_PTR(OCI_IPC_ITERATOR, iter) /* close iterator handle */ - if (iter->handle) + if (NULL != iter->handle) { - OCI_EXEC(OCIIterDelete(iter->coll->con->env, iter->coll->con->err, &iter->handle)) + CHECK_OCI + ( + iter->coll->con->err, + OCIIterDelete, + iter->coll->con->env, + iter->coll->con->err, + &iter->handle + ) } /* free data element */ - if (iter->elem) + if (NULL != iter->elem) { iter->elem->hstate = OCI_OBJECT_FETCHED_DIRTY; - OCI_ElemFree(iter->elem); + ElementFree(iter->elem); iter->elem = NULL; } /* free iterator structure */ - OCI_FREE(iter) + FREE(iter) - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IterGetNext + * IteratorGetNext * --------------------------------------------------------------------------------------------- */ -OCI_Elem * OCI_API OCI_IterGetNext +OCI_Elem * IteratorGetNext ( OCI_Iter *iter ) { - void *data = NULL; - OCIInd *p_ind = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Elem*, NULL, + /* context */ OCI_IPC_ITERATOR, iter + ) - OCI_CALL_ENTER(OCI_Elem *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_ITERATOR, iter) - OCI_CALL_CONTEXT_SET_FROM_CONN(iter->coll->con) + void *data = NULL; + OCIInd *p_ind = NULL; - if (!iter->eoc) - { - OCI_EXEC(OCIIterNext(iter->coll->con->env, iter->coll->con->err, iter->handle, &data, (dvoid **) &p_ind, &iter->eoc)) + CHECK_PTR(OCI_IPC_ITERATOR, iter) - if (OCI_STATUS && !iter->eoc) - { - OCI_RETVAL = iter->elem = OCI_ElemInit(iter->coll->con, iter->elem, data, p_ind, iter->coll->typinf); + CHECK(!iter->eoc) - iter->dirty = FALSE; - iter->boc = FALSE; - } - } + CHECK_OCI + ( + iter->coll->con->err, + OCIIterNext, + iter->coll->con->env, + iter->coll->con->err, + iter->handle, &data, + (dvoid **) &p_ind, + &iter->eoc + ) - OCI_CALL_EXIT() + CHECK(!iter->eoc) + + iter->elem = ElementInitialize(iter->coll->con, iter->elem, + data, p_ind, iter->coll->typinf); + iter->dirty = FALSE; + iter->boc = FALSE; + + SET_RETVAL(iter->elem) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IterGetPrev + * IteratorGetPrev * --------------------------------------------------------------------------------------------- */ -OCI_Elem * OCI_API OCI_IterGetPrev +OCI_Elem * IteratorGetPrev ( OCI_Iter *iter ) { - void *data = NULL; - OCIInd *p_ind = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Elem*, NULL, + /* context */ OCI_IPC_ITERATOR, iter + ) - OCI_CALL_ENTER(OCI_Elem *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_ITERATOR, iter) - OCI_CALL_CONTEXT_SET_FROM_CONN(iter->coll->con) + void *data = NULL; + OCIInd *p_ind = NULL; - if (!iter->boc) - { - OCI_EXEC(OCIIterPrev(iter->coll->con->env, iter->coll->con->err, iter->handle, &data, (dvoid **) &p_ind, &iter->boc)) + CHECK_PTR(OCI_IPC_ITERATOR, iter) - if (OCI_STATUS && !iter->boc) - { - OCI_RETVAL = iter->elem = OCI_ElemInit(iter->coll->con, iter->elem, data, p_ind, iter->coll->typinf); + CHECK(!iter->boc) - iter->dirty = FALSE; - iter->eoc = FALSE; - } - } + CHECK_OCI + ( + iter->coll->con->err, + OCIIterPrev, + iter->coll->con->env, + iter->coll->con->err, + iter->handle, &data, + (dvoid **) &p_ind, + &iter->boc + ) - OCI_CALL_EXIT() + CHECK(!iter->boc) + + iter->elem = ElementInitialize(iter->coll->con, iter->elem, data, p_ind, iter->coll->typinf); + iter->dirty = FALSE; + iter->eoc = FALSE; + + SET_RETVAL(iter->elem) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IterGetCurrent + * IteratorGetCurrent * --------------------------------------------------------------------------------------------- */ -OCI_Elem * OCI_API OCI_IterGetCurrent +OCI_Elem * IteratorGetCurrent ( OCI_Iter *iter ) { - OCI_CALL_ENTER(OCI_Elem*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_ITERATOR, iter) - OCI_CALL_CONTEXT_SET_FROM_CONN(iter->coll->con) + ENTER_FUNC + ( + /* returns */ OCI_Elem*, NULL, + /* context */ OCI_IPC_ITERATOR, iter + ) - if (iter->elem && !iter->boc && !iter->eoc && !iter->dirty) - { - OCI_RETVAL = iter->elem; - } + CHECK_PTR(OCI_IPC_ITERATOR, iter) + + CHECK(NULL != iter->elem && !iter->boc && !iter->eoc && !iter->dirty) + + SET_RETVAL(iter->elem) - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/iterator.h b/src/iterator.h new file mode 100644 index 00000000..79df41b2 --- /dev/null +++ b/src/iterator.h @@ -0,0 +1,51 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_ITERATOR_H_INCLUDED +#define OCILIB_ITERATOR_H_INCLUDED + +#include "types.h" + +OCI_Iter * IteratorCreate +( + OCI_Coll *coll +); + +boolean IteratorFree +( + OCI_Iter *iter +); + +OCI_Elem* IteratorGetNext +( + OCI_Iter *iter +); + +OCI_Elem* IteratorGetPrev +( + OCI_Iter *iter +); + +OCI_Elem* IteratorGetCurrent +( + OCI_Iter *iter +); + +#endif /* OCILIB_ITERATOR_H_INCLUDED */ diff --git a/src/list.c b/src/list.c index 89353a0d..b69306c4 100644 --- a/src/list.c +++ b/src/list.c @@ -18,162 +18,203 @@ * limitations under the License. */ -#include "ocilib_internal.h" - - -#define LIST_FOR_EACH(exp) \ -\ - if (list) \ - { \ - OCI_Item *item = NULL; \ - if (list->mutex ) \ - { \ - OCI_MutexAcquire(list->mutex); \ - } \ - item = list->head; \ - while (item) \ - { \ - exp; \ - item = item->next; \ - } \ - if (list->mutex) \ - { \ - OCI_MutexRelease(list->mutex); \ - } \ - } \ - - -/* ********************************************************************************************* * - * LOCAL FUNCTIONS - * ********************************************************************************************* */ +#include "list.h" + +#include "macros.h" +#include "memory.h" +#include "mutex.h" + +#define ACQUIRE_LOCK() \ + \ + if (NULL != list->mutex) \ + { \ + CHECK(MutexAcquire(list->mutex)) \ + } + +#define RELEASE_LOCK() \ + \ + if (NULL != list->mutex) \ + { \ + CHECK(MutexRelease(list->mutex)) \ + } + +#define LIST_FOR_EACH(exp) \ + \ + if (list) \ + { \ + OCI_Item *item = NULL; \ + ACQUIRE_LOCK() \ + item = list->head; \ + while (item) \ + { \ + exp; \ + item = item->next; \ + } \ + RELEASE_LOCK() \ + } /* --------------------------------------------------------------------------------------------- * - * OCI_ListCreateItem + * ListCreateItem * --------------------------------------------------------------------------------------------- */ -OCI_Item * OCI_ListCreateItem +OCI_Item * ListCreateItem ( int type, int size ) { - OCI_Item *item = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Item*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + + OCI_Item* item = NULL; + + CHECK_BOUND(size, 0, INT_MAX) /* allocate list item entry */ - item = (OCI_Item *) OCI_MemAlloc(OCI_IPC_LIST_ITEM, sizeof(*item), (size_t) 1, TRUE); + item = (OCI_Item *) MemoryAlloc(OCI_IPC_LIST_ITEM, + sizeof(*item), + (size_t) 1, TRUE); - if (item) - { - /* allocate item data buffer */ + CHECK_NULL(item) + + /* allocate item data buffer */ - item->data = (void *) OCI_MemAlloc(type, (size_t) size, (size_t) 1, TRUE); + item->data = (void *) MemoryAlloc(type, (size_t) size, + (size_t) 1, TRUE); - if (!item->data) + CHECK_NULL(item->data) + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - OCI_FREE(item) + if (NULL != item->data) + { + FREE(item->data) + } + + if (NULL != item) + { + FREE(item) + } } - } - return item; + SET_RETVAL(item) + ) } -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_ListCreate + * ListCreate * --------------------------------------------------------------------------------------------- */ -OCI_List * OCI_ListCreate +OCI_List* ListCreate ( int type ) { - OCI_List *list = NULL; + ENTER_FUNC + ( + /* returns */ OCI_List*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) /* allocate list */ - list = (OCI_List *) OCI_MemAlloc(OCI_IPC_LIST, sizeof(*list), (size_t) 1, TRUE); + OCI_List *list = (OCI_List *) MemoryAlloc(OCI_IPC_LIST, + sizeof(*list), + (size_t) 1, TRUE); + + CHECK_NULL(list) /* create a mutex on multi threaded environments */ - if (list) + list->type = type; + + if (LIB_THREADED) { - list->type = type; + list->mutex = MutexCreateInternal(); + } - if (OCI_LIB_THREADED) + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - list->mutex = OCI_MutexCreateInternal(); - - if (!list->mutex) - { - OCI_FREE(list) - } + FREE(list) } - } - return list; + SET_RETVAL(list) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ListFree + * ListFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_ListFree +boolean ListFree ( OCI_List *list ) { - boolean res = TRUE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LIST, list + ) - OCI_CHECK(NULL == list, FALSE) + CHECK_PTR(OCI_IPC_LIST, list) - OCI_ListClear(list); + ListClear(list); - if (list->mutex) + if (NULL!= list->mutex) { - res = OCI_MutexFree(list->mutex); + MutexFree(list->mutex); } - OCI_FREE(list) + FREE(list) + + SET_SUCCESS() - return res; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ListAppend + * ListAppend * --------------------------------------------------------------------------------------------- */ -void * OCI_ListAppend +void * ListAppend ( OCI_List *list, int size ) { + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_LIST, list + ) + OCI_Item *item = NULL; OCI_Item *temp = NULL; - OCI_CHECK(NULL == list, NULL); + CHECK_PTR(OCI_IPC_LIST, list) - item = OCI_ListCreateItem(list->type, size); + item = ListCreateItem(list->type, size); + CHECK_NULL(item) - OCI_CHECK(NULL == item, FALSE) - - if (list->mutex) - { - OCI_MutexAcquire(list->mutex); - } + ACQUIRE_LOCK() temp = list->head; - while (temp && temp->next) + while (NULL != temp && NULL != temp->next) { temp = temp->next; } - if (temp) + if (NULL != temp) { temp->next = item; } @@ -184,127 +225,148 @@ void * OCI_ListAppend list->count++; - if (list->mutex) - { - OCI_MutexRelease(list->mutex); - } + RELEASE_LOCK() - return item->data; + SET_RETVAL(item->data) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ListClear + * ListClear * --------------------------------------------------------------------------------------------- */ -boolean OCI_ListClear +boolean ListClear ( OCI_List *list ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LIST, list + ) + OCI_Item *item = NULL; - OCI_CHECK(NULL == list, FALSE) + CHECK_PTR(OCI_IPC_LIST, list) - if (list->mutex) - { - OCI_MutexAcquire(list->mutex); - } + ACQUIRE_LOCK() /* walk along the list to free item's buffer */ item = list->head; - while (item) + while (NULL != item) { OCI_Item *temp = item; - + item = item->next; /* free data */ - OCI_FREE(temp->data) - OCI_FREE(temp) + FREE(temp->data) + FREE(temp) } list->head = NULL; list->count = 0; - if (list->mutex) - { - OCI_MutexRelease(list->mutex); - } + RELEASE_LOCK() + + SET_SUCCESS() - return TRUE; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ListForEach + * ListForEach * --------------------------------------------------------------------------------------------- */ -boolean OCI_ListForEach +boolean ListForEach ( OCI_List *list, POCI_LIST_FOR_EACH proc ) { - OCI_CHECK(NULL == list, FALSE) - OCI_CHECK(NULL == proc, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LIST, list + ) + + CHECK_PTR(OCI_IPC_LIST, list) + CHECK_PTR(OCI_IPC_VOID, proc) LIST_FOR_EACH(proc(item->data)) - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_ListForEachWithParam +* ListForEachWithParam * --------------------------------------------------------------------------------------------- */ -boolean OCI_ListForEachWithParam +boolean ListForEachWithParam ( - OCI_List *list, - void *param, + OCI_List *list, + void *param, POCI_LIST_FOR_EACH_WITH_PARAM proc ) { - OCI_CHECK(NULL == list, FALSE) - OCI_CHECK(NULL == proc, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LIST, list + ) + + CHECK_PTR(OCI_IPC_LIST, list) + CHECK_PTR(OCI_IPC_VOID, proc) LIST_FOR_EACH(proc(item->data, param)) - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ListRemove + * ListRemove * --------------------------------------------------------------------------------------------- */ -boolean OCI_ListRemove +boolean ListRemove ( OCI_List *list, void *data ) { - boolean found = FALSE; - OCI_Item *item = NULL; - OCI_Item *temp = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LIST, list + ) - OCI_CHECK(NULL == list, FALSE) - OCI_CHECK(NULL == data, FALSE) + OCI_Item *item = NULL; + OCI_Item *temp = NULL; - if (list->mutex) - { - OCI_MutexAcquire(list->mutex); - } + CHECK_PTR(OCI_IPC_LIST, list) + CHECK_PTR(OCI_IPC_VOID, data) + + ACQUIRE_LOCK() item = list->head; - while (item) + boolean found = FALSE; + + while (NULL != item) { if (item->data == data) { found = TRUE; - if (temp) + if (NULL != temp) { temp->next = item->next; } @@ -317,7 +379,7 @@ boolean OCI_ListRemove list->head = item->next; } - OCI_FREE(item) + FREE(item) break; } @@ -331,64 +393,76 @@ boolean OCI_ListRemove list->count--; } - if (list->mutex) - { - OCI_MutexRelease(list->mutex); - } + RELEASE_LOCK() + + SET_RETVAL(found) - return TRUE; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_ListExists +* ListExists * --------------------------------------------------------------------------------------------- */ -boolean OCI_ListExists +boolean ListExists ( OCI_List *list, void *data ) { - boolean found = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LIST, list + ) - OCI_CHECK(NULL == list, FALSE) + CHECK_PTR(OCI_IPC_LIST, list) + CHECK_PTR(OCI_IPC_VOID, data) LIST_FOR_EACH ( if (item->data == data) { - found = TRUE; + SET_SUCCESS() break; } ) - return found; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_ListFind +* ListFind * --------------------------------------------------------------------------------------------- */ -void * OCI_ListFind +void * ListFind ( - OCI_List *list, - POCI_LIST_FIND proc, - void *param + OCI_List *list, + POCI_LIST_FIND proc, + void *param ) { - void * result = NULL; + ENTER_FUNC + ( + /* returns */ void *, NULL, + /* context */ OCI_IPC_LIST, list + ) - OCI_CHECK(NULL == list, NULL) - OCI_CHECK(NULL == proc, NULL) + CHECK_PTR(OCI_IPC_LIST, list) + CHECK_PTR(OCI_IPC_VOID, param) + + void* data = NULL; LIST_FOR_EACH ( if (proc(item->data, param)) { - result = item->data; + data = item->data; break; } ) - return result; + SET_RETVAL(data) + + EXIT_FUNC() } diff --git a/src/list.h b/src/list.h new file mode 100644 index 00000000..121c853e --- /dev/null +++ b/src/list.h @@ -0,0 +1,96 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_LIST_H_INCLUDED +#define OCILIB_LIST_H_INCLUDED + +#include "types.h" + +OCI_List* ListCreate +( + int type +); + +boolean ListFree +( + OCI_List* list +); + +void* ListAppend +( + OCI_List* list, + int size +); + +boolean ListClear +( + OCI_List* list +); + +typedef void (*POCI_LIST_FOR_EACH) +( + void* data +); + +boolean ListForEach +( + OCI_List * list, + POCI_LIST_FOR_EACH proc +); + +typedef void (*POCI_LIST_FOR_EACH_WITH_PARAM) +( + void* data, + void* param +); + +boolean ListForEachWithParam +( + OCI_List * list, + void * param, + POCI_LIST_FOR_EACH_WITH_PARAM proc +); + +boolean ListRemove +( + OCI_List* list, + void * data +); + +boolean ListExists +( + OCI_List* list, + void * data +); + +typedef boolean (*POCI_LIST_FIND) +( + void* data, + void* param +); + +void* ListFind +( + OCI_List * list, + POCI_LIST_FIND proc, + void * param +); + +#endif /* OCILIB_LIST_H_INCLUDED */ diff --git a/src/oci_loader.h b/src/loader.h similarity index 53% rename from src/oci_loader.h rename to src/loader.h index 9fd22266..8c8c2e89 100644 --- a/src/oci_loader.h +++ b/src/loader.h @@ -1,64 +1,63 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OCILIB_OCI_LOADER_H_INCLUDED -#define OCILIB_OCI_LOADER_H_INCLUDED - -#if defined(_AIX) - #define LIB_OPEN_FLAGS (RTLD_NOW | RTLD_GLOBAL | RTLD_MEMBER) -#elif defined(__hpux) - #define LIB_OPEN_FLAGS (BIND_DEFERRED |BIND_VERBOSE| DYNAMIC_PATH) -#else - #define LIB_OPEN_FLAGS (RTLD_NOW | RTLD_GLOBAL) -#endif - -#if defined(_WINDOWS) - - #include - - #define LIB_HANDLE HMODULE - #define LIB_OPEN(l) LoadLibraryA(l) - #define LIB_CLOSE FreeLibrary - #define LIB_SYMBOL(h, s, p, t) p = (t) GetProcAddress(h, s) - -#elif defined(__hpux) - - #include - - #define LIB_HANDLE shl_t - #define LIB_OPEN(l) shl_load(l, LIB_OPEN_FLAGS, 0L) - #define LIB_CLOSE shl_unload - #define LIB_SYMBOL(h, s, p, t) shl_findsym(&h, s, (short) TYPE_PROCEDURE, (void *) &p) - -#else - - #ifdef HAVE_DLFCN_H - #include - #endif - - #define LIB_HANDLE void * - #define LIB_OPEN(l) dlopen(l, LIB_OPEN_FLAGS) - #define LIB_CLOSE dlclose - #define LIB_SYMBOL(h, s, p, t) p = (t) dlsym(h, s) - -#endif - -#endif /* OCILIB_OCI_LOADER_H_INCLUDED */ - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_OCI_LOADER_H_INCLUDED +#define OCILIB_OCI_LOADER_H_INCLUDED + +#if defined(_AIX) +#define LIB_OPEN_FLAGS (RTLD_NOW | RTLD_GLOBAL | RTLD_MEMBER) +#elif defined(__hpux) +#define LIB_OPEN_FLAGS (BIND_DEFERRED |BIND_VERBOSE| DYNAMIC_PATH) +#else +#define LIB_OPEN_FLAGS (RTLD_NOW | RTLD_GLOBAL) +#endif + +#if defined(_WINDOWS) + + #include + +#define LIB_HANDLE HMODULE +#define LIB_OPEN(l) LoadLibraryA(l) +#define LIB_CLOSE FreeLibrary +#define LIB_SYMBOL(h, s, p, t) p = (t) GetProcAddress(h, s) + +#elif defined(__hpux) + + #include + +#define LIB_HANDLE shl_t +#define LIB_OPEN(l) shl_load(l, LIB_OPEN_FLAGS, 0L) +#define LIB_CLOSE shl_unload +#define LIB_SYMBOL(h, s, p, t) shl_findsym(&h, s, (short) TYPE_PROCEDURE, (void *) &p) + +#else + + #ifdef HAVE_DLFCN_H + #include + #endif + +#define LIB_HANDLE void * +#define LIB_OPEN(l) dlopen(l, LIB_OPEN_FLAGS) +#define LIB_CLOSE dlclose +#define LIB_SYMBOL(h, s, p, t) p = (t) dlsym(h, s) + +#endif + +#endif /* OCILIB_OCI_LOADER_H_INCLUDED */ diff --git a/src/lob.c b/src/lob.c index 61ef501d..f446e64f 100644 --- a/src/lob.c +++ b/src/lob.c @@ -18,25 +18,39 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "lob.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "array.h" +#include "connection.h" +#include "macros.h" +#include "memory.h" +#include "strings.h" -static const unsigned int SeekModeValues[] = { OCI_SEEK_SET, OCI_SEEK_END, OCI_SEEK_CUR }; -static const unsigned int OpenModeValues[] = { OCI_LOB_READONLY, OCI_LOB_READWRITE }; -static const unsigned int LobTypeValues[] = { OCI_CLOB, OCI_NCLOB, OCI_BLOB }; +static const unsigned int SeekModeValues[] = +{ + OCI_SEEK_SET, + OCI_SEEK_END, + OCI_SEEK_CUR +}; + +static const unsigned int OpenModeValues[] = +{ + OCI_LOB_READONLY, + OCI_LOB_READWRITE +}; -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int LobTypeValues[] = +{ + OCI_CLOB, + OCI_NCLOB, + OCI_BLOB +}; /* --------------------------------------------------------------------------------------------- * - * OCI_LobInit + * LobInit * --------------------------------------------------------------------------------------------- */ -OCI_Lob * OCI_LobInit +OCI_Lob * LobInitialize ( OCI_Connection *con, OCI_Lob *lob, @@ -44,264 +58,320 @@ OCI_Lob * OCI_LobInit ub4 type ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Lob*, NULL, + /* context */ OCI_IPC_LOB, lob + ) + + ALLOC_DATA(OCI_IPC_LOB, lob, 1); - OCI_ALLOCATE_DATA(OCI_IPC_LOB, lob, 1); + lob->type = type; + lob->con = con; + lob->handle = handle; + lob->offset = 1; - if (OCI_STATUS) + if (NULL == lob->handle || (OCI_OBJECT_ALLOCATED_ARRAY == lob->hstate)) { - lob->type = type; - lob->con = con; - lob->handle = handle; - lob->offset = 1; + const ub2 csid = OCI_DEFAULT; + ub1 csfrm = OCI_DEFAULT; + ub1 lobtype = 0; + ub4 empty = 0; - if (!lob->handle || (OCI_OBJECT_ALLOCATED_ARRAY == lob->hstate)) + if (OCI_NCLOB == lob->type) { - const ub2 csid = OCI_DEFAULT; - ub1 csfrm = OCI_DEFAULT; - ub1 lobtype = 0; - ub4 empty = 0; - - if (OCI_NCLOB == lob->type) - { - csfrm = SQLCS_NCHAR; - lobtype = OCI_TEMP_CLOB; - } - else if (OCI_CLOB == lob->type) - { - csfrm = SQLCS_IMPLICIT; - lobtype = OCI_TEMP_CLOB; - } - else - { - lobtype = OCI_TEMP_BLOB; - } - - /* allocate handle for non fetched lob (temporary lob) */ - - if (OCI_OBJECT_ALLOCATED_ARRAY != lob->hstate) - { - lob->hstate = OCI_OBJECT_ALLOCATED; - - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)lob->con->env, (dvoid **)(void *)&lob->handle, OCI_DTYPE_LOB); - } - - OCI_SET_ATTRIB(OCI_DTYPE_LOB, OCI_ATTR_LOBEMPTY, lob->handle, &empty, sizeof(empty)) - OCI_EXEC(OCILobCreateTemporary(lob->con->cxt, lob->con->err, lob->handle, csid, csfrm, lobtype, FALSE, OCI_DURATION_SESSION)) + csfrm = SQLCS_NCHAR; + lobtype = OCI_TEMP_CLOB; + } + else if (OCI_CLOB == lob->type) + { + csfrm = SQLCS_IMPLICIT; + lobtype = OCI_TEMP_CLOB; } else { - lob->hstate = OCI_OBJECT_FETCHED_CLEAN; + lobtype = OCI_TEMP_BLOB; } - } - - /* check for failure */ - if (!OCI_STATUS && lob) + /* allocate handle for non fetched lob (temporary lob) */ + + if (OCI_OBJECT_ALLOCATED_ARRAY != lob->hstate) + { + lob->hstate = OCI_OBJECT_ALLOCATED; + + CHECK + ( + MemoryAllocDescriptor + ( + (dvoid *)lob->con->env, + (dvoid **)(void *)&lob->handle, OCI_DTYPE_LOB + ) + ) + } + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_LOB, OCI_ATTR_LOBEMPTY, + lob->handle, &empty, sizeof(empty), + lob->con->err + ) + + CHECK_OCI + ( + lob->con->err, + OCILobCreateTemporary, + lob->con->cxt, lob->con->err, lob->handle, + csid, csfrm, lobtype, FALSE, OCI_DURATION_SESSION + ) + } + else { - OCI_LobFree(lob); - lob = NULL; + lob->hstate = OCI_OBJECT_FETCHED_CLEAN; } - return lob; -} + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + LobFree(lob); + lob = NULL; + } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + SET_RETVAL(lob) + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_LobCreate + * LobCreate * --------------------------------------------------------------------------------------------- */ -OCI_Lob * OCI_API OCI_LobCreate +OCI_Lob * LobCreate ( OCI_Connection *con, unsigned int type ) { - OCI_CALL_ENTER(OCI_Lob*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, LobTypeValues, OTEXT("Lob type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Lob*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_RETVAL = OCI_LobInit(con, NULL, NULL, type); - OCI_STATUS = (NULL != OCI_RETVAL); + CHECK_ENUM_VALUE(type, LobTypeValues, OTEXT("Lob type")) - OCI_CALL_EXIT() + SET_RETVAL(LobInitialize(con, NULL, NULL, type)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobFree + * LobFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobFree +boolean LobFree ( OCI_Lob *lob ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_OBJECT_FETCHED(lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_OBJECT_FETCHED(lob) - if (OCI_LobIsTemporary(lob)) + if (LobIsTemporary(lob)) { - OCI_EXEC(OCILobFreeTemporary(lob->con->cxt, lob->con->err, lob->handle)) + CHECK_OCI + ( + lob->con->err, + OCILobFreeTemporary, + lob->con->cxt, lob->con->err, + lob->handle + ) } if (OCI_OBJECT_ALLOCATED == lob->hstate) { - OCI_DescriptorFree((dvoid *) lob->handle, (ub4) OCI_DTYPE_LOB); + MemoryFreeDescriptor((dvoid*)lob->handle, (ub4)OCI_DTYPE_LOB); } if (OCI_OBJECT_ALLOCATED_ARRAY != lob->hstate) { - OCI_FREE(lob) + FREE(lob) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobArrayCreate + * LobCreateArray * --------------------------------------------------------------------------------------------- */ -OCI_Lob ** OCI_API OCI_LobArrayCreate +OCI_Lob ** LobCreateArray ( OCI_Connection *con, unsigned int type, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Lob**, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Lob **, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, LobTypeValues, OTEXT("Lob type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_ENUM_VALUE(type, LobTypeValues, OTEXT("Lob type")) - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_LOB, type, sizeof(OCILobLocator *), sizeof(OCI_Lob), OCI_DTYPE_LOB, NULL); - OCI_STATUS = (NULL != arr); + arr = ArrayCreate(con, nbelem, OCI_CDT_LOB, type, + sizeof(OCILobLocator*), sizeof(OCI_Lob), + OCI_DTYPE_LOB, NULL); - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Lob **)arr->tab_obj; - } + CHECK_NULL(arr) + + SET_RETVAL((OCI_Lob**)arr->tab_obj) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobArrayFree + * LobFreeArray * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobArrayFree +boolean LobFreeArray ( OCI_Lob **lobs ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, lobs) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)lobs); + CHECK_PTR(OCI_IPC_ARRAY, lobs) - OCI_CALL_EXIT() + SET_RETVAL(ArrayFreeFromHandles((void**)lobs)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobGetType + * LobGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LobGetType +unsigned int LobGetType ( OCI_Lob *lob ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_LOB, lob, type, lob->con, NULL, lob->con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_LOB, lob, + /* member */ type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_LobSeek + * LobSeek * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobSeek +boolean LobSeek ( OCI_Lob *lob, big_uint offset, unsigned int mode ) { - big_uint size = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_ENUM_VALUE(mode, SeekModeValues, OTEXT("Seek Mode")) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_ENUM_VALUE(lob->con, NULL, mode, SeekModeValues, OTEXT("Seek Mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + const big_uint size = LobGetLength(lob); - size = OCI_LobGetLength(lob); + boolean success = FALSE; switch (mode) { case OCI_SEEK_CUR: { - if ((offset + lob->offset - 1) <= size) + if ((offset + lob->offset - 1) <= size) { lob->offset += offset; - OCI_RETVAL = TRUE; + + success = FALSE; } break; } case OCI_SEEK_SET: { - if (offset <= size) + if (offset <= size) { lob->offset = offset + 1; - OCI_RETVAL = TRUE; + + success = FALSE; } break; } case OCI_SEEK_END: { - if (offset <= size) + if (offset <= size) { lob->offset = size - offset + 1; - OCI_RETVAL = TRUE; + + success = FALSE; } break; } } - - OCI_CALL_EXIT() + + SET_RETVAL(success) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobGetOffset + * LobGetOffset * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_LobGetOffset +big_uint LobGetOffset ( OCI_Lob *lob ) { - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob); - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_LOB, lob + ) - OCI_RETVAL = lob->offset - 1; - OCI_STATUS = TRUE; + CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_EXIT() + SET_RETVAL(lob->offset - 1) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobRead2 + * LobRead2 * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobRead2 +boolean LobRead2 ( OCI_Lob *lob, void *buffer, @@ -309,25 +379,29 @@ boolean OCI_API OCI_LobRead2 unsigned int *byte_count ) { - ub1 csfrm = 0; - ub2 csid = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + ub1 csfrm = 0; + ub2 csid = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, char_count) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, byte_count) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_INT, char_count) + CHECK_PTR(OCI_IPC_INT, byte_count) if (OCI_BLOB != lob->type) { - if (OCI_CHAR_WIDE == OCILib.charset) + if (OCI_CHAR_WIDE == Env.charset) { csid = OCI_UTF16ID; } if (((*byte_count) == 0) && ((*char_count) > 0)) { - if (OCILib.nls_utf8) + if (Env.nls_utf8) { (*byte_count) = (*char_count) * (ub4)OCI_UTF8_BYTES_PER_CHAR; } @@ -342,22 +416,24 @@ boolean OCI_API OCI_LobRead2 #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) - { + if (Env.use_lob_ub8) + { ub8 size_in_out_char = (ub8) (*char_count); ub8 size_in_out_byte = (ub8) (*byte_count); - OCI_EXEC + CHECK_OCI ( - OCILobRead2(lob->con->cxt, lob->con->err, lob->handle, - &size_in_out_byte, &size_in_out_char, - (ub8) lob->offset, buffer,(ub8) (*byte_count), - (ub1) OCI_ONE_PIECE, (void *) NULL, - NULL, csid, csfrm) + lob->con->err, + OCILobRead2, + lob->con->cxt, lob->con->err, lob->handle, + &size_in_out_byte, &size_in_out_char, + (ub8) lob->offset, buffer,(ub8) (*byte_count), + (ub1) OCI_ONE_PIECE, (void *) NULL, + NULL, csid, csfrm ) - (*char_count) = (ub4) size_in_out_char; - (*byte_count) = (ub4) size_in_out_byte; + (*char_count) = (ub4) size_in_out_char; + (*byte_count) = (ub4) size_in_out_byte; } else @@ -367,77 +443,76 @@ boolean OCI_API OCI_LobRead2 { ub4 size_in_out_char_byte = (lob->type == OCI_BLOB) ? *byte_count : *char_count; - OCI_EXEC + CHECK_OCI ( - OCILobRead(lob->con->cxt, lob->con->err, lob->handle, - &size_in_out_char_byte, (ub4) lob->offset, - buffer, (ub4) (*byte_count), (void *) NULL, - NULL, csid, csfrm) + lob->con->err, + OCILobRead, + lob->con->cxt, lob->con->err, lob->handle, + &size_in_out_char_byte, (ub4) lob->offset, + buffer, (ub4) (*byte_count), (void *) NULL, + NULL, csid, csfrm ) - (*char_count) = (ub4) size_in_out_char_byte; - (*byte_count) = (ub4) size_in_out_char_byte; + (*char_count) = (ub4) size_in_out_char_byte; + (*byte_count) = (ub4) size_in_out_char_byte; } if (OCI_BLOB != lob->type) { ub4 ora_byte_count = (ub4) *byte_count; - if (!OCILib.use_lob_ub8 && !OCILib.nls_utf8) + if (!Env.use_lob_ub8 && !Env.nls_utf8) { ora_byte_count *= sizeof(dbtext); } memset(((char *) buffer) + ora_byte_count, 0, sizeof(dbtext)); - #ifndef OCI_LOB2_API_ENABLED +#ifndef OCI_LOB2_API_ENABLED - if (OCILib.nls_utf8) + if (Env.nls_utf8) { - (*char_count) = (ub4) OCI_StringLength((const char *)buffer, sizeof(char)); + (*char_count) = (ub4) StringLength((const char *)buffer, sizeof(char)); } - #endif +#endif } - if (OCI_STATUS) + if (OCI_BLOB == lob->type) { - if (OCI_BLOB == lob->type) - { - lob->offset += (big_uint) (*byte_count); - } - else - { - lob->offset += (big_uint) (*char_count); + lob->offset += (big_uint) (*byte_count); + } + else + { + lob->offset += (big_uint) (*char_count); - if (!OCILib.nls_utf8 && OCILib.use_wide_char_conv) - { - OCI_StringUTF16ToUTF32(buffer, buffer, (int) (*char_count)); - (*byte_count) = (ub4) (*char_count) * (ub4) sizeof(otext); - } + if (!Env.nls_utf8 && Env.use_wide_char_conv) + { + StringUTF16ToUTF32(buffer, buffer, (int) (*char_count)); + (*byte_count) = (ub4) (*char_count) * (ub4) sizeof(otext); } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobRead + * LobRead * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LobRead +unsigned int LobRead ( OCI_Lob *lob, void *buffer, unsigned int len ) { - unsigned int char_count = 0; - unsigned int byte_count = 0; - unsigned int *ptr_count = NULL; + unsigned int char_count = 0; + unsigned int byte_count = 0; + unsigned int *ptr_count = NULL; if (lob) { @@ -453,16 +528,16 @@ unsigned int OCI_API OCI_LobRead } } - OCI_LobRead2(lob, buffer, &char_count, &byte_count); + LobRead2(lob, buffer, &char_count, &byte_count); return (NULL != ptr_count ? *ptr_count : 0); } /* --------------------------------------------------------------------------------------------- * - * OCI_LobWrite + * LobWrite * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobWrite2 +boolean LobWrite2 ( OCI_Lob *lob, void *buffer, @@ -470,26 +545,30 @@ boolean OCI_API OCI_LobWrite2 unsigned int *byte_count ) { - ub1 csfrm = 0; - ub2 csid = 0; - void *obuf = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, char_count) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, byte_count) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ub1 csfrm = 0; + ub2 csid = 0; + void *obuf = NULL; + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_INT, char_count) + CHECK_PTR(OCI_IPC_INT, byte_count) if (OCI_BLOB != lob->type) { - if (OCI_CHAR_WIDE == OCILib.charset) + if (OCI_CHAR_WIDE == Env.charset) { csid = OCI_UTF16ID; } if (((*byte_count) == 0) && ((*char_count) > 0)) { - if (OCILib.nls_utf8) + if (Env.nls_utf8) { (*byte_count) = (unsigned int) strlen((const char *) buffer); } @@ -501,14 +580,14 @@ boolean OCI_API OCI_LobWrite2 if (((*char_count) == 0) && ((*byte_count) > 0)) { - if (OCILib.nls_utf8 ) + if (Env.nls_utf8 ) { - #ifndef OCI_LOB2_API_ENABLED +#ifndef OCI_LOB2_API_ENABLED - (*char_count) = (ub4) OCI_StringLength((const char *)buffer, sizeof(char)); + (*char_count) = (ub4) StringLength((const char *)buffer, sizeof(char)); - #endif +#endif } else @@ -517,7 +596,7 @@ boolean OCI_API OCI_LobWrite2 } } - obuf = OCI_StringGetOracleString( (otext *) buffer, (int *) byte_count); + obuf = StringGetDBString( (otext *) buffer, (int *) byte_count); } else { @@ -528,22 +607,24 @@ boolean OCI_API OCI_LobWrite2 #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { ub8 size_in_out_char = (ub8) (*char_count); ub8 size_in_out_byte = (ub8) (*byte_count); - OCI_EXEC + CHECK_OCI ( - OCILobWrite2(lob->con->cxt, lob->con->err, lob->handle, - &size_in_out_byte, &size_in_out_char, - (ub8) lob->offset, obuf, (ub8) (*byte_count), - (ub1) OCI_ONE_PIECE, (void *) NULL, - NULL, csid, csfrm) + lob->con->err, + OCILobWrite2, + lob->con->cxt, lob->con->err, lob->handle, + &size_in_out_byte, &size_in_out_char, + (ub8) lob->offset, obuf, (ub8) (*byte_count), + (ub1) OCI_ONE_PIECE, (void *) NULL, + NULL, csid, csfrm ) - (*char_count) = (ub4) size_in_out_char; - (*byte_count) = (ub4) size_in_out_byte; + (*char_count) = (ub4) size_in_out_char; + (*byte_count) = (ub4) size_in_out_byte; } else @@ -553,7 +634,7 @@ boolean OCI_API OCI_LobWrite2 { ub4 size_in_out_char_byte = 0; - if ((OCI_BLOB == lob->type) || OCILib.nls_utf8) + if ((OCI_BLOB == lob->type) || Env.nls_utf8) { size_in_out_char_byte = (*byte_count); } @@ -562,59 +643,59 @@ boolean OCI_API OCI_LobWrite2 size_in_out_char_byte = (*char_count); } - OCI_EXEC + CHECK_OCI ( - OCILobWrite(lob->con->cxt, lob->con->err, lob->handle, - &size_in_out_char_byte, (ub4) lob->offset, - obuf, (ub4) (*byte_count), (ub1) OCI_ONE_PIECE, - (void *) NULL, NULL, csid, csfrm) + lob->con->err, + OCILobWrite, + lob->con->cxt, lob->con->err, lob->handle, + &size_in_out_char_byte, (ub4) lob->offset, + obuf, (ub4) (*byte_count), (ub1) OCI_ONE_PIECE, + (void *) NULL, NULL, csid, csfrm ) - (*char_count) = (ub4) size_in_out_char_byte; - (*byte_count) = (ub4) size_in_out_char_byte; + (*char_count) = (ub4) size_in_out_char_byte; + (*byte_count) = (ub4) size_in_out_char_byte; - if ((OCI_CLOB == lob->type) && !OCILib.nls_utf8) + if ((OCI_CLOB == lob->type) && !Env.nls_utf8) { - (*byte_count) *= (ub4) sizeof(otext); + (*byte_count) *= (ub4) sizeof(otext); } } - if (OCI_STATUS) + if (OCI_BLOB == lob->type) { - if (OCI_BLOB == lob->type) - { - lob->offset += (big_uint) (*byte_count); - } - else - { - lob->offset += (big_uint) (*char_count); - } + lob->offset += (big_uint) (*byte_count); } - - if (obuf != buffer) + else { - OCI_StringReleaseOracleString((dbtext *) obuf); + lob->offset += (big_uint) (*char_count); } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (obuf != buffer) + { + StringReleaseDBString((dbtext*)obuf); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_LobWrite + * LobWrite * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LobWrite +unsigned int LobWrite ( OCI_Lob *lob, void *buffer, unsigned int len ) { - unsigned int char_count = 0; - unsigned int byte_count = 0; - unsigned int *ptr_count = NULL; + unsigned int char_count = 0; + unsigned int byte_count = 0; + unsigned int *ptr_count = NULL; if (lob) { @@ -630,76 +711,99 @@ unsigned int OCI_API OCI_LobWrite } } - OCI_LobWrite2(lob, buffer, &char_count, &byte_count); + LobWrite2(lob, buffer, &char_count, &byte_count); return (NULL != ptr_count ? *ptr_count : 0); } /* --------------------------------------------------------------------------------------------- * - * OCI_LobTruncate + * LobTruncate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobTruncate +boolean LobTruncate ( OCI_Lob *lob, big_uint size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { - OCI_EXEC(OCILobTrim2(lob->con->cxt, lob->con->err, lob->handle, (ub8) size)) + CHECK_OCI + ( + lob->con->err, + OCILobTrim2, + lob->con->cxt, lob->con->err, + lob->handle, (ub8) size + ) } else #endif { - OCI_EXEC(OCILobTrim(lob->con->cxt, lob->con->err, lob->handle, (ub4) size)) + CHECK_OCI + ( + lob->con->err, + OCILobTrim, + lob->con->cxt, lob->con->err, + lob->handle, (ub4) size + ) } - if (OCI_STATUS) + if (lob->offset > size) { - if (lob->offset > size) - { - lob->offset = OCI_LobGetLength(lob) + 1; - } + lob->offset = LobGetLength(lob) + 1; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobErase + * LobErase * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_LobErase +big_uint LobErase ( OCI_Lob *lob, big_uint offset, big_uint size ) { - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob); - OCI_CALL_CHECK_MIN(lob->con, NULL, size, 1); - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_MIN(size, 1) #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { ub8 lob_size = (ub8) size; - OCI_EXEC(OCILobErase2(lob->con->cxt, lob->con->err, lob->handle, (ub8 *) &lob_size, (ub8) (offset + 1))) + CHECK_OCI + ( + lob->con->err, + OCILobErase2, + lob->con->cxt, lob->con->err, + lob->handle, (ub8 *) &lob_size, + (ub8) (offset + 1) + ) size = (big_uint) lob_size; } @@ -710,41 +814,56 @@ big_uint OCI_API OCI_LobErase { ub4 lob_size = (ub4) size; - OCI_EXEC(OCILobErase(lob->con->cxt, lob->con->err, lob->handle, &lob_size, (ub4) offset + 1)) + CHECK_OCI + ( + lob->con->err, + OCILobErase, + lob->con->cxt, lob->con->err, + lob->handle, &lob_size, + (ub4) offset + 1 + ) size = (big_uint) lob_size; } - if (OCI_SUCCESS) - { - OCI_RETVAL = size; - } + SET_RETVAL(size) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobGetLength + * LobGetLength * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_LobGetLength +big_uint LobGetLength ( OCI_Lob *lob ) { - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + + big_uint size = 0; #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { ub8 lob_size = 0; + CHECK_OCI + ( + lob->con->err, + OCILobGetLength2, + lob->con->cxt, lob->con->err, + lob->handle, &lob_size + ) - OCI_EXEC(OCILobGetLength2(lob->con->cxt, lob->con->err, lob->handle, (ub8 *) &lob_size)) - - OCI_RETVAL = (big_uint) lob_size; + size = lob_size; } else @@ -753,41 +872,59 @@ big_uint OCI_API OCI_LobGetLength { ub4 lob_size = 0; - OCI_EXEC(OCILobGetLength(lob->con->cxt, lob->con->err, lob->handle, &lob_size)) + CHECK_OCI + ( + lob->con->err, + OCILobGetLength, + lob->con->cxt, lob->con->err, + lob->handle, &lob_size + ) - OCI_RETVAL = (big_uint) lob_size; + size = (big_uint) lob_size; } - OCI_CALL_EXIT() + SET_RETVAL(size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobGetChunkSize + * LobGetChunkSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LobGetChunkSize +unsigned int LobGetChunkSize ( OCI_Lob *lob ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_LOB, lob + ) + ub4 size = 0; - OCI_CALL_ENTER(unsigned int, size) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + CHECK_PTR(OCI_IPC_LOB, lob) - OCI_EXEC(OCILobGetChunkSize(lob->con->cxt, lob->con->err, lob->handle, &size)) + CHECK_OCI + ( + lob->con->err, + OCILobGetChunkSize, + lob->con->cxt, lob->con->err, + lob->handle, &size + ) - OCI_RETVAL = (unsigned int) size; + SET_RETVAL((unsigned int) size) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobCopy + * LobCopy * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobCopy +boolean LobCopy ( OCI_Lob *lob, OCI_Lob *lob_src, @@ -796,47 +933,55 @@ boolean OCI_API OCI_LobCopy big_uint count ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob_src) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_LOB, lob_src) #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { - OCI_EXEC + CHECK_OCI ( - OCILobCopy2(lob->con->cxt, lob->con->err, lob->handle, - lob_src->handle, (ub8) count, - (ub8) (offset_dst + 1), - (ub8) (offset_src + 1)) + lob->con->err, + OCILobCopy2, + lob->con->cxt, lob->con->err, lob->handle, + lob_src->handle, (ub8) count, + (ub8) (offset_dst + 1), + (ub8) (offset_src + 1) ) } else #endif -{ - OCI_EXEC + { + CHECK_OCI ( - OCILobCopy(lob->con->cxt, lob->con->err, lob->handle, - lob_src->handle, (ub4) count, - (ub4) (offset_dst + 1), - (ub4) (offset_src + 1)) + lob->con->err, + OCILobCopy, + lob->con->cxt, lob->con->err, lob->handle, + lob_src->handle, (ub4) count, + (ub4) (offset_dst + 1), + (ub4) (offset_src + 1) ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobCopyFromFile + * LobCopyFromFile * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobCopyFromFile +boolean LobCopyFromFile ( OCI_Lob *lob, OCI_File *file, @@ -845,22 +990,28 @@ boolean OCI_API OCI_LobCopyFromFile big_uint count ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_FILE, file) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_FILE, file) #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { - OCI_EXEC + CHECK_OCI ( - OCILobLoadFromFile2(lob->con->cxt, lob->con->err, - lob->handle, file->handle, - (ub8) count, - (ub8) (offset_dst + 1), - (ub8) (offset_src + 1)) + lob->con->err, + OCILobLoadFromFile2, + lob->con->cxt, lob->con->err, + lob->handle, file->handle, + (ub8) count, + (ub8) (offset_dst + 1), + (ub8) (offset_src + 1) ) } else @@ -868,26 +1019,28 @@ boolean OCI_API OCI_LobCopyFromFile #endif { - OCI_EXEC + CHECK_OCI ( - OCILobLoadFromFile(lob->con->cxt, lob->con->err, - lob->handle, file->handle, - (ub4) count, - (ub4) (offset_dst + 1), - (ub4) (offset_src + 1)) + lob->con->err, + OCILobLoadFromFile, + lob->con->cxt, lob->con->err, + lob->handle, file->handle, + (ub4) count, + (ub4) (offset_dst + 1), + (ub4) (offset_src + 1) ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobAppend2 + * LobAppend2 * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobAppend2 +boolean LobAppend2 ( OCI_Lob *lob, void *buffer, @@ -895,39 +1048,42 @@ boolean OCI_API OCI_LobAppend2 unsigned int *byte_count ) { - ub1 csfrm = 0; - ub2 csid = 0; - void *obuf = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) - OCI_CALL_DECLARE_VARIABLES(boolean, FALSE, TRUE) + ub1 csfrm = 0; + ub2 csid = 0; + void *obuf = NULL; /* OCILobWriteAppend() seems to cause problems on Oracle client 8.1 and 9.0 It's an Oracle known bug #886191 So we use OCI_LobSeek() + OCI_LobWrite() instead */ - if (OCILib.version_runtime < OCI_10_1) + if (Env.version_runtime < OCI_10_1) { - return OCI_LobSeek(lob, OCI_LobGetLength(lob), OCI_SEEK_SET) && - OCI_LobWrite2(lob, buffer, char_count, byte_count); + CHECK(LobSeek(lob, LobGetLength(lob), OCI_SEEK_SET)) + CHECK(LobWrite2(lob, buffer, char_count, byte_count)) + SET_SUCCESS() + JUMP_CLEANUP() } - OCI_CALL_CONTEXT_ENTER(OCILib.env_mode) - - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, char_count) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, byte_count) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_INT, char_count) + CHECK_PTR(OCI_IPC_INT, byte_count) if (OCI_BLOB != lob->type) { - if (OCI_CHAR_WIDE == OCILib.charset) + if (OCI_CHAR_WIDE == Env.charset) { csid = OCI_UTF16ID; } if (((*byte_count) == 0) && ((*char_count) > 0)) { - if (OCILib.nls_utf8) + if (Env.nls_utf8) { (*byte_count) = (unsigned int) strlen( (char *) buffer); } @@ -939,14 +1095,14 @@ boolean OCI_API OCI_LobAppend2 if (((*char_count) == 0) && ((*byte_count) > 0)) { - if (OCILib.nls_utf8) + if (Env.nls_utf8) { - #ifndef OCI_LOB2_API_ENABLED +#ifndef OCI_LOB2_API_ENABLED - (*char_count) = (ub4) OCI_StringLength((const char *)buffer, sizeof(char)); + (*char_count) = (ub4) StringLength((const char *)buffer, sizeof(char)); - #endif +#endif } else @@ -955,7 +1111,7 @@ boolean OCI_API OCI_LobAppend2 } } - obuf = OCI_StringGetOracleString((const otext *) buffer, (int *) byte_count); + obuf = StringGetDBString((const otext *) buffer, (int *) byte_count); } else { @@ -963,21 +1119,23 @@ boolean OCI_API OCI_LobAppend2 } csfrm = (OCI_NCLOB == lob->type) ? SQLCS_NCHAR : SQLCS_IMPLICIT; - + #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { ub8 size_in_out_char = (ub8) (*char_count); ub8 size_in_out_byte = (ub8) (*byte_count); - OCI_EXEC + CHECK_OCI ( - OCILobWriteAppend2(lob->con->cxt, lob->con->err, lob->handle, - &size_in_out_byte, &size_in_out_char, - obuf, (ub8) (*byte_count), (ub1) OCI_ONE_PIECE, - (dvoid *) NULL, NULL, csid, csfrm) - ) + lob->con->err, + OCILobWriteAppend2, + lob->con->cxt, lob->con->err, lob->handle, + &size_in_out_byte, &size_in_out_char, + obuf, (ub8) (*byte_count), (ub1) OCI_ONE_PIECE, + (dvoid *) NULL, NULL, csid, csfrm + ); (*char_count) = (ub4) size_in_out_char; (*byte_count) = (ub4) size_in_out_byte; @@ -990,7 +1148,7 @@ boolean OCI_API OCI_LobAppend2 { ub4 size_in_out_char_byte = 0; - if ((OCI_BLOB == lob->type) || !OCILib.nls_utf8) + if ((OCI_BLOB == lob->type) || !Env.nls_utf8) { size_in_out_char_byte = (*byte_count); } @@ -999,60 +1157,60 @@ boolean OCI_API OCI_LobAppend2 size_in_out_char_byte = (*char_count); } - OCI_EXEC + CHECK_OCI ( - OCILobWriteAppend(lob->con->cxt, lob->con->err, lob->handle, - &size_in_out_char_byte, obuf, (*byte_count), - (ub1) OCI_ONE_PIECE, (dvoid *) NULL, NULL, csid, csfrm) - ) + lob->con->err, + OCILobWriteAppend, + lob->con->cxt, lob->con->err, lob->handle, + &size_in_out_char_byte, obuf, (*byte_count), + (ub1) OCI_ONE_PIECE, (dvoid *) NULL, NULL, csid, csfrm + ); (*char_count) = (ub4) size_in_out_char_byte; (*byte_count) = (ub4) size_in_out_char_byte; - if ((OCI_CLOB == lob->type) && !OCILib.nls_utf8) + if ((OCI_CLOB == lob->type) && !Env.nls_utf8) { - (*byte_count) *= (ub4) sizeof(otext); + (*byte_count) *= (ub4) sizeof(otext); } } - if (OCI_STATUS) + if (OCI_BLOB == lob->type) { - if (OCI_BLOB == lob->type) - { - lob->offset += (big_uint) (*byte_count); - } - else - { - lob->offset += (big_uint) (*char_count); - } + lob->offset += (big_uint) (*byte_count); } - - if (obuf != buffer) + else { - OCI_StringReleaseOracleString((dbtext *) obuf); + lob->offset += (big_uint) (*char_count); } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (obuf != buffer) + { + StringReleaseDBString((dbtext*)obuf); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_LobAppend + * LobAppend * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LobAppend +unsigned int LobAppend ( OCI_Lob *lob, void *buffer, unsigned int len ) { - unsigned int char_count = 0; - unsigned int byte_count = 0; - unsigned int *ptr_count = NULL; + unsigned int char_count = 0; + unsigned int byte_count = 0; + unsigned int *ptr_count = NULL; - if (lob) + if (NULL != lob) { if(OCI_BLOB == lob->type) { @@ -1066,257 +1224,386 @@ unsigned int OCI_API OCI_LobAppend } } - OCI_LobAppend2(lob, buffer, &char_count, &byte_count); + LobAppend2(lob, buffer, &char_count, &byte_count); return (NULL != ptr_count ? *ptr_count : 0); } /* --------------------------------------------------------------------------------------------- * - * OCI_LobAppendLob + * LobAppendLob * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobAppendLob +boolean LobAppendLob ( OCI_Lob *lob, OCI_Lob *lob_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob_src) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) - OCI_EXEC(OCILobAppend(lob->con->cxt, lob->con->err, lob->handle, lob_src->handle)) + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_LOB, lob_src) - if (OCI_STATUS) - { - lob->offset += OCI_LobGetLength(lob); - } + CHECK_OCI + ( + lob->con->err, + OCILobAppend, + lob->con->cxt, lob->con->err, + lob->handle, lob_src->handle + ) + + lob->offset = LobGetLength(lob); - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobIsTemporary + * LobIsTemporary * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobIsTemporary +boolean LobIsTemporary ( OCI_Lob *lob ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) - OCI_EXEC(OCILobIsTemporary(lob->con->env, lob->con->err, lob->handle, &OCI_RETVAL)) + CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_EXIT() + boolean is_temp = FALSE; + + CHECK_OCI + ( + lob->con->err, + OCILobIsTemporary, + lob->con->env, lob->con->err, + lob->handle, &is_temp + ) + + SET_RETVAL(is_temp) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobOpen + * LobOpen * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobOpen +boolean LobOpen ( OCI_Lob *lob, unsigned int mode ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_ENUM_VALUE(lob->con, NULL, mode, OpenModeValues, OTEXT("Open mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) - - OCI_EXEC(OCILobOpen(lob->con->cxt, lob->con->err, lob->handle, (ub1) mode)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_ENUM_VALUE(mode, OpenModeValues, OTEXT("Open mode")) + + CHECK_OCI + ( + lob->con->err, + OCILobOpen, + lob->con->cxt, lob->con->err, + lob->handle, (ub1) mode + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobClose + * LobClose * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobClose +boolean LobClose ( OCI_Lob *lob ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) - OCI_EXEC(OCILobClose(lob->con->cxt, lob->con->err, lob->handle)) + CHECK_OCI + ( + lob->con->err, + OCILobClose, + lob->con->cxt, lob->con->err, + lob->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobIsEqual + * LobIsEqual * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobIsEqual +boolean LobIsEqual ( OCI_Lob *lob, OCI_Lob *lob2 ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob2) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_LOB, lob2) + + boolean is_equal = FALSE; + + CHECK_OCI + ( + lob->con->err, + OCILobIsEqual, + lob->con->env, lob->handle, + lob2->handle, &is_equal + ) - OCI_EXEC(OCILobIsEqual(lob->con->env, lob->handle, lob2->handle, &OCI_RETVAL)) + SET_RETVAL(is_equal) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobAssign + * LobAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobAssign +boolean LobAssign ( OCI_Lob *lob, OCI_Lob *lob_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob_src) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + CHECK_PTR(OCI_IPC_LOB, lob_src) if ((OCI_OBJECT_ALLOCATED == lob->hstate) || (OCI_OBJECT_ALLOCATED_ARRAY == lob->hstate)) { - OCI_EXEC(OCILobLocatorAssign(lob->con->cxt, lob->con->err, lob_src->handle, &lob->handle)) + CHECK_OCI + ( + lob->con->err, + OCILobLocatorAssign, + lob->con->cxt, lob->con->err, + lob_src->handle, &lob->handle + ) } else { - OCI_EXEC(OCILobAssign(lob->con->env, lob->con->err, lob_src->handle, &lob->handle)) + CHECK_OCI + ( + lob->con->err, + OCILobAssign, lob->con->env, + lob->con->err, lob_src->handle, + &lob->handle + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobGetMaxSize + * LobGetMaxSize * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_LobGetMaxSize +big_uint LobGetMaxSize ( OCI_Lob *lob ) { - OCI_CALL_ENTER(big_uint, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ big_uint, 0, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + + big_uint max_size = 0; #ifdef OCI_LOB2_API_ENABLED - if (OCILib.use_lob_ub8) + if (Env.use_lob_ub8) { ub8 size = 0; - OCI_EXEC(OCILobGetStorageLimit(lob->con->cxt, lob->con->err, lob->handle, (ub8 *) &size)) + CHECK_OCI + ( + lob->con->err, + OCILobGetStorageLimit, + lob->con->cxt, lob->con->err, + lob->handle, (ub8 *) &size + ) - OCI_RETVAL = size; + max_size = size; } #endif - OCI_CALL_EXIT() + SET_RETVAL(max_size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobFlush + * LobFlush * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobFlush +boolean LobFlush ( OCI_Lob *lob ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) - OCI_EXEC(OCILobFlushBuffer(lob->con->cxt, lob->con->err, lob->handle, (ub4) OCI_DEFAULT)) + CHECK_OCI + ( + lob->con->err, + OCILobFlushBuffer, + lob->con->cxt, lob->con->err, + lob->handle, (ub4) OCI_DEFAULT + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LobEnableBuffering + * LobEnableBuffering * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobEnableBuffering +boolean LobEnableBuffering ( OCI_Lob *lob, boolean value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) if (value) { - OCI_EXEC(OCILobEnableBuffering(lob->con->cxt, lob->con->err, lob->handle)) + CHECK_OCI + ( + lob->con->err, + OCILobEnableBuffering, + lob->con->cxt, lob->con->err, + lob->handle + ) } else { - OCI_EXEC(OCILobDisableBuffering(lob->con->cxt, lob->con->err, lob->handle)) + CHECK_OCI + ( + lob->con->err, + OCILobDisableBuffering, + lob->con->cxt, lob->con->err, + lob->handle + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_LobGetConnection +* LobGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_LobGetConnection +OCI_Connection * LobGetConnection ( OCI_Lob *lob ) { - OCI_GET_PROP(OCI_Connection *, NULL, OCI_IPC_LOB, lob, con, lob->con, NULL, lob->con->err) + GET_PROP + ( + /* result */ OCI_Connection *, NULL, + /* handle */ OCI_IPC_LOB, lob, + /* member */ con + ) } /* --------------------------------------------------------------------------------------------- * -* OCI_LobIsRemote +* LobIsRemote * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LobIsRemote +boolean LobIsRemote ( OCI_Lob *lob ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LOB, lob) - OCI_CALL_CONTEXT_SET_FROM_CONN(lob->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LOB, lob + ) + + CHECK_PTR(OCI_IPC_LOB, lob) + + boolean is_remote = FALSE; #if OCI_VERSION_COMPILE >= OCI_12_2 - if (OCI_ConnectionIsVersionSupported(lob->con, OCI_12_2)) + if (ConnectionIsVersionSupported(lob->con, OCI_12_2)) { - OCI_GET_ATTRIB(OCI_DTYPE_LOB, OCI_ATTR_LOB_REMOTE, lob->handle, &OCI_RETVAL, sizeof(OCI_RETVAL)) + CHECK_ATTRIB_GET + ( + OCI_DTYPE_LOB, OCI_ATTR_LOB_REMOTE, + lob->handle, &is_remote, sizeof(is_remote), + lob->con->err + ) } #endif - OCI_CALL_EXIT() + SET_RETVAL(is_remote) + + EXIT_FUNC() } diff --git a/src/lob.h b/src/lob.h new file mode 100644 index 00000000..f43c859c --- /dev/null +++ b/src/lob.h @@ -0,0 +1,220 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_LOB_H_INCLUDED +#define OCILIB_LOB_H_INCLUDED + +#include "types.h" + +OCI_Lob * LobInitialize +( + OCI_Connection *con, + OCI_Lob *lob, + OCILobLocator *handle, + ub4 type +); + +OCI_Lob * LobCreate +( + OCI_Connection *con, + unsigned int type +); + +boolean LobFree +( + OCI_Lob *lob +); + +OCI_Lob ** LobCreateArray +( + OCI_Connection *con, + unsigned int type, + unsigned int nbelem +); + +boolean LobFreeArray +( + OCI_Lob **lobs +); + +unsigned int LobGetType +( + OCI_Lob *lob +); + +boolean LobSeek +( + OCI_Lob *lob, + big_uint offset, + unsigned int mode +); + +big_uint LobGetOffset +( + OCI_Lob *lob +); + +boolean LobRead2 +( + OCI_Lob *lob, + void *buffer, + unsigned int *char_count, + unsigned int *byte_count +); + +unsigned int LobRead +( + OCI_Lob *lob, + void *buffer, + unsigned int len +); + +boolean LobWrite2 +( + OCI_Lob *lob, + void *buffer, + unsigned int *char_count, + unsigned int *byte_count +); + +unsigned int LobWrite +( + OCI_Lob *lob, + void *buffer, + unsigned int len +); + +boolean LobTruncate +( + OCI_Lob *lob, + big_uint size +); + +big_uint LobErase +( + OCI_Lob *lob, + big_uint offset, + big_uint size +); + +big_uint LobGetLength +( + OCI_Lob *lob +); + +unsigned int LobGetChunkSize +( + OCI_Lob *lob +); + +boolean LobCopy +( + OCI_Lob *lob, + OCI_Lob *lob_src, + big_uint offset_dst, + big_uint offset_src, + big_uint count +); + +boolean LobCopyFromFile +( + OCI_Lob *lob, + OCI_File *file, + big_uint offset_dst, + big_uint offset_src, + big_uint count +); + +boolean LobAppend2 +( + OCI_Lob *lob, + void *buffer, + unsigned int *char_count, + unsigned int *byte_count +); + +unsigned int LobAppend +( + OCI_Lob *lob, + void *buffer, + unsigned int len +); + +boolean LobAppendLob +( + OCI_Lob *lob, + OCI_Lob *lob_src +); + +boolean LobIsTemporary +( + OCI_Lob *lob +); + +boolean LobOpen +( + OCI_Lob *lob, + unsigned int mode +); + +boolean LobClose +( + OCI_Lob *lob +); + +boolean LobIsEqual +( + OCI_Lob *lob, + OCI_Lob *lob2 +); + +boolean LobAssign +( + OCI_Lob *lob, + OCI_Lob *lob_src +); + +big_uint LobGetMaxSize +( + OCI_Lob *lob +); + +boolean LobFlush +( + OCI_Lob *lob +); + +boolean LobEnableBuffering +( + OCI_Lob *lob, + boolean value +); + +OCI_Connection * LobGetConnection +( + OCI_Lob *lob +); + +boolean LobIsRemote +( + OCI_Lob* lob +); + +#endif /* OCILIB_LOB_H_INCLUDED */ diff --git a/src/long.c b/src/long.c index 9bc7d9d8..d1cba0f0 100644 --- a/src/long.c +++ b/src/long.c @@ -18,23 +18,23 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "long.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "macros.h" +#include "memory.h" +#include "strings.h" -static const unsigned int LongTypeValues[] = { OCI_CLONG, OCI_BLONG }; - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static const unsigned int LongTypeValues[] = +{ + OCI_CLONG, + OCI_BLONG +}; /* --------------------------------------------------------------------------------------------- * - * OCI_LongInit + * LongInitialize * --------------------------------------------------------------------------------------------- */ -OCI_Long * OCI_LongInit +OCI_Long * LongInitialize ( OCI_Statement *stmt, OCI_Long *lg, @@ -42,110 +42,128 @@ OCI_Long * OCI_LongInit unsigned int type ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) - - OCI_ALLOCATE_DATA(OCI_IPC_LONG, lg, 1); - - if (OCI_STATUS) + ENTER_FUNC + ( + /* returns */ OCI_Long*, lg, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + ALLOC_DATA(OCI_IPC_LONG, lg, 1); + + lg->size = 0; + lg->maxsize = 0; + lg->stmt = stmt; + lg->def = def; + lg->type = type; + lg->offset = 0; + + if (def) { - lg->size = 0; - lg->maxsize = 0; - lg->stmt = stmt; - lg->def = def; - lg->type = type; - lg->offset = 0; - - if (def) - { - lg->hstate = OCI_OBJECT_FETCHED_CLEAN; - } - else if (OCI_OBJECT_ALLOCATED_ARRAY != lg->hstate) + lg->hstate = OCI_OBJECT_FETCHED_CLEAN; + } + else if (OCI_OBJECT_ALLOCATED_ARRAY != lg->hstate) + { + lg->hstate = OCI_OBJECT_ALLOCATED; + } + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - lg->hstate = OCI_OBJECT_ALLOCATED; + LongFree(lg); + lg = NULL; } - } - return lg; + SET_RETVAL(lg) + ) } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_LongCreate + * LongCreate * --------------------------------------------------------------------------------------------- */ -OCI_Long * OCI_API OCI_LongCreate +OCI_Long * LongCreate ( OCI_Statement *stmt, unsigned int type ) { - OCI_CALL_ENTER(OCI_Long*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, LongTypeValues, OTEXT("Long Type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ OCI_Long*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_ENUM_VALUE(type, LongTypeValues, OTEXT("Long Type")) - OCI_RETVAL = OCI_LongInit(stmt, NULL, NULL, type); - OCI_STATUS = (NULL != OCI_RETVAL); + SET_RETVAL(LongInitialize(stmt, NULL, NULL, type)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LongFree + * LongFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_LongFree +boolean LongFree ( OCI_Long *lg ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_LONG, lg) - OCI_CALL_CHECK_OBJECT_FETCHED(lg) - OCI_CALL_CONTEXT_SET_FROM_STMT(lg->stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_LONG, lg + ) - OCI_FREE(lg->buffer) - OCI_FREE(lg) + CHECK_PTR(OCI_IPC_LONG, lg) + CHECK_OBJECT_FETCHED(lg) - OCI_RETVAL = OCI_STATUS; + FREE(lg->buffer) + FREE(lg) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LongGetType + * LongGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LongGetType +unsigned int LongGetType ( OCI_Long *lg ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_LONG, lg, type, lg->stmt->con, lg->stmt, lg->stmt->con->err) + GET_PROP + ( + /* result */ unsigned int, OCI_UNKNOWN, + /* handle */ OCI_IPC_LONG, lg, + /* member */ type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_LongRead + * LongRead * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LongRead +unsigned int LongRead ( OCI_Long *lg, void *buffer, unsigned int len ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_LONG, lg) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, buffer) - OCI_CALL_CONTEXT_SET_FROM_STMT(lg->stmt) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_LONG, lg + ) - OCI_STATUS = TRUE; - OCI_RETVAL = len; + CHECK_PTR(OCI_IPC_LONG, lg) + CHECK_PTR(OCI_IPC_VOID, buffer) /* lg->size and lg offset are still expressed in db text units even if the buffer had already been expanded to otext * @@ -153,62 +171,68 @@ unsigned int OCI_API OCI_LongRead if (OCI_CLONG == lg->type) { - OCI_RETVAL *= (unsigned int) sizeof(dbtext); + len *= (unsigned int) sizeof(dbtext); } /* check buffer size to read */ - if ((OCI_RETVAL + lg->offset) > lg->size) + if ((len + lg->offset) > lg->size) { - OCI_RETVAL = lg->size - lg->offset; + len = lg->size - lg->offset; } /* copy buffer */ - memcpy(buffer, lg->buffer + (size_t) lg->offset, (size_t) (OCI_RETVAL)); + memcpy(buffer, lg->buffer + (size_t) lg->offset, (size_t) (len)); - lg->offset += OCI_RETVAL; + lg->offset += len; if (OCI_CLONG == lg->type) { - ((otext *)buffer)[OCI_RETVAL] = 0; + ((otext *)buffer)[len] = 0; - OCI_RETVAL /= (unsigned int) sizeof(otext); + len /= (unsigned int) sizeof(otext); } - OCI_CALL_EXIT() + SET_RETVAL(len) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LongWrite + * LongWrite * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LongWrite +unsigned int LongWrite ( OCI_Long *lg, void *buffer, unsigned int len ) { - sword code = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_LONG, lg + ) + + sword code = OCI_SUCCESS; void *obuf = NULL; void *handle = NULL; - ub1 in_out = OCI_PARAM_IN; - ub1 piece = OCI_ONE_PIECE; - ub4 type = 0; - ub4 iter = 0; - ub4 dx = 0; - ub4 count = 0; - - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, buffer) - OCI_CALL_CHECK_PTR(OCI_IPC_LONG, lg) - OCI_CALL_CONTEXT_SET_FROM_STMT(lg->stmt) + ub1 in_out = OCI_PARAM_IN; + ub1 piece = OCI_ONE_PIECE; + ub4 type = 0; + ub4 iter = 0; + ub4 dx = 0; + ub4 count = 0; + + CHECK_PTR(OCI_IPC_VOID, buffer) + CHECK_PTR(OCI_IPC_LONG, lg) if (OCI_CLONG == lg->type) { len *= (unsigned int) sizeof(otext); - obuf = OCI_StringGetOracleString((const otext *) buffer, (int *) &len); + obuf = StringGetDBString((const otext *) buffer, (int *) &len); } else { @@ -217,7 +241,13 @@ unsigned int OCI_API OCI_LongWrite /* get piece info */ - OCI_EXEC(OCIStmtGetPieceInfo(lg->stmt->stmt, lg->stmt->con->err, &handle, &type, &in_out, &iter, &dx, &piece)) + CHECK_OCI + ( + lg->stmt->con->err, + OCIStmtGetPieceInfo, + lg->stmt->stmt, lg->stmt->con->err, + &handle, &type, &in_out, &iter, &dx, &piece + ) /* set up piece type */ @@ -244,82 +274,92 @@ unsigned int OCI_API OCI_LongWrite /* set up info for writing */ - OCI_EXEC(OCIStmtSetPieceInfo(handle, type, lg->stmt->con->err, (dvoid *) obuf, &count, piece, (dvoid *) NULL, (ub2 *) NULL)) + CHECK_OCI + ( + lg->stmt->con->err, + OCIStmtSetPieceInfo, + handle, type, lg->stmt->con->err, + (dvoid *) obuf, &count, piece, + (dvoid *) NULL, (ub2 *) NULL + ) /* perform write call */ - if (OCI_STATUS) - { - code = OCIStmtExecute(lg->stmt->con->cxt, lg->stmt->stmt, - lg->stmt->con->err, (ub4) 1, (ub4) 0, - (OCISnapshot *) NULL, (OCISnapshot *) NULL, - (ub4) 0); - } + code = OCIStmtExecute(lg->stmt->con->cxt, lg->stmt->stmt, + lg->stmt->con->err, (ub4) 1, (ub4) 0, + (OCISnapshot *) NULL, (OCISnapshot *) NULL, + (ub4) 0); if (OCI_FAILURE(code) && (OCI_NEED_DATA != code)) { - OCI_STATUS = (OCI_SUCCESS_WITH_INFO == code); - - OCI_ExceptionOCI(lg->stmt->con->err, lg->stmt->con, lg->stmt, OCI_STATUS); - } - - if (OCI_CLONG == lg->type) - { - OCI_StringReleaseOracleString((dbtext *) obuf); + THROW(ExceptionOCI, lg->stmt->con->err, code) } /* update size */ - if (OCI_STATUS) - { - lg->size += count; + lg->size += count; - /* at this point, count is expressed in db text bytes for character LONGs - **/ - - if (OCI_CLONG == lg->type) - { - count /= (unsigned int) sizeof(dbtext); - } + /* at this point, count is expressed in db text bytes for character LONGs + **/ + if (OCI_CLONG == lg->type) + { + count /= (unsigned int) sizeof(dbtext); } - OCI_RETVAL = count; + SET_RETVAL(count) - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != lg && OCI_CLONG == lg->type) + { + StringReleaseDBString((dbtext*)obuf); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_LongGetSize + * LongGetSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_LongGetSize +unsigned int LongGetSize ( OCI_Long *lg ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_LONG, lg) - OCI_CALL_CONTEXT_SET_FROM_STMT(lg->stmt) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_LONG, lg + ) - OCI_RETVAL = lg->size; + CHECK_PTR(OCI_IPC_LONG, lg) + + unsigned int size = lg->size; if (OCI_CLONG == lg->type) { - OCI_RETVAL /= (unsigned int) sizeof(dbtext); + size /= (unsigned int) sizeof(dbtext); } - OCI_CALL_EXIT() + SET_RETVAL(size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_LongGetBuffer + * LongGetBuffer * --------------------------------------------------------------------------------------------- */ -void * OCI_API OCI_LongGetBuffer +void * LongGetBuffer ( OCI_Long *lg ) { - OCI_GET_PROP(void *, NULL, OCI_IPC_LONG, lg, buffer, lg->stmt->con, lg->stmt, lg->stmt->con->err) + GET_PROP + ( + /* result */ void *, NULL, + /* handle */ OCI_IPC_LONG, lg, + /* member */ buffer + ) } diff --git a/src/long.h b/src/long.h new file mode 100644 index 00000000..560bbc2c --- /dev/null +++ b/src/long.h @@ -0,0 +1,74 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_LONG_H_INCLUDED +#define OCILIB_LONG_H_INCLUDED + +#include "types.h" + +OCI_Long * LongInitialize +( + OCI_Statement *stmt, + OCI_Long *lg, + OCI_Define *def, + unsigned int type +); + +OCI_Long * LongCreate +( + OCI_Statement *stmt, + unsigned int type +); + +boolean LongFree +( + OCI_Long *lg +); + +unsigned int LongGetType +( + OCI_Long *lg +); + +unsigned int LongRead +( + OCI_Long *lg, + void *buffer, + unsigned int len +); + +unsigned int LongWrite +( + OCI_Long *lg, + void *buffer, + unsigned int len +); + +unsigned int LongGetSize +( + OCI_Long *lg +); + +void * LongGetBuffer +( + OCI_Long *lg +); + +#endif /* OCILIB_LONG_H_INCLUDED */ diff --git a/src/macros.h b/src/macros.h new file mode 100644 index 00000000..d5bf67ce --- /dev/null +++ b/src/macros.h @@ -0,0 +1,436 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_MACROS_H_INCLUDED +#define OCILIB_MACROS_H_INCLUDED + +#include "error.h" +#include "exception.h" +#include "memory.h" +#include "types.h" + +/* declare a call context */ + +#define CONTEXT(src_type, src_ptr) \ + \ + OCI_Context call_context; \ + call_context.source_ptr = src_ptr; \ + call_context.source_type = src_type; \ + call_context.location = __func__; \ + +/* enter in a call */ + +#define ENTER_FUNC(ret_type, ret_value, src_type, src_ptr) \ + \ + ret_type call_retval = ret_value; \ + boolean call_status = TRUE; \ + CONTEXT(src_type, src_ptr) \ + +#define ENTER_VOID(src_type, src_ptr) \ + \ + boolean call_status = TRUE; \ + CONTEXT(src_type, src_ptr) \ + +/* jumps */ + +#define JUMP_CLEANUP() \ + \ + goto CleanupLabel; \ + +#define JUMP_EXIT() \ + \ + goto ExitLabel; \ + +/* labels */ + +#define LABEL_CLEANUP(exp) \ + \ +CleanupLabel: \ + {exp;} \ + goto ExitLabel; \ + +/* return to the caller */ + +#define LABEL_EXIT_VOID() \ + \ +ExitLabel: \ + return; + +#define LABEL_EXIT_FUNC() \ + \ +ExitLabel: \ + return call_retval; + +/* status management */ + +#define CHECK(exp) \ + \ + { \ + call_status = (exp); \ + if (!call_status) \ + { \ + JUMP_CLEANUP() \ + } \ + } + +/* invoke exception and jump to cleanup */ + +#define THROW_NO_ARGS(func) \ + \ + func(&call_context); \ + CHECK(FALSE) \ + +#define THROW(func, ...) \ + \ + func(&call_context, __VA_ARGS__); \ + CHECK(FALSE) \ + + +/* exit a call */ + +#define EXIT_FUNC() \ + \ + LABEL_CLEANUP(; ) \ + LABEL_EXIT_FUNC() + +#define CLEANUP_AND_EXIT_FUNC(exp) \ + \ + LABEL_CLEANUP(exp) \ + LABEL_EXIT_FUNC() + +#define EXIT_VOID() \ + \ + LABEL_CLEANUP(; ) \ + LABEL_EXIT_VOID() \ + + +#define FAILURE (call_status == FALSE) + +/* return value management */ + +#define SET_RETVAL(exp) { call_retval = exp; } + +#define SET_SUCCESS() SET_RETVAL(TRUE) + +/* error management when calling or assigning */ + +#define CHECK_NULL(ptr) \ + \ + if (NULL == (ptr)) \ + { \ + CHECK(FALSE) \ + } + +/* checking macros */ + +#define CHECK_FALSE(exp, ret) if (exp) return (ret); + +#define CHECK_ERROR(err) CHECK(NULL == (err) || OCI_UNKNOWN == (err)->type) + +#define CHECK_PTR(type, ptr) \ + \ + if (!(ptr)) \ + { \ + THROW(ExceptionNullPointer, (type)) \ + } + +#define CHECK_BOUND(v, b1, b2) \ + \ + if (((v) < (b1)) || ((v) > (b2))) \ + { \ + THROW(ExceptionOutOfBounds, (v)) \ + } + +#define CHECK_MIN(v, m) \ + \ + if ((v) < (m)) \ + { \ + THROW(ExceptionMinimumValue, (m)) \ + } + +#define CHECK_COMPAT(exp) \ + \ + if (!(exp)) \ + { \ + THROW_NO_ARGS(ExceptionTypeNotCompatible) \ + } + +#define CHECK_STMT_STATUS(st, v) \ + \ + if ((((st)->status) & (v)) == 0) \ + { \ + THROW(ExceptionStatementState, (v)) \ + } + +#define CHECK_OBJECT_FETCHED(obj) \ + \ + if (OCI_OBJECT_FETCHED_CLEAN == (obj)->hstate) \ + { \ + JUMP_EXIT() \ + } \ + +#define CHECK_CON_STATUS(cn, v) \ + \ + if ((cn)->cstate != (v)) \ + { \ + JUMP_EXIT() \ + } \ + +#define CHECK_SCROLLABLE_CURSOR_ACTIVATED(st) \ + \ + if (((st)->nb_rbinds > 0) || \ + ((st)->exec_mode != OCI_STMT_SCROLLABLE_READONLY)) \ + { \ + THROW_NO_ARGS(ExceptionStatementNotScrollable) \ + } + +#define CHECK_DIRPATH_STATUS(dp, v) \ + \ + if ((dp)->status != (v)) \ + { \ + THROW(ExceptionDirPathState, (dp)->status) \ + } + +#define CHECK_INITIALIZED() \ + \ + if (!Env.loaded) \ + { \ + THROW_NO_ARGS(ExceptionNotInitialized) \ + } + +#define CHECK_FEATURE(con, feat, ver) \ + \ + if (Env.version_runtime < (ver) || ((con) && (con)->ver_num < (ver))) \ + { \ + THROW(ExceptionNotAvailable, (feat)) \ + } + +#define CHECK_THREAD_ENABLED() \ + \ + if (!(LIB_THREADED)) \ + { \ + THROW_NO_ARGS(ExceptionNotMultithreaded) \ + } + +#define CHECK_TIMESTAMP_ENABLED(con) \ + \ + CHECK_FEATURE(con, OCI_FEATURE_TIMESTAMP, OCI_9_0) + +#define CHECK_INTERVAL_ENABLED(con) \ + \ + CHECK_FEATURE(con, OCI_FEATURE_TIMESTAMP, OCI_9_0) + +#define CHECK_SCROLLABLE_CURSOR_ENABLED(con) \ + \ + CHECK_FEATURE(con, OCI_FEATURE_SCROLLABLE_CURSOR, OCI_9_0) + +#define CHECK_EXTENDED_PLSQLTYPES_ENABLED(con) \ + \ + CHECK_FEATURE(con, OCI_FEATURE_EXTENDED_PLSQLTYPES, OCI_12_1) + +#define CHECK_STATEMENT_CACHING_ENABLED() \ + \ + if (Env.version_runtime < OCI_9_2) \ + { \ + THROW(ExceptionNotAvailable, OCI_FEATURE_STATEMENT_CACHING) \ + } + +#define CHECK_DIRPATH_DATE_CACHE_ENABLED(dp) \ + \ + if (Env.version_runtime < OCI_9_2) \ + { \ + THROW(ExceptionNotAvailable, OCI_FEATURE_DIRPATH_DATE_CACHE) \ + } + +#define CHECK_REMOTE_DBS_CONTROL_ENABLED() \ + \ + if (Env.version_runtime < OCI_10_2) \ + { \ + THROW(ExceptionNotAvailable, OCI_FEATURE_REMOTE_DBS_CONTROL) \ + } + +#define CHECK_DATABASE_NOTIFY_ENABLED() \ + \ + if (Env.version_runtime < OCI_10_2) \ + { \ + THROW(ExceptionNotAvailable, OCI_FEATURE_DATABASE_NOTIFY) \ + } + +#define CHECK_HIGH_AVAILABILITY_ENABLED() \ + \ + if (Env.version_runtime < OCI_10_2) \ + { \ + THROW(ExceptionNotAvailable, OCI_FEATURE_HIGH_AVAILABILITY) \ + } + +#define CHECK_XA_ENABLED(mode) \ + \ + if ( ((mode) & OCI_SESSION_XA) && (!Env.use_xa) ) \ + { \ + THROW(ExceptionNotAvailable, OCI_FEATURE_XA) \ + } + +#define CHECK_ENUM_VALUE(mode, values, name) \ + \ + { \ + size_t ii = 0, nn = sizeof(values) / sizeof((values)[0]); \ + for (; ii < nn; ii++) \ + { \ + if ((mode) == (values)[ii]) break; \ + } \ + if (ii >= nn) \ + { \ + THROW(ExceptionArgInvalidValue, (name), (mode)) \ + } \ + } + +/* memory management helpers */ + +#define FREE(ptr) { MemoryFree(ptr); (ptr) = NULL; } + +/* helpers macros */ + +#define GET_PROP(rtype, rvalue, stype, sptr, prop) \ + \ + ENTER_FUNC(rtype, rvalue, stype, sptr) \ + \ + CHECK_PTR(stype, sptr) \ + \ + SET_RETVAL((rtype) ((sptr)->prop)) \ + \ + EXIT_FUNC() + +#define SET_PROP(stype, sptr, prop, ptype, val) \ + \ + ENTER_FUNC(boolean, TRUE, stype, sptr) \ + \ + CHECK_PTR(stype, sptr) \ + \ + (sptr)->prop = (ptype) (val); \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() + +#define SET_PROP_ENUM(stype, sptr, prop, ptype, val, enms, msg) \ + \ + ENTER_FUNC(boolean, TRUE, stype, sptr) \ + \ + CHECK_PTR(stype, sptr) \ + CHECK_ENUM_VALUE((val), (enms), (msg)) \ + \ + (sptr)->prop = (ptype) (val); \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() + +#define GET_LIB_PROP(type, value, prop) \ + \ + ENTER_FUNC(type, value, OCI_IPC_VOID, &Env) \ + \ + CHECK_INITIALIZED() \ + \ + SET_RETVAL((type) (prop)) \ + \ + EXIT_FUNC() \ + +#define SET_LIB_PROP(prop, value) \ + \ + ENTER_FUNC(boolean, FALSE, OCI_IPC_VOID, &Env) \ + \ + CHECK_INITIALIZED() \ + \ + (prop) = (value); \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() \ + +#define ALLOC_BUFFER(type, ptr, size, count) \ + \ + if (!(ptr)) \ + { \ + (ptr) = MemoryAlloc(type, size, (size_t) (count), TRUE); \ + \ + CHECK_NULL((ptr)) \ + } \ + +#define REALLOC_BUFFER(type, ptr, size, current, allocated, requested) \ + \ + if (!(ptr)) \ + { \ + (ptr) = MemoryAlloc(type, size, (size_t) (requested), TRUE); \ + if (ptr) (allocated) = (requested); \ + } \ + else if ((current) >= (allocated)) \ + { \ + (ptr) = MemoryRealloc(ptr, type, size, (size_t) (requested), TRUE); \ + if (ptr) (allocated) = (requested); \ + } \ + \ + CHECK_NULL((ptr)) \ + +#define ALLOC_DATA(type, ptr, count) \ + \ + ALLOC_BUFFER(type, ptr, sizeof(*(ptr)), count) + +#define REALLOC_DATA(type, ptr, cur, alloc, inc) \ + \ + REALLOC_BUFFER(type, ptr, sizeof(*(ptr)), cur, alloc, inc) + +#define ARRAY_GET_AT(ptr, size, offset) \ + \ + (((ub1 *) (ptr)) + (size_t)((size)*i)) + +#define ARRAY_SET_AT(ptr, type, offset, value) \ + \ + *(type*)(ARRAY_GET_AT(ptr, sizeof(type), i)) = (type) (value); + +#define IS_STRING_VALID(s) ((s) && ((s)[0])) + +#define CHECK_OCI(oci_err, func, ...) \ + \ + { \ + sword oci_retcall = func(__VA_ARGS__); \ + if (OCI_FAILURE(oci_retcall)) \ + { \ + ExceptionOCI(&call_context, oci_err, oci_retcall); \ + CHECK(OCI_SUCCESS_WITH_INFO == oci_retcall) \ + } \ + } \ + +#define CHECK_ATTRIB_GET(htype, atype, handle, value, size, err) \ + \ + CHECK_OCI \ + ( \ + err, OCIAttrGet, (void*) (handle), (ub4) (htype), (void*) (value), \ + (ub4*) (size), (ub4) (atype), err \ + ) \ + +#define CHECK_ATTRIB_SET(htype, atype, handle, value, size, err) \ + \ + CHECK_OCI \ + ( \ + err, OCIAttrSet, (void*) (handle), (ub4) (htype), (void*) (value), \ + (ub4) (size), (ub4) (atype), err \ + ) \ + +#endif /* OCILIB_MACROS_H_INCLUDED */ diff --git a/src/memory.c b/src/memory.c index 3c93af13..c1e0889a 100644 --- a/src/memory.c +++ b/src/memory.c @@ -18,31 +18,53 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -#define OCI_MUTEXED_CALL(exp) \ - \ - if (OCILib.mem_mutex) \ - { \ - OCI_MutexAcquire(OCILib.mem_mutex); \ - } \ - \ - (exp); \ - \ - if (OCILib.mem_mutex) \ - { \ - OCI_MutexRelease(OCILib.mem_mutex); \ - } \ +#include "memory.h" + +#include "defs.h" +#include "exception.h" +#include "macros.h" +#include "mutex.h" + +#define MUTEXED_CALL(exp) \ + \ + if (Env.mem_mutex) \ + { \ + MutexAcquire(Env.mem_mutex); \ + } \ + \ + (exp); \ + \ + if (Env.mem_mutex) \ + { \ + MutexRelease(Env.mem_mutex); \ + } \ + /* --------------------------------------------------------------------------------------------- * - * OCI_MemAlloc + * MemoryUpdateBytes * --------------------------------------------------------------------------------------------- */ -void * OCI_MemAlloc +void MemoryUpdateBytes +( + int type, + big_int size +) +{ + if (OCI_IPC_ORACLE == type) + { + MUTEXED_CALL(Env.mem_bytes_oci += size) + } + else + { + MUTEXED_CALL(Env.mem_bytes_lib += size) + } +} + +/* --------------------------------------------------------------------------------------------- * + * MemoryAlloc + * --------------------------------------------------------------------------------------------- */ + +void * MemoryAlloc ( int ptr_type, size_t block_size, @@ -50,200 +72,213 @@ void * OCI_MemAlloc boolean zero_fill ) { - OCI_MemoryBlock * mem_block = NULL; + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + const size_t size = sizeof(OCI_MemoryBlock) + (block_size * block_count); - mem_block = (OCI_MemoryBlock *)malloc(size); + OCI_MemoryBlock* mem_block = (OCI_MemoryBlock *)malloc(size); - if (mem_block) + if (NULL == mem_block) { - if (zero_fill) - { - memset(mem_block, 0, size); - } - - mem_block->type = ptr_type; - mem_block->size = (unsigned int) size; - - OCI_MemUpdateBytes(mem_block->type, mem_block->size); + THROW(ExceptionMemory, ptr_type, size) } - else + + if (zero_fill) { - OCI_ExceptionMemory(ptr_type, size, NULL, NULL); + memset(mem_block, 0, size); } - return ((unsigned char *) mem_block) + sizeof(*mem_block); + mem_block->type = ptr_type; + mem_block->size = (unsigned int) size; + + MemoryUpdateBytes(mem_block->type, mem_block->size); + + SET_RETVAL(((unsigned char*)mem_block) + sizeof(*mem_block)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_MemRealloc + * MemoryRealloc * --------------------------------------------------------------------------------------------- */ -void * OCI_MemRealloc +void * MemoryRealloc ( - void * ptr_mem, - int ptr_type, - size_t block_size, - size_t block_count, + void * ptr_mem, + int ptr_type, + size_t block_size, + size_t block_count, boolean zero_fill ) { - OCI_MemoryBlock * mem_block = NULL; - size_t size = 0; + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) - if (ptr_mem) + if (ptr_mem != NULL) { - mem_block = (OCI_MemoryBlock *) (((unsigned char*)ptr_mem) - sizeof(*mem_block)); - } + OCI_MemoryBlock* block = (OCI_MemoryBlock*)(((unsigned char*)ptr_mem) - sizeof(*block)); - size = sizeof(OCI_MemoryBlock) + (block_size * block_count); + const size_t size = sizeof(OCI_MemoryBlock) + (block_size * block_count); - if (!mem_block || mem_block->size < size) - { - void *ptr_new = realloc(mem_block, size); - - if (ptr_new) + if (block->size < size) { - big_int size_diff = 0; - mem_block = (OCI_MemoryBlock *) ptr_new; - - size_diff = (big_int) size - mem_block->size; + void* ptr_new = realloc(block, size); - if (zero_fill) + if (NULL == ptr_new) { - memset(((unsigned char *)mem_block) + mem_block->size, 0, size - mem_block->size); + MemoryFree(ptr_mem); + THROW(ExceptionMemory, ptr_type, size); } - mem_block->type = ptr_type; - mem_block->size = (unsigned int) size; + block = (OCI_MemoryBlock*)ptr_new; - OCI_MemUpdateBytes(mem_block->type, size_diff); - } - else if (ptr_mem) - { - OCI_MemFree(ptr_mem); + const big_int size_diff = (big_int)size - block->size; + + block->type = ptr_type; + block->size = (unsigned int)size; - OCI_ExceptionMemory(ptr_type, size, NULL, NULL); + if (zero_fill) + { + memset(((unsigned char*)block) + block->size, 0, size - block->size); + } - mem_block = NULL; + MemoryUpdateBytes(block->type, size_diff); } + + ptr_mem = ((unsigned char*)block) + sizeof(*block); + } + else + { + ptr_mem = MemoryAlloc(ptr_type, block_size, block_count, zero_fill); } - return mem_block ? ((unsigned char *)mem_block) + sizeof(*mem_block) : NULL; + SET_RETVAL(ptr_mem) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_MemFree + * MemoryFree * --------------------------------------------------------------------------------------------- */ -void OCI_MemFree +void MemoryFree ( void * ptr_mem ) { if (ptr_mem) { - OCI_MemoryBlock *mem_block = (OCI_MemoryBlock *)(((unsigned char*)ptr_mem) - sizeof(*mem_block)); - - if (mem_block) + OCI_MemoryBlock *block = (OCI_MemoryBlock *)(((unsigned char*)ptr_mem) - sizeof(*block)); + + if (block) { - OCI_MemUpdateBytes(mem_block->type, (big_int) 0 - mem_block->size); + MemoryUpdateBytes(block->type, (big_int) 0 - block->size); - free(mem_block); + free(block); } } } /* --------------------------------------------------------------------------------------------- * -* OCI_MemUpdateBytes -* --------------------------------------------------------------------------------------------- */ - -void OCI_MemUpdateBytes -( - int type, - big_int size -) -{ - if (OCI_IPC_ORACLE == type) - { - OCI_MUTEXED_CALL(OCILib.mem_bytes_oci += size) - } - else - { - OCI_MUTEXED_CALL(OCILib.mem_bytes_lib += size) - } -} - - -/* --------------------------------------------------------------------------------------------- * - * OCI_HandleAlloc + * MemoryAllocHandle * --------------------------------------------------------------------------------------------- */ -boolean OCI_HandleAlloc +boolean MemoryAllocHandle ( CONST dvoid *parenth, dvoid **hndlpp, ub4 type - ) +) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_NULL(hndlpp) + const sword ret = OCIHandleAlloc(parenth, hndlpp, type, 0, NULL); if (OCI_SUCCESSFUL(ret)) { - OCI_MUTEXED_CALL(OCILib.nb_hndlp++) + MUTEXED_CALL(Env.nb_hndlp++) + SET_SUCCESS() } - return OCI_SUCCESSFUL(ret); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_HandleFree + * MemoryFreeHandle * --------------------------------------------------------------------------------------------- */ -boolean OCI_HandleFree +boolean MemoryFreeHandle ( dvoid *hndlp, ub4 type ) { - sword ret = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - if (hndlp) - { - OCI_MUTEXED_CALL(OCILib.nb_hndlp--) + CHECK_NULL(hndlp) + const sword ret = OCIHandleFree(hndlp, type); - ret = OCIHandleFree(hndlp, type); + if (OCI_SUCCESSFUL(ret)) + { + MUTEXED_CALL(Env.nb_hndlp--) + SET_SUCCESS() } - return OCI_SUCCESSFUL(ret); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DescriptorAlloc + * MemoryAllocDescriptor * --------------------------------------------------------------------------------------------- */ -boolean OCI_DescriptorAlloc +boolean MemoryAllocDescriptor ( CONST dvoid *parenth, dvoid **descpp, ub4 type - ) +) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_NULL(descpp) + const sword ret = OCIDescriptorAlloc(parenth, descpp, type, 0, NULL); if (OCI_SUCCESSFUL(ret)) { - OCI_MUTEXED_CALL(OCILib.nb_descp++) + MUTEXED_CALL(Env.nb_descp++) + SET_SUCCESS() } - return OCI_SUCCESSFUL(ret); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DescriptorArrayAlloc + * MemoryAllocDescriptorArray * --------------------------------------------------------------------------------------------- */ -boolean OCI_DescriptorArrayAlloc +boolean MemoryAllocDescriptorArray ( CONST dvoid *parenth, dvoid **descpp, @@ -251,11 +286,19 @@ boolean OCI_DescriptorArrayAlloc ub4 nb_elem ) { - sword ret = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_NULL(descpp) + + sword ret = OCI_ERROR; #if OCI_VERSION_COMPILE >= OCI_11_1 - if (OCILib.version_runtime >= OCI_11_1) + if (Env.version_runtime >= OCI_11_1) { ret = OCIArrayDescriptorAlloc(parenth, descpp, type, nb_elem, 0, NULL); @@ -273,60 +316,75 @@ boolean OCI_DescriptorArrayAlloc if (OCI_SUCCESSFUL(ret)) { - OCI_MUTEXED_CALL(OCILib.nb_descp += nb_elem) + MUTEXED_CALL(Env.nb_descp += nb_elem) + SET_SUCCESS() } - return OCI_SUCCESSFUL(ret); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DescriptorFree + * MemoryFreeDescriptor * --------------------------------------------------------------------------------------------- */ -boolean OCI_DescriptorFree +boolean MemoryFreeDescriptor ( dvoid *descp, - ub4 type + ub4 type ) { - sword ret = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - if (descp) - { - OCI_MUTEXED_CALL(OCILib.nb_descp--) + CHECK_NULL(descp) + + const sword ret = OCIDescriptorFree(descp, type); - ret = OCIDescriptorFree(descp, type); + if (OCI_SUCCESSFUL(ret)) + { + MUTEXED_CALL(Env.nb_descp--) + SET_SUCCESS() } - return OCI_SUCCESSFUL(ret); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_DescriptorFree + * MemoryFreeDescriptor * --------------------------------------------------------------------------------------------- */ -boolean OCI_DescriptorArrayFree +boolean MemoryFreeDescriptorArray ( - dvoid **descp, - ub4 type, - ub4 nb_elem + dvoid **descp, + ub4 type, + ub4 nb_elem ) { - sword ret = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_NULL(descp) + + sword ret = OCI_ERROR; if (descp) { - #if OCI_VERSION_COMPILE >= OCI_11_1 +#if OCI_VERSION_COMPILE >= OCI_11_1 - if (OCILib.version_runtime >= OCI_11_1) + if (Env.version_runtime >= OCI_11_1) { ret = OCIArrayDescriptorFree(descp, type); - } else - #endif +#endif { for (ub4 i = 0; (i < nb_elem) && (OCI_SUCCESS == ret); i++) @@ -334,18 +392,22 @@ boolean OCI_DescriptorArrayFree ret = OCIDescriptorFree(descp[i], type); } } + } - OCI_MUTEXED_CALL(OCILib.nb_descp -= nb_elem) + if (OCI_SUCCESSFUL(ret)) + { + MUTEXED_CALL(Env.nb_descp -= nb_elem) + SET_SUCCESS() } - return OCI_SUCCESSFUL(ret); + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectNew + * MemoryAllocateObject * --------------------------------------------------------------------------------------------- */ -sword OCI_ObjectNew +boolean MemoryAllocateObject ( OCIEnv *env, OCIError *err, @@ -358,21 +420,32 @@ sword OCI_ObjectNew dvoid **instance ) { - const sword ret = OCIObjectNew(env, err, svc, typecode, tdo, table, duration, value, instance); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - if (OCI_SUCCESSFUL(ret)) - { - OCI_MUTEXED_CALL(OCILib.nb_objinst++) - } + CHECK_OCI + ( + err, + OCIObjectNew, + env, err, svc, typecode, tdo, table, + duration, value, instance + ) + + SET_SUCCESS() + + MUTEXED_CALL(Env.nb_objinst++) - return ret; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_OCIObjectFree + * MemoryFreeObject * --------------------------------------------------------------------------------------------- */ -sword OCI_OCIObjectFree +boolean MemoryFreeObject ( OCIEnv *env, OCIError *err, @@ -380,54 +453,64 @@ sword OCI_OCIObjectFree ub2 flags ) { - sword ret = OCI_SUCCESS; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - if (instance) - { - OCI_MUTEXED_CALL(OCILib.nb_objinst--) + CHECK_PTR(OCI_IPC_VOID, instance) - ret = OCIObjectFree(env, err, instance, flags); - } + CHECK_OCI + ( + err, + OCIObjectFree, + env, err, instance, flags + ) + + SET_SUCCESS() - return ret; + MUTEXED_CALL(Env.nb_objinst--) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_MemAllocOracleClient +* MemoryAllocOracleCallback * --------------------------------------------------------------------------------------------- */ -void * OCI_MemAllocOracleClient +void * MemoryAllocOracleCallback ( - void *ctxp, + void *ctxp, size_t size ) { OCI_NOT_USED(ctxp) - - return OCI_MemAlloc(OCI_IPC_ORACLE, size, 1, FALSE); + + return MemoryAlloc(OCI_IPC_ORACLE, size, 1, FALSE); } /* --------------------------------------------------------------------------------------------- * -* OCI_MemReallocOracleClient +* MemoryReallocOracleCallback * --------------------------------------------------------------------------------------------- */ -void * OCI_MemReallocOracleClient +void * MemoryReallocOracleCallback ( - void *ctxp, - void *memptr, + void *ctxp, + void *memptr, size_t newsize ) { OCI_NOT_USED(ctxp) - - return OCI_MemRealloc(memptr, OCI_IPC_ORACLE, newsize, 1, FALSE); + + return MemoryRealloc(memptr, OCI_IPC_ORACLE, newsize, 1, FALSE); } /* --------------------------------------------------------------------------------------------- * -* OCI_MemFreeOracleClient +* MemoryFreeOracleCallback * --------------------------------------------------------------------------------------------- */ -void OCI_MemFreeOracleClient +void MemoryFreeOracleCallback ( void *ctxp, void *memptr @@ -435,5 +518,5 @@ void OCI_MemFreeOracleClient { OCI_NOT_USED(ctxp) - OCI_MemFree(memptr); + MemoryFree(memptr); } diff --git a/src/memory.h b/src/memory.h new file mode 100644 index 00000000..500c7cd8 --- /dev/null +++ b/src/memory.h @@ -0,0 +1,129 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_MEMORY_H_INCLUDED +#define OCILIB_MEMORY_H_INCLUDED + +#include "types.h" + +void * MemoryAlloc +( + int ptr_type, + size_t block_size, + size_t block_count, + boolean zero_fill +); + +void * MemoryRealloc +( + void * ptr_mem, + int ptr_type, + size_t block_size, + size_t block_count, + boolean zero_fill +); + +void MemoryFree +( + void * ptr_mem +); + +boolean MemoryAllocHandle +( + CONST dvoid *parenth, + dvoid **hndlpp, + ub4 type +); + +boolean MemoryFreeHandle +( + dvoid* hndlp, + ub4 type +); + +boolean MemoryAllocDescriptor +( + CONST dvoid *parenth, + dvoid **descpp, + ub4 type +); + +boolean MemoryAllocDescriptorArray +( + CONST dvoid *parenth, + dvoid **descpp, + ub4 type, + ub4 nb_elem +); + +boolean MemoryFreeDescriptor +( + dvoid *descp, + ub4 type +); + +boolean MemoryFreeDescriptorArray +( + dvoid **descp, + ub4 type, + ub4 nb_elem +); + +sword MemoryAllocateObject +( + OCIEnv *env, + OCIError *err, + CONST OCISvcCtx *svc, + OCITypeCode typecode, + OCIType *tdo, + dvoid *table, + OCIDuration duration, + boolean value, + dvoid **instance +); + +sword MemoryFreeObject +( + OCIEnv * env, + OCIError* err, + dvoid * instance, + ub2 flags +); + +void * MemoryAllocOracleCallback +( + void *ctxp, + size_t size +); + +void * MemoryReallocOracleCallback +( + void *ctxp, + void *memptr, + size_t newsize +); + +void MemoryFreeOracleCallback +( + void *ctxp, + void *memptr +); + +#endif /* OCILIB_MEMORY_H_INCLUDED */ diff --git a/src/message.c b/src/message.c new file mode 100644 index 00000000..ab9175de --- /dev/null +++ b/src/message.c @@ -0,0 +1,1012 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "message.h" + +#include "agent.h" +#include "date.h" +#include "macros.h" +#include "memory.h" +#include "object.h" +#include "strings.h" + +/* --------------------------------------------------------------------------------------------- * + * MessageCreate + * --------------------------------------------------------------------------------------------- */ + +OCI_Msg * MessageCreate +( + OCI_TypeInfo *typinf +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Msg*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) + + OCI_Msg* msg = NULL; + + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + + /* allocate message structure */ + + ALLOC_DATA(OCI_IPC_MSG, msg, 1) + + msg->typinf = typinf; + msg->ind = OCI_IND_NULL; + + /* allocate message properties descriptor */ + + CHECK + ( + MemoryAllocDescriptor + ( + (dvoid *)msg->typinf->con->env, + (dvoid **)&msg->proph, + OCI_DTYPE_AQMSG_PROPERTIES + ) + ) + + /* allocate internal OCI_Object handle if payload is not RAW */ + + if (OCI_UNKNOWN != msg->typinf->typecode) + { + msg->obj = ObjectCreate(typinf->con, typinf); + CHECK_NULL(msg->obj) + } + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + MessageFree(msg); + msg = NULL; + } + + SET_RETVAL(msg) + ) +} + +/* --------------------------------------------------------------------------------------------- * + * MessageFree + * --------------------------------------------------------------------------------------------- */ + +boolean MessageFree +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + /* free local OCI_Agent object */ + + if (NULL != msg->sender) + { + AgentFree(msg->sender); + } + + /* free internal OCI_Object handle if payload is not RAW */ + + if (NULL != msg->obj) + { + msg->obj->hstate = OCI_OBJECT_ALLOCATED; + + ObjectFree(msg->obj); + + msg->obj = NULL; + } + + /* free message RAW payload if necessary */ + + if (NULL != msg->id && (OCI_UNKNOWN == msg->typinf->typecode)) + { + CHECK_OCI + ( + msg->typinf->con->err, + OCIRawResize, + msg->typinf->con->env, msg->typinf->con->err, 0, + (OCIRaw **) &msg->payload + ) + } + + /* free message ID */ + + if (NULL != msg->id) + { + CHECK_OCI + ( + msg->typinf->con->err, + OCIRawResize, + msg->typinf->con->env, msg->typinf->con->err, + 0, (OCIRaw **) &msg->id + ) + } + + msg->id = NULL; + + /* free OCI descriptor */ + + MemoryFreeDescriptor((dvoid*)msg->proph, OCI_DTYPE_AQMSG_PROPERTIES); + + FREE(msg) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageReset + * --------------------------------------------------------------------------------------------- */ + +boolean MessageReset +( + OCI_Msg *msg +) +{ + const unsigned int len = 0; + + boolean res = + ( + MessageSetExpiration(msg, -1) && + MessageSetEnqueueDelay(msg, 0) && + MessageSetPriority(msg,0) && + MessageSetOriginalID(msg, NULL, len) && + MessageSetSender(msg, NULL) && + MessageSetConsumers(msg, NULL, len) && + MessageSetCorrelation(msg, NULL) && + MessageSetExceptionQueue(msg, NULL) + ); + + if (res) + { + if (OCI_UNKNOWN == msg->typinf->typecode) + { + res = MessageSetRaw(msg, NULL, len); + } + else + { + res = MessageSetObject(msg, NULL); + } + } + + return res; +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetObject + * --------------------------------------------------------------------------------------------- */ + +OCI_Object * MessageGetObject +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Object*, NULL, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + CHECK_COMPAT(msg->typinf->typecode != OCI_UNKNOWN) + + CHECK(OCI_IND_NULL != msg->ind) + + SET_RETVAL((OCI_Object *) msg->obj) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetObject + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetObject +( + OCI_Msg *msg, + OCI_Object *obj +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + CHECK_COMPAT(msg->typinf->typecode != OCI_UNKNOWN) + + if (NULL != obj) + { + /* assign the given object to the message internal object */ + + CHECK(ObjectAssign((OCI_Object *) msg->obj, obj)) + + msg->ind = OCI_IND_NOTNULL; + } + else + { + msg->ind = OCI_IND_NULL; + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetRaw + * --------------------------------------------------------------------------------------------- */ + +boolean MessageGetRaw +( + OCI_Msg *msg, + void *raw, + unsigned int *size +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + CHECK_PTR(OCI_IPC_VOID, raw) + CHECK_PTR(OCI_IPC_VOID, size) + CHECK_COMPAT(OCI_UNKNOWN == msg->typinf->typecode) + + if ((msg->payload) && (OCI_IND_NULL != msg->ind)) + { + const unsigned int raw_size = OCIRawSize(msg->typinf->con->env, (OCIRaw *) msg->payload); + + if (*size > raw_size) + { + *size = raw_size; + } + + memcpy(raw, OCIRawPtr(msg->typinf->con->env, msg->payload), (size_t) (*size)); + } + else + { + *size = 0; + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetRaw + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetRaw +( + OCI_Msg *msg, + const void *raw, + unsigned int size +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_OCI + ( + msg->typinf->con->err, + OCIRawAssignBytes, + msg->typinf->con->env, msg->typinf->con->err, + (ub1*) raw, (ub4) size, (OCIRaw **) &msg->payload + ) + + if (NULL != msg->payload && (size > 0)) + { + msg->ind = OCI_IND_NOTNULL; + } + else + { + msg->ind = OCI_IND_NULL; + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetAttemptCount + * --------------------------------------------------------------------------------------------- */ + +int MessageGetAttemptCount +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 value = 0; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ATTEMPTS, + msg->proph, &value, NULL, + msg->typinf->con->err + ) + + SET_RETVAL(value) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetEnqueueDelay + * --------------------------------------------------------------------------------------------- */ + +int MessageGetEnqueueDelay +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 value = 0; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_DELAY, + msg->proph, &value, NULL, + msg->typinf->con->err + ) + + SET_RETVAL(value) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetEnqueueDelay + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetEnqueueDelay +( + OCI_Msg *msg, + int value +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 sval = (sb4) value; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_DELAY, + msg->proph, &sval, sizeof(sval), + msg->typinf->con->err + ) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetEnqueueTime + * --------------------------------------------------------------------------------------------- */ + +OCI_Date * MessageGetEnqueueTime +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Date*, NULL, + /* context */ OCI_IPC_MSG, msg + ) + + OCIDate date; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ENQ_TIME, + msg->proph, &date, NULL, + msg->typinf->con->err + ) + + msg->date = DateInitialize(msg->typinf->con, msg->date, &date, FALSE, FALSE); + CHECK_NULL(msg->date) + + SET_RETVAL(msg->date) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetExpiration + * --------------------------------------------------------------------------------------------- */ + +int MessageGetExpiration +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 value = 0; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_EXPIRATION, + msg->proph, &value, NULL, + msg->typinf->con->err + ) + + SET_RETVAL(value) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetExpiration + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetExpiration +( + OCI_Msg *msg, + int value +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 sval = (sb4) value; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_EXPIRATION, + msg->proph, &sval, sizeof(sval), + msg->typinf->con->err + ) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetState + * --------------------------------------------------------------------------------------------- */ + +unsigned int MessageGetState +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ unsigned int, OCI_UNKNOWN, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 value = 0; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_MSG_STATE, + msg->proph, &value, NULL, + msg->typinf->con->err + ) + + /* increment value to handle return code OCI_UNKNOWN on failure */ + + SET_RETVAL(++value) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetPriority + * --------------------------------------------------------------------------------------------- */ + +int MessageGetPriority +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 value = 0; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_PRIORITY, + msg->proph, &value, NULL, + msg->typinf->con->err + ) + + SET_RETVAL(value) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetPriority + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetPriority +( + OCI_Msg *msg, + int value +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + sb4 sval = (sb4) value; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_PRIORITY, + msg->proph, &sval, sizeof(sval), + msg->typinf->con->err + ) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetID + * --------------------------------------------------------------------------------------------- */ + +boolean MessageGetID +( + OCI_Msg *msg, + void *id, + unsigned int *len +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + CHECK_PTR(OCI_IPC_VOID, id) + CHECK_PTR(OCI_IPC_VOID, len) + + if (msg->id) + { + const ub4 raw_len = OCIRawSize(msg->typinf->con->env, msg->id); + + if (*len > raw_len) + { + *len = raw_len; + } + + memcpy(id, OCIRawPtr(msg->typinf->con->env, msg->id), (size_t) (*len)); + } + else + { + *len = 0; + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetOriginalID + * --------------------------------------------------------------------------------------------- */ + +boolean MessageGetOriginalID +( + OCI_Msg *msg, + void *id, + unsigned int *len +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + OCIRaw *value = NULL; + + CHECK_PTR(OCI_IPC_MSG, msg) + CHECK_PTR(OCI_IPC_VOID, id) + CHECK_PTR(OCI_IPC_VOID, len) + + *len = 0; + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ORIGINAL_MSGID, + msg->proph, &value, NULL, + msg->typinf->con->err + ) + + if (NULL != value) + { + const ub4 raw_len = OCIRawSize(msg->typinf->con->env, value); + + if (*len > raw_len) + { + *len = raw_len; + } + + memcpy(id, OCIRawPtr(msg->typinf->con->env, value), (size_t) (*len)); + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetOriginalID + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetOriginalID +( + OCI_Msg *msg, + const void *id, + unsigned int len +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + OCIRaw *value = NULL; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_OCI + ( + msg->typinf->con->err, + OCIRawAssignBytes, + msg->typinf->con->env, msg->typinf->con->err, + (ub1*) id, (ub4) len, (OCIRaw **) &value + ) + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ORIGINAL_MSGID, + msg->proph, &value, 0, + msg->typinf->con->err + ) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetCorrelation + * --------------------------------------------------------------------------------------------- */ + +const otext * MessageGetCorrelation +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + if (!msg->correlation) + { + unsigned int size = 0; + + CHECK(StringGetAttribute(msg->typinf->con, + msg->proph, + OCI_DTYPE_AQMSG_PROPERTIES, + OCI_ATTR_CORRELATION, + &msg->correlation, + &size)) + } + + SET_RETVAL(msg->correlation) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetCorrelation + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetCorrelation +( + OCI_Msg *msg, + const otext *correlation +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK(StringSetAttribute(msg->typinf->con, + msg->proph, + OCI_DTYPE_AQMSG_PROPERTIES, + OCI_ATTR_CORRELATION, + &msg->correlation, + correlation)) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetExceptionQueue + * --------------------------------------------------------------------------------------------- */ + +const otext * MessageGetExceptionQueue +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + if (!msg->except_queue) + { + unsigned int size = 0; + + CHECK(StringGetAttribute(msg->typinf->con, + msg->proph, + OCI_DTYPE_AQMSG_PROPERTIES, + OCI_ATTR_EXCEPTION_QUEUE, + &msg->except_queue, + &size)) + } + + SET_RETVAL(msg->except_queue) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetExceptionQueue + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetExceptionQueue +( + OCI_Msg *msg, + const otext *queue +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK(StringSetAttribute(msg->typinf->con, + msg->proph, + OCI_DTYPE_AQMSG_PROPERTIES, + OCI_ATTR_EXCEPTION_QUEUE, + &msg->except_queue, + queue)) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageGetSender + * --------------------------------------------------------------------------------------------- */ + +OCI_Agent * MessageGetSender +( + OCI_Msg *msg +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Agent*, NULL, + /* context */ OCI_IPC_MSG, msg + ) + + OCIAQAgent *handle = NULL; + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_SENDER_ID, + msg->proph, &handle, NULL, + msg->typinf->con->err + ) + + if (NULL != handle) + { + msg->sender = AgentInitialize(msg->typinf->con, msg->sender, handle, NULL, NULL); + CHECK_NULL(msg->sender) + } + + SET_RETVAL(msg->sender) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetSender + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetSender +( + OCI_Msg *msg, + OCI_Agent *sender +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + CHECK_PTR(OCI_IPC_MSG, msg) + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_SENDER_ID, + msg->proph, (sender ? sender->handle : NULL), 0, + msg->typinf->con->err + ) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * MessageSetConsumers + * --------------------------------------------------------------------------------------------- */ + +boolean MessageSetConsumers +( + OCI_Msg *msg, + OCI_Agent **consumers, + unsigned int count +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MSG, msg + ) + + OCIAQAgent **handles = NULL; + + CHECK_PTR(OCI_IPC_MSG, msg) + + /* allocate local array of OCIAQAgent handles if needed */ + + if (NULL != consumers && (count > 0)) + { + ALLOC_DATA(OCI_IPC_ARRAY, handles, count) + + for(unsigned int i = 0; i < count; i++) + { + handles[i] = consumers[i]->handle; + } + } + else + { + count = 0; + } + + CHECK_ATTRIB_SET + ( + OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_RECIPIENT_LIST, + msg->proph, handles, count, + msg->typinf->con->err + ) + + /* free local array of OCIAQAgent handles if needed */ + + if (NULL != handles) + { + FREE(handles) + } + + SET_SUCCESS() + + EXIT_FUNC() +} diff --git a/src/message.h b/src/message.h new file mode 100644 index 00000000..3f8702cd --- /dev/null +++ b/src/message.h @@ -0,0 +1,175 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_MSG_H_INCLUDED +#define OCILIB_MSG_H_INCLUDED + +#include "types.h" + +OCI_Msg* MessageCreate +( + OCI_TypeInfo* typinf +); + +boolean MessageFree +( + OCI_Msg* msg +); + +boolean MessageReset +( + OCI_Msg* msg +); + +OCI_Object* MessageGetObject +( + OCI_Msg* msg +); + +boolean MessageSetObject +( + OCI_Msg * msg, + OCI_Object* obj +); + +boolean MessageGetRaw +( + OCI_Msg * msg, + void * raw, + unsigned int* size +); + +boolean MessageSetRaw +( + OCI_Msg * msg, + const void * raw, + unsigned int size +); + +int MessageGetAttemptCount +( + OCI_Msg* msg +); + +int MessageGetEnqueueDelay +( + OCI_Msg* msg +); + +boolean MessageSetEnqueueDelay +( + OCI_Msg* msg, + int value +); + +OCI_Date* MessageGetEnqueueTime +( + OCI_Msg* msg +); + +int MessageGetExpiration +( + OCI_Msg* msg +); + +boolean MessageSetExpiration +( + OCI_Msg* msg, + int value +); + +unsigned int MessageGetState +( + OCI_Msg* msg +); + +int MessageGetPriority +( + OCI_Msg* msg +); + +boolean MessageSetPriority +( + OCI_Msg* msg, + int value +); + +boolean MessageGetID +( + OCI_Msg * msg, + void * id, + unsigned int* len +); + +boolean MessageGetOriginalID +( + OCI_Msg * msg, + void * id, + unsigned int* len +); + +boolean MessageSetOriginalID +( + OCI_Msg * msg, + const void * id, + unsigned int len +); + +const otext* MessageGetCorrelation +( + OCI_Msg* msg +); + +boolean MessageSetCorrelation +( + OCI_Msg * msg, + const otext* correlation +); + +const otext* MessageGetExceptionQueue +( + OCI_Msg* msg +); + +boolean MessageSetExceptionQueue +( + OCI_Msg * msg, + const otext* queue +); + +OCI_Agent* MessageGetSender +( + OCI_Msg* msg +); + +boolean MessageSetSender +( + OCI_Msg * msg, + OCI_Agent* sender +); + +boolean MessageSetConsumers +( + OCI_Msg * msg, + OCI_Agent ** consumers, + unsigned int count +); + +#endif /* OCILIB_MSG_H_INCLUDED */ diff --git a/src/msg.c b/src/msg.c deleted file mode 100644 index 4a34ace7..00000000 --- a/src/msg.c +++ /dev/null @@ -1,830 +0,0 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgCreate - * --------------------------------------------------------------------------------------------- */ - -OCI_Msg * OCI_API OCI_MsgCreate -( - OCI_TypeInfo *typinf -) -{ - OCI_Msg *msg = NULL; - - OCI_CALL_ENTER(OCI_Msg*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) - - /* allocate message structure */ - - OCI_ALLOCATE_DATA(OCI_IPC_MSG, msg, 1) - - if (OCI_STATUS) - { - msg->typinf = typinf; - msg->ind = OCI_IND_NULL; - - /* allocate message properties descriptor */ - - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)msg->typinf->con->env, (dvoid **)&msg->proph, OCI_DTYPE_AQMSG_PROPERTIES); - - if (OCI_STATUS) - { - /* allocate internal OCI_Object handle if payload is not RAW */ - - if (OCI_UNKNOWN != msg->typinf->typecode) - { - msg->obj = OCI_ObjectCreate(typinf->con, typinf); - - OCI_STATUS = (NULL != msg->obj); - } - } - } - - /* check for failure */ - - if (OCI_STATUS) - { - OCI_RETVAL = msg; - } - else if (msg) - { - OCI_MsgFree(msg); - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgFree - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgFree -( - OCI_Msg *msg -) -{ - OCI_CALL_ENTER(boolean, TRUE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - /* free local OCI_Agent object */ - - if (msg->sender) - { - OCI_AgentFree(msg->sender); - } - - /* free internal OCI_Object handle if payload is not RAW */ - - if (msg->obj) - { - msg->obj->hstate = OCI_OBJECT_ALLOCATED; - - OCI_ObjectFree(msg->obj); - - msg->obj = NULL; - } - - /* free message RAW payload if necessary */ - - if (msg->id && (OCI_UNKNOWN == msg->typinf->typecode)) - { - OCI_EXEC(OCIRawResize(msg->typinf->con->env, msg->typinf->con->err, 0, (OCIRaw **) &msg->payload)) - } - - /* free message ID */ - - if (msg->id) - { - - OCI_EXEC(OCIRawResize(msg->typinf->con->env, msg->typinf->con->err, 0, (OCIRaw **) &msg->id)) - } - - msg->id = NULL; - - /* free OCI descriptor */ - - OCI_DescriptorFree((dvoid *) msg->proph, OCI_DTYPE_AQMSG_PROPERTIES); - - OCI_FREE(msg) - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgReset - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgReset -( - OCI_Msg *msg -) -{ - const unsigned int len = 0; - - boolean res = - ( - OCI_MsgSetExpiration(msg, -1) && - OCI_MsgSetEnqueueDelay(msg, 0) && - OCI_MsgSetPriority(msg,0) && - OCI_MsgSetOriginalID(msg, NULL, len) && - OCI_MsgSetSender(msg, NULL) && - OCI_MsgSetConsumers(msg, NULL, len) && - OCI_MsgSetCorrelation(msg, NULL) && - OCI_MsgSetExceptionQueue(msg, NULL) - ); - - if (res) - { - if (OCI_UNKNOWN == msg->typinf->typecode) - { - res = OCI_MsgSetRaw(msg, NULL, len); - } - else - { - res = OCI_MsgSetObject(msg, NULL); - } - } - - return res; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetObject - * --------------------------------------------------------------------------------------------- */ - -OCI_Object * OCI_API OCI_MsgGetObject -( - OCI_Msg *msg -) -{ - OCI_CALL_ENTER(OCI_Object *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CHECK_COMPAT(msg->typinf->con, msg->typinf->typecode != OCI_UNKNOWN) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - if (OCI_IND_NULL != msg->ind) - { - OCI_RETVAL = (OCI_Object *) msg->obj; - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetObject - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetObject -( - OCI_Msg *msg, - OCI_Object *obj -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CHECK_COMPAT(msg->typinf->con, msg->typinf->typecode != OCI_UNKNOWN) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - if (obj) - { - /* assign the given object to the message internal object */ - - OCI_STATUS = OCI_ObjectAssign((OCI_Object *) msg->obj, obj); - - if (OCI_STATUS) - { - msg->ind = OCI_IND_NOTNULL; - } - } - else - { - OCI_STATUS = TRUE; - msg->ind = OCI_IND_NULL; - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetRaw - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgGetRaw -( - OCI_Msg *msg, - void *raw, - unsigned int *size -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, raw) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, size) - OCI_CALL_CHECK_COMPAT(msg->typinf->con, OCI_UNKNOWN == msg->typinf->typecode) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - if ((msg->payload) && (OCI_IND_NULL != msg->ind)) - { - const unsigned int raw_size = OCIRawSize(msg->typinf->con->env, (OCIRaw *) msg->payload); - - if (*size > raw_size) - { - *size = raw_size; - } - - memcpy(raw, OCIRawPtr(msg->typinf->con->env, msg->payload), (size_t) (*size)); - } - else - { - *size = 0; - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetRaw - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetRaw -( - OCI_Msg *msg, - const void *raw, - unsigned int size -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_EXEC(OCIRawAssignBytes(msg->typinf->con->env, msg->typinf->con->err, (ub1*) raw, (ub4) size, (OCIRaw **) &msg->payload)) - - if (OCI_STATUS && msg->payload && (size > 0)) - { - msg->ind = OCI_IND_NOTNULL; - } - else - { - msg->ind = OCI_IND_NULL; - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetAttemptCount - * --------------------------------------------------------------------------------------------- */ - -int OCI_API OCI_MsgGetAttemptCount -( - OCI_Msg *msg -) -{ - sb4 value = 0; - - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ATTEMPTS, msg->proph, &value, NULL) - - OCI_RETVAL = value; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetEnqueueDelay - * --------------------------------------------------------------------------------------------- */ - -int OCI_API OCI_MsgGetEnqueueDelay -( - OCI_Msg *msg -) -{ - sb4 value = 0; - - OCI_CALL_ENTER(int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_DELAY, msg->proph, &value, NULL) - - OCI_RETVAL = value; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetEnqueueDelay - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetEnqueueDelay -( - OCI_Msg *msg, - int value -) -{ - sb4 sval = (sb4) value; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_SET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_DELAY, msg->proph, &sval, sizeof(sval)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetEnqueueTime - * --------------------------------------------------------------------------------------------- */ - -OCI_Date * OCI_API OCI_MsgGetEnqueueTime -( - OCI_Msg *msg -) -{ - OCIDate date; - - OCI_CALL_ENTER(OCI_Date*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ENQ_TIME, msg->proph, &date, NULL) - - if (OCI_STATUS) - { - OCI_RETVAL = msg->date = OCI_DateInit(msg->typinf->con, msg->date, &date, FALSE, FALSE); - OCI_STATUS = (NULL != OCI_RETVAL); - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetExpiration - * --------------------------------------------------------------------------------------------- */ - -int OCI_API OCI_MsgGetExpiration -( - OCI_Msg *msg -) -{ - sb4 value = 0; - - OCI_CALL_ENTER(int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_EXPIRATION, msg->proph, &value, NULL) - - OCI_RETVAL = value; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetExpiration - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetExpiration -( - OCI_Msg *msg, - int value -) -{ - sb4 sval = (sb4) value; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_SET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_EXPIRATION, msg->proph, &sval, sizeof(sval)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetState - * --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_API OCI_MsgGetState -( - OCI_Msg *msg -) -{ - sb4 value = 0; - - OCI_CALL_ENTER(unsigned int, OCI_UNKNOWN) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_MSG_STATE, msg->proph, &value, NULL) - - /* increment value to handle return code OCI_UNKNOWN on failure */ - - if (OCI_STATUS) - { - OCI_RETVAL = ++value; - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetPriority - * --------------------------------------------------------------------------------------------- */ - -int OCI_API OCI_MsgGetPriority -( - OCI_Msg *msg -) -{ - sb4 value = 0; - - OCI_CALL_ENTER(int, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_PRIORITY, msg->proph, &value, NULL) - - OCI_RETVAL = value; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetPriority - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetPriority -( - OCI_Msg *msg, - int value -) -{ - sb4 sval = (sb4) value; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_SET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_PRIORITY, msg->proph, &sval, sizeof(sval)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetID - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgGetID -( - OCI_Msg *msg, - void *id, - unsigned int *len -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, id) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, len) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - if (msg->id) - { - const ub4 raw_len = OCIRawSize(msg->typinf->con->env, msg->id); - - if (*len > raw_len) - { - *len = raw_len; - } - - memcpy(id, OCIRawPtr(msg->typinf->con->env, msg->id), (size_t) (*len)); - } - else - { - *len = 0; - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetOriginalID - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgGetOriginalID -( - OCI_Msg *msg, - void *id, - unsigned int *len -) -{ - OCIRaw *value = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, id) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, len) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - *len = 0; - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ORIGINAL_MSGID, msg->proph, &value, NULL) - - if (OCI_STATUS && value) - { - const ub4 raw_len = OCIRawSize(msg->typinf->con->env, value); - - if (*len > raw_len) - { - *len = raw_len; - } - - memcpy(id, OCIRawPtr(msg->typinf->con->env, value), (size_t) (*len)); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetOriginalID - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetOriginalID -( - OCI_Msg *msg, - const void *id, - unsigned int len -) -{ - OCIRaw *value = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_EXEC(OCIRawAssignBytes(msg->typinf->con->env, msg->typinf->con->err, (ub1*) id, (ub4) len, (OCIRaw **) &value)) - OCI_SET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_ORIGINAL_MSGID, msg->proph, &value, 0) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetCorrelation - * --------------------------------------------------------------------------------------------- */ - -const otext * OCI_API OCI_MsgGetCorrelation -( - OCI_Msg *msg -) -{ - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - if (!msg->correlation) - { - unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute(msg->typinf->con, - msg->proph, - OCI_DTYPE_AQMSG_PROPERTIES, - OCI_ATTR_CORRELATION, - &msg->correlation, - &size); - } - - OCI_RETVAL = msg->correlation; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetCorrelation - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetCorrelation -( - OCI_Msg *msg, - const otext *correlation -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_STATUS = OCI_SetStringAttribute(msg->typinf->con, - msg->proph, - OCI_DTYPE_AQMSG_PROPERTIES, - OCI_ATTR_CORRELATION, - &msg->correlation, - correlation); - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetExceptionQueue - * --------------------------------------------------------------------------------------------- */ - -const otext * OCI_API OCI_MsgGetExceptionQueue -( - OCI_Msg *msg -) -{ - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - if (!msg->except_queue) - { - unsigned int size = 0; - - OCI_STATUS = OCI_GetStringAttribute - ( - msg->typinf->con, - msg->proph, - OCI_DTYPE_AQMSG_PROPERTIES, - OCI_ATTR_EXCEPTION_QUEUE, - &msg->except_queue, - &size - ); - } - - OCI_RETVAL = msg->except_queue; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetExceptionQueue - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetExceptionQueue -( - OCI_Msg *msg, - const otext *queue -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_STATUS = OCI_SetStringAttribute(msg->typinf->con, - msg->proph, - OCI_DTYPE_AQMSG_PROPERTIES, - OCI_ATTR_EXCEPTION_QUEUE, - &msg->except_queue, - queue); - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgGetSender - * --------------------------------------------------------------------------------------------- */ - -OCI_Agent * OCI_API OCI_MsgGetSender -( - OCI_Msg *msg -) -{ - OCIAQAgent *handle = NULL; - - OCI_CALL_ENTER(OCI_Agent *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_GET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_SENDER_ID, msg->proph, &handle, NULL) - - if (OCI_STATUS && handle) - { - OCI_RETVAL = msg->sender = OCI_AgentInit(msg->typinf->con, msg->sender, handle, NULL, NULL); - OCI_STATUS = (NULL != OCI_RETVAL); - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetSender - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetSender -( - OCI_Msg *msg, - OCI_Agent *sender -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - OCI_SET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_SENDER_ID, msg->proph, (sender ? sender->handle : NULL), 0) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_MsgSetConsumers - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_MsgSetConsumers -( - OCI_Msg *msg, - OCI_Agent **consumers, - unsigned int count -) -{ - OCIAQAgent **handles = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MSG, msg) - OCI_CALL_CONTEXT_SET_FROM_CONN(msg->typinf->con) - - /* allocate local array of OCIAQAgent handles if needed */ - - if (consumers && (count > 0)) - { - OCI_ALLOCATE_DATA(OCI_IPC_ARRAY, handles, count) - - if (OCI_STATUS) - { - for(unsigned int i = 0; i < count; i++) - { - handles[i] = consumers[i]->handle; - } - } - } - else - { - count = 0; - } - - OCI_SET_ATTRIB(OCI_DTYPE_AQMSG_PROPERTIES, OCI_ATTR_RECIPIENT_LIST, msg->proph, handles, count) - - /* free local array of OCIAQAgent handles if needed */ - - if (handles) - { - OCI_FREE(handles) - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} diff --git a/src/mutex.c b/src/mutex.c index 4705dc35..55c87473 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -18,143 +18,179 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "mutex.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "macros.h" +#include "memory.h" /* --------------------------------------------------------------------------------------------- * - * OCI_MutexCreateInternal - * --------------------------------------------------------------------------------------------- */ + * MutexCreateInternal + * --------------------------------------------------------------------------------------------- */ -OCI_Mutex * OCI_MutexCreateInternal +OCI_Mutex * MutexCreateInternal ( void ) { - OCI_Mutex *mutex = NULL; - - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ OCI_Mutex*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) /* allocate mutex structure */ - OCI_ALLOCATE_DATA(OCI_IPC_MUTEX, mutex, 1) + OCI_Mutex *mutex = NULL; - if (OCI_STATUS) - { - /* allocate error handle */ + ALLOC_DATA(OCI_IPC_MUTEX, mutex, 1) - OCI_STATUS = OCI_HandleAlloc(OCILib.env, (dvoid **)(void *)&mutex->err, OCI_HTYPE_ERROR); + /* allocate error handle */ - /* allocate mutex handle */ + CHECK(MemoryAllocHandle(Env.env, (dvoid **)(void *)&mutex->err, OCI_HTYPE_ERROR)) - OCI_EXEC(OCIThreadMutexInit(OCILib.env, mutex->err, &mutex->handle)) - } + /* allocate mutex handle */ - if (!OCI_STATUS && mutex) - { - OCI_MutexFree(mutex); - mutex = NULL; - } + CHECK_OCI + ( + mutex->err, + OCIThreadMutexInit, + Env.env, mutex->err, + &mutex->handle + ) - return mutex; -} + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + MutexFree(mutex); + mutex = NULL; + } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + SET_RETVAL(mutex) + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_MutexCreate + * MutexCreate * --------------------------------------------------------------------------------------------- */ -OCI_Mutex * OCI_API OCI_MutexCreate +OCI_Mutex * MutexCreate ( void ) { - OCI_CALL_ENTER(OCI_Mutex*, NULL) - OCI_CALL_CHECK_INITIALIZED() + ENTER_FUNC + ( + /* returns */ OCI_Mutex*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_RETVAL = OCI_MutexCreateInternal(); - OCI_STATUS = (NULL != OCI_RETVAL); + CHECK_INITIALIZED() - OCI_CALL_EXIT() + SET_RETVAL(MutexCreateInternal()) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_MutexFree + * MutexFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_MutexFree +boolean MutexFree ( OCI_Mutex *mutex ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MUTEX, mutex) - OCI_CALL_CONTEXT_SET_FROM_ERR(mutex->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MUTEX, mutex + ) + + CHECK_PTR(OCI_IPC_MUTEX, mutex) /* close mutex handle */ - if (mutex->handle) + if (NULL != mutex->handle) { - OCI_EXEC(OCIThreadMutexDestroy(OCILib.env, mutex->err, &mutex->handle)) + CHECK_OCI + ( + mutex->err, + OCIThreadMutexDestroy, + Env.env, mutex->err, &mutex->handle + ) } /* close error handle */ - if (mutex->err) + if (NULL != mutex->err) { - OCI_HandleFree(mutex->err, OCI_HTYPE_ERROR); + MemoryFreeHandle(mutex->err, OCI_HTYPE_ERROR); } /* free mutex structure */ - OCI_FREE(mutex) + FREE(mutex) - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_MutexAcquire + * MutexAcquire * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_MutexAcquire +boolean MutexAcquire ( OCI_Mutex *mutex ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MUTEX, mutex) - OCI_CALL_CONTEXT_SET_FROM_ERR(mutex->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MUTEX, mutex + ) + + CHECK_PTR(OCI_IPC_MUTEX, mutex) - OCI_EXEC(OCIThreadMutexAcquire(OCILib.env, mutex->err, mutex->handle)) + CHECK_OCI + ( + mutex->err, + OCIThreadMutexAcquire, + Env.env, mutex->err, mutex->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_MutexRelease + * MutexRelease * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_MutexRelease +boolean MutexRelease ( OCI_Mutex *mutex ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_MUTEX, mutex) - OCI_CALL_CONTEXT_SET_FROM_ERR(mutex->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_MUTEX, mutex + ) + + CHECK_PTR(OCI_IPC_MUTEX, mutex) + + CHECK_OCI + ( + mutex->err, + OCIThreadMutexRelease, + Env.env, mutex->err, mutex->handle + ) - OCI_EXEC(OCIThreadMutexRelease(OCILib.env, mutex->err, mutex->handle)) - - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/mutex.h b/src/mutex.h new file mode 100644 index 00000000..0e7af1a5 --- /dev/null +++ b/src/mutex.h @@ -0,0 +1,51 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_MUTEX_H_INCLUDED +#define OCILIB_MUTEX_H_INCLUDED + +#include "types.h" + +OCI_Mutex* MutexCreateInternal +( + void +); + +OCI_Mutex * MutexCreate +( + void +); + +boolean MutexFree +( + OCI_Mutex *mutex +); + +boolean MutexAcquire +( + OCI_Mutex *mutex +); + +boolean MutexRelease +( + OCI_Mutex *mutex +); + +#endif /* OCILIB_MUTEX_H_INCLUDED */ diff --git a/src/number.c b/src/number.c index 3a993c05..a0fa0c31 100644 --- a/src/number.c +++ b/src/number.c @@ -18,11 +18,12 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "number.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "array.h" +#include "environment.h" +#include "macros.h" +#include "strings.h" typedef struct MagicNumber { @@ -32,35 +33,35 @@ typedef struct MagicNumber static const MagicNumber MagicNumbers[] = { - { { 2, 255, 101 }, OTEXT("~") }, - { { 1, 0, 0 }, OTEXT("-~") } + { { 2, 255, 101 }, OTEXT("~") }, + { { 1, 0, 0 }, OTEXT("-~") } }; -#define OCI_MAGIC_NUMBER_COUNT 2 - - -#define OCI_NUMBER_OPERATION(func) \ - \ - OCINumber src_num = { {0} }; \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) \ - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) \ - \ - OCI_STATUS = OCI_TranslateNumericValue(number->con, value, type, \ - &src_num, OCI_NUM_NUMBER); \ - \ - OCI_EXEC(func(number->err, number->handle, &src_num, number->handle)) \ - \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() \ +#define MAGIC_NUMBER_COUNT 2 + +#define NUMBER_OPERATION(func) \ + \ + ENTER_FUNC(boolean, FALSE, OCI_IPC_NUMBER, number) \ + \ + OCINumber src_num = { {0} }; \ + CHECK_PTR(OCI_IPC_NUMBER, number) \ + \ + CHECK(NumberTranslateValue(number->con, value, type, \ + &src_num, OCI_NUM_NUMBER)) \ + \ + CHECK_OCI(number->err, func, number->err, number->handle, \ + &src_num, number->handle) \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() \ /* --------------------------------------------------------------------------------------------- * -* OCI_GetNumericTypeSize +* GetNumericTypeSize * --------------------------------------------------------------------------------------------- */ -uword OCI_GetNumericTypeSize +uword GetNumericTypeSize ( unsigned int type ) @@ -91,14 +92,15 @@ uword OCI_GetNumericTypeSize { size = sizeof(OCINumber); } + return size; } /* --------------------------------------------------------------------------------------------- * - * OCI_TranslateNumericValue + * NumberTranslateValue * --------------------------------------------------------------------------------------------- */ -boolean OCI_TranslateNumericValue +boolean NumberTranslateValue ( OCI_Connection *con, void *in_value, @@ -107,26 +109,30 @@ boolean OCI_TranslateNumericValue uword out_type ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + /* translate numeric values: - signed/unsigned integers (short, int, big_int) to double, float and OCINumber - double, float to signed/unsigned integers and OCINumber - OCINumber to signed/unsigned integers, double, and float */ - const uword in_size = OCI_GetNumericTypeSize(in_type); - const uword out_size = OCI_GetNumericTypeSize(out_type); + const uword in_size = GetNumericTypeSize(in_type); + const uword out_size = GetNumericTypeSize(out_type); const uword in_sign = (in_type & OCI_NUM_UNSIGNED) ? OCI_NUMBER_UNSIGNED : OCI_NUMBER_SIGNED; const uword out_sign = (out_type & OCI_NUM_UNSIGNED) ? OCI_NUMBER_UNSIGNED : OCI_NUMBER_SIGNED; OCINumber tmp; memset(&tmp, 0, sizeof(tmp)); - OCI_CALL_DECLARE_CONTEXT(TRUE) + OCIError* err = con ? con->err : Env.err; - OCI_CHECK(NULL == in_value, FALSE) - OCI_CHECK(NULL == out_value, FALSE) - - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_VOID, in_value) + CHECK_PTR(OCI_IPC_VOID, out_value) if (in_type == out_type) { @@ -141,13 +147,25 @@ boolean OCI_TranslateNumericValue { /* OCINumber to double / float */ - OCI_EXEC(OCINumberToReal(ctx->oci_err, in_value, out_size, out_value)) + CHECK_OCI + ( + err, + OCINumberToReal, + err, in_value, + out_size, out_value + ) } else { /* OCINumber to integers */ - OCI_EXEC(OCINumberToInt(ctx->oci_err, in_value, out_size, out_sign, out_value)) + CHECK_OCI + ( + err, + OCINumberToInt, + err, in_value, out_size, + out_sign, out_value + ) } } else if (in_type & OCI_NUM_DOUBLE || in_type & OCI_NUM_FLOAT) @@ -156,15 +174,21 @@ boolean OCI_TranslateNumericValue { /* double / float to OCINumber */ - OCI_EXEC(OCINumberFromReal(ctx->oci_err, in_value, in_size, (OCINumber *)out_value)) + CHECK_OCI + ( + err, + OCINumberFromReal, + err, in_value, in_size, + (OCINumber *)out_value + ) } - else if (out_type & OCI_NUM_DOUBLE || out_type & OCI_NUM_FLOAT) + else if (out_type & OCI_NUM_DOUBLE || out_type & OCI_NUM_FLOAT) { /* double to float and float to double */ - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCILib.version_runtime >= OCI_10_1) + if (Env.version_runtime >= OCI_10_1) { if (in_type & OCI_NUM_FLOAT && (out_type & OCI_NUM_DOUBLE)) { @@ -176,21 +200,39 @@ boolean OCI_TranslateNumericValue } } - #endif +#endif } else { /* double / float to integers */ - OCI_EXEC(OCINumberFromReal(ctx->oci_err, in_value, in_size, (OCINumber *)&tmp)) - OCI_EXEC(OCINumberToInt(ctx->oci_err, &tmp, out_size, out_sign, out_value)) + CHECK_OCI + ( + err, + OCINumberFromReal, + err, in_value, in_size, + (OCINumber *)&tmp + ) + + CHECK_OCI + ( + err, + OCINumberToInt, + err, &tmp, out_size, + out_sign, out_value + ) } } else { - OCI_EXEC(OCINumberFromInt(ctx->oci_err, in_value, in_size, in_sign, (OCINumber *)&tmp)) - + CHECK_OCI + ( + err, OCINumberFromInt, + err, in_value, in_size, + in_sign, (OCINumber *)&tmp + ) + if (out_type == OCI_NUM_NUMBER) { /* integers to OCINumber */ @@ -201,24 +243,37 @@ boolean OCI_TranslateNumericValue { /* integers to double / float */ - OCI_EXEC(OCINumberToReal(ctx->oci_err, &tmp, out_size, out_value)) + CHECK_OCI + ( + err, OCINumberToReal, + err, &tmp, + out_size, out_value + ) } else - { + { /* only for conversions between integers with different sizes or sign */ - OCI_EXEC(OCINumberToInt(ctx->oci_err, &tmp, out_size, out_sign, out_value)) + CHECK_OCI + ( + err, + OCINumberToInt, + err, &tmp, out_size, + out_sign, out_value + ) } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberFromString + * NumberFromStringInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_NumberFromString +boolean NumberFromStringInternal ( OCI_Connection *con, void *out_value, @@ -227,14 +282,24 @@ boolean OCI_NumberFromString const otext * fmt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + boolean done = FALSE; - OCI_CALL_DECLARE_CONTEXT(TRUE) + OCIError *err = con ? con->err : Env.err; - OCI_CHECK(NULL == out_value, FALSE) - OCI_CHECK(NULL == in_value, FALSE) + dbtext* dbstr1 = NULL; + dbtext* dbstr2 = NULL; - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + int dbsize1 = -1; + int dbsize2 = -1; + + CHECK_PTR(OCI_IPC_VOID, in_value) + CHECK_PTR(OCI_IPC_VOID, out_value) /* For binary types, perform a C based conversion */ @@ -242,39 +307,40 @@ boolean OCI_NumberFromString { if (type & OCI_NUM_SHORT) { - OCI_STATUS = (osscanf(in_value, OCI_STRING_FORMAT_NUM_SHORT, (short *)out_value) == 1); + CHECK(osscanf(in_value, OCI_STRING_FORMAT_NUM_SHORT, (short *)out_value) == 1) done = TRUE; } else if (type & OCI_NUM_INT) { - OCI_STATUS = (osscanf(in_value, OCI_STRING_FORMAT_NUM_INT, (int *)out_value) == 1); + CHECK(osscanf(in_value, OCI_STRING_FORMAT_NUM_INT, (int *)out_value) == 1) done = TRUE; } - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 - if (!done && OCILib.version_runtime >= OCI_10_1) + if (!done && Env.version_runtime >= OCI_10_1) { const otext *tmp_fmt = fmt; - if (!tmp_fmt) + if (NULL == tmp_fmt) { - tmp_fmt = OCI_GetFormat(con, type & OCI_NUM_DOUBLE ? OCI_FMT_BINARY_DOUBLE : OCI_FMT_BINARY_FLOAT); + tmp_fmt = EnvironmentGetFormat(con, type & OCI_NUM_DOUBLE ? OCI_FMT_BINARY_DOUBLE : OCI_FMT_BINARY_FLOAT); + CHECK_NULL(tmp_fmt) } if (type & OCI_NUM_DOUBLE) { - OCI_STATUS = (osscanf(in_value, tmp_fmt, (double *)out_value) == 1); + CHECK(osscanf(in_value, tmp_fmt, (double *)out_value) == 1) done = TRUE; } else if (type & OCI_NUM_FLOAT) { - OCI_STATUS = (osscanf(in_value, tmp_fmt, (float *)out_value) == 1); + CHECK(osscanf(in_value, tmp_fmt, (float *)out_value) == 1) done = TRUE; } } - #endif +#endif } @@ -282,7 +348,7 @@ boolean OCI_NumberFromString if (!done) { - for (int i = 0; i < OCI_MAGIC_NUMBER_COUNT; i++) + for (int i = 0; i < MAGIC_NUMBER_COUNT; i++) { const MagicNumber *mag_num = &MagicNumbers[i]; @@ -290,50 +356,52 @@ boolean OCI_NumberFromString { memset(out_value, 0, sizeof(OCINumber)); memcpy(out_value, mag_num->number, mag_num->number[0] + 1); - OCI_STATUS = done = TRUE; + done = TRUE; break; } } if (!done) { - dbtext *dbstr1 = NULL; - dbtext *dbstr2 = NULL; - int dbsize1 = -1; - int dbsize2 = -1; OCINumber number; - if (!fmt) + if (NULL == fmt) { - fmt = OCI_GetFormat(con, OCI_FMT_NUMERIC); + fmt = EnvironmentGetFormat(con, OCI_FMT_NUMERIC); + CHECK_NULL(fmt) } - dbstr1 = OCI_StringGetOracleString(in_value, &dbsize1); - dbstr2 = OCI_StringGetOracleString(fmt, &dbsize2); + dbstr1 = StringGetDBString(in_value, &dbsize1); + dbstr2 = StringGetDBString(fmt, &dbsize2); memset(&number, 0, sizeof(number)); - OCI_EXEC + CHECK_OCI ( - OCINumberFromText(ctx->oci_err, (oratext *) dbstr1, (ub4) dbsize1, (oratext *) dbstr2, - (ub4) dbsize2, (oratext *) NULL, (ub4) 0, (OCINumber *) &number) + err, + OCINumberFromText, + err, (oratext *) dbstr1, (ub4) dbsize1, (oratext *) dbstr2, + (ub4) dbsize2, (oratext *) NULL, (ub4) 0, (OCINumber *) &number ) - OCI_StringReleaseOracleString(dbstr2); - OCI_StringReleaseOracleString(dbstr1); - - OCI_STATUS = OCI_STATUS && OCI_TranslateNumericValue(con, &number, OCI_NUM_NUMBER, out_value, type); + CHECK(NumberTranslateValue(con, &number, OCI_NUM_NUMBER, out_value, type)) } } - return OCI_STATUS; + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberToString + * NumberToStringInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_NumberToString +boolean NumberToStringInternal ( OCI_Connection *con, void *number, @@ -343,14 +411,23 @@ boolean OCI_NumberToString const otext * fmt ) { - boolean done = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + dbtext* dbstr1 = NULL; + dbtext* dbstr2 = NULL; + int dbsize1 = out_value_size * (int)sizeof(otext); + int dbsize2 = -1; - OCI_CALL_DECLARE_CONTEXT(TRUE) + OCIError* err = con ? con->err : Env.err; - OCI_CHECK(NULL == out_value, FALSE) - OCI_CHECK(NULL == number, FALSE) + boolean done = FALSE; - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_VOID, out_value) + CHECK_PTR(OCI_IPC_VOID, number) out_value[0] = 0; @@ -360,34 +437,43 @@ boolean OCI_NumberToString { if (type & OCI_NUM_SHORT) { - out_value_size = osprintf(out_value, out_value_size, OCI_STRING_FORMAT_NUM_SHORT, *((short *)number)); + out_value_size = osprintf(out_value, out_value_size, + OCI_STRING_FORMAT_NUM_SHORT, + *((short *)number)); + done = TRUE; } else if (type & OCI_NUM_INT) { - out_value_size = osprintf(out_value, out_value_size, OCI_STRING_FORMAT_NUM_INT, *((int *)number)); + out_value_size = osprintf(out_value, out_value_size, + OCI_STRING_FORMAT_NUM_INT, + *((int *)number)); + done = TRUE; } - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 - if (!done && (OCILib.version_runtime >= OCI_10_1)) + if (!done && (Env.version_runtime >= OCI_10_1)) { const otext *tmp_fmt = fmt; - if (!tmp_fmt) + if (NULL == tmp_fmt) { - tmp_fmt = OCI_GetFormat(con, type & OCI_NUM_DOUBLE ? OCI_FMT_BINARY_DOUBLE : OCI_FMT_BINARY_FLOAT); + tmp_fmt = EnvironmentGetFormat(con, type & OCI_NUM_DOUBLE ? OCI_FMT_BINARY_DOUBLE : OCI_FMT_BINARY_FLOAT); + CHECK_NULL(tmp_fmt) } if (type & OCI_NUM_DOUBLE) { out_value_size = osprintf(out_value, out_value_size, tmp_fmt, *((double *)number)); + done = TRUE; } else if (type & OCI_NUM_FLOAT) { out_value_size = osprintf(out_value, out_value_size, tmp_fmt, *((float *)number)); + done = TRUE; } @@ -405,7 +491,7 @@ boolean OCI_NumberToString } } - #endif +#endif } @@ -413,43 +499,39 @@ boolean OCI_NumberToString if (!done) { - for (int i = 0; i < OCI_MAGIC_NUMBER_COUNT; i++) + for (int i = 0; i < MAGIC_NUMBER_COUNT; i++) { const MagicNumber *mag_num = &MagicNumbers[i]; if (memcmp(number, mag_num->number, mag_num->number[0] + 1) == 0) { ostrcpy(out_value, mag_num->name); - OCI_STATUS = done = TRUE; + done = TRUE; break; } } if (!done) { - dbtext *dbstr1 = NULL; - dbtext *dbstr2 = NULL; - int dbsize1 = out_value_size * (int) sizeof(otext); - int dbsize2 = -1; - - if (!fmt) + if (NULL == fmt) { - fmt = OCI_GetFormat(con, OCI_FMT_NUMERIC); + fmt = EnvironmentGetFormat(con, OCI_FMT_NUMERIC); + CHECK_NULL(fmt) } - dbstr1 = OCI_StringGetOracleString(out_value, &dbsize1); - dbstr2 = OCI_StringGetOracleString(fmt, &dbsize2); + dbstr1 = StringGetDBString(out_value, &dbsize1); + dbstr2 = StringGetDBString(fmt, &dbsize2); - OCI_EXEC + CHECK_OCI ( - OCINumberToText(ctx->oci_err, (OCINumber *)number, (oratext *)dbstr2, - (ub4)dbsize2, (oratext *)NULL, (ub4)0, - (ub4 *)&dbsize1, (oratext *)dbstr1) + err, + OCINumberToText, + err, (OCINumber *)number, (oratext *)dbstr2, + (ub4)dbsize2, (oratext *)NULL, (ub4)0, + (ub4 *)&dbsize1, (oratext *)dbstr1 ) - OCI_StringCopyOracleStringToNativeString(dbstr1, out_value, dbcharcount(dbsize1)); - OCI_StringReleaseOracleString(dbstr2); - OCI_StringReleaseOracleString(dbstr1); + StringCopyDBStringToNativeString(dbstr1, out_value, dbcharcount(dbsize1)); out_value_size = (dbsize1 / (int) sizeof(dbtext)); } @@ -466,184 +548,215 @@ boolean OCI_NumberToString } } - return OCI_STATUS; + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr2); + StringReleaseDBString(dbstr1); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberInit + * NumberInitialize * --------------------------------------------------------------------------------------------- */ -OCI_Number * OCI_NumberInit +OCI_Number * NumberInitialize ( - OCI_Connection *con, - OCI_Number *number, - OCINumber *buffer + OCI_Connection *con, + OCI_Number *number, + OCINumber *buffer ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Number*, number, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) - OCI_ALLOCATE_DATA(OCI_IPC_NUMBER, number, 1); + ALLOC_DATA(OCI_IPC_NUMBER, number, 1); - if (OCI_STATUS) - { - number->con = con; - number->handle = buffer; + number->con = con; + number->handle = buffer; - /* get the right error handle */ + /* get the right error handle */ - number->err = con ? con->err : OCILib.err; - number->env = con ? con->env : OCILib.env; + number->err = con ? con->err : Env.err; + number->env = con ? con->env : Env.env; - /* allocate buffer if needed */ + /* allocate buffer if needed */ - if (!number->handle || (OCI_OBJECT_ALLOCATED_ARRAY == number->hstate)) - { - if (OCI_OBJECT_ALLOCATED_ARRAY != number->hstate) - { - number->hstate = OCI_OBJECT_ALLOCATED; - OCI_ALLOCATE_DATA(OCI_IPC_ARRAY, number->handle, 1) - } - } - else + if (NULL == number->handle || (OCI_OBJECT_ALLOCATED_ARRAY == number->hstate)) + { + if (OCI_OBJECT_ALLOCATED_ARRAY != number->hstate) { - number->hstate = OCI_OBJECT_FETCHED_CLEAN; + number->hstate = OCI_OBJECT_ALLOCATED; + ALLOC_DATA(OCI_IPC_ARRAY, number->handle, 1) } } + else + { + number->hstate = OCI_OBJECT_FETCHED_CLEAN; + } /* check for failure */ - if (!OCI_STATUS && number) - { - OCI_NumberFree(number); - number = NULL; - } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + NumberFree(number); + number = NULL; + } - return number; + SET_RETVAL(number) + ) } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_NumberCreate + * NumberCreate * --------------------------------------------------------------------------------------------- */ -OCI_Number * OCI_API OCI_NumberCreate +OCI_Number * NumberCreate ( OCI_Connection *con ) { - OCI_CALL_ENTER(OCI_Number*, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Number*, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) - OCI_RETVAL = OCI_NumberInit(con, NULL, NULL); - OCI_STATUS = (NULL != OCI_RETVAL); + CHECK_INITIALIZED() - OCI_CALL_EXIT() + SET_RETVAL(NumberInitialize(con, NULL, NULL)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberAssign + * NumberAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberFree +boolean NumberFree ( OCI_Number *number ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CHECK_OBJECT_FETCHED(number); - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) + + CHECK_PTR(OCI_IPC_NUMBER, number) + CHECK_OBJECT_FETCHED(number); if (OCI_OBJECT_ALLOCATED == number->hstate) { - OCI_FREE(number->handle) + FREE(number->handle) } if (OCI_OBJECT_ALLOCATED_ARRAY != number->hstate) { - OCI_FREE(number) + FREE(number) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberArrayCreate + * NumberCreateArray * --------------------------------------------------------------------------------------------- */ -OCI_Number ** OCI_API OCI_NumberArrayCreate +OCI_Number ** NumberCreateArray ( OCI_Connection *con, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Number**, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Number **, NULL) - OCI_CALL_CHECK_INITIALIZED() + CHECK_INITIALIZED() - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_NUMERIC, OCI_NUM_NUMBER, sizeof(OCINumber), sizeof(OCI_Number), 0, NULL); - OCI_STATUS = (NULL != arr); + arr = ArrayCreate(con, nbelem, OCI_CDT_NUMERIC, OCI_NUM_NUMBER, + sizeof(OCINumber), sizeof(OCI_Number), 0, NULL); - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Number **)arr->tab_obj; - } + CHECK_NULL(arr) + + SET_RETVAL((OCI_Number**)arr->tab_obj) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberArrayFree + * NumberFreeArray * --------------------------------------------------------------------------------------------- */ -OCI_EXPORT boolean OCI_API OCI_NumberArrayFree +boolean NumberFreeArray ( - OCI_Number **numbmers + OCI_Number **nummers ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, numbmers) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)numbmers); + CHECK_PTR(OCI_IPC_ARRAY, nummers) - OCI_CALL_EXIT() + SET_RETVAL(ArrayFreeFromHandles((void**)nummers)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberAssign + * NumberAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberAssign +boolean NumberAssign ( OCI_Number *number, OCI_Number *number_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number_src) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) - - OCI_EXEC(OCINumberAssign(number->err, number_src->handle, number->handle)) - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) + + CHECK_PTR(OCI_IPC_NUMBER, number) + CHECK_PTR(OCI_IPC_NUMBER, number_src) + + CHECK_OCI + ( + number->err, + OCINumberAssign, + number->err, number_src->handle, + number->handle + ) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberToText + * NumberToString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberToText +boolean NumberToString ( OCI_Number *number, const otext *fmt, @@ -651,200 +764,234 @@ boolean OCI_API OCI_NumberToText otext *str ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) + + CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_RETVAL = OCI_NumberToString(number->con, number->handle, OCI_NUM_NUMBER, str, size, fmt); + SET_RETVAL(NumberToStringInternal(number->con, number->handle, + OCI_NUM_NUMBER, str, size, fmt)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberFromText + * NumberFromString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberFromText +boolean NumberFromString ( OCI_Number *number, const otext *str, const otext *fmt ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) + + CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_RETVAL = OCI_NumberFromString(number->con, number->handle, OCI_NUM_NUMBER, str, fmt); + SET_RETVAL(NumberFromStringInternal(number->con, number->handle, + OCI_NUM_NUMBER, str, fmt)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberGetContent + * NumberGetContent * --------------------------------------------------------------------------------------------- */ -unsigned char * OCI_API OCI_NumberGetContent +unsigned char * NumberGetContent ( OCI_Number *number ) { - OCI_CALL_ENTER(unsigned char *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ unsigned char*, NULL, + /* context */ OCI_IPC_NUMBER, number + ) - if (number->handle) - { - OCI_RETVAL = number->handle->OCINumberPart; - } + CHECK_PTR(OCI_IPC_NUMBER, number) + + CHECK_NULL(number->handle) - OCI_CALL_EXIT() + SET_RETVAL(number->handle->OCINumberPart) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberSetContent + * NumberSetContent * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberSetContent +boolean NumberSetContent ( - OCI_Number *number, - unsigned char *content + OCI_Number *number, + unsigned char *content ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, content) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) + + CHECK_PTR(OCI_IPC_NUMBER, number) + CHECK_PTR(OCI_IPC_VOID, content) - if (number->handle) + if (NULL != number->handle) { memcpy(number->handle->OCINumberPart, content, sizeof(number->handle->OCINumberPart)); } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberSetValue + * NumberSetValue * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberSetValue +boolean NumberSetValue ( - OCI_Number *number, - unsigned int type, - void *value + OCI_Number *number, + unsigned int type, + void *value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) - OCI_RETVAL = OCI_STATUS = OCI_TranslateNumericValue(number->con, value, type, number->handle, OCI_NUM_NUMBER); + CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_EXIT() + SET_RETVAL(NumberTranslateValue(number->con, value, type, + number->handle, OCI_NUM_NUMBER)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberGetValue + * NumberGetValue * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberGetValue +boolean NumberGetValue ( - OCI_Number *number, - unsigned int type, - void *value + OCI_Number *number, + unsigned int type, + void *value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_CALL_CONTEXT_SET_FROM_OBJ(number) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NUMBER, number + ) + + CHECK_PTR(OCI_IPC_NUMBER, number) - OCI_RETVAL = OCI_STATUS = OCI_TranslateNumericValue(number->con, number->handle, OCI_NUM_NUMBER, value, type); + SET_RETVAL(NumberTranslateValue(number->con, number->handle, + OCI_NUM_NUMBER, value, type)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberAdd + * NumberAdd * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberAdd +boolean NumberAdd ( - OCI_Number *number, - unsigned int type, - void *value + OCI_Number *number, + unsigned int type, + void *value ) { - OCI_NUMBER_OPERATION(OCINumberAdd) + NUMBER_OPERATION(OCINumberAdd) } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberSub + * NumberSub * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberSub +boolean NumberSub ( - OCI_Number *number, - unsigned int type, - void *value + OCI_Number *number, + unsigned int type, + void *value ) { - OCI_NUMBER_OPERATION(OCINumberSub) + NUMBER_OPERATION(OCINumberSub) } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberMultiply + * NumberMultiply * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberMultiply +boolean NumberMultiply ( - OCI_Number *number, - unsigned int type, - void *value + OCI_Number *number, + unsigned int type, + void *value ) { - OCI_NUMBER_OPERATION(OCINumberMul) + NUMBER_OPERATION(OCINumberMul) } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberDivide + * NumberDivide * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_NumberDivide +boolean NumberDivide ( - OCI_Number *number, - unsigned int type, - void *value + OCI_Number *number, + unsigned int type, + void *value ) { - OCI_NUMBER_OPERATION(OCINumberDiv) + NUMBER_OPERATION(OCINumberDiv) } /* --------------------------------------------------------------------------------------------- * - * OCI_NumberCompare + * NumberCompare * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_NumberCompare +int NumberCompare ( OCI_Number *number1, OCI_Number *number2 ) { + ENTER_FUNC + ( + /* returns */ int, OCI_ERROR, + /* context */ OCI_IPC_NUMBER, number1 + ) + sword value = OCI_ERROR; - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number1) - OCI_CALL_CHECK_PTR(OCI_IPC_NUMBER, number2) - OCI_CALL_CONTEXT_SET_FROM_CONN(number1->con) + CHECK_PTR(OCI_IPC_NUMBER, number1) + CHECK_PTR(OCI_IPC_NUMBER, number2) - OCI_EXEC(OCINumberCmp(number1->err, number1->handle, number2->handle, &value)) + CHECK_OCI + ( + number1->err, + OCINumberCmp, + number1->err, number1->handle, + number2->handle, &value + ) - OCI_RETVAL = (int) value; + SET_RETVAL((int) value) - OCI_CALL_EXIT() + EXIT_FUNC() } - - - diff --git a/src/number.h b/src/number.h new file mode 100644 index 00000000..44fd6170 --- /dev/null +++ b/src/number.h @@ -0,0 +1,162 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_NUMBER_H_INCLUDED +#define OCILIB_NUMBER_H_INCLUDED + +#include "types.h" + +boolean NumberTranslateValue +( + OCI_Connection* con, + void * in_value, + uword in_type, + void * out_value, + uword out_type +); + +OCI_Number* NumberInitialize +( + OCI_Connection* con, + OCI_Number * number, + OCINumber * buffer +); + +boolean NumberFromStringInternal +( + OCI_Connection* con, + void * out_value, + uword type, + const otext * in_value, + const otext * fmt +); + +boolean NumberToStringInternal +( + OCI_Connection* con, + void * number, + unsigned int type, + otext * out_value, + int out_value_size, + const otext * fmt +); + +OCI_Number* NumberCreate +( + OCI_Connection* con +); + +boolean NumberFree +( + OCI_Number* number +); + +OCI_Number** NumberCreateArray +( + OCI_Connection* con, + unsigned int nbelem +); + +boolean NumberFreeArray +( + OCI_Number** numbmers +); + +boolean NumberAssign +( + OCI_Number* number, + OCI_Number* number_src +); + +boolean NumberToString +( + OCI_Number * number, + const otext* fmt, + int size, + otext * str +); + +boolean NumberFromString +( + OCI_Number * number, + const otext* str, + const otext* fmt +); + +unsigned char* NumberGetContent +( + OCI_Number* number +); + +boolean NumberSetContent +( + OCI_Number * number, + unsigned char* content +); + +boolean NumberSetValue +( + OCI_Number * number, + unsigned int type, + void * value +); + +boolean NumberGetValue +( + OCI_Number * number, + unsigned int type, + void * value +); + +boolean NumberAdd +( + OCI_Number * number, + unsigned int type, + void * value +); + +boolean NumberSub +( + OCI_Number * number, + unsigned int type, + void * value +); + +boolean NumberMultiply +( + OCI_Number * number, + unsigned int type, + void * value +); + +boolean NumberDivide +( + OCI_Number * number, + unsigned int type, + void * value +); + +int NumberCompare +( + OCI_Number* number1, + OCI_Number* number2 +); + +#endif /* OCILIB_NUMBER_H_INCLUDED */ diff --git a/src/object.c b/src/object.c index 5b95a8a6..f625d66b 100644 --- a/src/object.c +++ b/src/object.c @@ -18,183 +18,276 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -#define OCI_OBJECT_SET_VALUE(datatype, type, func) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) \ - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) \ - \ - OCI_STATUS = FALSE; \ - \ - if (!value) \ - { \ - OCI_STATUS = OCI_ObjectSetNull(obj, attr); \ - } \ - else \ - { \ - int index = OCI_ObjectGetAttrIndex(obj, attr, datatype, TRUE); \ - \ - if (index >= 0) \ - { \ - OCIInd *ind = NULL; \ - type *data = (type *) OCI_ObjectGetAttr(obj, index, &ind); \ - \ - OCI_STATUS = TRUE; \ - \ - OCI_EXEC(func) \ - \ - if (OCI_STATUS) \ - { \ - *ind = OCI_IND_NOTNULL; \ - } \ - } \ - } \ - \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() - -#define OCI_OBJECT_GET_VALUE(datatype, object_type, type, func) \ - \ - int index = 0; \ - \ - OCI_CALL_ENTER(object_type, NULL) \ - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) \ - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) \ - \ - OCI_STATUS = FALSE; \ - \ - index = OCI_ObjectGetAttrIndex(obj, attr, datatype, TRUE); \ - if (index >= 0) \ - { \ - OCIInd *ind = NULL; \ - type *value = NULL; \ - \ - OCI_STATUS = TRUE; \ - \ - value = (type *) OCI_ObjectGetAttr(obj, index, &ind); \ - \ - if (value && ind && (OCI_IND_NULL != *ind)) \ - { \ - OCI_RETVAL = obj->objs[index] = func; \ - OCI_STATUS = (NULL != OCI_RETVAL); \ - } \ - } \ - \ - OCI_CALL_EXIT() - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -boolean OCI_ObjectGetAttrInfo -( - OCI_TypeInfo *typinf, - int index, - size_t *p_size, - size_t *p_align +#include "object.h" + +#include "array.h" +#include "collection.h" +#include "column.h" +#include "date.h" +#include "file.h" +#include "helpers.h" +#include "interval.h" +#include "list.h" +#include "lob.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "reference.h" +#include "strings.h" +#include "timestamp.h" +#include "typeinfo.h" + +#define OBJECT_SET_VALUE(datatype, type, func, ...) \ + \ + ENTER_FUNC(boolean, FALSE, OCI_IPC_OBJECT, obj) \ + \ + CHECK_PTR(OCI_IPC_OBJECT, obj) \ + \ + if (NULL == value) \ + { \ + CHECK(ObjectSetNull(obj, attr) ) \ + } \ + else \ + { \ + int index = ObjectGetAttributeIndex(obj, attr, datatype, TRUE); \ + \ + if (index >= 0) \ + { \ + OCIInd *ind = NULL; \ + type *data = (type *) ObjectGetAttr(obj, index, &ind); \ + \ + CHECK_OCI(obj->con->err, func, __VA_ARGS__) \ + \ + *ind = OCI_IND_NOTNULL; \ + } \ + } \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() + +#define OBJECT_GET_VALUE(datatype, object_type, type, func, ...) \ + \ + ENTER_FUNC(object_type, NULL, OCI_IPC_OBJECT, obj) \ + \ + int index = 0; \ + \ + CHECK_PTR(OCI_IPC_OBJECT, obj) \ + \ + index = ObjectGetAttributeIndex(obj, attr, datatype, TRUE); \ + CHECK(index >= 0) \ + \ + OCIInd *ind = NULL; \ + type *value = NULL; \ + \ + value = (type *) ObjectGetAttr(obj, index, &ind); \ + \ + object_type tmp = NULL; \ + \ + if (value && ind && (OCI_IND_NULL != *ind)) \ + { \ + tmp = obj->objs[index] = func(__VA_ARGS__); \ + CHECK_NULL(tmp) \ + } \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +#define OBJECT_GET_NUMBER(number_type, type, value) \ + \ + ENTER_FUNC(type, value, OCI_IPC_OBJECT, obj) \ + \ + CHECK_PTR(OCI_IPC_OBJECT, obj) \ + \ + type tmp = value; \ + \ + CHECK(ObjectGetNumberInternal(obj, attr, \ + (void *) (&tmp), \ + (uword) (number_type))); \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +#define OBJECT_SET_NUMBER(number_type, value) \ + \ + ENTER_FUNC(boolean, FALSE,OCI_IPC_OBJECT, obj) \ + \ + CHECK_PTR(OCI_IPC_OBJECT, obj) \ + \ + CHECK(ObjectSetNumberInternal(obj, attr, (void *) &(value), \ + (uword) (number_type))) \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() + +/* pre declaration */ + +boolean ObjectGetAttributeInfo +( + OCI_TypeInfo * typinf, + int index, + size_t * p_size, + size_t * p_align ); - /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetRealTypeInfo +/* --------------------------------------------------------------------------------------------- * + * TypeInfoFind * --------------------------------------------------------------------------------------------- */ -OCI_TypeInfo * OCI_ObjectGetRealTypeInfo(OCI_TypeInfo *typinf, void *object) +static boolean TypeInfoFind(OCI_TypeInfo * typinf, OCIType* tdo) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + return NULL != typinf && typinf->tdo == tdo; +} - OCI_TypeInfo *result = typinf; +/* --------------------------------------------------------------------------------------------- * + * ObjectGetRealTypeInfo + * --------------------------------------------------------------------------------------------- */ - if (!result) - { - return result; - } +OCI_TypeInfo * ObjectGetRealTypeInfo(OCI_TypeInfo *typinf, void *object) +{ + ENTER_FUNC + ( + /* returns */ OCI_TypeInfo*, typinf, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) - OCI_CALL_CONTEXT_SET_FROM_CONN(result->con) + OCIRef* ref = NULL; + OCIType * tdo = NULL; + OCIDescribe * descr = NULL; + OCI_TypeInfo* parent = NULL; - /* if the type is related to UTDs and is virtual (e.g. non final), we must find the real type of the instance */ + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - if (object && result->type == OCI_TIF_TYPE && !result->is_final) - { - OCIRef *ref = NULL; - OCIType *tdo = NULL; + CHECK_NULL(object) - /* create a local REF to store a REF to the object real type */ + /* nothing to do if the type is final */ + CHECK(typinf->type == OCI_TIF_TYPE && !typinf->is_final) - OCI_EXEC(OCI_ObjectNew(result->con->env, result->con->err, result->con->cxt, SQLT_REF, (OCIType *)0, NULL, OCI_DURATION_SESSION, 0, (void**)&ref)) - OCI_EXEC(OCIObjectGetTypeRef(result->con->env, result->con->err, (dvoid*)object, ref)) - OCI_EXEC(OCITypeByRef(result->con->env, result->con->err, ref, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, &tdo)) + /* if the type is related to UTDs and is virtual (e.g. non final), we must find the real type of + * the instance */ - /* the object instance type pointer is different only if the instance is from an inherited type */ + /* create a local REF to store a REF to the object real type */ - if (tdo && tdo != result->tdo) - { - /* first try to find it in list */ - const boolean found = OCI_ListExists(typinf->con->tinfs, tdo); + CHECK(MemoryAllocateObject(typinf->con->env, typinf->con->err, + typinf->con->cxt, SQLT_REF, (OCIType *)0, + NULL, OCI_DURATION_SESSION, 0, (void**)&ref)) - if (!found) - { - OCIDescribe *descr = NULL; - OCIParam *param = NULL; - otext *schema_name = NULL; - otext *object_name = NULL; + CHECK_OCI + ( + typinf->con->err, + OCIObjectGetTypeRef, + typinf->con->env, + typinf->con->err, + (dvoid*)object, ref + ) - unsigned int size_schema = 0; - unsigned int size_object = 0; + CHECK_OCI + ( + typinf->con->err, + OCITypeByRef, typinf->con->env, + typinf->con->err, ref, + OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, + &tdo + ) - otext fullname[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); + CHECK_NULL(tdo) - OCI_STATUS = OCI_HandleAlloc(result->con->env, (void**) &descr, OCI_HTYPE_DESCRIBE); + /* the object instance type pointer is different only if the instance is from an inherited type + * */ - OCI_EXEC(OCIDescribeAny(result->con->cxt, result->con->err, (dvoid *)tdo, 0, OCI_OTYPE_PTR, OCI_DEFAULT, OCI_PTYPE_UNK, descr)) - OCI_GET_ATTRIB(OCI_HTYPE_DESCRIBE, OCI_ATTR_PARAM, descr, ¶m, NULL) + CHECK(tdo != typinf->tdo) - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(result->con, param, OCI_DTYPE_PARAM, OCI_ATTR_SCHEMA_NAME, &schema_name, &size_schema); - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(result->con, param, OCI_DTYPE_PARAM, OCI_ATTR_NAME, &object_name, &size_object); + /* first try to find it in list */ - if (OCI_STATUS) - { - /* compute link full name */ + parent = ListFind(typinf->con->tinfs, (POCI_LIST_FIND)TypeInfoFind, tdo); - OCI_StringGetFullTypeName(schema_name, NULL, object_name, NULL, fullname, (sizeof(fullname) / sizeof(otext)) - 1); + /* if found, it will be assigned in the cleanup part */ - /* retrieve the type info of the real object */ + CHECK(parent == NULL) - result = OCI_TypeInfoGet(result->con, fullname, OCI_TIF_TYPE); - } + OCIParam *param = NULL; + otext *schema_name = NULL; + otext *object_name = NULL; - OCI_HandleFree(descr, OCI_HTYPE_DESCRIBE); - } - } + unsigned int size_schema = 0; + unsigned int size_object = 0; - /* free local REF */ + otext fullname[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); - OCI_OCIObjectFree(result->con->env, result->con->err, ref, OCI_DEFAULT); - } + CHECK(MemoryAllocHandle(typinf->con->env, (void**) &descr, OCI_HTYPE_DESCRIBE)) - return result; + CHECK_OCI + ( + typinf->con->err, + OCIDescribeAny, + typinf->con->cxt, typinf->con->err, + (dvoid *)tdo, 0, OCI_OTYPE_PTR, OCI_DEFAULT, + OCI_PTYPE_UNK, descr + ) + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DESCRIBE, OCI_ATTR_PARAM, + descr, ¶m, NULL, + typinf->con->err + ) + + CHECK(StringGetAttribute(typinf->con, param, OCI_DTYPE_PARAM, + OCI_ATTR_SCHEMA_NAME, &schema_name, &size_schema)) + + CHECK(StringGetAttribute(typinf->con, param, OCI_DTYPE_PARAM, + OCI_ATTR_NAME, &object_name, &size_object)) + + /* compute link full name */ + + StringGetFullTypeName(schema_name, NULL, object_name, NULL, + fullname, (sizeof(fullname) / sizeof(otext)) - 1); + + /* retrieve the type info of the real object */ + parent = TypeInfoGet(typinf->con, fullname, OCI_TIF_TYPE); + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != typinf) + { + if (NULL != ref) + { + MemoryFreeObject(typinf->con->env, typinf->con->err, ref, OCI_DEFAULT); + } + + if (NULL != descr) + { + MemoryFreeHandle(descr, OCI_HTYPE_DESCRIBE); + } + } + + SET_RETVAL( NULL != parent ? parent : typinf) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetIndicatorOffset + * ObjectGetIndicatorOffset * --------------------------------------------------------------------------------------------- */ -ub2 OCI_ObjectGetIndOffset +ub2 ObjectGetIndOffset ( OCI_TypeInfo *typinf, int index ) { - ub2 i = 0, j = 1; + int i = 0; + ub2 j = 1; - OCI_CHECK(typinf == NULL, 0); + CHECK_FALSE(typinf == NULL, 0); - for (i = 0; i < (int) index; i++) + for (i = 0; i < index; i++) { if (OCI_CDT_OBJECT == typinf->cols[i].datatype) { - j += OCI_ObjectGetIndOffset(typinf->cols[i].typinf, typinf->cols[i].typinf->nb_cols); + j += ObjectGetIndOffset(typinf->cols[i].typinf, typinf->cols[i].typinf->nb_cols); } else { @@ -207,17 +300,17 @@ ub2 OCI_ObjectGetIndOffset } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetStructSize + * ObjectGetStructSize * --------------------------------------------------------------------------------------------- */ -void OCI_ObjectGetStructSize +void ObjectGetStructSize ( OCI_TypeInfo *typinf, size_t *p_size, size_t *p_align ) { - if (!typinf || !p_size || !p_align) + if (NULL == typinf || NULL == p_size || NULL == p_align) { return; } @@ -237,8 +330,8 @@ void OCI_ObjectGetStructSize if (typinf->parent_type) { /* if super type information has not been already cached, then let's compute it now */ - - OCI_ObjectGetStructSize(typinf->parent_type, &size, &align); + + ObjectGetStructSize(typinf->parent_type, &size, &align); /* copy super type members offsets to the current sub type of members offsets */ @@ -248,22 +341,24 @@ void OCI_ObjectGetStructSize } /* adjust current member index to start to compute with the first of the derived type */ - + i = typinf->parent_type->nb_cols; - /* compute the first derived member in order to not touch to the next for loop code that is working :) */ - + /* compute the first derived member in order to not touch to the next for loop code that + * is working :) */ + if (i < typinf->nb_cols) { size_t next_align = 0; - /* set current alignment to the parent one as it is the first member of the current structure */ + /* set current alignment to the parent one as it is the first member of the current + * structure */ typinf->align = align; /* get current type self first member information (after parent type) */ - OCI_ObjectGetAttrInfo(typinf, i, &size2, &next_align); + ObjectGetAttributeInfo(typinf, i, &size2, &next_align); /* make sure that parent field is aligned */ @@ -281,12 +376,12 @@ void OCI_ObjectGetStructSize } else { - OCI_ObjectGetAttrInfo(typinf, i, &size1, &align); + ObjectGetAttributeInfo(typinf, i, &size1, &align); typinf->offsets[i] = 0; } - OCI_ObjectGetAttrInfo(typinf, i + 1, &size2, &align); + ObjectGetAttributeInfo(typinf, i + 1, &size2, &align); size += size1; @@ -301,14 +396,14 @@ void OCI_ObjectGetStructSize } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetUserStructSize + * ObjectGetUserStructSize * --------------------------------------------------------------------------------------------- */ -void OCI_ObjectGetUserStructSize +void ObjectGetUserStructSize ( - OCI_TypeInfo *typinf, - size_t *p_size, - size_t *p_align + OCI_TypeInfo* typinf, + size_t * p_size, + size_t * p_align ) { size_t size1 = 0; @@ -326,8 +421,8 @@ void OCI_ObjectGetUserStructSize for (ub2 i = 0; i < typinf->nb_cols; i++) { - OCI_ColumnGetAttrInfo(&typinf->cols[i], typinf->nb_cols, i, &size1, &align1); - OCI_ColumnGetAttrInfo(&typinf->cols[i+1], typinf->nb_cols, i+1, &size2, &align2); + ColumnGetAttributeInfo(&typinf->cols[i], typinf->nb_cols, i, &size1, &align1); + ColumnGetAttributeInfo(&typinf->cols[i+1], typinf->nb_cols, i+1, &size2, &align2); if (align < align1) { @@ -349,10 +444,10 @@ void OCI_ObjectGetUserStructSize } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetAttrInfo + * ObjectGetAttributeInfo * --------------------------------------------------------------------------------------------- */ -boolean OCI_ObjectGetAttrInfo +boolean ObjectGetAttributeInfo ( OCI_TypeInfo *typinf, int index, @@ -360,10 +455,9 @@ boolean OCI_ObjectGetAttrInfo size_t *p_align ) { - OCI_CHECK(typinf == NULL, 0); - OCI_CHECK(p_size == NULL, 0); - OCI_CHECK(p_align == NULL, 0); - + CHECK_FALSE(typinf == NULL, 0); + CHECK_FALSE(p_size == NULL, 0); + CHECK_FALSE(p_align == NULL, 0); if (index >= typinf->nb_cols) { @@ -419,7 +513,7 @@ boolean OCI_ObjectGetAttrInfo } case OCI_CDT_OBJECT: { - OCI_ObjectGetStructSize(typinf->cols[index].typinf, p_size, p_align); + ObjectGetStructSize(typinf->cols[index].typinf, p_size, p_align); break; } default: @@ -435,25 +529,23 @@ boolean OCI_ObjectGetAttrInfo typinf->align = *p_align; } - return TRUE; } - /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectReset + * ObjectReset * --------------------------------------------------------------------------------------------- */ -void OCI_ObjectReset +void ObjectReset ( OCI_Object *obj ) { - if (!obj) + if (NULL == obj) { return; } - + for (ub2 i = 0; i < obj->typinf->nb_cols; i++) { if (obj->objs[i]) @@ -465,22 +557,22 @@ void OCI_ObjectReset data->hstate = OCI_OBJECT_FETCHED_DIRTY; } - OCI_FreeObjectFromType(obj->objs[i], obj->typinf->cols[i].datatype); - + FreeObjectFromType(obj->objs[i], obj->typinf->cols[i].datatype); + obj->objs[i] = NULL; } - OCI_FREE(obj->tmpbufs[i]) + FREE(obj->tmpbufs[i]) obj->tmpsizes[i] = 0; } } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectInit + * ObjectInitialize * --------------------------------------------------------------------------------------------- */ -OCI_Object * OCI_ObjectInit +OCI_Object * ObjectInitialize ( OCI_Connection *con, OCI_Object *obj, @@ -491,115 +583,113 @@ OCI_Object * OCI_ObjectInit boolean reset ) { - OCI_TypeInfo *real_typinf = NULL; - - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ OCI_Object*, obj, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + OCI_TypeInfo* real_typinf = ObjectGetRealTypeInfo(typinf, handle); + CHECK_NULL(real_typinf) - real_typinf = OCI_ObjectGetRealTypeInfo(typinf, handle); - OCI_STATUS = (NULL != real_typinf); + ALLOC_DATA(OCI_IPC_OBJECT, obj, 1); - OCI_ALLOCATE_DATA(OCI_IPC_OBJECT, obj, 1); + obj->con = con; + obj->handle = handle; + obj->typinf = real_typinf; - if (OCI_STATUS) - { - obj->con = con; - obj->handle = handle; - obj->typinf = real_typinf; + if (real_typinf != typinf) + { + FREE(obj->objs) + FREE(obj->tmpbufs) + FREE(obj->tmpsizes) + } - if (real_typinf != typinf) - { - OCI_FREE(obj->objs) - OCI_FREE(obj->tmpbufs) - OCI_FREE(obj->tmpsizes) - } + ALLOC_DATA(OCI_IPC_BUFF_ARRAY, obj->tmpbufs, obj->typinf->nb_cols) + ALLOC_DATA(OCI_IPC_BUFF_ARRAY, obj->tmpsizes, obj->typinf->nb_cols) + ALLOC_DATA(OCI_IPC_BUFF_ARRAY, obj->objs, obj->typinf->nb_cols) - OCI_ALLOCATE_DATA(OCI_IPC_BUFF_ARRAY, obj->tmpbufs, obj->typinf->nb_cols) - OCI_ALLOCATE_DATA(OCI_IPC_BUFF_ARRAY, obj->tmpsizes, obj->typinf->nb_cols) - OCI_ALLOCATE_DATA(OCI_IPC_BUFF_ARRAY, obj->objs, obj->typinf->nb_cols) + ObjectReset(obj); - OCI_ObjectReset(obj); + if (NULL == obj->handle || OCI_OBJECT_ALLOCATED_ARRAY == obj->hstate) + { + /* allocates handle for non fetched object */ - if (OCI_STATUS && (!obj->handle || (OCI_OBJECT_ALLOCATED_ARRAY == obj->hstate))) + if (OCI_OBJECT_ALLOCATED_ARRAY != obj->hstate) { - /* allocates handle for non fetched object */ + obj->hstate = OCI_OBJECT_ALLOCATED; + } - if (OCI_OBJECT_ALLOCATED_ARRAY != obj->hstate) - { - obj->hstate = OCI_OBJECT_ALLOCATED; - } + CHECK(MemoryAllocateObject(obj->con->env, obj->con->err, obj->con->cxt, + (OCITypeCode)obj->typinf->typecode, obj->typinf->tdo, + (dvoid *) NULL, (OCIDuration) OCI_DURATION_SESSION, + (boolean) TRUE, (dvoid **) &obj->handle)) + } + else + { + obj->hstate = OCI_OBJECT_FETCHED_CLEAN; + } - OCI_EXEC - ( - OCI_ObjectNew(obj->con->env, obj->con->err, obj->con->cxt, - (OCITypeCode) obj->typinf->typecode, obj->typinf->tdo, (dvoid *) NULL, - (OCIDuration) OCI_DURATION_SESSION, (boolean) TRUE, - (dvoid **) &obj->handle) - ) + if (OCI_UNKNOWN == obj->type) + { + ub4 size = sizeof(obj->type); + + /* calling OCIObjectGetProperty() on objects that are attributes of + parent objects leads to a segmentation fault on MS Windows ! + We need to report that to Oracle! Because sub objects always are + values, if the parent indicator array is not null, let's assign + the object type properties ourselves */ + + if (NULL == parent) + { + OCIObjectGetProperty(obj->con->env, obj->con->err, + obj->handle, + (OCIObjectPropId) OCI_OBJECTPROP_LIFETIME, + (void *) &obj->type, &size); } else { - obj->hstate = OCI_OBJECT_FETCHED_CLEAN; + obj->type = OCI_OBJECT_VALUE; } + } - if (OCI_STATUS && (OCI_UNKNOWN == obj->type)) + if (reset || NULL == obj->tab_ind) + { + if (NULL == parent) { - ub4 size = sizeof(obj->type); - - /* calling OCIObjectGetProperty() on objects that are attributes of - parent objects leads to a segmentation fault on MS Windows ! - We need to report that to Oracle! Because sub objects always are - values, if the parent indicator array is not null, let's assign - the object type properties ourselves */ - - if (!parent) - { - OCIObjectGetProperty(obj->con->env, obj->con->err, obj->handle, - (OCIObjectPropId) OCI_OBJECTPROP_LIFETIME, - (void *) &obj->type, &size); - } - else - { - obj->type = OCI_OBJECT_VALUE; - } + CHECK_OCI + ( + obj->con->err, + OCIObjectGetInd, + obj->con->env, obj->con->err, + (dvoid *)obj->handle, + (dvoid **) &obj->tab_ind + ) } - - if (OCI_STATUS && (reset || !obj->tab_ind)) + else { - if (!parent) - { - OCI_EXEC - ( - OCIObjectGetInd(obj->con->env, obj->con->err, - (dvoid *) obj->handle, - (dvoid **) &obj->tab_ind) - ) - } - else - { - obj->tab_ind = parent->tab_ind; - obj->idx_ind = parent->idx_ind + OCI_ObjectGetIndOffset(parent->typinf, index); - } + obj->tab_ind = parent->tab_ind; + obj->idx_ind = parent->idx_ind + ObjectGetIndOffset(parent->typinf, index); } } - /* check for failure */ - - if (!OCI_STATUS && obj) - { - OCI_ObjectFree(obj); - obj = NULL; - } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ObjectFree(obj); + obj = NULL; + } - return obj; + SET_RETVAL(obj) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetAttrIndex + * ObjectGetAttributeIndex * --------------------------------------------------------------------------------------------- */ -int OCI_ObjectGetAttrIndex +int ObjectGetAttributeIndex ( OCI_Object *obj, const otext *attr, @@ -607,10 +697,16 @@ int OCI_ObjectGetAttrIndex boolean check ) { - int res = -1; + ENTER_FUNC + ( + /* returns */ int, -1, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_CHECK(obj == NULL, res) - OCI_CHECK(attr == NULL, res); + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) + + int index = -1; for (ub2 i = 0; i < obj->typinf->nb_cols; i++) { @@ -618,59 +714,69 @@ int OCI_ObjectGetAttrIndex if (((type == -1) || (col->datatype == type)) && (ostrcasecmp(col->name, attr) == 0)) { - res = (int) i; + index = (int) i; break; } } - if (check && res == -1) + if (check && index == -1) { - OCI_ExceptionAttributeNotFound(obj->con, attr); + THROW(ExceptionAttributeNotFound, attr) } - return res; + SET_RETVAL(index) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetAttr + * ObjectGetAttr * --------------------------------------------------------------------------------------------- */ -void * OCI_ObjectGetAttr +void * ObjectGetAttr ( OCI_Object *obj, unsigned int index, OCIInd **pind ) { + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_OBJECT, obj + ) + size_t offset = 0; - size_t size = 0; - size_t align = 0; + size_t size = 0; + size_t align = 0; - OCI_CHECK(obj == NULL, NULL) - OCI_CHECK(pind == NULL, NULL) + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_VOID, pind) if (obj->typinf->struct_size == 0) { - OCI_ObjectGetStructSize(obj->typinf, &size, &align); + ObjectGetStructSize(obj->typinf, &size, &align); } offset = (size_t) obj->typinf->offsets[index]; if (pind) { - const int ind_index = obj->idx_ind + OCI_ObjectGetIndOffset(obj->typinf, index); + const int ind_index = obj->idx_ind + ObjectGetIndOffset(obj->typinf, (int) index); *pind = &obj->tab_ind[ind_index]; } - return ((char *) obj->handle + offset); + SET_RETVAL(((char *) obj->handle + offset)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetNumberInternal + * ObjectSetNumberInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_ObjectSetNumberInternal +boolean ObjectSetNumberInternal ( OCI_Object *obj, const otext *attr, @@ -678,41 +784,42 @@ boolean OCI_ObjectSetNumberInternal uword flag ) { - int index = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + int index = 0; - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_NUMERIC, TRUE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_NUMERIC, TRUE); - if (index >= 0) + if (index == -1) { - OCIInd *ind = NULL; - void *num = OCI_ObjectGetAttr(obj, index, &ind); - OCI_Column *col = &obj->typinf->cols[index]; + THROW(ExceptionAttributeNotFound, attr) + } - OCI_STATUS = OCI_TranslateNumericValue(obj->con, value, flag, num, col->subtype); + OCIInd *ind = NULL; + void *num = ObjectGetAttr(obj, index, &ind); + OCI_Column *col = &obj->typinf->cols[index]; - if (OCI_STATUS) - { - *ind = OCI_IND_NOTNULL; - } - } + CHECK(NumberTranslateValue(obj->con, value, flag, num, col->subtype)) + + *ind = OCI_IND_NOTNULL; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetNumberInternal + * ObjectGetNumberInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_ObjectGetNumberInternal +boolean ObjectGetNumberInternal ( OCI_Object *obj, const otext *attr, @@ -720,447 +827,440 @@ boolean OCI_ObjectGetNumberInternal uword flag ) { - int index = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + int index = 0; - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_NUMERIC, FALSE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_NUMERIC, FALSE); if (index >= 0) { OCIInd *ind = NULL; void *ptr = NULL; - ptr = OCI_ObjectGetAttr(obj, index, &ind); + ptr = ObjectGetAttr(obj, index, &ind); if (ptr && (OCI_IND_NULL != *ind)) { OCI_Column *col = &obj->typinf->cols[index]; - OCI_STATUS = OCI_TranslateNumericValue(obj->con, ptr, col->subtype, value, flag); + CHECK(NumberTranslateValue(obj->con, ptr, col->subtype, value, flag)) } } else { - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_TEXT, FALSE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_TEXT, FALSE); if (index >= 0) { - OCI_STATUS = OCI_NumberFromString(obj->con, value, flag, OCI_ObjectGetString(obj, attr), NULL); + CHECK(NumberFromStringInternal(obj->con, value, flag, ObjectGetString(obj, attr), NULL)) } } if (index == -1) { - OCI_ExceptionAttributeNotFound(obj->con, attr); + THROW(ExceptionAttributeNotFound, attr) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectCreate + * ObjectCreate * --------------------------------------------------------------------------------------------- */ -OCI_Object * OCI_API OCI_ObjectCreate +OCI_Object * ObjectCreate ( OCI_Connection *con, OCI_TypeInfo *typinf ) { - OCI_CALL_ENTER(OCI_Object *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Object*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_RETVAL = OCI_ObjectInit(con, NULL, NULL, typinf, NULL, -1, TRUE); - OCI_STATUS = (NULL != OCI_RETVAL); + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_EXIT() + SET_RETVAL(ObjectInitialize(con, NULL, NULL, typinf, NULL, -1, TRUE)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectFree + * ObjectFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectFree +boolean ObjectFree ( OCI_Object *obj ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_OBJECT_FETCHED(obj) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_OBJECT_FETCHED(obj) /* if the object has sub-objects that have been fetched, we need to free these objects */ - OCI_ObjectReset(obj); + ObjectReset(obj); - OCI_FREE(obj->objs) - OCI_FREE(obj->tmpbufs) - OCI_FREE(obj->tmpsizes) + FREE(obj->objs) + FREE(obj->tmpbufs) + FREE(obj->tmpsizes) if ((OCI_OBJECT_ALLOCATED == obj->hstate) || (OCI_OBJECT_ALLOCATED_ARRAY == obj->hstate)) { - OCI_OCIObjectFree(obj->con->env, obj->con->err, obj->handle, OCI_DEFAULT); + MemoryFreeObject(obj->con->env, obj->con->err, obj->handle, OCI_DEFAULT); } if (OCI_OBJECT_ALLOCATED_ARRAY != obj->hstate) { - OCI_FREE(obj) + FREE(obj) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectArrayCreate + * ObjectCreateArray * --------------------------------------------------------------------------------------------- */ -OCI_Object ** OCI_API OCI_ObjectArrayCreate +OCI_Object ** ObjectCreateArray ( OCI_Connection *con, OCI_TypeInfo *typinf, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Object**, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Object **, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_OBJECT, 0, sizeof(void *), sizeof(OCI_Object), 0, typinf); - OCI_STATUS = (NULL != arr); + arr = ArrayCreate(con, nbelem, OCI_CDT_OBJECT, 0, + sizeof(void *), sizeof(OCI_Object), + 0, typinf); - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Object **) arr->tab_obj; - } + CHECK_NULL(arr) - OCI_CALL_EXIT() + SET_RETVAL((OCI_Object **) arr->tab_obj) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectArrayFree + * ObjectFreeArray * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectArrayFree +boolean ObjectFreeArray ( OCI_Object **objs ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, objs) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_PTR(OCI_IPC_ARRAY, objs) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)objs); + SET_RETVAL(ArrayFreeFromHandles((void **)objs)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectAssign + * ObjectAssign * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectAssign +boolean ObjectAssign ( OCI_Object *obj, OCI_Object *obj_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj_src); - OCI_CALL_CHECK_COMPAT(obj->con, obj->typinf->tdo == obj_src->typinf->tdo) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_OBJECT, obj_src); + CHECK_COMPAT(obj->typinf->tdo == obj_src->typinf->tdo) - OCI_EXEC + CHECK_OCI ( - OCIObjectCopy(obj->con->env, obj->con->err, obj->con->cxt, - obj_src->handle, (obj_src->tab_ind + obj_src->idx_ind), - obj->handle, (obj->tab_ind + obj->idx_ind), - obj->typinf->tdo, OCI_DURATION_SESSION, OCI_DEFAULT) + obj->con->err, + OCIObjectCopy, + obj->con->env, obj->con->err, obj->con->cxt, + obj_src->handle, (obj_src->tab_ind + obj_src->idx_ind), + obj->handle, (obj->tab_ind + obj->idx_ind), + obj->typinf->tdo, OCI_DURATION_SESSION, OCI_DEFAULT ) - if (OCI_STATUS) - { - obj->typinf = obj_src->typinf; + obj->typinf = obj_src->typinf; - OCI_ObjectReset(obj); - } + ObjectReset(obj); - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetShort + * ObjectGetShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectGetBoolean +boolean ObjectGetBoolean ( OCI_Object *obj, const otext *attr ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) int index = -1; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) - - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_BOOLEAN, TRUE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_BOOLEAN, TRUE); - if (index >= 0) + if (index < 0) { - OCIInd *ind = NULL; - boolean *value = NULL; + THROW(ExceptionAttributeNotFound, attr) + } - OCI_STATUS = TRUE; + OCIInd *ind = NULL; + void *ptr = NULL; - value = (boolean *)OCI_ObjectGetAttr(obj, index, &ind); + boolean value = FALSE; - if (value && ind && (OCI_IND_NULL != *ind)) - { - OCI_RETVAL = *value; - } + ptr = ObjectGetAttr(obj, index, &ind); + + if (NULL != ptr && ind && (OCI_IND_NULL != *ind)) + { + value = *((boolean *) ptr); } - OCI_CALL_EXIT() + SET_RETVAL(value) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetNumber + * ObjectGetNumber * --------------------------------------------------------------------------------------------- */ -OCI_Number * OCI_API OCI_ObjectGetNumber +OCI_Number * ObjectGetNumber ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_NUMERIC, OCI_Number*, OCINumber*, - OCI_NumberInit(obj->con, (OCI_Number *) obj->objs[index], (OCINumber *) value) + NumberInitialize, + obj->con, + (OCI_Number *) obj->objs[index], + (OCINumber *) value ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetShort + * ObjectGetShort * --------------------------------------------------------------------------------------------- */ -short OCI_API OCI_ObjectGetShort +short ObjectGetShort ( OCI_Object *obj, const otext *attr ) { - short value = 0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_SHORT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_SHORT, short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetUnsignedShort + * ObjectGetUnsignedShort * --------------------------------------------------------------------------------------------- */ -unsigned short OCI_API OCI_ObjectGetUnsignedShort +unsigned short ObjectGetUnsignedShort ( OCI_Object *obj, const otext *attr ) { - unsigned short value = 0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_USHORT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_USHORT, unsigned short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetInt + * ObjectGetInt * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ObjectGetInt +int ObjectGetInt ( OCI_Object *obj, const otext *attr ) { - int value = 0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_INT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_INT, int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetUnsignedInt + * ObjectGetUnsignedInt * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ObjectGetUnsignedInt +unsigned int ObjectGetUnsignedInt ( OCI_Object *obj, const otext *attr ) { - unsigned int value = 0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_UINT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_UINT, unsigned int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetBigInt + * ObjectGetBigInt * --------------------------------------------------------------------------------------------- */ -big_int OCI_API OCI_ObjectGetBigInt +big_int ObjectGetBigInt ( OCI_Object *obj, const otext *attr ) { - big_int value = 0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_BIGINT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_BIGINT, big_int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetUnsignedBigInt + * ObjectGetUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_ObjectGetUnsignedBigInt +big_uint ObjectGetUnsignedBigInt ( OCI_Object *obj, const otext *attr ) { - big_uint value = 0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_BIGUINT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_BIGUINT, big_uint, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetDouble + * ObjectGetDouble * --------------------------------------------------------------------------------------------- */ -double OCI_API OCI_ObjectGetDouble +double ObjectGetDouble ( OCI_Object *obj, const otext *attr ) { - double value = 0.0; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_DOUBLE); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_DOUBLE, double, 0.0) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetFloat + * ObjectGetFloat * --------------------------------------------------------------------------------------------- */ -float OCI_API OCI_ObjectGetFloat +float ObjectGetFloat ( OCI_Object *obj, const otext *attr ) { - float value = 0.0f; - - OCI_ObjectGetNumberInternal(obj, attr, &value, OCI_NUM_FLOAT); - - return value; + OBJECT_GET_NUMBER(OCI_NUM_FLOAT, float, 0.0f) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetString + * ObjectGetString * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_ObjectGetString +const otext * ObjectGetString ( OCI_Object *obj, const otext *attr ) { + ENTER_FUNC + ( + /* returns */ const otext *, NULL, + /* context */ OCI_IPC_OBJECT, obj + ) + int index = -1; - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + const otext* str = NULL; - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_TEXT, FALSE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_TEXT, FALSE); if (index >= 0) { - OCIInd *ind = NULL; + OCIInd *ind = NULL; OCIString **value = NULL; - OCI_STATUS = TRUE; - - value = (OCIString **) OCI_ObjectGetAttr(obj, index, &ind); + value = (OCIString **) ObjectGetAttr(obj, index, &ind); if (value && ind && (OCI_IND_NULL != *ind)) { - if (OCILib.use_wide_char_conv) + if (Env.use_wide_char_conv) { - OCI_RETVAL = OCI_StringFromStringPtr(obj->con->env, *value, &obj->tmpbufs[index], &obj->tmpsizes[index]); + str = StringFromStringPtr(obj->con->env, *value, &obj->tmpbufs[index], &obj->tmpsizes[index]); } else { - OCI_RETVAL = (otext *)OCIStringPtr(obj->con->env, *value); + str = (otext *)OCIStringPtr(obj->con->env, *value); } } } else { - index = OCI_ObjectGetAttrIndex(obj, attr, -1, FALSE); + index = ObjectGetAttributeIndex(obj, attr, -1, FALSE); if (index >= 0) { - OCI_Error *err = OCI_ErrorGet(TRUE, TRUE); + OCI_Error *err = ErrorGet(TRUE, TRUE); OCIInd *ind = NULL; void *value = NULL; unsigned int size = 0; unsigned int len = 0; - OCI_STATUS = TRUE; - - value = OCI_ObjectGetAttr(obj, index, &ind); + value = ObjectGetAttr(obj, index, &ind); /* special case of RAW attribute, we need their length */ if (OCI_CDT_RAW == obj->typinf->cols[index].datatype) @@ -1172,23 +1272,26 @@ const otext * OCI_API OCI_ObjectGetString } } - len = OCI_StringGetFromType(obj->con, &obj->typinf->cols[index], value, size, NULL, 0, FALSE); - OCI_STATUS = (NULL == err || OCI_UNKNOWN == err->type); + len = StringGetFromType(obj->con, &obj->typinf->cols[index], value, size, NULL, 0, FALSE); + + CHECK_ERROR(err) - if (OCI_STATUS && len > 0) + if (len > 0) { - OCI_STATUS = OCI_StringRequestBuffer(&obj->tmpbufs[index], &obj->tmpsizes[index], len); + CHECK(StringRequestBuffer(&obj->tmpbufs[index], &obj->tmpsizes[index], len)) - if (OCI_STATUS) - { - const unsigned int real_tmpsize = OCI_StringGetFromType(obj->con, &obj->typinf->cols[index], value, size, obj->tmpbufs[index], obj->tmpsizes[index], FALSE); - - OCI_STATUS = (NULL == err || OCI_UNKNOWN == err->type); + const unsigned int real_tmpsize = StringGetFromType(obj->con, + &obj->typinf->cols[index], + value, size, + obj->tmpbufs[index], + obj->tmpsizes[index], + FALSE); - if (OCI_STATUS && real_tmpsize > 0) - { - OCI_RETVAL = obj->tmpbufs[index]; - } + CHECK(NULL == err || OCI_UNKNOWN == err->type) + + if (real_tmpsize > 0) + { + str = obj->tmpbufs[index]; } } } @@ -1196,17 +1299,19 @@ const otext * OCI_API OCI_ObjectGetString if (index == -1) { - OCI_ExceptionAttributeNotFound(obj->con, attr); + THROW(ExceptionAttributeNotFound, attr) } - OCI_CALL_EXIT() + SET_RETVAL(str) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetRaw + * ObjectGetRaw * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_ObjectGetRaw +int ObjectGetRaw ( OCI_Object *obj, const otext *attr, @@ -1214,110 +1319,122 @@ int OCI_API OCI_ObjectGetRaw unsigned int len ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_CALL_ENTER(int, 0); - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + int index = -1; + int size = 0; - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_RAW, TRUE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_RAW, TRUE); - if (index >= 0) + if (index < 0) { - OCIInd *ind = NULL; - OCIRaw **value = NULL; + THROW(ExceptionAttributeNotFound, attr) + } - OCI_STATUS = TRUE; + OCIInd *ind = NULL; + OCIRaw **value = NULL; - value = (OCIRaw **) OCI_ObjectGetAttr(obj, index, &ind); + value = (OCIRaw **) ObjectGetAttr(obj, index, &ind); - if (value && ind && (OCI_IND_NULL != *ind)) - { - const ub4 raw_len = OCIRawSize(obj->con->env, *value); + if (value && ind && (OCI_IND_NULL != *ind)) + { + const ub4 raw_len = OCIRawSize(obj->con->env, *value); - if (len > raw_len) - { - len = raw_len; - } + if (len > raw_len) + { + len = raw_len; + } - memcpy(buffer, OCIRawPtr(obj->con->env, *value), (size_t) len); + memcpy(buffer, OCIRawPtr(obj->con->env, *value), (size_t) len); - OCI_RETVAL = (int) len; - } + size = (int) len; } - OCI_CALL_EXIT() + SET_RETVAL(size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_ObjectGetRawSize +* ObjectGetRawSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ObjectGetRawSize +unsigned int ObjectGetRawSize ( OCI_Object *obj, const otext *attr ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + ub4 raw_len = 0; int index = -1; - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) - - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_RAW, TRUE); + index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_RAW, TRUE); - if (index >= 0) + if (index < 0) { - OCIInd *ind = NULL; - OCIRaw **value = NULL; + THROW(ExceptionAttributeNotFound, attr) + } - OCI_STATUS = TRUE; + OCIInd *ind = NULL; + OCIRaw **value = NULL; - value = (OCIRaw **)OCI_ObjectGetAttr(obj, index, &ind); + value = (OCIRaw **)ObjectGetAttr(obj, index, &ind); - if (value && ind && (OCI_IND_NULL != *ind)) - { - raw_len = OCIRawSize(obj->con->env, *value); - } + if (value && ind && (OCI_IND_NULL != *ind)) + { + raw_len = OCIRawSize(obj->con->env, *value); } - OCI_RETVAL = raw_len; + SET_RETVAL(raw_len) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetDate + * ObjectGetDate * --------------------------------------------------------------------------------------------- */ -OCI_Date * OCI_API OCI_ObjectGetDate +OCI_Date * ObjectGetDate ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_DATETIME, OCI_Date*, OCIDate, - OCI_DateInit(obj->con, (OCI_Date *) obj->objs[index], value, FALSE, FALSE) + DateInitialize, + obj->con, + (OCI_Date *) obj->objs[index], + value, + FALSE, + FALSE ) - } +} /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetTimestamp + * ObjectGetTimestamp * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_API OCI_ObjectGetTimestamp +OCI_Timestamp * ObjectGetTimestamp ( OCI_Object *obj, const otext *attr @@ -1325,29 +1442,38 @@ OCI_Timestamp * OCI_API OCI_ObjectGetTimestamp { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_TIMESTAMP, OCI_Timestamp*, OCIDateTime*, - OCI_TimestampInit(obj->con, (OCI_Timestamp *) obj->objs[index], - (OCIDateTime *) *value, obj->typinf->cols[index].subtype) + TimestampInitialize, + obj->con, + (OCI_Timestamp *) obj->objs[index], + (OCIDateTime *) *value, + obj->typinf->cols[index].subtype ) #else - OCI_CALL_ENTER( OCI_Timestamp *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ OCI_Timestamp*, NULL, + /* context */ OCI_IPC_OBJECT, obj + ) + + CHECK_PTR(OCI_IPC_OBJECT, obj) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetInterval + * ObjectGetInterval * --------------------------------------------------------------------------------------------- */ -OCI_Interval * OCI_API OCI_ObjectGetInterval +OCI_Interval * ObjectGetInterval ( OCI_Object *obj, const otext *attr @@ -1355,117 +1481,146 @@ OCI_Interval * OCI_API OCI_ObjectGetInterval { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_OBJECT_GET_VALUE - ( + OBJECT_GET_VALUE + ( OCI_CDT_INTERVAL, OCI_Interval*, OCIInterval *, - OCI_IntervalInit(obj->con, (OCI_Interval *) obj->objs[index], - (OCIInterval *) *value, obj->typinf->cols[index].subtype) + IntervalInitialize, + obj->con, + (OCI_Interval *) obj->objs[index], + (OCIInterval *) *value, + obj->typinf->cols[index].subtype ) #else - OCI_CALL_ENTER(OCI_Interval *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ OCI_Interval*, NULL, + /* context */ OCI_IPC_OBJECT, obj + ) + + CHECK_PTR(OCI_IPC_OBJECT, obj) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetColl + * ObjectGetColl * --------------------------------------------------------------------------------------------- */ -OCI_Coll * OCI_API OCI_ObjectGetColl +OCI_Coll * ObjectGetColl ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_COLLECTION, OCI_Coll*, OCIColl*, - OCI_CollInit(obj->con, (OCI_Coll *) obj->objs[index], (OCIColl *) *value, obj->typinf->cols[index].typinf) + CollectionInitialize, + obj->con, + (OCI_Coll *) obj->objs[index], + (OCIColl *) *value, + obj->typinf->cols[index].typinf ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetObject + * ObjectGetObject * --------------------------------------------------------------------------------------------- */ -OCI_Object * OCI_API OCI_ObjectGetObject +OCI_Object * ObjectGetObject ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_OBJECT, OCI_Object*, void, - OCI_ObjectInit(obj->con, (OCI_Object *) obj->objs[index], value, - obj->typinf->cols[index].typinf, obj, index, FALSE) + ObjectInitialize, + obj->con, + (OCI_Object *) obj->objs[index], + value, + obj->typinf->cols[index].typinf, + obj, index, FALSE ) - } +} /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetLob + * ObjectGetLob * --------------------------------------------------------------------------------------------- */ -OCI_Lob * OCI_API OCI_ObjectGetLob +OCI_Lob * ObjectGetLob ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_LOB, OCI_Lob*, OCILobLocator*, - OCI_LobInit(obj->con, (OCI_Lob *) obj->objs[index], *value, obj->typinf->cols[index].subtype) + LobInitialize, + obj->con, + (OCI_Lob *) obj->objs[index], + *value, + obj->typinf->cols[index].subtype ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetFile + * ObjectGetFile * --------------------------------------------------------------------------------------------- */ -OCI_File * OCI_API OCI_ObjectGetFile +OCI_File * ObjectGetFile ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_FILE, OCI_File *, OCILobLocator*, - OCI_FileInit(obj->con, (OCI_File *) obj->objs[index], *value, obj->typinf->cols[index].subtype) + FileInitialize, + obj->con, + (OCI_File *) obj->objs[index], + *value, + obj->typinf->cols[index].subtype ) - } +} /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetRef + * ObjectGetReference * --------------------------------------------------------------------------------------------- */ -OCI_Ref * OCI_API OCI_ObjectGetRef +OCI_Ref * ObjectGetReference ( OCI_Object *obj, const otext *attr ) { - OCI_OBJECT_GET_VALUE + OBJECT_GET_VALUE ( OCI_CDT_REF, OCI_Ref*, OCIRef*, - OCI_RefInit(obj->con, NULL, (OCI_Ref *) obj->objs[index], *value) + ReferenceInitialize, + obj->con, + NULL, + (OCI_Ref *) obj->objs[index], + *value ) } @@ -1473,222 +1628,227 @@ OCI_Ref * OCI_API OCI_ObjectGetRef * OCI_ObjectSetBoolean * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetBoolean +boolean ObjectSetBoolean ( OCI_Object *obj, const otext *attr, boolean value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - const int index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_BOOLEAN, TRUE); + const int index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_BOOLEAN, TRUE); - if (index >= 0) + if (index < 0) { - OCIInd *ind = NULL; - boolean *data = (boolean *)OCI_ObjectGetAttr(obj, index, &ind); + THROW(ExceptionAttributeNotFound, attr) + } - if (data) - { - *data = value; - *ind = OCI_IND_NOTNULL; + OCIInd *ind = NULL; + boolean *data = (boolean *)ObjectGetAttr(obj, index, &ind); - OCI_STATUS = TRUE; - } + if (data) + { + *data = value; + *ind = OCI_IND_NOTNULL; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetNumber + * ObjectSetNumber * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetNumber +boolean ObjectSetNumber ( OCI_Object *obj, const otext *attr, OCI_Number *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_NUMERIC, OCINumber, - OCINumberAssign( obj->con->err, value->handle, data) + OCINumberAssign, + obj->con->err, + value->handle, + data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetShort + * ObjectSetShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetShort +boolean ObjectSetShort ( OCI_Object *obj, const otext *attr, short value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_SHORT); + OBJECT_SET_NUMBER(OCI_NUM_SHORT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetUnsignedShort + * ObjectSetUnsignedShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetUnsignedShort +boolean ObjectSetUnsignedShort ( OCI_Object *obj, const otext *attr, unsigned short value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_USHORT); + OBJECT_SET_NUMBER(OCI_NUM_USHORT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetInt + * ObjectSetInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetInt +boolean ObjectSetInt ( OCI_Object *obj, const otext *attr, int value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_INT); + OBJECT_SET_NUMBER(OCI_NUM_INT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetUnsignedInt + * ObjectSetUnsignedInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetUnsignedInt +boolean ObjectSetUnsignedInt ( OCI_Object *obj, const otext *attr, unsigned int value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_UINT); + OBJECT_SET_NUMBER(OCI_NUM_UINT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetBigInt + * ObjectSetBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetBigInt +boolean ObjectSetBigInt ( OCI_Object *obj, const otext *attr, big_int value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_BIGINT); + OBJECT_SET_NUMBER(OCI_NUM_BIGINT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetUnsignedBigInt + * ObjectSetUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetUnsignedBigInt +boolean ObjectSetUnsignedBigInt ( OCI_Object *obj, const otext *attr, big_uint value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_BIGUINT); + OBJECT_SET_NUMBER(OCI_NUM_BIGUINT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetDouble + * ObjectSetDouble * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetDouble +boolean ObjectSetDouble ( OCI_Object *obj, const otext *attr, double value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_DOUBLE); + OBJECT_SET_NUMBER(OCI_NUM_DOUBLE, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetFloat + * ObjectSetFloat * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetFloat +boolean ObjectSetFloat ( OCI_Object *obj, const otext *attr, float value ) { - return OCI_ObjectSetNumberInternal(obj, attr, &value, (uword) OCI_NUM_FLOAT); + OBJECT_SET_NUMBER(OCI_NUM_FLOAT, value) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetString + * ObjectSetString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetString +boolean ObjectSetString ( OCI_Object *obj, const otext *attr, const otext *value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) - - OCI_STATUS = FALSE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - if (!value) + if (NULL == value) { - OCI_STATUS = OCI_ObjectSetNull(obj, attr); + CHECK(ObjectSetNull(obj, attr)) } else { - const int index = OCI_ObjectGetAttrIndex(obj, attr, OCI_CDT_TEXT, TRUE); + const int index = ObjectGetAttributeIndex(obj, attr, OCI_CDT_TEXT, TRUE); - if (index >= 0) + if (index < 0) { - OCIInd *ind = NULL; - OCIString **data = (OCIString **) OCI_ObjectGetAttr(obj, index, &ind); + THROW(ExceptionAttributeNotFound, attr) + } - OCI_STATUS = OCI_StringToStringPtr(obj->con->env, data, obj->con->err, value); + OCIInd *ind = NULL; + OCIString **data = (OCIString **) ObjectGetAttr(obj, index, &ind); - if (OCI_STATUS) - { - *ind = OCI_IND_NOTNULL; - } - } + CHECK(StringToStringPtr(obj->con->env, data, obj->con->err, value)) + + *ind = OCI_IND_NOTNULL; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetRaw + * ObjectSetRaw * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetRaw +boolean ObjectSetRaw ( OCI_Object *obj, const otext *attr, @@ -1696,38 +1856,46 @@ boolean OCI_API OCI_ObjectSetRaw unsigned int len ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_RAW, OCIRaw*, - OCIRawAssignBytes(obj->con->env, obj->con->err, (ub1*) value, len, data) + OCIRawAssignBytes, + obj->con->env, + obj->con->err, + (ub1*) value, + len, + data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetDate + * ObjectSetDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetDate +boolean ObjectSetDate ( OCI_Object *obj, const otext *attr, OCI_Date *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_DATETIME, OCIDate, - OCIDateAssign(obj->con->err, value->handle, data) + OCIDateAssign, + obj->con->err, + value->handle, + data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetTimestamp + * ObjectSetTimestamp * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetTimestamp +boolean ObjectSetTimestamp ( OCI_Object *obj, const otext *attr, @@ -1736,27 +1904,36 @@ boolean OCI_API OCI_ObjectSetTimestamp { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_TIMESTAMP, OCIDateTime*, - OCIDateTimeAssign((dvoid *) obj->con->env, obj->con->err, value->handle, *data) + OCIDateTimeAssign, + (dvoid *) obj->con->env, + obj->con->err, + value->handle, *data ) #else - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + + CHECK_PTR(OCI_IPC_OBJECT, obj) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetInterval + * ObjectSetInterval * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetInterval +boolean ObjectSetInterval ( OCI_Object *obj, const otext *attr, @@ -1765,249 +1942,312 @@ boolean OCI_API OCI_ObjectSetInterval { #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_INTERVAL, OCIInterval*, - OCIIntervalAssign((dvoid *) obj->con->env, obj->con->err, value->handle, *data) + OCIIntervalAssign, + (dvoid *) obj->con->env, + obj->con->err, + value->handle, + *data ) #else - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_EXIT() + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + + CHECK_PTR(OCI_IPC_OBJECT, obj) + + EXIT_FUNC() #endif } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetColl + * ObjectSetColl * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetColl +boolean ObjectSetColl ( OCI_Object *obj, const otext *attr, OCI_Coll *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_COLLECTION, OCIColl*, - OCICollAssign(obj->con->env, obj->con->err, value->handle, *data) + OCICollAssign, + obj->con->env, + obj->con->err, + value->handle, + *data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetObject + * ObjectSetObject * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetObject +boolean ObjectSetObject ( OCI_Object *obj, const otext *attr, OCI_Object *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_OBJECT, void, - OCIObjectCopy(obj->con->env, obj->con->err, obj->con->cxt, - value->handle, (value->tab_ind + value->idx_ind), - data, ind, obj->typinf->cols[index].typinf->tdo, - OCI_DURATION_SESSION, OCI_DEFAULT) + OCIObjectCopy, + obj->con->env, + obj->con->err, + obj->con->cxt, + value->handle, + (value->tab_ind + value->idx_ind), + data, + ind, + obj->typinf->cols[index].typinf->tdo, + OCI_DURATION_SESSION, + OCI_DEFAULT ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetLob + * ObjectSetLob * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetLob +boolean ObjectSetLob ( OCI_Object *obj, const otext *attr, OCI_Lob *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_LOB, OCILobLocator*, - OCILobLocatorAssign(obj->con->cxt, obj->con->err, value->handle, (OCILobLocator **) data) + OCILobLocatorAssign, + obj->con->cxt, + obj->con->err, + value->handle, + (OCILobLocator **) data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetFile + * ObjectSetFile * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetFile +boolean ObjectSetFile ( OCI_Object *obj, const otext *attr, OCI_File *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_FILE, OCILobLocator*, - OCILobLocatorAssign(obj->con->cxt, obj->con->err, value->handle, (OCILobLocator **) data) + OCILobLocatorAssign, + obj->con->cxt, + obj->con->err, + value->handle, + (OCILobLocator **) data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetRef + * ObjectSetReference * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetRef +boolean ObjectSetReference ( OCI_Object *obj, const otext *attr, OCI_Ref *value ) { - OCI_OBJECT_SET_VALUE + OBJECT_SET_VALUE ( OCI_CDT_REF, OCIRef*, - OCIRefAssign(obj->con->env, obj->con->err, value->handle, data) + OCIRefAssign, + obj->con->env, + obj->con->err, + value->handle, + data ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectSetNull + * ObjectSetNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectSetNull +boolean ObjectSetNull ( OCI_Object *obj, const otext *attr ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - const int index = OCI_ObjectGetAttrIndex(obj, attr, -1, TRUE); + const int index = ObjectGetAttributeIndex(obj, attr, -1, TRUE); - if (index >= 0) + if (index == -1) { - const int ind_index = obj->idx_ind + OCI_ObjectGetIndOffset(obj->typinf, index); + THROW(ExceptionAttributeNotFound, attr) + } - obj->tab_ind[ind_index] = OCI_IND_NULL; + const int ind_index = obj->idx_ind + ObjectGetIndOffset(obj->typinf, index); - OCI_STATUS = TRUE; - } + obj->tab_ind[ind_index] = OCI_IND_NULL; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectIsNull + * ObjectIsNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectIsNull +boolean ObjectIsNull ( OCI_Object *obj, const otext *attr ) { - int index = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, attr) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + int index = 0; - index = OCI_ObjectGetAttrIndex(obj, attr, -1, TRUE); + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_STRING, attr) - if (index >= 0) + index = ObjectGetAttributeIndex(obj, attr, -1, TRUE); + + if (index == -1) { - const int ind_index = obj->idx_ind + OCI_ObjectGetIndOffset(obj->typinf, index); + THROW(ExceptionAttributeNotFound, attr) + } - OCI_RETVAL = (OCI_IND_NOTNULL != obj->tab_ind[ind_index]); + const int ind_index = obj->idx_ind + ObjectGetIndOffset(obj->typinf, index); - OCI_STATUS = TRUE; - } + SET_RETVAL(OCI_IND_NOTNULL != obj->tab_ind[ind_index]) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetTypeInfo + * ObjectGetTypeInfo * --------------------------------------------------------------------------------------------- */ -OCI_TypeInfo * OCI_API OCI_ObjectGetTypeInfo +OCI_TypeInfo * ObjectGetTypeInfo ( OCI_Object *obj ) { - OCI_GET_PROP(OCI_TypeInfo*, NULL, OCI_IPC_OBJECT, obj, typinf, obj->con, NULL, obj->con->err) + GET_PROP + ( + OCI_TypeInfo*, NULL, + OCI_IPC_OBJECT, obj, + typinf + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetType + * ObjectGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_ObjectGetType +unsigned int ObjectGetType ( OCI_Object *obj ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_OBJECT, obj, type, obj->con, NULL, obj->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_OBJECT, obj, + type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetSelfRef + * ObjectGetSelfRef * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectGetSelfRef +boolean ObjectGetSelfRef ( OCI_Object *obj, OCI_Ref *ref ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CHECK_COMPAT(obj->con, obj->typinf->tdo == ref->typinf->tdo) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) - OCI_EXEC(OCIObjectGetObjectRef(obj->con->env, obj->con->err, obj->handle, ref->handle)) + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_REF, ref) + CHECK_COMPAT(obj->typinf->tdo == ref->typinf->tdo) - if (!OCI_STATUS && ref->obj) + CHECK_OCI + ( + obj->con->err, + OCIObjectGetObjectRef, + obj->con->env, obj->con->err, + obj->handle, ref->handle + ) + + if (NULL != ref->obj) { - OCI_ObjectFree(ref->obj); + ObjectFree(ref->obj); ref->obj = NULL; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectGetStruct + * ObjectGetStruct * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectGetStruct +boolean ObjectGetStruct ( OCI_Object *obj, void **pp_struct, void **pp_ind ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + CHECK_PTR(OCI_IPC_OBJECT, obj) if (pp_struct) { @@ -2019,55 +2259,59 @@ boolean OCI_API OCI_ObjectGetStruct *pp_ind = (void *) obj->tab_ind; } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ObjectToText + * ObjectToString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ObjectToText +boolean ObjectToString ( OCI_Object *obj, unsigned int *size, otext *str ) { - OCI_Error *err = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_OBJECT, obj + ) + + OCI_Error *err = NULL; otext *attr = NULL; boolean quote = TRUE; unsigned int len = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_OBJECT, obj) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, size) - OCI_CALL_CONTEXT_SET_FROM_CONN(obj->con) + CHECK_PTR(OCI_IPC_OBJECT, obj) + CHECK_PTR(OCI_IPC_VOID, size) - err = OCI_ErrorGet(TRUE, TRUE); + err = ErrorGet(TRUE, TRUE); if (str) { *str = 0; } - len += OCI_StringAddToBuffer(str, len, obj->typinf->name, (unsigned int) ostrlen(obj->typinf->name), FALSE); - len += OCI_StringAddToBuffer(str, len, OTEXT("("), 1, FALSE); + len += StringAddToBuffer(str, len, obj->typinf->name, (unsigned int) ostrlen(obj->typinf->name), FALSE); + len += StringAddToBuffer(str, len, OTEXT("("), 1, FALSE); - for (int i = 0; i < obj->typinf->nb_cols && OCI_STATUS; i++) + for (int i = 0; i < obj->typinf->nb_cols; i++) { attr = obj->typinf->cols[i].name; quote = TRUE; - if (OCI_ObjectIsNull(obj, attr)) + if (ObjectIsNull(obj, attr)) { - len += OCI_StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); + len += StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); } else { - void *data = NULL; - unsigned int data_size = 0; + void *data = NULL; + unsigned int data_size = 0; const unsigned int data_type = obj->typinf->cols[i].datatype; switch (data_type) @@ -2075,12 +2319,12 @@ boolean OCI_API OCI_ObjectToText case OCI_CDT_TEXT: { OCIInd *ind = NULL; - data = OCI_ObjectGetAttr(obj, i, &ind); + data = ObjectGetAttr(obj, i, &ind); if (data && ind && (OCI_IND_NULL != *ind)) { - data_size = OCIStringSize(OCILib.env, (*(OCIString **)data)); - data = (void *)OCI_ObjectGetString(obj, attr); + data_size = OCIStringSize(Env.env, (*(OCIString **)data)); + data = (void *)ObjectGetString(obj, attr); } else { @@ -2091,21 +2335,21 @@ boolean OCI_API OCI_ObjectToText case OCI_CDT_BOOLEAN: { OCIInd *ind = NULL; - data = OCI_ObjectGetAttr(obj, i, &ind); + data = ObjectGetAttr(obj, i, &ind); quote = FALSE; break; } case OCI_CDT_NUMERIC: { OCIInd *ind = NULL; - data = OCI_ObjectGetAttr(obj, i, &ind); + data = ObjectGetAttr(obj, i, &ind); quote = FALSE; break; } case OCI_CDT_RAW: { OCIInd *ind = NULL; - data = OCI_ObjectGetAttr(obj, i, &ind); + data = ObjectGetAttr(obj, i, &ind); if (data && ind && (OCI_IND_NULL != *ind)) { @@ -2115,100 +2359,97 @@ boolean OCI_API OCI_ObjectToText else { data = NULL; - } + } break; } case OCI_CDT_DATETIME: { - data = (void *) OCI_ObjectGetDate(obj, attr); + data = (void *) ObjectGetDate(obj, attr); break; } case OCI_CDT_TIMESTAMP: { - data = (void *) OCI_ObjectGetTimestamp(obj, attr); + data = (void *) ObjectGetTimestamp(obj, attr); break; } case OCI_CDT_INTERVAL: { - data = (void *) OCI_ObjectGetInterval(obj, attr); + data = (void *) ObjectGetInterval(obj, attr); break; } case OCI_CDT_LOB: { - data = (void *) OCI_ObjectGetLob(obj, attr); + data = (void *) ObjectGetLob(obj, attr); break; } case OCI_CDT_FILE: { - data = (void *) OCI_ObjectGetFile(obj, attr); + data = (void *) ObjectGetFile(obj, attr); break; } case OCI_CDT_REF: { - data = (void *) OCI_ObjectGetRef(obj, attr); + data = (void *) ObjectGetReference(obj, attr); break; } case OCI_CDT_OBJECT: { - data = (void *) OCI_ObjectGetObject(obj, attr); + data = (void *) ObjectGetObject(obj, attr); quote = FALSE; break; } case OCI_CDT_COLLECTION: { - data = (void *) OCI_ObjectGetColl(obj, attr); + data = (void *) ObjectGetColl(obj, attr); quote = FALSE; } } - OCI_STATUS = (NULL != data || OCI_CDT_TEXT == data_type) && (NULL == err || !err->raise); + CHECK(NULL != data || OCI_CDT_TEXT == data_type) + CHECK_ERROR(err) - if (OCI_STATUS) - { - otext *tmpbuf = str; + otext *tmpbuf = str; - if (tmpbuf) - { - tmpbuf += len; - } - - if (data) - { - len += OCI_StringGetFromType(obj->con, &obj->typinf->cols[i], data, data_size, tmpbuf, tmpbuf && size ? *size - len : 0, quote); - } - else - { - len += OCI_StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); - } + if (tmpbuf) + { + tmpbuf += len; + } - OCI_STATUS = (NULL == err || OCI_UNKNOWN == err->type); + if (data) + { + len += StringGetFromType(obj->con, &obj->typinf->cols[i], data, data_size, + tmpbuf, tmpbuf && size ? *size - len : 0, quote); } + else + { + len += StringAddToBuffer(str, len, OCI_STRING_NULL, OCI_STRING_NULL_SIZE, FALSE); + } + + CHECK(NULL == err || OCI_UNKNOWN == err->type) } - if (OCI_STATUS && i < (obj->typinf->nb_cols-1)) + if (i < (obj->typinf->nb_cols-1)) { - len += OCI_StringAddToBuffer(str, len, OTEXT(", "), 2, quote); + len += StringAddToBuffer(str, len, OTEXT(", "), 2, quote); } } - if (OCI_STATUS) - { - len += OCI_StringAddToBuffer(str, len, OTEXT(")"), 1, FALSE); + len += StringAddToBuffer(str, len, OTEXT(")"), 1, FALSE); - *size = len; - } - else - { - *size = 0; + *size = len; - if (str) - { - *str = 0; - } - } + SET_SUCCESS() - OCI_RETVAL = OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + *size = 0; - OCI_CALL_EXIT() + if (NULL != str) + { + *str = 0; + } + } + ) } - diff --git a/src/object.h b/src/object.h new file mode 100644 index 00000000..4a6e0ed2 --- /dev/null +++ b/src/object.h @@ -0,0 +1,384 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_OBJECT_H_INCLUDED +#define OCILIB_OBJECT_H_INCLUDED + +#include "types.h" + +void ObjectGetUserStructSize +( + OCI_TypeInfo* typinf, + size_t * p_size, + size_t * p_align +); + +OCI_Object * ObjectInitialize +( + OCI_Connection *con, + OCI_Object *obj, + void *handle, + OCI_TypeInfo *typinf, + OCI_Object *parent, + int index, + boolean reset +); + +OCI_Object * ObjectCreate +( + OCI_Connection *con, + OCI_TypeInfo *typinf +); + +boolean ObjectFree +( + OCI_Object *obj +); + +OCI_Object ** ObjectCreateArray +( + OCI_Connection *con, + OCI_TypeInfo *typinf, + unsigned int nbelem +); + +boolean ObjectFreeArray +( + OCI_Object **objs +); + +boolean ObjectAssign +( + OCI_Object *obj, + OCI_Object *obj_src +); + +boolean ObjectGetBoolean +( + OCI_Object *obj, + const otext *attr +); + +OCI_Number * ObjectGetNumber +( + OCI_Object *obj, + const otext *attr +); + +short ObjectGetShort +( + OCI_Object *obj, + const otext *attr +); + +unsigned short ObjectGetUnsignedShort +( + OCI_Object *obj, + const otext *attr +); + +int ObjectGetInt +( + OCI_Object *obj, + const otext *attr +); + +unsigned int ObjectGetUnsignedInt +( + OCI_Object *obj, + const otext *attr +); + +big_int ObjectGetBigInt +( + OCI_Object *obj, + const otext *attr +); + +big_uint ObjectGetUnsignedBigInt +( + OCI_Object *obj, + const otext *attr +); + +double ObjectGetDouble +( + OCI_Object *obj, + const otext *attr +); + +float ObjectGetFloat +( + OCI_Object *obj, + const otext *attr +); + +const otext * ObjectGetString +( + OCI_Object *obj, + const otext *attr +); + +int ObjectGetRaw +( + OCI_Object *obj, + const otext *attr, + void *buffer, + unsigned int len +); + +unsigned int ObjectGetRawSize +( + OCI_Object *obj, + const otext *attr +); + +OCI_Date * ObjectGetDate +( + OCI_Object *obj, + const otext *attr +); + +OCI_Timestamp * ObjectGetTimestamp +( + OCI_Object *obj, + const otext *attr +); + +OCI_Interval * ObjectGetInterval +( + OCI_Object *obj, + const otext *attr +); + +OCI_Coll * ObjectGetColl +( + OCI_Object *obj, + const otext *attr +); + +OCI_Object * ObjectGetObject +( + OCI_Object *obj, + const otext *attr +); + +OCI_Lob * ObjectGetLob +( + OCI_Object *obj, + const otext *attr +); + +OCI_File * ObjectGetFile +( + OCI_Object *obj, + const otext *attr +); + +OCI_Ref * ObjectGetReference +( + OCI_Object *obj, + const otext *attr +); + +boolean ObjectSetBoolean +( + OCI_Object *obj, + const otext *attr, + boolean value +); + +boolean ObjectSetNumber +( + OCI_Object *obj, + const otext *attr, + OCI_Number *value +); + +boolean ObjectSetShort +( + OCI_Object *obj, + const otext *attr, + short value +); + +boolean ObjectSetUnsignedShort +( + OCI_Object *obj, + const otext *attr, + unsigned short value +); + +boolean ObjectSetInt +( + OCI_Object *obj, + const otext *attr, + int value +); + +boolean ObjectSetUnsignedInt +( + OCI_Object *obj, + const otext *attr, + unsigned int value +); + +boolean ObjectSetBigInt +( + OCI_Object *obj, + const otext *attr, + big_int value +); + +boolean ObjectSetUnsignedBigInt +( + OCI_Object *obj, + const otext *attr, + big_uint value +); + +boolean ObjectSetDouble +( + OCI_Object *obj, + const otext *attr, + double value +); + +boolean ObjectSetFloat +( + OCI_Object *obj, + const otext *attr, + float value +); + +boolean ObjectSetString +( + OCI_Object *obj, + const otext *attr, + const otext *value +); + +boolean ObjectSetRaw +( + OCI_Object *obj, + const otext *attr, + void * value, + unsigned int len +); + +boolean ObjectSetDate +( + OCI_Object * obj, + const otext *attr, + OCI_Date *value +); + +boolean ObjectSetTimestamp +( + OCI_Object * obj, + const otext *attr, + OCI_Timestamp *value +); + +boolean ObjectSetInterval +( + OCI_Object *obj, + const otext *attr, + OCI_Interval *value +); + +boolean ObjectSetColl +( + OCI_Object *obj, + const otext *attr, + OCI_Coll *value +); + +boolean ObjectSetObject +( + OCI_Object *obj, + const otext *attr, + OCI_Object *value +); + +boolean ObjectSetLob +( + OCI_Object *obj, + const otext *attr, + OCI_Lob *value +); + +boolean ObjectSetFile +( + OCI_Object *obj, + const otext *attr, + OCI_File *value +); + +boolean ObjectSetReference +( + OCI_Object *obj, + const otext *attr, + OCI_Ref *value +); + +boolean ObjectSetNull +( + OCI_Object *obj, + const otext *attr +); + +boolean ObjectIsNull +( + OCI_Object *obj, + const otext *attr +); + +OCI_TypeInfo * ObjectGetTypeInfo +( + OCI_Object *obj +); + +unsigned int ObjectGetType +( + OCI_Object *obj +); + +boolean ObjectGetSelfRef +( + OCI_Object *obj, + OCI_Ref *ref +); + +boolean ObjectGetStruct +( + OCI_Object *obj, + void **pp_struct, + void **pp_ind +); + +boolean ObjectToString +( + OCI_Object *obj, + unsigned int *size, + otext *str +); + +#endif /* OCILIB_OBJECT_H_INCLUDED */ diff --git a/src/oci_api.h b/src/oci/api.h similarity index 95% rename from src/oci_api.h rename to src/oci/api.h index b1f22233..778c50fc 100644 --- a/src/oci_api.h +++ b/src/oci/api.h @@ -1,2181 +1,2181 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * IMPORTANT NOTICE - * - * THIS FILE CONTAINS CONSTANTS AND STRUCTURES DECLARATIONS THAT WERE - * PICKED UP FROM ORACLE PUBLIC HEADER FILES. - * - * SO THE CONTENT OF THIS FILE MAY BE UNDER ORACLE COPYRIGHT AND THE - * DECLARATIONS REPRODUCED HERE ARE ORIGINALLY WRITTEN BY ORACLE CORPORATION - * - * THE AUTHOR OF OCILIB LIBRARY HAS NOT WRITTEN THE CONTENT OF THIS - * FILE AND HAS PARTIALLY INTEGRATED SOME ORACLE OCI DEFINITIONS TO - * ALLOW COMPILATION OF THIS OPEN SOURCE LIBRARY WITHOUT HAVING - * ORACLE PRODUCTS INSTALLED ON DEVELOPMENT ENVIRONMENTS - * - */ - -#ifndef OCILIB_OCI_API_H_INCLUDED -#define OCILIB_OCI_API_H_INCLUDED - -#include "oci_defs.h" - -/* ********************************************************************************************* * - * PUBLIC OCI API PROTOTYPES - * ********************************************************************************************* */ - -/* API introduced in 8.0 */ - -typedef sword (*OCIENVCREATE) -( - OCIEnv **envhpp, - ub4 mode, - void *ctxp, - void *(*malocfp)(void *ctxp, size_t size), - void *(*ralocfp)(void *ctxp, void *memptr, size_t newsize), - void (*mfreefp) - ( - void *ctxp, - void *memptr - ), - size_t xtramem_sz, - void **usrmempp -); - -typedef sword (*OCIHANDLEALLOC) -( - const void *parenth, - void **hndlpp, - const ub4 type, - const size_t xtramem_sz, - void **usrmempp -); - -typedef sword (*OCIHANDLEFREE) -( - void *hndlp, - const ub4 type -); - -typedef sword (*OCIDESCRIPTORALLOC) -( - const void *parenth, - void **descpp, - const ub4 type, - const size_t xtramem_sz, - void **usrmempp -); - -typedef sword (*OCIDESCRIPTORFREE) -( - void *descp, - const ub4 type -); - -typedef sword (*OCIENVINIT) -( - OCIEnv **envp, - ub4 mode, - size_t xtramem_sz, - void **usrmempp -); - -typedef sword (*OCISERVERATTACH) -( - OCIServer *srvhp, - OCIError *errhp, - const OraText *dblink, - sb4 dblink_len, - ub4 mode -); - -typedef sword (*OCISERVERDETACH) -( - OCIServer *srvhp, - OCIError *errhp, - ub4 mode -); - -typedef sword (*OCISESSIONBEGIN) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCISession *usrhp, - ub4 credt, - ub4 mode -); - -typedef sword (*OCISESSIONEND) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCISession *usrhp, - ub4 mode -); - -typedef sword (*OCIPASSWORDCHANGE) -( - OCISvcCtx *svchp, - OCIError *errhp, - CONST OraText *user_name, - ub4 usernm_len, - CONST OraText *opasswd, - ub4 opasswd_len, - CONST OraText *npasswd, - ub4 npasswd_len, - ub4 mode -); - -typedef sword (*OCISTMTPREPARE) -( - OCIStmt *stmtp, - OCIError *errhp, - const OraText *stmt, - ub4 stmt_len, - ub4 language, - ub4 mode -); - -typedef sword (*OCIBINDBYPOS) -( - OCIStmt *stmtp, - OCIBind **bindp, - OCIError *errhp, - ub4 position, - void *valuep, - sb4 value_sz, - ub2 dty, - void *indp, - ub2 *alenp, - ub2 *rcodep, - ub4 maxarr_len, - ub4 *curelep, - ub4 mode -); - -typedef sword (*OCIBINDBYNAME) -( - OCIStmt *stmtp, - OCIBind **bindp, - OCIError *errhp, - const OraText *placeholder, - sb4 placeh_len, - void *valuep, - sb4 value_sz, - ub2 dty, - void *indp, - ub2 *alenp, - ub2 *rcodep, - ub4 maxarr_len, - ub4 *curelep, - ub4 mode -); - -typedef sword (*OCIBINDDYNAMIC) -( - OCIBind *bindp, - OCIError *errhp, - dvoid *ictxp, - sb4 (*icbfp) - ( - dvoid *ictxp, - OCIBind *bindp, - ub4 iter, - ub4 index, - dvoid **bufpp, - ub4 *alenp, - ub1 *piecep, - dvoid **indp - ), - dvoid *octxp, - sb4 (*ocbfp) - ( - dvoid *octxp, - OCIBind *bindp, - ub4 iter, - ub4 index, - dvoid **bufpp, - ub4 **alenp, - ub1 *piecep, - dvoid **indp, - ub2 **rcodep - ) -); - -typedef sword (*OCIBINDOBJECT) -( - OCIBind *bindp, - OCIError *errhp, - CONST OCIType *type, - dvoid **pgvpp, - ub4 *pvszsp, - dvoid **indpp, - ub4 *indszp -); - -typedef sword (*OCISTMTGETPIECEINFO) -( - OCIStmt *stmtp, - OCIError *errhp, - void **hndlpp, - ub4 *typep, - ub1 *in_outp, - ub4 *iterp, - ub4 *idxp, - ub1 *piecep -); - -typedef sword (*OCISTMTSETPIECEINFO) -( - void *hndlp, - ub4 type, - OCIError *errhp, - const void *bufp, - ub4 *alenp, - ub1 piece, - const void *indp, - ub2 *rcodep -); - -typedef sword (*OCISTMTEXECUTE) -( - OCISvcCtx *svchp, - OCIStmt *stmtp, - OCIError *errhp, - ub4 iters, - ub4 rowoff, - const OCISnapshot *snap_in, - OCISnapshot *snap_out, - ub4 mode -); - -typedef sword (*OCIDEFINEBYPOS) -( - OCIStmt *stmtp, - OCIDefine **defnp, - OCIError *errhp, - ub4 position, - void *valuep, - sb4 value_sz, - ub2 dty, - void *indp, - ub2 *rlenp, - ub2 *rcodep, - ub4 mode -); - -typedef sword (*OCIDEFINEOBJECT) -( - OCIDefine *defnp, - OCIError *errhp, - CONST OCIType *type, - dvoid **pgvpp, - ub4 *pvszsp, - dvoid **indpp, - ub4 *indszp -); - -typedef sword (*OCISTMTFETCH ) -( - OCIStmt *stmtp, - OCIError *errhp, - ub4 nrows, - ub2 orientation, - ub4 mode -); - -typedef sword (*OCIPARAMGET) -( - const void *hndlp, - ub4 htype, - OCIError *errhp, - void **parmdpp, - ub4 pos -); - -typedef sword (*OCIPARAMSET) -( - void *hdlp, - ub4 htyp, - OCIError *errhp, - const void *dscp, - ub4 dtyp, - ub4 pos -); - -typedef sword (*OCITRANSSTART) -( - OCISvcCtx *svchp, - OCIError *errhp, - uword timeout, - ub4 flags -); - -typedef sword (*OCITRANSDETACH) -( - OCISvcCtx *svchp, - OCIError *errhp, - ub4 flags -); - -typedef sword (*OCITRANSPREPARE) -( - OCISvcCtx *svchp, - OCIError *errhp, - ub4 flags -); - -typedef sword (*OCITRANSFORGET) -( - OCISvcCtx *svchp, - OCIError *errhp, - ub4 flags -); - -typedef sword (*OCITRANSCOMMIT) -( - OCISvcCtx *svchp, - OCIError *errhp, - ub4 flags -); - -typedef sword (*OCITRANSROLLBACK) -( - OCISvcCtx *svchp, - OCIError *errhp, - ub4 flags -); - -typedef sword (*OCIERRORGET) -( - void *hndlp, - ub4 recordno, - OraText *sqlstate, - sb4 *errcodep, - OraText *bufp, - ub4 bufsiz, - ub4 type -); - -typedef sword (*OCILOBCREATETEMPORARY) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub2 csid, - ub1 csfrm, - ub1 lobtype, - boolean cache, - OCIDuration duration -); - -typedef sword (*OCILOBFREETEMPORARY) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp -); - -typedef sword (*OCILOBISTEMPORARY) -( - OCIEnv *envp, - OCIError *errhp, - OCILobLocator *locp, - boolean *is_temporary -); - -typedef sword (*OCILOBAPPEND) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *dst_locp, - OCILobLocator *src_locp -); - -typedef sword (*OCILOBCOPY) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *dst_locp, - OCILobLocator *src_locp, - ub4 amount, - ub4 dst_offset, - ub4 src_offset -); - -typedef sword (*OCILOBREAD) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 *amtp, - ub4 offset, - void *bufp, - ub4 bufl, - void *ctxp, - sb4 (*cbfp) - ( - void *ctxp, - const void *bufp, - ub4 len, - ub1 piece - ), - ub2 csid, - ub1 csfrm -); - -typedef sword (*OCILOBTRIM) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 newlen -); - -typedef sword (*OCILOBERASE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 *amount, - ub4 offset -); - -typedef sword (*OCILOBWRITE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 *amtp, - ub4 offset, - void *bufp, - ub4 buflen, - ub1 piece, - void *ctxp, - sb4 (*cbfp) - ( - void *ctxp, - void *bufp, - ub4 *len, - ub1 *piece - ), - ub2 csid, - ub1 csfrm -); - -typedef sword (*OCILOBGETLENGTH) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 *lenp -); - -typedef sword (*OCILOBGETCHUNKSIZE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 *chunksizep -); - -typedef sword (*OCILOBOPEN) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub1 mode -); - -typedef sword (*OCILOBCLOSE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp -); - -typedef sword (*OCILOBLOCATORASSIGN) -( - OCISvcCtx *svchp, - OCIError *errhp, - CONST OCILobLocator *src_locp, - OCILobLocator **dst_locpp -); - -typedef sword (*OCILOBASSIGN) -( - OCIEnv *envhp, - OCIError *errhp, - CONST OCILobLocator *src_locp, - OCILobLocator **dst_locpp -); - -typedef sword (*OCILOBENABLEBUFFERING) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp -); - -typedef sword (*OCILOBDISABLEBUFFERING) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp -); - -typedef sword (*OCILOBFILEOPEN) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *filep, - ub1 mode -); - -typedef sword (*OCILOBFILECLOSE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *filep -); - -typedef sword (*OCILOBFILECLOSEALL) -( - OCISvcCtx *svchp, - OCIError *errhp -); - -typedef sword (*OCILOBFILEISOPEN) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *filep, - boolean *flag -); - -typedef sword (*OCILOBFILEEXISTS) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *filep, - boolean *flag -); - -typedef sword (*OCILOBFIELGETNAME) -( - OCIEnv *envhp, - OCIError *errhp, - CONST OCILobLocator *filep, - OraText *dir_alias, - ub2 *d_length, - OraText *filename, - ub2 *f_length -); - -typedef sword (*OCILOBFILESETNAME) -( - OCIEnv *envhp, - OCIError *errhp, - OCILobLocator **filepp, - CONST OraText *dir_alias, - ub2 d_length, - CONST OraText *filename, - ub2 f_length -); - -typedef sword (*OCILOBLOADFROMFILE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *dst_locp, - OCILobLocator *src_filep, - ub4 amount, - ub4 dst_offset, - ub4 src_offset -); - -typedef sword (*OCILOBWRITEAPPEND) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *lobp, - ub4 *amtp, - dvoid *bufp, - ub4 bufl, - ub1 piece, - dvoid *ctxp, - sb4 (*cbfp) - ( - void *ctxp, - void *bufp, - ub4 *len, - ub1 *piece - ), - ub2 csid, - ub1 csfrm -); - -typedef sword (*OCILOBISEQUAL) -( - OCIEnv *envhp, - CONST OCILobLocator *x, - CONST OCILobLocator *y, - boolean *is_equal -); - -typedef sword (*OCILOBFLUSHBUFFER) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - ub4 flag -); - -typedef sword (*OCISERVERVERSION) -( - void *hndlp, - OCIError *errhp, - OraText *bufp, - ub4 bufsz, - ub1 hndltype -); - -typedef sword (*OCIBREAK) -( - dvoid *hndlp, - OCIError *errhp -); - -typedef sword (*OCIATTRGET) -( - const void *trgthndlp, - ub4 trghndltyp, - void *attributep, - ub4 *sizep, - ub4 attrtype, - OCIError *errhp -); - -typedef sword (*OCIATTRSET) -( - void *trgthndlp, - ub4 trghndltyp, - void *attributep, - ub4 size, - ub4 attrtype, - OCIError *errhp -); - -typedef sword (*OCIDATEASSIGN) -( - OCIError *err, - CONST OCIDate *from, - OCIDate *to -); - -typedef sword (*OCIDATETOTEXT) -( - OCIError *err, - CONST OCIDate *date, - CONST text *fmt, - ub1 fmt_length, - CONST text *lang_name, - ub4 lang_length, - ub4 *buf_size, - text *buf -); - -typedef sword (*OCIDATEFROMTEXT) -( - OCIError *err, - CONST text *date_str, - ub4 d_str_length, - CONST text *fmt, - ub1 fmt_length, - CONST text *lang_name, - ub4 lang_length, - OCIDate *date -); - -typedef sword (*OCIDATECOMPARE) -( - OCIError *err, - CONST OCIDate *date1, - CONST OCIDate *date2, - sword *result -); - -typedef sword (*OCIDATEADDMONTHS) -( - OCIError *err, - CONST OCIDate *date, - sb4 num_months, - OCIDate *result -); - -typedef sword (*OCIDATEADDDAYS) -( - OCIError *err, - CONST OCIDate *date, - sb4 num_days, - OCIDate *result -); - -typedef sword (*OCIDATELASTDAY) -( - OCIError *err, - CONST OCIDate *date, - OCIDate *last_day -); - -typedef sword (*OCIDATEDAYSBETWEEN) -( - OCIError *err, - CONST OCIDate *date1, - CONST OCIDate *date2, - sb4 *num_days -); - -typedef sword (*OCIDATEZONETOZONE) -( - OCIError *err, - CONST OCIDate *date1, - CONST text *zon1, - ub4 zon1_length, - CONST text *zon2, - ub4 zon2_length, - OCIDate *date2 -); - -typedef sword (*OCIDATENEXTDAY) -( - OCIError *err, - CONST OCIDate *date, - CONST text *day_p, - ub4 day_length, - OCIDate *next_day -); - -typedef sword (*OCIDATECHECK) -( - OCIError *err, - CONST OCIDate *date, - uword *valid -); - -typedef sword (*OCIDATESYSDATE) -( - OCIError *err, - OCIDate *sys_date -); - -typedef sword (*OCIDESCRIBEANY) -( - OCISvcCtx *svchp, - OCIError *errhp, - dvoid *objptr, - ub4 objnm_len, - ub1 objptr_typ, - ub1 info_level, - ub1 objtyp, - OCIDescribe *dschp -); - -typedef sword (*OCIINTERVALASSIGN) -( - dvoid *hndl, - OCIError *err, - CONST OCIInterval *inpinter, - OCIInterval *outinter -); - -typedef sword (*OCIINTERVALCHECK) -( - dvoid *hndl, - OCIError *err, - CONST OCIInterval *interval, - ub4 *valid -); - -typedef sword (*OCIINTERVALCOMPARE) -( - dvoid *hndl, - OCIError *err, - OCIInterval *inter1, - OCIInterval *inter2, - sword *result -); - -typedef sword (*OCIINTERVALTOTEXT) -( - dvoid *hndl, - OCIError *err, - CONST OCIInterval *interval, - ub1 lfprec, - ub1 fsprec, - OraText *buffer, - size_t buflen, - size_t *resultlen -); - -typedef sword (*OCIINTERVALFROMTEXT) -( - dvoid *hndl, - OCIError *err, - CONST OraText *inpstring, - size_t str_len, - OCIInterval *result -); - -typedef sword (*OCIINTERVALFROMTZ) -( - dvoid *hndl, - OCIError *err, - CONST oratext *inpstring, - size_t str_len, - OCIInterval *result -) ; - -typedef sword (*OCIINTERVALGETDAYSECOND) -( - dvoid *hndl, - OCIError *err, - sb4 *dy, - sb4 *hr, - sb4 *mm, - sb4 *ss, - sb4 *fsec, - CONST OCIInterval *interval -); - -typedef sword (*OCIINTERVALGETYEARMONTH) -( - dvoid *hndl, - OCIError *err, - sb4 *yr, - sb4 *mnth, - CONST OCIInterval *interval -); - -typedef sword (*OCIINTERVALSETDAYSECOND) -( - dvoid *hndl, - OCIError *err, - sb4 dy, - sb4 hr, - sb4 mm, - sb4 ss, - sb4 fsec, - OCIInterval *result -); - -typedef sword (*OCIINTERVALSETYEARMONTH) -( - dvoid *hndl, - OCIError *err, - sb4 yr, - sb4 mnth, - OCIInterval *result -); - -typedef sword (*OCIINTERVALADD) -( - dvoid *hndl, - OCIError *err, - OCIInterval *addend1, - OCIInterval *addend2, - OCIInterval *result -); - -typedef sword (*OCIINTERVALSUBTRACT) -( - dvoid *hndl, - OCIError *err, - OCIInterval *minuend, - OCIInterval *subtrahend, - OCIInterval *result -); - -typedef sword (*OCIDATETIMEASSIGN) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *from, - OCIDateTime *to -); - -typedef sword (*OCIDATETIMECHECK) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *date, - ub4 *valid -); - -typedef sword (*OCIDATETIMECOMPARE) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *date1, - CONST OCIDateTime *date2, - sword *result -); - -typedef sword (*OCIDATETIMECONSTRUCT) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *datetime, - sb2 year, - ub1 month, - ub1 day, - ub1 hour, - ub1 min, - ub1 sec, - ub4 fsec, - OraText *timezone, - size_t timezone_length -); - -typedef sword (*OCIDATETIMECONVERT) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *indate, - OCIDateTime *outdate -); - -typedef sword (*OCIDATETIMEFROMARRAY) -( - dvoid *hndl, - OCIError *err, - CONST ub1 *inarray, - ub4 *len, - ub1 type, - OCIDateTime *datetime, - CONST OCIInterval *reftz, - ub1 fsprec -); - -typedef sword (*OCIDATETIMETOARRAY) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *datetime, - CONST OCIInterval *reftz, - ub1 *outarray, - ub4 *len, - ub1 fsprec -); - -typedef sword (*OCIDATETIMEFROMTEXT) -( - dvoid *hndl, - OCIError *err, - CONST OraText *date_str, - size_t dstr_length, - CONST OraText *fmt, - ub1 fmt_length, - CONST OraText *lang_name, - size_t lang_length, - OCIDateTime *datetime -); - -typedef sword (*OCIDATETIMETOTEXT) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *date, - CONST OraText *fmt, - ub1 fmt_length, - ub1 fsprec, - CONST OraText *lang_name, - size_t lang_length, - ub4 *buf_size, - OraText *buf -); - -typedef sword (*OCIDATETIMEGETDATE) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *datetime, - sb2 *year, - ub1 *month, - ub1 *day -); - -typedef sword (*OCIDATETIMEGETTIME) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *datetime, - ub1 *hour, - ub1 *min, - ub1 *sec, - ub4 *fsec -); - -typedef sword (*OCIDATETIMEGETTIMEZONENAME) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *datetime, - ub1 *buf, - ub4 *buflen -); - -typedef sword (*OCIDATETIMEGETTIMEZONEOFFSET) -( - dvoid *hndl, - OCIError *err, - CONST OCIDateTime *datetime, - sb1 *hour, - sb1 *min -); - -typedef sword (*OCIDATETIMEINTERVALADD) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *datetime, - OCIInterval *inter, - OCIDateTime *outdatetime -); - -typedef sword (*OCIDATETIMEINTERVALSUB) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *datetime, - OCIInterval *inter, - OCIDateTime *outdatetime -); - -typedef sword (*OCIDATETIMESUBTRACT) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *indate1, - OCIDateTime *indate2, - OCIInterval *inter -); - -typedef sword (*OCIDATETIMESYSTIMESTAMP) -( - dvoid *hndl, - OCIError *err, - OCIDateTime *sys_date -); - -typedef sword (*OCITYPEBYREF) -( - OCIEnv *env, - OCIError *err, - const OCIRef *type_ref, - OCIDuration pin_duration, - OCITypeGetOpt get_option, - OCIType **tdo -); - -typedef sword (*OCIOBJECTNEW) -( - OCIEnv *env, - OCIError *err, - CONST OCISvcCtx *svc, - OCITypeCode typecode, - OCIType *tdo, - dvoid *table, - OCIDuration duration, - boolean value, - dvoid **instance -); - -typedef sword (*OCIOBJECTFREE) -( - OCIEnv *env, - OCIError *err, - dvoid *instance, - ub2 flags -); - -typedef sword (*OCIOBJECTGETATTR) -( - OCIEnv *env, - OCIError *err, - dvoid *instance, - dvoid *null_struct, - struct OCIType *tdo, - CONST text **names, - CONST ub4 *lengths, - CONST ub4 name_count, - CONST ub4 *indexes, - CONST ub4 index_count, - OCIInd *attr_null_status, - dvoid **attr_null_struct, - dvoid **attr_value, - struct OCIType **attr_tdo -); - -typedef sword (*OCIOBJECTSETATTR) -( - OCIEnv *env, - OCIError *err, - dvoid *instance, - dvoid *null_struct, - struct OCIType *tdo, - CONST text **names, - CONST ub4 *lengths, - CONST ub4 name_count, - CONST ub4 *indexes, - CONST ub4 index_count, - CONST OCIInd null_status, - CONST dvoid *attr_null_struct, - CONST dvoid *attr_value -); - -typedef sword (*OCIOBJECTPIN) -( - OCIEnv *env, - OCIError *err, - OCIRef *object_ref, - OCIComplexObject *corhdl, - OCIPinOpt pin_option, - OCIDuration pin_duration, - OCILockOpt lock_option, - dvoid **object -); - -typedef sword (*OCIOBJECTUNPIN) -( - OCIEnv *env, - OCIError *err, - dvoid *object -); - -typedef sword (*OCIOBJECTCOPY) -( - OCIEnv *env, - OCIError *err, - CONST OCISvcCtx *svc, - dvoid *source, - dvoid *null_source, - dvoid *target, - dvoid *null_target, - OCIType *tdo, - OCIDuration duration, - ub1 option -); - -typedef sword (*OCIOBJECTGETOBJECTREF) -( - OCIEnv *env, - OCIError *err, - dvoid *object, - OCIRef *object_ref -); - -typedef sword (*OCIOBJECTGETPROPERTY) -( - OCIEnv *envh, - OCIError *errh, - const void *obj, - OCIObjectPropId propertyId, - void *property, - ub4 *size -); - -typedef sword (*OCIOBJECTGETIND) -( - OCIEnv *env, - OCIError *err, - dvoid *instance, - dvoid **null_struct -); - -typedef sword (*OCIOBJECTGETTYPEREF) -( - OCIEnv *env, - OCIError *err, - void *instance, - OCIRef *type_ref -); - -typedef sword (*OCIREFASSIGN) -( - OCIEnv *env, - OCIError *err, - CONST OCIRef *source, - OCIRef **target -); - -typedef boolean (*OCIREFISNULL) -( - OCIEnv *env, - CONST OCIRef *ref -); - -typedef void (*OCIREFCLEAR) -( - OCIEnv *env, - OCIRef *ref -); - -typedef sword (*OCIREFTOHEX) -( - OCIEnv *env, - OCIError *err, - CONST OCIRef *ref, - oratext *hex, - ub4 *hex_length -); - -typedef ub4 (*OCIREFHEXSIZE) -( - OCIEnv *env, - const OCIRef *ref -); - -typedef sword (*OCINUMBERTOINT) -( - OCIError *err, - CONST OCINumber *number, - uword rsl_length, - uword rsl_flag, - dvoid *rsl -); - -typedef sword (*OCINUMBERFROMINT) -( - OCIError *err, - CONST dvoid *inum, - uword inum_length, - uword inum_s_flag, - OCINumber *number -); - -typedef sword (*OCINUMBERFROMREAL) -( - OCIError *err, - CONST dvoid *rnum, - uword rnum_length, - OCINumber *number -); - -typedef sword (*OCINUMBERTOREAL) -( - OCIError *err, - CONST OCINumber *number, - uword rsl_length, - dvoid *rsl -); - -typedef sword (*OCINUMBERTOTEXT) -( - OCIError *err, - CONST OCINumber *number, - CONST text *fmt, - ub4 fmt_length, - CONST text *nls_params, - ub4 nls_p_length, - ub4 *buf_size, - text *buf -); - -typedef sword (*OCINUMBERFROMTEXT) -( - OCIError *err, - CONST oratext *str, - ub4 str_length, - CONST oratext *fmt, - ub4 fmt_length, - CONST oratext *nls_params, - ub4 nls_p_length, - OCINumber *number -); - -typedef sword (*OCINUMBERASSIGN) -( - OCIError *err, - CONST OCINumber *from, - OCINumber *to -); - -typedef sword (*OCINUMBERADD) -( - OCIError *err, - const OCINumber *number1, - const OCINumber *number2, - OCINumber *result -); - -typedef sword (*OCINUMBERSUB) -( - OCIError *err, - const OCINumber *number1, - const OCINumber *number2, - OCINumber *result -); - -typedef sword (*OCINUMBERMUL) -( - OCIError *err, - const OCINumber *number1, - const OCINumber *number2, - OCINumber *result -); - -typedef sword (*OCINUMBERDIV) -( - OCIError *err, - const OCINumber *number1, - const OCINumber *number2, - OCINumber *result -); - -typedef sword(*OCINUMBERCMP) -( - OCIError *err, - const OCINumber *number1, - const OCINumber *number2, - sword *result -); - -typedef oratext * (*OCISTRINGPTR) -( - OCIEnv *env, - CONST OCIString *vs -); - -typedef ub4 (*OCISTRINGSIZE) -( - OCIEnv *env, - CONST OCIString *vs -); - -typedef sword (*OCISTRINGASSIGNTEXT) -( - OCIEnv *env, - OCIError *err, - CONST oratext *rhs, - ub4 rhs_len, - OCIString **lhs -); - -typedef sword (*OCISTRINGRESIZE) -( - OCIEnv *env, - OCIError *err, - ub4 new_size, - OCIString **str -); - -typedef ub1 * (*OCIRAWPTR) -( - OCIEnv * env, - CONST OCIRaw *raw -); - -typedef sword (*OCIRAWASSIGNBYTES) -( - OCIEnv *env, - OCIError *err, - CONST ub1 *rhs, - ub4 rhs_len, - OCIRaw **lhs -); - -typedef sword (*OCIRAWRESIZE) -( - OCIEnv *env, - OCIError *err, - ub4 new_size, - OCIRaw **raw -); - -typedef sword (*OCIRAWALLOCSIZE) -( - OCIEnv *env, - OCIError *err, - CONST OCIRaw *raw, - ub4 *allocsize -); - -typedef ub4 (*OCIRAWSIZE) -( - OCIEnv *env, - const OCIRaw *raw -); - -typedef sword (*OCICONNECTIONPOOLCREATE) -( - OCIEnv *envhp, - OCIError *errhp, - OCICPool *poolhp, - OraText **poolName, - sb4 *poolNameLen, - CONST OraText *dblink, - sb4 dblinkLen, - ub4 connMin, - ub4 connMax, - ub4 connIncr, - CONST OraText *poolUserName, - sb4 poolUserLen, - CONST OraText *poolPassword, - sb4 poolPassLen, - ub4 mode -); - -typedef sword (*OCICONNECTIONPOOLDESTROY) -( - OCICPool *poolhp, - OCIError *errhp, - ub4 mode -); - -typedef sword (*OCISESSIONPOOLCREATE) -( - OCIEnv *envhp, - OCIError *errhp, - OCISPool *spoolhp, - OraText **poolName, - ub4 *poolNameLen, - CONST OraText *connStr, - ub4 connStrLen, - ub4 sessMin, - ub4 sessMax, - ub4 sessIncr, - OraText *userid, - ub4 useridLen, - OraText *password, - ub4 passwordLen, - ub4 mode -); - -typedef sword (*OCISESSIONPOOLDESTROY) -( - OCISPool *spoolhp, - OCIError *errhp, - ub4 mode -); - -typedef sword (*OCISESSIONGET) -( - OCIEnv *envhp, - OCIError *errhp, - OCISvcCtx **svchp, - OCIAuthInfo *authhp, - OraText *poolName, - ub4 poolName_len, - CONST OraText *tagInfo, - ub4 tagInfo_len, - OraText **retTagInfo, - ub4 *retTagInfo_len, - boolean *found, - ub4 mode -); - -typedef sword (*OCISESSIONRELEASE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OraText *tag, - ub4 tag_len, - ub4 mode -); - -typedef sword (*OCICOLLSIZE) -( - OCIEnv *env, - OCIError *err, - CONST OCIColl *coll, - sb4 *size -); - -typedef sb4 (*OCICOLLMAX) -( - OCIEnv *env, - CONST OCIColl *coll -); - -typedef sword (*OCICOLLGETITEM) -( - OCIEnv *env, - OCIError *err, - CONST OCIColl *coll, - sb4 index, - boolean *exists, - dvoid **elem, - dvoid **elemind -); - -typedef sword (*OCICOLLASSIGNELEM) -( - OCIEnv *env, - OCIError *err, - sb4 index, - CONST dvoid *elem, - CONST dvoid *elemind, - OCIColl *coll -); - -typedef sword (*OCICOLLASSIGN) -( - OCIEnv *env, - OCIError *err, - CONST OCIColl *rhs, - OCIColl *lhs -); - -typedef sword (*OCICOLLAPPEND) -( - OCIEnv *env, - OCIError *err, - CONST dvoid *elem, - CONST dvoid *elemind, - OCIColl *coll -); - -typedef sword (*OCICOLLTRIM) -( - OCIEnv *env, - OCIError *err, - sb4 trim_num, - OCIColl *coll -); - -typedef sword (*OCITABLESIZE) -( - OCIEnv *env, - OCIError *err, - CONST OCITable *tbl, - sb4 *size -); - -typedef sword (*OCITABLEDELETE) -( - OCIEnv *env, - OCIError *err, - sb4 index, - OCITable *tbl -); - -typedef sword (*OCIITERCREATE) -( - OCIEnv *env, - OCIError *err, - CONST OCIColl *coll, - OCIIter **itr -); - -typedef sword (*OCIITERDELETE) -( - OCIEnv *env, - OCIError *err, - OCIIter **itr -); - -typedef sword (*OCIITERINIT) -( - OCIEnv *env, - OCIError *err, - CONST OCIColl *coll, - OCIIter *itr -); - -typedef sword (*OCIITERNEXT) -( - OCIEnv *env, - OCIError *err, - OCIIter *itr, - void **elem, - dvoid **elemind, - boolean *eoc -); - -typedef sword (*OCIITERPREV) -( - OCIEnv *env, - OCIError *err, - OCIIter *itr, - dvoid **elem, - dvoid **elemind, - boolean *boc -); - -typedef sword (*OCIAQENQ) -( - OCISvcCtx *svchp, - OCIError *errhp, - OraText *queue_name, - OCIAQEnqOptions *enqopt, - OCIAQMsgProperties *msgprop, - OCIType *payload_tdo, - dvoid **payload, - dvoid **payload_ind, - OCIRaw **msgid, - ub4 flags -); - -typedef sword (*OCIAQDEQ) -( - OCISvcCtx *svchp, - OCIError *errhp, - OraText *queue_name, - OCIAQDeqOptions *deqopt, - OCIAQMsgProperties *msgprop, - OCIType *payload_tdo, - dvoid **payload, - dvoid **payload_ind, - OCIRaw **msgid, - ub4 flags -); - -typedef sword (*OCIAQLISTEN) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCIAQAgent **agent_list, - ub4 num_agents, - sb4 wait, - OCIAQAgent **agent, - ub4 flags -); - -typedef OCISvcCtx * (*XAOSVCCTX) -( - OraText *dbname -); - -typedef OCIEnv * (*XAOENV) -( - OraText *dbname -); - -/* API introduced in 8.1 */ - -typedef void (*OCITHREADPROCESSINIT) -( - void -); - -typedef sword (*OCITHREADINIT) -( - dvoid *hndl, - OCIError *err -); - -typedef sword (*OCITHREADTERM) -( - dvoid *hndl, - OCIError *err -); - -typedef sword (*OCITHREADIDINIT) -( - dvoid *hndl, - OCIError *err, - OCIThreadId **tid -); - -typedef sword (*OCITHREADIDDESTROY) -( - dvoid *hndl, - OCIError *err, - OCIThreadId **tid -); - -typedef sword (*OCITHREADHNDINIT) -( - dvoid *hndl, - OCIError *err, - OCIThreadHandle **thnd -); - -typedef sword (*OCITHREADHNDDESTROY) -( - dvoid *hndl, - OCIError *err, - OCIThreadHandle **thnd -); - -typedef sword (*OCITHREADCREATE) -( - dvoid *hndl, - OCIError *err, - void (*start) - ( - dvoid * - ), - dvoid *arg, - OCIThreadId *tid, - OCIThreadHandle *tHnd -); - -typedef sword (*OCITHREADJOIN) -( - dvoid *hndl, - OCIError *err, - OCIThreadHandle *tHnd -); - -typedef sword (*OCITHREADCLOSE) -( - dvoid *hndl, - OCIError *err, - OCIThreadHandle *tHnd -); - -typedef sword (*OCITHREADMUTEXINIT) -( - dvoid *hndl, - OCIError *err, - OCIThreadMutex **mutex -); - -typedef sword (*OCITHREADMUTEXDESTROY) -( - dvoid *hndl, - OCIError *err, - OCIThreadMutex **mutex -); - -typedef sword (*OCITHREADMUTEXACQUIRE) -( - dvoid *hndl, - OCIError *err, - OCIThreadMutex *mutex -); - -typedef sword (*OCITHREADMUTEXRELEASE) -( - dvoid *hndl, - OCIError *err, - OCIThreadMutex *mutex -); - -typedef sword (*OCITHREADKEYINIT) -( - dvoid *hndl, - OCIError *err, - OCIThreadKey **key, - void (*destFn) - ( - void * - ) -); - -typedef sword (*OCITHREADKEYDESTROY) -( - dvoid *hndl, - OCIError *err, - OCIThreadKey **key -); - -typedef sword (*OCITHREADKEYSET) -( - dvoid *hndl, - OCIError *err, - OCIThreadKey *key, - dvoid **pValue -); - -typedef sword (*OCITHREADKEYGET) -( - dvoid *hndl, - OCIError *err, - OCIThreadKey *key, - dvoid *value -); - -typedef sword (*OCIDIRPATHABORT) -( - OCIDirPathCtx *dpctx, - OCIError *errhp -); - -typedef sword (*OCIDIRPATHDATASAVE) -( - OCIDirPathCtx *dpctx, - OCIError *errhp, - ub4 action -); - -typedef sword (*OCIDIRPATHFINISH) -( - OCIDirPathCtx *dpctx, - OCIError *errhp -); - -typedef sword (*OCIDIRPATHPREPARE) -( - OCIDirPathCtx *dpctx, - OCISvcCtx *svchp, - OCIError *errhp -); - -typedef sword (*OCIDIRPATHLOADSTREAM) -( - OCIDirPathCtx *dpctx, - OCIDirPathStream *dpstr, - OCIError *errhp -); - -typedef sword (*OCIDIRPATHCOLARRAYENTRYSET) -( - OCIDirPathColArray *dpca, - OCIError *errhp, - ub4 rownum, - ub2 colIdx, - ub1 *cvalp, - ub4 clen, - ub1 cflg -); - -typedef sword (*OCIDIRPATHCOLARRAYRESET) -( - OCIDirPathColArray *dpca, - OCIError *errhp -); - -typedef sword (*OCIDIRPATHCOLARRAYTOSTREAM) -( - OCIDirPathColArray *dpca, - OCIDirPathCtx *dpctx, - OCIDirPathStream *dpstr, - OCIError *errhp, - ub4 rowcnt, - ub4 rowoff -); - -typedef sword (*OCIDIRPATHSTREAMRESET) -( - OCIDirPathStream *dpstr, - OCIError *errhp -); - -typedef sword (*OCIDIRPATHFLUSHROW) -( - OCIDirPathCtx *dpctx, - OCIError *errhp -); - -typedef sword (*OCICACHEFREE) -( - OCIEnv *env, - OCIError *err, - CONST OCISvcCtx *svc -); - -typedef sword (*OCISUBSCRIPTIONREGISTER) -( - OCISvcCtx *svchp, - OCISubscription **subscrhpp, - ub2 count, - OCIError *errhp, - ub4 mode -); - -typedef sword (*OCISUBSCRIPTIONUNREGISTER) -( - OCISvcCtx *svchp, - OCISubscription *subscrhp, - OCIError *errhp, - ub4 mode -); - -/* API introduced in 9.1 */ - -typedef sword (*OCISTMTFETCH2 ) -( - OCIStmt *stmtp, - OCIError *errhp, - ub4 nrows, - ub2 orientation, - sb4 fetchOffset, - ub4 mode -); - -/* API introduced in 9.2 */ - -typedef sword (*OCISTMTPREPARE2) -( - OCISvcCtx *svchp, - OCIStmt **stmtp, - OCIError *errhp, - CONST OraText *stmt, - ub4 stmt_len, - CONST OraText *key, - ub4 key_len, - ub4 language, - ub4 mode -); - -typedef sword (*OCISTMTRELEASE) -( - OCIStmt *stmtp, - OCIError *errhp, - CONST OraText *key, - ub4 key_len, - ub4 mode -); - -/* API introduced in 10.1 */ - -#ifdef ORAXB8_DEFINED - -typedef sword (*OCILOBGETSTORAGELIMIT) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *lobp, - oraub8 *limitp -); - -typedef sword (*OCILOBCOPY2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *dst_locp, - OCILobLocator *src_locp, - oraub8 amount, - oraub8 dst_offset, - oraub8 src_offset -); - -typedef sword (*OCILOBERASE2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - oraub8 *amount, - oraub8 offset -); - -typedef sword (*OCILOBGETLENGTH2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - oraub8 *lenp -); - -typedef sword (*OCILOBLOADFROMFILE2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *dst_locp, - OCILobLocator *src_filep, - oraub8 amount, - oraub8 dst_offset, - oraub8 src_offset -); - -typedef sword (*OCILOBREAD2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - oraub8 *byte_amtp, - oraub8 *char_amtp, - oraub8 offset, - dvoid *bufp, - oraub8 bufl, - ub1 piece, - dvoid *ctxp, - sb4 (*cbfp) - ( - dvoid *ctxp, - CONST dvoid *bufp, - oraub8 len, - ub1 piece, - dvoid **changed_bufpp, - oraub8 *changed_lenp - ), - ub2 csid, - ub1 csfrm -); - -typedef sword (*OCILOBTRIM2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - oraub8 newlen -); - -typedef sword (*OCILOBWRITE2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *locp, - oraub8 *byte_amtp, - oraub8 *char_amtp, - oraub8 offset, - dvoid *bufp, - oraub8 buflen, - ub1 piece, - dvoid *ctxp, - sb4 (*cbfp) - ( - dvoid *ctxp, - CONST dvoid *bufp, - oraub8 len, - ub1 piece, - dvoid **changed_bufpp, - oraub8 *changed_lenp - ), - ub2 csid, - ub1 csfrm -); - -typedef sword (*OCILOBWRITEAPPEND2) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *lobp, - oraub8 *byte_amtp, - oraub8 *char_amtp, - dvoid *bufp, - oraub8 bufl, - ub1 piece, - dvoid *ctxp, - sb4 (*cbfp) - ( - dvoid *ctxp, - dvoid *bufp, - oraub8 *lenp, - ub1 *piece, - dvoid **changed_bufpp, - oraub8 *changed_lenp - ), - ub2 csid, - ub1 csfrm -); - -#endif /* ORAXB8_DEFINED */ - -/* API introduced in 10.2 */ - -/* Oracle 10g test */ - -typedef void (*OCICLIENTVERSION) -( - sword *major_version, - sword *minor_version, - sword *update_num, - sword *patch_num, - sword *port_update_num -); - -typedef sword (*OCIDBSTARTUP) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCIAdmin *admhp, - ub4 mode, - ub4 flags -); - -typedef sword (*OCIDBSHUTDOWN) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCIAdmin *admhp, - ub4 mode -); - -typedef sword (*OCIPING) -( - OCISvcCtx *svchp, - OCIError *errhp, - ub4 mode -); - -/* API introduced in 11.1 */ - -typedef sword (*OCIARRAYDESCRIPTORALLOC) -( - const void *parenth, - void **descpp, - const ub4 type, - ub4 array_size, - const size_t xtramem_sz, - void **usrmempp -); - -typedef sword (*OCIARRAYDESCRIPTORFREE) -( - void **descp, - const ub4 type -); - -/* API introduced in 11.2 */ - -typedef sword (*OCILOBGETCONTENTTYPE) -( - OCISvcCtx *svchp, - OCIError *errhp, - OCILobLocator *lobp, - oratext *contenttypep, - ub4 *contenttypelenp, - ub4 mode -); - -/* API introduced in 12.1 */ - -typedef sword (*OCISTMTGETNEXTRESULT) -( - OCIStmt *stmthp, - OCIError *errhp, - void **result, - ub4 *rtype, - ub4 mode -); - -/* API introduced in 18.1 */ - -typedef sword(*OCISERVERRELEASE2) -( - void *hndlp, - OCIError *errhp, - OraText *bufp, - ub4 bufsz, - ub1 hndltype, - ub4 *versionp, - ub4 mode -); - -/* API introduced in 18.3 */ - -typedef sword(*OCISODAOPERKEYSSET) -( - const void *operhp, // should be OCISodaOperationOptions - OraText **keysArray, - ub4 *lengthsArray, - ub4 count, - OCIError *errhp, - ub4 mode -); - -#endif /* OCILIB_OCI_API_H_INCLUDED */ - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * IMPORTANT NOTICE + * + * THIS FILE CONTAINS CONSTANTS AND STRUCTURES DECLARATIONS THAT WERE + * PICKED UP FROM ORACLE PUBLIC HEADER FILES. + * + * SO THE CONTENT OF THIS FILE MAY BE UNDER ORACLE COPYRIGHT AND THE + * DECLARATIONS REPRODUCED HERE ARE ORIGINALLY WRITTEN BY ORACLE CORPORATION + * + * THE AUTHOR OF OCILIB LIBRARY HAS NOT WRITTEN THE CONTENT OF THIS + * FILE AND HAS PARTIALLY INTEGRATED SOME ORACLE OCI DEFINITIONS TO + * ALLOW COMPILATION OF THIS OPEN SOURCE LIBRARY WITHOUT HAVING + * ORACLE PRODUCTS INSTALLED ON DEVELOPMENT ENVIRONMENTS + * + */ + +#ifndef OCILIB_OCI_API_H_INCLUDED +#define OCILIB_OCI_API_H_INCLUDED + +#include "defs.h" + +/* ********************************************************************************************* * + * PUBLIC OCI API PROTOTYPES + * ********************************************************************************************* */ + +/* API introduced in 8.0 */ + +typedef sword (*OCIENVCREATE) +( + OCIEnv **envhpp, + ub4 mode, + void *ctxp, + void *(*malocfp)(void *ctxp, size_t size), + void *(*ralocfp)(void *ctxp, void *memptr, size_t newsize), + void (*mfreefp) + ( + void *ctxp, + void *memptr + ), + size_t xtramem_sz, + void **usrmempp +); + +typedef sword (*OCIHANDLEALLOC) +( + const void *parenth, + void **hndlpp, + const ub4 type, + const size_t xtramem_sz, + void **usrmempp +); + +typedef sword (*OCIHANDLEFREE) +( + void *hndlp, + const ub4 type +); + +typedef sword (*OCIDESCRIPTORALLOC) +( + const void *parenth, + void **descpp, + const ub4 type, + const size_t xtramem_sz, + void **usrmempp +); + +typedef sword (*OCIDESCRIPTORFREE) +( + void *descp, + const ub4 type +); + +typedef sword (*OCIENVINIT) +( + OCIEnv **envp, + ub4 mode, + size_t xtramem_sz, + void **usrmempp +); + +typedef sword (*OCISERVERATTACH) +( + OCIServer *srvhp, + OCIError *errhp, + const OraText *dblink, + sb4 dblink_len, + ub4 mode +); + +typedef sword (*OCISERVERDETACH) +( + OCIServer *srvhp, + OCIError *errhp, + ub4 mode +); + +typedef sword (*OCISESSIONBEGIN) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCISession *usrhp, + ub4 credt, + ub4 mode +); + +typedef sword (*OCISESSIONEND) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCISession *usrhp, + ub4 mode +); + +typedef sword (*OCIPASSWORDCHANGE) +( + OCISvcCtx *svchp, + OCIError *errhp, + CONST OraText *user_name, + ub4 usernm_len, + CONST OraText *opasswd, + ub4 opasswd_len, + CONST OraText *npasswd, + ub4 npasswd_len, + ub4 mode +); + +typedef sword (*OCISTMTPREPARE) +( + OCIStmt *stmtp, + OCIError *errhp, + const OraText *stmt, + ub4 stmt_len, + ub4 language, + ub4 mode +); + +typedef sword (*OCIBINDBYPOS) +( + OCIStmt *stmtp, + OCIBind **bindp, + OCIError *errhp, + ub4 position, + void *valuep, + sb4 value_sz, + ub2 dty, + void *indp, + ub2 *alenp, + ub2 *rcodep, + ub4 maxarr_len, + ub4 *curelep, + ub4 mode +); + +typedef sword (*OCIBINDBYNAME) +( + OCIStmt *stmtp, + OCIBind **bindp, + OCIError *errhp, + const OraText *placeholder, + sb4 placeh_len, + void *valuep, + sb4 value_sz, + ub2 dty, + void *indp, + ub2 *alenp, + ub2 *rcodep, + ub4 maxarr_len, + ub4 *curelep, + ub4 mode +); + +typedef sword (*OCIBINDDYNAMIC) +( + OCIBind *bindp, + OCIError *errhp, + dvoid *ictxp, + sb4 (*icbfp) + ( + dvoid *ictxp, + OCIBind *bindp, + ub4 iter, + ub4 index, + dvoid **bufpp, + ub4 *alenp, + ub1 *piecep, + dvoid **indp + ), + dvoid *octxp, + sb4 (*ocbfp) + ( + dvoid *octxp, + OCIBind *bindp, + ub4 iter, + ub4 index, + dvoid **bufpp, + ub4 **alenp, + ub1 *piecep, + dvoid **indp, + ub2 **rcodep + ) +); + +typedef sword (*OCIBINDOBJECT) +( + OCIBind *bindp, + OCIError *errhp, + CONST OCIType *type, + dvoid **pgvpp, + ub4 *pvszsp, + dvoid **indpp, + ub4 *indszp +); + +typedef sword (*OCISTMTGETPIECEINFO) +( + OCIStmt *stmtp, + OCIError *errhp, + void **hndlpp, + ub4 *typep, + ub1 *in_outp, + ub4 *iterp, + ub4 *idxp, + ub1 *piecep +); + +typedef sword (*OCISTMTSETPIECEINFO) +( + void *hndlp, + ub4 type, + OCIError *errhp, + const void *bufp, + ub4 *alenp, + ub1 piece, + const void *indp, + ub2 *rcodep +); + +typedef sword (*OCISTMTEXECUTE) +( + OCISvcCtx *svchp, + OCIStmt *stmtp, + OCIError *errhp, + ub4 iters, + ub4 rowoff, + const OCISnapshot *snap_in, + OCISnapshot *snap_out, + ub4 mode +); + +typedef sword (*OCIDEFINEBYPOS) +( + OCIStmt *stmtp, + OCIDefine **defnp, + OCIError *errhp, + ub4 position, + void *valuep, + sb4 value_sz, + ub2 dty, + void *indp, + ub2 *rlenp, + ub2 *rcodep, + ub4 mode +); + +typedef sword (*OCIDEFINEOBJECT) +( + OCIDefine *defnp, + OCIError *errhp, + CONST OCIType *type, + dvoid **pgvpp, + ub4 *pvszsp, + dvoid **indpp, + ub4 *indszp +); + +typedef sword (*OCISTMTFETCH ) +( + OCIStmt *stmtp, + OCIError *errhp, + ub4 nrows, + ub2 orientation, + ub4 mode +); + +typedef sword (*OCIPARAMGET) +( + const void *hndlp, + ub4 htype, + OCIError *errhp, + void **parmdpp, + ub4 pos +); + +typedef sword (*OCIPARAMSET) +( + void *hdlp, + ub4 htyp, + OCIError *errhp, + const void *dscp, + ub4 dtyp, + ub4 pos +); + +typedef sword (*OCITRANSSTART) +( + OCISvcCtx *svchp, + OCIError *errhp, + uword timeout, + ub4 flags +); + +typedef sword (*OCITRANSDETACH) +( + OCISvcCtx *svchp, + OCIError *errhp, + ub4 flags +); + +typedef sword (*OCITRANSPREPARE) +( + OCISvcCtx *svchp, + OCIError *errhp, + ub4 flags +); + +typedef sword (*OCITRANSFORGET) +( + OCISvcCtx *svchp, + OCIError *errhp, + ub4 flags +); + +typedef sword (*OCITRANSCOMMIT) +( + OCISvcCtx *svchp, + OCIError *errhp, + ub4 flags +); + +typedef sword (*OCITRANSROLLBACK) +( + OCISvcCtx *svchp, + OCIError *errhp, + ub4 flags +); + +typedef sword (*OCIERRORGET) +( + void *hndlp, + ub4 recordno, + OraText *sqlstate, + sb4 *errcodep, + OraText *bufp, + ub4 bufsiz, + ub4 type +); + +typedef sword (*OCILOBCREATETEMPORARY) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub2 csid, + ub1 csfrm, + ub1 lobtype, + boolean cache, + OCIDuration duration +); + +typedef sword (*OCILOBFREETEMPORARY) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp +); + +typedef sword (*OCILOBISTEMPORARY) +( + OCIEnv *envp, + OCIError *errhp, + OCILobLocator *locp, + boolean *is_temporary +); + +typedef sword (*OCILOBAPPEND) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *dst_locp, + OCILobLocator *src_locp +); + +typedef sword (*OCILOBCOPY) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *dst_locp, + OCILobLocator *src_locp, + ub4 amount, + ub4 dst_offset, + ub4 src_offset +); + +typedef sword (*OCILOBREAD) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 *amtp, + ub4 offset, + void *bufp, + ub4 bufl, + void *ctxp, + sb4 (*cbfp) + ( + void *ctxp, + const void *bufp, + ub4 len, + ub1 piece + ), + ub2 csid, + ub1 csfrm +); + +typedef sword (*OCILOBTRIM) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 newlen +); + +typedef sword (*OCILOBERASE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 *amount, + ub4 offset +); + +typedef sword (*OCILOBWRITE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 *amtp, + ub4 offset, + void *bufp, + ub4 buflen, + ub1 piece, + void *ctxp, + sb4 (*cbfp) + ( + void *ctxp, + void *bufp, + ub4 *len, + ub1 *piece + ), + ub2 csid, + ub1 csfrm +); + +typedef sword (*OCILOBGETLENGTH) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 *lenp +); + +typedef sword (*OCILOBGETCHUNKSIZE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 *chunksizep +); + +typedef sword (*OCILOBOPEN) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub1 mode +); + +typedef sword (*OCILOBCLOSE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp +); + +typedef sword (*OCILOBLOCATORASSIGN) +( + OCISvcCtx *svchp, + OCIError *errhp, + CONST OCILobLocator *src_locp, + OCILobLocator **dst_locpp +); + +typedef sword (*OCILOBASSIGN) +( + OCIEnv *envhp, + OCIError *errhp, + CONST OCILobLocator *src_locp, + OCILobLocator **dst_locpp +); + +typedef sword (*OCILOBENABLEBUFFERING) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp +); + +typedef sword (*OCILOBDISABLEBUFFERING) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp +); + +typedef sword (*OCILOBFILEOPEN) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *filep, + ub1 mode +); + +typedef sword (*OCILOBFILECLOSE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *filep +); + +typedef sword (*OCILOBFILECLOSEALL) +( + OCISvcCtx *svchp, + OCIError *errhp +); + +typedef sword (*OCILOBFILEISOPEN) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *filep, + boolean *flag +); + +typedef sword (*OCILOBFILEEXISTS) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *filep, + boolean *flag +); + +typedef sword (*OCILOBFIELGETNAME) +( + OCIEnv *envhp, + OCIError *errhp, + CONST OCILobLocator *filep, + OraText *dir_alias, + ub2 *d_length, + OraText *filename, + ub2 *f_length +); + +typedef sword (*OCILOBFILESETNAME) +( + OCIEnv *envhp, + OCIError *errhp, + OCILobLocator **filepp, + CONST OraText *dir_alias, + ub2 d_length, + CONST OraText *filename, + ub2 f_length +); + +typedef sword (*OCILOBLOADFROMFILE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *dst_locp, + OCILobLocator *src_filep, + ub4 amount, + ub4 dst_offset, + ub4 src_offset +); + +typedef sword (*OCILOBWRITEAPPEND) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *lobp, + ub4 *amtp, + dvoid *bufp, + ub4 bufl, + ub1 piece, + dvoid *ctxp, + sb4 (*cbfp) + ( + void *ctxp, + void *bufp, + ub4 *len, + ub1 *piece + ), + ub2 csid, + ub1 csfrm +); + +typedef sword (*OCILOBISEQUAL) +( + OCIEnv *envhp, + CONST OCILobLocator *x, + CONST OCILobLocator *y, + boolean *is_equal +); + +typedef sword (*OCILOBFLUSHBUFFER) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + ub4 flag +); + +typedef sword (*OCISERVERVERSION) +( + void *hndlp, + OCIError *errhp, + OraText *bufp, + ub4 bufsz, + ub1 hndltype +); + +typedef sword (*OCIBREAK) +( + dvoid *hndlp, + OCIError *errhp +); + +typedef sword (*OCIATTRGET) +( + const void *trgthndlp, + ub4 trghndltyp, + void *attributep, + ub4 *sizep, + ub4 attrtype, + OCIError *errhp +); + +typedef sword (*OCIATTRSET) +( + void *trgthndlp, + ub4 trghndltyp, + void *attributep, + ub4 size, + ub4 attrtype, + OCIError *errhp +); + +typedef sword (*OCIDATEASSIGN) +( + OCIError *err, + CONST OCIDate *from, + OCIDate *to +); + +typedef sword (*OCIDATETOTEXT) +( + OCIError *err, + CONST OCIDate *date, + CONST text *fmt, + ub1 fmt_length, + CONST text *lang_name, + ub4 lang_length, + ub4 *buf_size, + text *buf +); + +typedef sword (*OCIDATEFROMTEXT) +( + OCIError *err, + CONST text *date_str, + ub4 d_str_length, + CONST text *fmt, + ub1 fmt_length, + CONST text *lang_name, + ub4 lang_length, + OCIDate *date +); + +typedef sword (*OCIDATECOMPARE) +( + OCIError *err, + CONST OCIDate *date1, + CONST OCIDate *date2, + sword *result +); + +typedef sword (*OCIDATEADDMONTHS) +( + OCIError *err, + CONST OCIDate *date, + sb4 num_months, + OCIDate *result +); + +typedef sword (*OCIDATEADDDAYS) +( + OCIError *err, + CONST OCIDate *date, + sb4 num_days, + OCIDate *result +); + +typedef sword (*OCIDATELASTDAY) +( + OCIError *err, + CONST OCIDate *date, + OCIDate *last_day +); + +typedef sword (*OCIDATEDAYSBETWEEN) +( + OCIError *err, + CONST OCIDate *date1, + CONST OCIDate *date2, + sb4 *num_days +); + +typedef sword (*OCIDATEZONETOZONE) +( + OCIError *err, + CONST OCIDate *date1, + CONST text *zon1, + ub4 zon1_length, + CONST text *zon2, + ub4 zon2_length, + OCIDate *date2 +); + +typedef sword (*OCIDATENEXTDAY) +( + OCIError *err, + CONST OCIDate *date, + CONST text *day_p, + ub4 day_length, + OCIDate *next_day +); + +typedef sword (*OCIDATECHECK) +( + OCIError *err, + CONST OCIDate *date, + uword *valid +); + +typedef sword (*OCIDATESYSDATE) +( + OCIError *err, + OCIDate *sys_date +); + +typedef sword (*OCIDESCRIBEANY) +( + OCISvcCtx *svchp, + OCIError *errhp, + dvoid *objptr, + ub4 objnm_len, + ub1 objptr_typ, + ub1 info_level, + ub1 objtyp, + OCIDescribe *dschp +); + +typedef sword (*OCIINTERVALASSIGN) +( + dvoid *hndl, + OCIError *err, + CONST OCIInterval *inpinter, + OCIInterval *outinter +); + +typedef sword (*OCIINTERVALCHECK) +( + dvoid *hndl, + OCIError *err, + CONST OCIInterval *interval, + ub4 *valid +); + +typedef sword (*OCIINTERVALCOMPARE) +( + dvoid *hndl, + OCIError *err, + OCIInterval *inter1, + OCIInterval *inter2, + sword *result +); + +typedef sword (*OCIINTERVALTOTEXT) +( + dvoid *hndl, + OCIError *err, + CONST OCIInterval *interval, + ub1 lfprec, + ub1 fsprec, + OraText *buffer, + size_t buflen, + size_t *resultlen +); + +typedef sword (*OCIINTERVALFROMTEXT) +( + dvoid *hndl, + OCIError *err, + CONST OraText *inpstring, + size_t str_len, + OCIInterval *result +); + +typedef sword (*OCIINTERVALFROMTZ) +( + dvoid *hndl, + OCIError *err, + CONST oratext *inpstring, + size_t str_len, + OCIInterval *result +) ; + +typedef sword (*OCIINTERVALGETDAYSECOND) +( + dvoid *hndl, + OCIError *err, + sb4 *dy, + sb4 *hr, + sb4 *mm, + sb4 *ss, + sb4 *fsec, + CONST OCIInterval *interval +); + +typedef sword (*OCIINTERVALGETYEARMONTH) +( + dvoid *hndl, + OCIError *err, + sb4 *yr, + sb4 *mnth, + CONST OCIInterval *interval +); + +typedef sword (*OCIINTERVALSETDAYSECOND) +( + dvoid *hndl, + OCIError *err, + sb4 dy, + sb4 hr, + sb4 mm, + sb4 ss, + sb4 fsec, + OCIInterval *result +); + +typedef sword (*OCIINTERVALSETYEARMONTH) +( + dvoid *hndl, + OCIError *err, + sb4 yr, + sb4 mnth, + OCIInterval *result +); + +typedef sword (*OCIINTERVALADD) +( + dvoid *hndl, + OCIError *err, + OCIInterval *addend1, + OCIInterval *addend2, + OCIInterval *result +); + +typedef sword (*OCIINTERVALSUBTRACT) +( + dvoid *hndl, + OCIError *err, + OCIInterval *minuend, + OCIInterval *subtrahend, + OCIInterval *result +); + +typedef sword (*OCIDATETIMEASSIGN) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *from, + OCIDateTime *to +); + +typedef sword (*OCIDATETIMECHECK) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *date, + ub4 *valid +); + +typedef sword (*OCIDATETIMECOMPARE) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *date1, + CONST OCIDateTime *date2, + sword *result +); + +typedef sword (*OCIDATETIMECONSTRUCT) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *datetime, + sb2 year, + ub1 month, + ub1 day, + ub1 hour, + ub1 min, + ub1 sec, + ub4 fsec, + OraText *timezone, + size_t timezone_length +); + +typedef sword (*OCIDATETIMECONVERT) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *indate, + OCIDateTime *outdate +); + +typedef sword (*OCIDATETIMEFROMARRAY) +( + dvoid *hndl, + OCIError *err, + CONST ub1 *inarray, + ub4 *len, + ub1 type, + OCIDateTime *datetime, + CONST OCIInterval *reftz, + ub1 fsprec +); + +typedef sword (*OCIDATETIMETOARRAY) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *datetime, + CONST OCIInterval *reftz, + ub1 *outarray, + ub4 *len, + ub1 fsprec +); + +typedef sword (*OCIDATETIMEFROMTEXT) +( + dvoid *hndl, + OCIError *err, + CONST OraText *date_str, + size_t dstr_length, + CONST OraText *fmt, + ub1 fmt_length, + CONST OraText *lang_name, + size_t lang_length, + OCIDateTime *datetime +); + +typedef sword (*OCIDATETIMETOTEXT) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *date, + CONST OraText *fmt, + ub1 fmt_length, + ub1 fsprec, + CONST OraText *lang_name, + size_t lang_length, + ub4 *buf_size, + OraText *buf +); + +typedef sword (*OCIDATETIMEGETDATE) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *datetime, + sb2 *year, + ub1 *month, + ub1 *day +); + +typedef sword (*OCIDATETIMEGETTIME) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *datetime, + ub1 *hour, + ub1 *min, + ub1 *sec, + ub4 *fsec +); + +typedef sword (*OCIDATETIMEGETTIMEZONENAME) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *datetime, + ub1 *buf, + ub4 *buflen +); + +typedef sword (*OCIDATETIMEGETTIMEZONEOFFSET) +( + dvoid *hndl, + OCIError *err, + CONST OCIDateTime *datetime, + sb1 *hour, + sb1 *min +); + +typedef sword (*OCIDATETIMEINTERVALADD) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *datetime, + OCIInterval *inter, + OCIDateTime *outdatetime +); + +typedef sword (*OCIDATETIMEINTERVALSUB) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *datetime, + OCIInterval *inter, + OCIDateTime *outdatetime +); + +typedef sword (*OCIDATETIMESUBTRACT) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *indate1, + OCIDateTime *indate2, + OCIInterval *inter +); + +typedef sword (*OCIDATETIMESYSTIMESTAMP) +( + dvoid *hndl, + OCIError *err, + OCIDateTime *sys_date +); + +typedef sword (*OCITYPEBYREF) +( + OCIEnv *env, + OCIError *err, + const OCIRef *type_ref, + OCIDuration pin_duration, + OCITypeGetOpt get_option, + OCIType **tdo +); + +typedef sword (*OCIOBJECTNEW) +( + OCIEnv *env, + OCIError *err, + CONST OCISvcCtx *svc, + OCITypeCode typecode, + OCIType *tdo, + dvoid *table, + OCIDuration duration, + boolean value, + dvoid **instance +); + +typedef sword (*OCIOBJECTFREE) +( + OCIEnv *env, + OCIError *err, + dvoid *instance, + ub2 flags +); + +typedef sword (*OCIOBJECTGETATTR) +( + OCIEnv *env, + OCIError *err, + dvoid *instance, + dvoid *null_struct, + struct OCIType *tdo, + CONST text **names, + CONST ub4 *lengths, + CONST ub4 name_count, + CONST ub4 *indexes, + CONST ub4 index_count, + OCIInd *attr_null_status, + dvoid **attr_null_struct, + dvoid **attr_value, + struct OCIType **attr_tdo +); + +typedef sword (*OCIOBJECTSETATTR) +( + OCIEnv *env, + OCIError *err, + dvoid *instance, + dvoid *null_struct, + struct OCIType *tdo, + CONST text **names, + CONST ub4 *lengths, + CONST ub4 name_count, + CONST ub4 *indexes, + CONST ub4 index_count, + CONST OCIInd null_status, + CONST dvoid *attr_null_struct, + CONST dvoid *attr_value +); + +typedef sword (*OCIOBJECTPIN) +( + OCIEnv *env, + OCIError *err, + OCIRef *object_ref, + OCIComplexObject *corhdl, + OCIPinOpt pin_option, + OCIDuration pin_duration, + OCILockOpt lock_option, + dvoid **object +); + +typedef sword (*OCIOBJECTUNPIN) +( + OCIEnv *env, + OCIError *err, + dvoid *object +); + +typedef sword (*OCIOBJECTCOPY) +( + OCIEnv *env, + OCIError *err, + CONST OCISvcCtx *svc, + dvoid *source, + dvoid *null_source, + dvoid *target, + dvoid *null_target, + OCIType *tdo, + OCIDuration duration, + ub1 option +); + +typedef sword (*OCIOBJECTGETOBJECTREF) +( + OCIEnv *env, + OCIError *err, + dvoid *object, + OCIRef *object_ref +); + +typedef sword (*OCIOBJECTGETPROPERTY) +( + OCIEnv *envh, + OCIError *errh, + const void *obj, + OCIObjectPropId propertyId, + void *property, + ub4 *size +); + +typedef sword (*OCIOBJECTGETIND) +( + OCIEnv *env, + OCIError *err, + dvoid *instance, + dvoid **null_struct +); + +typedef sword (*OCIOBJECTGETTYPEREF) +( + OCIEnv *env, + OCIError *err, + void *instance, + OCIRef *type_ref +); + +typedef sword (*OCIREFASSIGN) +( + OCIEnv *env, + OCIError *err, + CONST OCIRef *source, + OCIRef **target +); + +typedef boolean (*OCIREFISNULL) +( + OCIEnv *env, + CONST OCIRef *ref +); + +typedef void (*OCIREFCLEAR) +( + OCIEnv *env, + OCIRef *ref +); + +typedef sword (*OCIREFTOHEX) +( + OCIEnv *env, + OCIError *err, + CONST OCIRef *ref, + oratext *hex, + ub4 *hex_length +); + +typedef ub4 (*OCIREFHEXSIZE) +( + OCIEnv *env, + const OCIRef *ref +); + +typedef sword (*OCINUMBERTOINT) +( + OCIError *err, + CONST OCINumber *number, + uword rsl_length, + uword rsl_flag, + dvoid *rsl +); + +typedef sword (*OCINUMBERFROMINT) +( + OCIError *err, + CONST dvoid *inum, + uword inum_length, + uword inum_s_flag, + OCINumber *number +); + +typedef sword (*OCINUMBERFROMREAL) +( + OCIError *err, + CONST dvoid *rnum, + uword rnum_length, + OCINumber *number +); + +typedef sword (*OCINUMBERTOREAL) +( + OCIError *err, + CONST OCINumber *number, + uword rsl_length, + dvoid *rsl +); + +typedef sword (*OCINUMBERTOTEXT) +( + OCIError *err, + CONST OCINumber *number, + CONST text *fmt, + ub4 fmt_length, + CONST text *nls_params, + ub4 nls_p_length, + ub4 *buf_size, + text *buf +); + +typedef sword (*OCINUMBERFROMTEXT) +( + OCIError *err, + CONST oratext *str, + ub4 str_length, + CONST oratext *fmt, + ub4 fmt_length, + CONST oratext *nls_params, + ub4 nls_p_length, + OCINumber *number +); + +typedef sword (*OCINUMBERASSIGN) +( + OCIError *err, + CONST OCINumber *from, + OCINumber *to +); + +typedef sword (*OCINUMBERADD) +( + OCIError *err, + const OCINumber *number1, + const OCINumber *number2, + OCINumber *result +); + +typedef sword (*OCINUMBERSUB) +( + OCIError *err, + const OCINumber *number1, + const OCINumber *number2, + OCINumber *result +); + +typedef sword (*OCINUMBERMUL) +( + OCIError *err, + const OCINumber *number1, + const OCINumber *number2, + OCINumber *result +); + +typedef sword (*OCINUMBERDIV) +( + OCIError *err, + const OCINumber *number1, + const OCINumber *number2, + OCINumber *result +); + +typedef sword(*OCINUMBERCMP) +( + OCIError *err, + const OCINumber *number1, + const OCINumber *number2, + sword *result +); + +typedef oratext * (*OCISTRINGPTR) +( + OCIEnv *env, + CONST OCIString *vs +); + +typedef ub4 (*OCISTRINGSIZE) +( + OCIEnv *env, + CONST OCIString *vs +); + +typedef sword (*OCISTRINGASSIGNTEXT) +( + OCIEnv *env, + OCIError *err, + CONST oratext *rhs, + ub4 rhs_len, + OCIString **lhs +); + +typedef sword (*OCISTRINGRESIZE) +( + OCIEnv *env, + OCIError *err, + ub4 new_size, + OCIString **str +); + +typedef ub1 * (*OCIRAWPTR) +( + OCIEnv * env, + CONST OCIRaw *raw +); + +typedef sword (*OCIRAWASSIGNBYTES) +( + OCIEnv *env, + OCIError *err, + CONST ub1 *rhs, + ub4 rhs_len, + OCIRaw **lhs +); + +typedef sword (*OCIRAWRESIZE) +( + OCIEnv *env, + OCIError *err, + ub4 new_size, + OCIRaw **raw +); + +typedef sword (*OCIRAWALLOCSIZE) +( + OCIEnv *env, + OCIError *err, + CONST OCIRaw *raw, + ub4 *allocsize +); + +typedef ub4 (*OCIRAWSIZE) +( + OCIEnv *env, + const OCIRaw *raw +); + +typedef sword (*OCICONNECTIONPOOLCREATE) +( + OCIEnv *envhp, + OCIError *errhp, + OCICPool *poolhp, + OraText **poolName, + sb4 *poolNameLen, + CONST OraText *dblink, + sb4 dblinkLen, + ub4 connMin, + ub4 connMax, + ub4 connIncr, + CONST OraText *poolUserName, + sb4 poolUserLen, + CONST OraText *poolPassword, + sb4 poolPassLen, + ub4 mode +); + +typedef sword (*OCICONNECTIONPOOLDESTROY) +( + OCICPool *poolhp, + OCIError *errhp, + ub4 mode +); + +typedef sword (*OCISESSIONPOOLCREATE) +( + OCIEnv *envhp, + OCIError *errhp, + OCISPool *spoolhp, + OraText **poolName, + ub4 *poolNameLen, + CONST OraText *connStr, + ub4 connStrLen, + ub4 sessMin, + ub4 sessMax, + ub4 sessIncr, + OraText *userid, + ub4 useridLen, + OraText *password, + ub4 passwordLen, + ub4 mode +); + +typedef sword (*OCISESSIONPOOLDESTROY) +( + OCISPool *spoolhp, + OCIError *errhp, + ub4 mode +); + +typedef sword (*OCISESSIONGET) +( + OCIEnv *envhp, + OCIError *errhp, + OCISvcCtx **svchp, + OCIAuthInfo *authhp, + OraText *poolName, + ub4 poolName_len, + CONST OraText *tagInfo, + ub4 tagInfo_len, + OraText **retTagInfo, + ub4 *retTagInfo_len, + boolean *found, + ub4 mode +); + +typedef sword (*OCISESSIONRELEASE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OraText *tag, + ub4 tag_len, + ub4 mode +); + +typedef sword (*OCICOLLSIZE) +( + OCIEnv *env, + OCIError *err, + CONST OCIColl *coll, + sb4 *size +); + +typedef sb4 (*OCICOLLMAX) +( + OCIEnv *env, + CONST OCIColl *coll +); + +typedef sword (*OCICOLLGETITEM) +( + OCIEnv *env, + OCIError *err, + CONST OCIColl *coll, + sb4 index, + boolean *exists, + dvoid **elem, + dvoid **elemind +); + +typedef sword (*OCICOLLASSIGNELEM) +( + OCIEnv *env, + OCIError *err, + sb4 index, + CONST dvoid *elem, + CONST dvoid *elemind, + OCIColl *coll +); + +typedef sword (*OCICOLLASSIGN) +( + OCIEnv *env, + OCIError *err, + CONST OCIColl *rhs, + OCIColl *lhs +); + +typedef sword (*OCICOLLAPPEND) +( + OCIEnv *env, + OCIError *err, + CONST dvoid *elem, + CONST dvoid *elemind, + OCIColl *coll +); + +typedef sword (*OCICOLLTRIM) +( + OCIEnv *env, + OCIError *err, + sb4 trim_num, + OCIColl *coll +); + +typedef sword (*OCITABLESIZE) +( + OCIEnv *env, + OCIError *err, + CONST OCITable *tbl, + sb4 *size +); + +typedef sword (*OCITABLEDELETE) +( + OCIEnv *env, + OCIError *err, + sb4 index, + OCITable *tbl +); + +typedef sword (*OCIITERCREATE) +( + OCIEnv *env, + OCIError *err, + CONST OCIColl *coll, + OCIIter **itr +); + +typedef sword (*OCIITERDELETE) +( + OCIEnv *env, + OCIError *err, + OCIIter **itr +); + +typedef sword (*OCIITERINIT) +( + OCIEnv *env, + OCIError *err, + CONST OCIColl *coll, + OCIIter *itr +); + +typedef sword (*OCIITERNEXT) +( + OCIEnv *env, + OCIError *err, + OCIIter *itr, + void **elem, + dvoid **elemind, + boolean *eoc +); + +typedef sword (*OCIITERPREV) +( + OCIEnv *env, + OCIError *err, + OCIIter *itr, + dvoid **elem, + dvoid **elemind, + boolean *boc +); + +typedef sword (*OCIAQENQ) +( + OCISvcCtx *svchp, + OCIError *errhp, + OraText *queue_name, + OCIAQEnqOptions *enqopt, + OCIAQMsgProperties *msgprop, + OCIType *payload_tdo, + dvoid **payload, + dvoid **payload_ind, + OCIRaw **msgid, + ub4 flags +); + +typedef sword (*OCIAQDEQ) +( + OCISvcCtx *svchp, + OCIError *errhp, + OraText *queue_name, + OCIAQDeqOptions *deqopt, + OCIAQMsgProperties *msgprop, + OCIType *payload_tdo, + dvoid **payload, + dvoid **payload_ind, + OCIRaw **msgid, + ub4 flags +); + +typedef sword (*OCIAQLISTEN) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCIAQAgent **agent_list, + ub4 num_agents, + sb4 wait, + OCIAQAgent **agent, + ub4 flags +); + +typedef OCISvcCtx * (*XAOSVCCTX) +( + OraText *dbname +); + +typedef OCIEnv * (*XAOENV) +( + OraText *dbname +); + +/* API introduced in 8.1 */ + +typedef void (*OCITHREADPROCESSINIT) +( + void +); + +typedef sword (*OCITHREADINIT) +( + dvoid *hndl, + OCIError *err +); + +typedef sword (*OCITHREADTERM) +( + dvoid *hndl, + OCIError *err +); + +typedef sword (*OCITHREADIDINIT) +( + dvoid *hndl, + OCIError *err, + OCIThreadId **tid +); + +typedef sword (*OCITHREADIDDESTROY) +( + dvoid *hndl, + OCIError *err, + OCIThreadId **tid +); + +typedef sword (*OCITHREADHNDINIT) +( + dvoid *hndl, + OCIError *err, + OCIThreadHandle **thnd +); + +typedef sword (*OCITHREADHNDDESTROY) +( + dvoid *hndl, + OCIError *err, + OCIThreadHandle **thnd +); + +typedef sword (*OCITHREADCREATE) +( + dvoid *hndl, + OCIError *err, + void (*start) + ( + dvoid * + ), + dvoid *arg, + OCIThreadId *tid, + OCIThreadHandle *tHnd +); + +typedef sword (*OCITHREADJOIN) +( + dvoid *hndl, + OCIError *err, + OCIThreadHandle *tHnd +); + +typedef sword (*OCITHREADCLOSE) +( + dvoid *hndl, + OCIError *err, + OCIThreadHandle *tHnd +); + +typedef sword (*OCITHREADMUTEXINIT) +( + dvoid *hndl, + OCIError *err, + OCIThreadMutex **mutex +); + +typedef sword (*OCITHREADMUTEXDESTROY) +( + dvoid *hndl, + OCIError *err, + OCIThreadMutex **mutex +); + +typedef sword (*OCITHREADMUTEXACQUIRE) +( + dvoid *hndl, + OCIError *err, + OCIThreadMutex *mutex +); + +typedef sword (*OCITHREADMUTEXRELEASE) +( + dvoid *hndl, + OCIError *err, + OCIThreadMutex *mutex +); + +typedef sword (*OCITHREADKEYINIT) +( + dvoid *hndl, + OCIError *err, + OCIThreadKey **key, + void (*destFn) + ( + void * + ) +); + +typedef sword (*OCITHREADKEYDESTROY) +( + dvoid *hndl, + OCIError *err, + OCIThreadKey **key +); + +typedef sword (*OCITHREADKEYSET) +( + dvoid *hndl, + OCIError *err, + OCIThreadKey *key, + dvoid **pValue +); + +typedef sword (*OCITHREADKEYGET) +( + dvoid *hndl, + OCIError *err, + OCIThreadKey *key, + dvoid *value +); + +typedef sword (*OCIDIRPATHABORT) +( + OCIDirPathCtx *dpctx, + OCIError *errhp +); + +typedef sword (*OCIDIRPATHDATASAVE) +( + OCIDirPathCtx *dpctx, + OCIError *errhp, + ub4 action +); + +typedef sword (*OCIDIRPATHFINISH) +( + OCIDirPathCtx *dpctx, + OCIError *errhp +); + +typedef sword (*OCIDIRPATHPREPARE) +( + OCIDirPathCtx *dpctx, + OCISvcCtx *svchp, + OCIError *errhp +); + +typedef sword (*OCIDIRPATHLOADSTREAM) +( + OCIDirPathCtx *dpctx, + OCIDirPathStream *dpstr, + OCIError *errhp +); + +typedef sword (*OCIDIRPATHCOLARRAYENTRYSET) +( + OCIDirPathColArray *dpca, + OCIError *errhp, + ub4 rownum, + ub2 colIdx, + ub1 *cvalp, + ub4 clen, + ub1 cflg +); + +typedef sword (*OCIDIRPATHCOLARRAYRESET) +( + OCIDirPathColArray *dpca, + OCIError *errhp +); + +typedef sword (*OCIDIRPATHCOLARRAYTOSTREAM) +( + OCIDirPathColArray *dpca, + OCIDirPathCtx *dpctx, + OCIDirPathStream *dpstr, + OCIError *errhp, + ub4 rowcnt, + ub4 rowoff +); + +typedef sword (*OCIDIRPATHSTREAMRESET) +( + OCIDirPathStream *dpstr, + OCIError *errhp +); + +typedef sword (*OCIDIRPATHFLUSHROW) +( + OCIDirPathCtx *dpctx, + OCIError *errhp +); + +typedef sword (*OCICACHEFREE) +( + OCIEnv *env, + OCIError *err, + CONST OCISvcCtx *svc +); + +typedef sword (*OCISUBSCRIPTIONREGISTER) +( + OCISvcCtx *svchp, + OCISubscription **subscrhpp, + ub2 count, + OCIError *errhp, + ub4 mode +); + +typedef sword (*OCISUBSCRIPTIONUNREGISTER) +( + OCISvcCtx *svchp, + OCISubscription *subscrhp, + OCIError *errhp, + ub4 mode +); + +/* API introduced in 9.1 */ + +typedef sword (*OCISTMTFETCH2 ) +( + OCIStmt *stmtp, + OCIError *errhp, + ub4 nrows, + ub2 orientation, + sb4 fetchOffset, + ub4 mode +); + +/* API introduced in 9.2 */ + +typedef sword (*OCISTMTPREPARE2) +( + OCISvcCtx *svchp, + OCIStmt **stmtp, + OCIError *errhp, + CONST OraText *stmt, + ub4 stmt_len, + CONST OraText *key, + ub4 key_len, + ub4 language, + ub4 mode +); + +typedef sword (*OCISTMTRELEASE) +( + OCIStmt *stmtp, + OCIError *errhp, + CONST OraText *key, + ub4 key_len, + ub4 mode +); + +/* API introduced in 10.1 */ + +#ifdef ORAXB8_DEFINED + +typedef sword (*OCILOBGETSTORAGELIMIT) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *lobp, + oraub8 *limitp +); + +typedef sword (*OCILOBCOPY2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *dst_locp, + OCILobLocator *src_locp, + oraub8 amount, + oraub8 dst_offset, + oraub8 src_offset +); + +typedef sword (*OCILOBERASE2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + oraub8 *amount, + oraub8 offset +); + +typedef sword (*OCILOBGETLENGTH2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + oraub8 *lenp +); + +typedef sword (*OCILOBLOADFROMFILE2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *dst_locp, + OCILobLocator *src_filep, + oraub8 amount, + oraub8 dst_offset, + oraub8 src_offset +); + +typedef sword (*OCILOBREAD2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + oraub8 *byte_amtp, + oraub8 *char_amtp, + oraub8 offset, + dvoid *bufp, + oraub8 bufl, + ub1 piece, + dvoid *ctxp, + sb4 (*cbfp) + ( + dvoid *ctxp, + CONST dvoid *bufp, + oraub8 len, + ub1 piece, + dvoid **changed_bufpp, + oraub8 *changed_lenp + ), + ub2 csid, + ub1 csfrm +); + +typedef sword (*OCILOBTRIM2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + oraub8 newlen +); + +typedef sword (*OCILOBWRITE2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *locp, + oraub8 *byte_amtp, + oraub8 *char_amtp, + oraub8 offset, + dvoid *bufp, + oraub8 buflen, + ub1 piece, + dvoid *ctxp, + sb4 (*cbfp) + ( + dvoid *ctxp, + CONST dvoid *bufp, + oraub8 len, + ub1 piece, + dvoid **changed_bufpp, + oraub8 *changed_lenp + ), + ub2 csid, + ub1 csfrm +); + +typedef sword (*OCILOBWRITEAPPEND2) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *lobp, + oraub8 *byte_amtp, + oraub8 *char_amtp, + dvoid *bufp, + oraub8 bufl, + ub1 piece, + dvoid *ctxp, + sb4 (*cbfp) + ( + dvoid *ctxp, + dvoid *bufp, + oraub8 *lenp, + ub1 *piece, + dvoid **changed_bufpp, + oraub8 *changed_lenp + ), + ub2 csid, + ub1 csfrm +); + +#endif /* ORAXB8_DEFINED */ + +/* API introduced in 10.2 */ + +/* Oracle 10g test */ + +typedef void (*OCICLIENTVERSION) +( + sword *major_version, + sword *minor_version, + sword *update_num, + sword *patch_num, + sword *port_update_num +); + +typedef sword (*OCIDBSTARTUP) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCIAdmin *admhp, + ub4 mode, + ub4 flags +); + +typedef sword (*OCIDBSHUTDOWN) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCIAdmin *admhp, + ub4 mode +); + +typedef sword (*OCIPING) +( + OCISvcCtx *svchp, + OCIError *errhp, + ub4 mode +); + +/* API introduced in 11.1 */ + +typedef sword (*OCIARRAYDESCRIPTORALLOC) +( + const void *parenth, + void **descpp, + const ub4 type, + ub4 array_size, + const size_t xtramem_sz, + void **usrmempp +); + +typedef sword (*OCIARRAYDESCRIPTORFREE) +( + void **descp, + const ub4 type +); + +/* API introduced in 11.2 */ + +typedef sword (*OCILOBGETCONTENTTYPE) +( + OCISvcCtx *svchp, + OCIError *errhp, + OCILobLocator *lobp, + oratext *contenttypep, + ub4 *contenttypelenp, + ub4 mode +); + +/* API introduced in 12.1 */ + +typedef sword (*OCISTMTGETNEXTRESULT) +( + OCIStmt *stmthp, + OCIError *errhp, + void **result, + ub4 *rtype, + ub4 mode +); + +/* API introduced in 18.1 */ + +typedef sword(*OCISERVERRELEASE2) +( + void *hndlp, + OCIError *errhp, + OraText *bufp, + ub4 bufsz, + ub1 hndltype, + ub4 *versionp, + ub4 mode +); + +/* API introduced in 18.3 */ + +typedef sword(*OCISODAOPERKEYSSET) +( + const void *operhp, // should be OCISodaOperationOptions + OraText **keysArray, + ub4 *lengthsArray, + ub4 count, + OCIError *errhp, + ub4 mode +); + +#endif /* OCILIB_OCI_API_H_INCLUDED */ + diff --git a/src/oci_defs.h b/src/oci/defs.h similarity index 98% rename from src/oci_defs.h rename to src/oci/defs.h index c2c004cd..6bbb3c6f 100644 --- a/src/oci_defs.h +++ b/src/oci/defs.h @@ -1,1063 +1,1063 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * IMPORTANT NOTICE - * - * THIS FILE CONTAINS CONSTANTS AND STRUCTURES DECLARATIONS THAT WERE - * PICKED UP FROM ORACLE PUBLIC HEADER FILES. - * - * SO THE CONTENT OF THIS FILE MAY BE UNDER ORACLE COPYRIGHT AND THE - * DECLARATIONS REPRODUCED HERE ARE ORIGINALLY WRITTEN BY ORACLE CORPORATION - * - * THE AUTHOR OF OCILIB LIBRARY HAS NOT WRITTEN THE CONTENT OF THIS - * FILE AND HAS PARTIALLY INTEGRATED SOME ORACLE OCI DEFINITIONS TO - * ALLOW COMPILATION OF THIS OPEN SOURCE LIBRARY WITHOUT HAVING - * ORACLE PRODUCTS INSTALLED ON DEVELOPMENT ENVIRONMENTS - * - */ - -#ifndef OCILIB_OCI_DEFS_H_INCLUDED -#define OCILIB_OCI_DEFS_H_INCLUDED - -#include "oci_types.h" - -/*--------------------------------------------------------------------------- - PUBLIC TYPES AND CONSTANTS - ---------------------------------------------------------------------------*/ - -/* input data types */ - -#define SQLT_CHR 1 /* (ORANET TYPE) character string */ -#define SQLT_NUM 2 /* (ORANET TYPE) oracle numeric */ -#define SQLT_INT 3 /* (ORANET TYPE) integer */ -#define SQLT_FLT 4 /* (ORANET TYPE) Floating point number */ -#define SQLT_STR 5 /* zero terminated string */ -#define SQLT_VNU 6 /* NUM with preceding length byte */ -#define SQLT_PDN 7 /* (ORANET TYPE) Packed Decimal Numeric */ -#define SQLT_LNG 8 /* long */ -#define SQLT_VCS 9 /* Variable character string */ -#define SQLT_NON 10 /* Null/empty PCC Descriptor entry */ -#define SQLT_RID 11 /* rowid */ -#define SQLT_DAT 12 /* date in oracle format */ -#define SQLT_VBI 15 /* binary in VCS format */ -#define SQLT_BFLOAT 21 /* Native Binary float*/ -#define SQLT_BDOUBLE 22 /* Native binary double */ -#define SQLT_BIN 23 /* binary data(DTYBIN) */ -#define SQLT_LBI 24 /* long binary */ -#define SQLT_UIN 68 /* unsigned integer */ -#define SQLT_SLS 91 /* Display sign leading separate */ -#define SQLT_LVC 94 /* Longer longs (char) */ -#define SQLT_LVB 95 /* Longer long binary */ -#define SQLT_AFC 96 /* Ansi fixed char */ -#define SQLT_AVC 97 /* Ansi Var char */ -#define SQLT_IBFLOAT 100 /* binary float canonical */ -#define SQLT_IBDOUBLE 101 /* binary double canonical */ -#define SQLT_CUR 102 /* cursor type */ -#define SQLT_RDD 104 /* rowid descriptor */ -#define SQLT_LAB 105 /* label type */ -#define SQLT_OSL 106 /* oslabel type */ - -#define SQLT_NTY 108 /* named object type */ -#define SQLT_REF 110 /* ref type */ -#define SQLT_CLOB 112 /* character lob */ -#define SQLT_BLOB 113 /* binary lob */ -#define SQLT_BFILEE 114 /* binary file lob */ -#define SQLT_CFILEE 115 /* character file lob */ -#define SQLT_RSET 116 /* result set type */ -#define SQLT_NCO 122 /* named collection type (varray or nested table) */ -#define SQLT_VST 155 /* OCIString type */ -#define SQLT_ODT 156 /* OCIDate type */ - -/* datetimes and intervals */ -#define SQLT_DATE 184 /* ANSI Date */ -#define SQLT_TIME 185 /* TIME */ -#define SQLT_TIME_TZ 186 /* TIME WITH TIME ZONE */ -#define SQLT_TIMESTAMP 187 /* TIMESTAMP */ -#define SQLT_TIMESTAMP_TZ 188 /* TIMESTAMP WITH TIME ZONE */ -#define SQLT_INTERVAL_YM 189 /* INTERVAL YEAR TO MONTH */ -#define SQLT_INTERVAL_DS 190 /* INTERVAL DAY TO SECOND */ -#define SQLT_TIMESTAMP_LTZ 232 /* TIMESTAMP WITH LOCAL TZ */ - -/* cxcheng: this has been added for backward compatibility - - it needs to be here because ocidfn.h can get included ahead of sqldef.h */ -#define SQLT_FILE SQLT_BFILEE /* binary file lob */ -#define SQLT_CFILE SQLT_CFILEE -#define SQLT_BFILE SQLT_BFILEE - -#define SQLT_PNTY 241 /* pl/sql representation of named types */ - -/* some pl/sql specific types */ -#define SQLT_REC 250 /* pl/sql 'record' (or %rowtype) */ -#define SQLT_TAB 251 /* pl/sql 'indexed table' */ -#define SQLT_BOL 252 /* pl/sql 'boolean' */ - -/* CHAR/NCHAR/VARCHAR2/NVARCHAR2/CLOB/NCLOB char set "form" information */ -#define SQLCS_IMPLICIT 1 /* for CHAR, VARCHAR2, CLOB w/o a specified set */ -#define SQLCS_NCHAR 2 /* for NCHAR, NCHAR VARYING, NCLOB */ -#define SQLCS_EXPLICIT 3 /* for CHAR, etc, with "CHARACTER SET ..." syntax */ -#define SQLCS_FLEXIBLE 4 /* for PL/SQL "flexible" parameters */ -#define SQLCS_LIT_NULL 5 /* for type check of NULL and empty_clob() */ - -/*-----------------------------Handle Types----------------------------------*/ -/* handle types range from 1 - 49 */ -#define OCI_HTYPE_FIRST 1 /* start value of handle type */ -#define OCI_HTYPE_ENV 1 /* environment handle */ -#define OCI_HTYPE_ERROR 2 /* error handle */ -#define OCI_HTYPE_SVCCTX 3 /* service handle */ -#define OCI_HTYPE_STMT 4 /* statement handle */ -#define OCI_HTYPE_BIND 5 /* bind handle */ -#define OCI_HTYPE_DEFINE 6 /* define handle */ -#define OCI_HTYPE_DESCRIBE 7 /* describe handle */ -#define OCI_HTYPE_SERVER 8 /* server handle */ -#define OCI_HTYPE_SESSION 9 /* authentication handle */ -#define OCI_HTYPE_AUTHINFO OCI_HTYPE_SESSION /* SessionGet auth handle */ -#define OCI_HTYPE_SUBSCRIPTION 13 /* subscription handle */ -#define OCI_HTYPE_DIRPATH_CTX 14 /* direct path context */ -#define OCI_HTYPE_DIRPATH_COLUMN_ARRAY 15 /* direct path column array */ -#define OCI_HTYPE_DIRPATH_STREAM 16 /* direct path stream */ -#define OCI_HTYPE_TRANS 10 /* transaction handle */ -#define OCI_HTYPE_CPOOL 26 /* connection pool handle */ -#define OCI_HTYPE_SPOOL 27 /* session pool handle */ -#define OCI_HTYPE_ADMIN 28 /* admin handle */ - -/*-------------------------Descriptor Types----------------------------------*/ - -#define OCI_DTYPE_LOB 50 /* lob locator */ -#define OCI_DTYPE_PARAM 53 /* a parameter descriptor obtained from ocigparm */ -#define OCI_DTYPE_FILE 56 /* File Lob locator */ -#define OCI_DTYPE_AQENQ_OPTIONS 57 /* enqueue options */ -#define OCI_DTYPE_AQDEQ_OPTIONS 58 /* dequeue options */ -#define OCI_DTYPE_AQMSG_PROPERTIES 59 /* message properties */ -#define OCI_DTYPE_AQAGENT 60 /* aq agent */ -#define OCI_DTYPE_INTERVAL_YM 62 /* Interval year month */ -#define OCI_DTYPE_INTERVAL_DS 63 /* Interval day second */ -#define OCI_DTYPE_AQNFY_DESCRIPTOR 64 /* AQ notify descriptor */ -#define OCI_DTYPE_DATE 65 /* Date */ -#define OCI_DTYPE_TIME 66 /* Time */ -#define OCI_DTYPE_TIME_TZ 67 /* Time with timezone */ -#define OCI_DTYPE_TIMESTAMP 68 /* Timestamp */ -#define OCI_DTYPE_TIMESTAMP_TZ 69 /* Timestamp with timezone */ -#define OCI_DTYPE_TIMESTAMP_LTZ 70 /* Timestamp with local tz */ -#define OCI_DTYPE_CHDES 77 /* Top level change notification - *desc */ -#define OCI_DTYPE_TABLE_CHDES 78 /* Table change descriptor - * */ -#define OCI_DTYPE_ROW_CHDES 79 /* Row change descriptor - * */ - -/*---------------------------------------------------------------------------*/ - -/*--------------------------------LOB types ---------------------------------*/ -#define OCI_TEMP_BLOB 1 /* LOB type - BLOB ------------------ */ -#define OCI_TEMP_CLOB 2 /* LOB type - CLOB ------------------ */ -/*---------------------------------------------------------------------------*/ - -/*--------------------------Attribute Types----------------------------------*/ - -#define OCI_ATTR_OBJECT 2 /* is the environment initialized in object mode */ -#define OCI_ATTR_SQLCODE 4 /* the SQL verb */ -#define OCI_ATTR_ENV 5 /* the environment handle */ -#define OCI_ATTR_SERVER 6 /* the server handle */ -#define OCI_ATTR_SESSION 7 /* the user session handle */ -#define OCI_ATTR_TRANS 8 /* the transaction handle */ -#define OCI_ATTR_ROW_COUNT 9 /* the rows processed so far */ -#define OCI_ATTR_SQLFNCODE 10 /* the SQL verb of the statement */ -#define OCI_ATTR_PREFETCH_ROWS 11 /* sets the number of rows to prefetch */ -#define OCI_ATTR_NESTED_PREFETCH_ROWS 12 /* the prefetch rows of nested table*/ -#define OCI_ATTR_PREFETCH_MEMORY 13 /* memory limit for rows fetched */ -#define OCI_ATTR_NESTED_PREFETCH_MEMORY 14 /* memory limit for nested rows */ -#define OCI_ATTR_PDSCL 16 /* packed decimal scale */ -#define OCI_ATTR_FSPRECISION OCI_ATTR_PDSCL - -/* fs prec for datetime data types */ -#define OCI_ATTR_PDPRC 17 /* packed decimal format */ -#define OCI_ATTR_LFPRECISION OCI_ATTR_PDPRC - -/* fs prec for datetime data types */ - -#define OCI_ATTR_PARAM_COUNT 18 /* number of column in the select list */ -#define OCI_ATTR_ROWID 19 /* the rowid */ -#define OCI_ATTR_CHARSET 20 /* the character set value */ -#define OCI_ATTR_USERNAME 22 /* username attribute */ -#define OCI_ATTR_PASSWORD 23 /* password attribute */ -#define OCI_ATTR_STMT_TYPE 24 /* statement type */ -#define OCI_ATTR_XID 27 /* XOPEN defined global transaction id */ -#define OCI_ATTR_CHARSET_ID 31 /* Character Set ID */ -#define OCI_ATTR_CHARSET_FORM 32 /* Character Set Form */ -#define OCI_ATTR_MAXDATA_SIZE 33 /* Maximumsize of data on the server */ -#define OCI_ATTR_ROWS_RETURNED 42 - -#define OCI_ATTR_FOCBK 43 /* Failover Callback attribute */ - - -/* Number of rows returned in current iter - for Bind handles */ - -#define OCI_ATTR_LOBEMPTY 45 /* empty lob ? */ - -#define OCI_ATTR_VISIBILITY 47 /* visibility */ -#define OCI_ATTR_RELATIVE_MSGID 48 /* relative message id */ -#define OCI_ATTR_SEQUENCE_DEVIATION 49 /* sequence deviation */ - -#define OCI_ATTR_CONSUMER_NAME 50 /* consumer name */ -#define OCI_ATTR_DEQ_MODE 51 /* dequeue mode */ -#define OCI_ATTR_NAVIGATION 52 /* navigation */ -#define OCI_ATTR_WAIT 53 /* wait */ -#define OCI_ATTR_DEQ_MSGID 54 /* dequeue message id */ - -#define OCI_ATTR_PRIORITY 55 /* priority */ -#define OCI_ATTR_DELAY 56 /* delay */ -#define OCI_ATTR_EXPIRATION 57 /* expiration */ -#define OCI_ATTR_CORRELATION 58 /* correlation id */ -#define OCI_ATTR_ATTEMPTS 59 /* # of attempts */ -#define OCI_ATTR_RECIPIENT_LIST 60 /* recipient list */ -#define OCI_ATTR_EXCEPTION_QUEUE 61 /* exception queue name */ -#define OCI_ATTR_ENQ_TIME 62 /* enqueue time (only OCIAttrGet) */ -#define OCI_ATTR_MSG_STATE 63 /* message state (only OCIAttrGet) */ -/* NOTE: 64-66 used below */ -#define OCI_ATTR_AGENT_NAME 64 /* agent name */ -#define OCI_ATTR_AGENT_ADDRESS 65 /* agent address */ -#define OCI_ATTR_AGENT_PROTOCOL 66 /* agent protocol */ -#define OCI_ATTR_USER_PROPERTY 67 /* user property */ -#define OCI_ATTR_SENDER_ID 68 /* sender id */ -#define OCI_ATTR_ORIGINAL_MSGID 69 /* original message id */ -#define OCI_ATTR_QUEUE_NAME 70 /* queue name */ - -#define OCI_ATTR_NUM_DML_ERRORS 73 /* num of errs in array DML */ -#define OCI_ATTR_DML_ROW_OFFSET 74 /* row offset in the array */ - -#define OCI_ATTR_DATEFORMAT 75 /* default date format string */ -#define OCI_ATTR_BUF_ADDR 76 /* buffer address */ -#define OCI_ATTR_BUF_SIZE 77 /* buffer size */ -#define OCI_ATTR_NUM_ROWS 81 /* number of rows in column array */ -#define OCI_ATTR_COL_COUNT 82 /* columns of column array - processed so far. */ - -#define OCI_ATTR_SUBSCR_NAME 94 /* name of subscription */ -#define OCI_ATTR_SUBSCR_CALLBACK 95 /* associated callback */ -#define OCI_ATTR_SUBSCR_CTX 96 /* associated callback context */ -#define OCI_ATTR_SUBSCR_PAYLOAD 97 /* associated payload */ -#define OCI_ATTR_SUBSCR_NAMESPACE 98 /* associated namespace */ - -#define OCI_ATTR_NUM_COLS 102 /* number of columns */ -#define OCI_ATTR_LIST_COLUMNS 103 /* parameter of the column list */ -#define OCI_ATTR_COL_PROPERTIES 104 /* column properties */ -#define OCI_ATTR_REF_TDO 110 /* REF to the type descriptor */ -#define OCI_ATTR_LINK 111 /* the database link name */ -#define OCI_ATTR_NUM_PARAMS 121 /* number of parameters */ - -#define OCI_ATTR_PTYPE 123 /* type of info described by */ -#define OCI_ATTR_PARAM 124 /* parameter descriptor */ -#define OCI_ATTR_PARSE_ERROR_OFFSET 129 /* Parse Error offset */ - -#define OCI_ATTR_SERVER_STATUS 143 /* state of the server hdl */ -#define OCI_ATTR_STATEMENT 144 /* statement txt in stmt hdl */ - -#define OCI_ATTR_SUBSCR_RECPTPROTO 149 /* protocol for recipient */ - -#define OCI_ATTR_CURRENT_POSITION 164 /* for scrollable result sets*/ -#define OCI_ATTR_STMTCACHESIZE 176 /* size of the stmt cache */ - -#define OCI_ATTR_CONN_NOWAIT 178 -#define OCI_ATTR_CONN_BUSY_COUNT 179 -#define OCI_ATTR_CONN_OPEN_COUNT 180 -#define OCI_ATTR_CONN_TIMEOUT 181 -#define OCI_ATTR_STMT_STATE 182 -#define OCI_ATTR_CONN_MIN 183 -#define OCI_ATTR_CONN_MAX 184 -#define OCI_ATTR_CONN_INCR 185 -#define OCI_ATTR_SUBSCR_RECPTPRES 195 -#define OCI_ATTR_ROWS_FETCHED 197 /* rows fetched in last call */ -#define OCI_ATTR_SPOOL_STMTCACHESIZE 208 /*Stmt cache size of pool */ - -#define OCI_ATTR_TYPECODE 216 /* object or collection */ -#define OCI_ATTR_COLLECTION_TYPECODE 217 /* varray or nested table */ -#define OCI_ATTR_IS_PREDEFINED_TYPE 221 /* a predefined type */ - -#define OCI_ATTR_SUBSCR_TIMEOUT 227 /* Timeout */ - -#define OCI_ATTR_COLLECTION_ELEMENT 227 /* has a collection attribute */ -#define OCI_ATTR_NUM_TYPE_ATTRS 228 /* number of attribute types */ -#define OCI_ATTR_LIST_TYPE_ATTRS 229 /* list of type attributes */ - -#define OCI_ATTR_DESC_PUBLIC 250 /* public object */ - -#define OCI_ATTR_IS_SUBTYPE 258 /* Is this a subtype? */ -#define OCI_ATTR_SUPERTYPE_SCHEMA_NAME 259 /* Name of the supertype schema */ -#define OCI_ATTR_SUPERTYPE_NAME 260 /* Name of the supertype */ - -#define OCI_ATTR_CLIENT_IDENTIFIER 278 /* value of client id to set*/ - -#define OCI_ATTR_IS_FINAL_TYPE 279 /* is final type ? */ - -#define OCI_ATTR_CHAR_USED 285 /* char length semantics */ -#define OCI_ATTR_CHAR_SIZE 286 /* char length */ - -#define OCI_ATTR_EVTCBK 304 /* ha callback */ -#define OCI_ATTR_EVTCTX 305 /* ctx for ha callback */ - -#define OCI_ATTR_SPOOL_TIMEOUT 308 /* session timeout */ -#define OCI_ATTR_SPOOL_GETMODE 309 /* session get mode */ -#define OCI_ATTR_SPOOL_BUSY_COUNT 310 /* busy session count */ -#define OCI_ATTR_SPOOL_OPEN_COUNT 311 /* open session count */ -#define OCI_ATTR_SPOOL_MIN 312 /* min session count */ -#define OCI_ATTR_SPOOL_MAX 313 /* max session count */ -#define OCI_ATTR_SPOOL_INCR 314 /* session increment count */ - -#define OCI_ATTR_TRANSACTION_NO 365 /* AQ enq txn number */ - -#define OCI_ATTR_MODULE 366 /* module for tracing */ -#define OCI_ATTR_ACTION 367 /* action for tracing */ -#define OCI_ATTR_CLIENT_INFO 368 /* client info */ - -#define OCI_ATTR_ADMIN_PFILE 389 /* client-side param file */ - -#define OCI_ATTR_SUBSCR_PORTNO 390 /* port no to listen */ - -#define OCI_ATTR_HOSTNAME 390 /* SYS_CONTEXT hostname */ -#define OCI_ATTR_DBNAME 391 /* SYS_CONTEXT dbname */ -#define OCI_ATTR_INSTNAME 392 /* SYS_CONTEXT instance name */ -#define OCI_ATTR_SERVICENAME 393 /* SYS_CONTEXT service name */ -#define OCI_ATTR_INSTSTARTTIME 394 /* v$instance instance start time */ -#define OCI_ATTR_HA_TIMESTAMP 395 /* event time */ -#define OCI_ATTR_DBDOMAIN 399 /* db domain */ -#define OCI_ATTR_EVENTTYPE 400 /* event type */ -#define OCI_ATTR_HA_SOURCE 401 -#define OCI_ATTR_HA_STATUS 402 -#define OCI_ATTR_HA_SRVFIRST 403 -#define OCI_ATTR_HA_SRVNEXT 404 -#define OCI_ATTR_TAF_ENABLED 405 -#define OCI_ATTR_DRIVER_NAME 424 /* Driver Name */ - -#define OCI_ATTR_SEND_TIMEOUT 435 /* NS send timeout */ -#define OCI_ATTR_RECEIVE_TIMEOUT 436 /* NS receive timeout */ - -#define OCI_ATTR_SPOOL_AUTH 460 /* Auth handle on pool handle*/ - -#define OCI_ATTR_IMPLICIT_RESULT_COUNT 463 - - -/*--------- Attributes related to LOB prefetch------------------------------ */ -#define OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE 438 /* default prefetch size */ -#define OCI_ATTR_LOBPREFETCH_SIZE 439 /* prefetch size */ -#define OCI_ATTR_LOBPREFETCH_LENGTH 440 /* prefetch length & chunk */ - -/* session handle attribute */ -#define OCI_ATTR_MAX_OPEN_CURSORS 471 - -/* add attribute for DBOP: DataBase OPeration */ -#define OCI_ATTR_DBOP 485 - -#define OCI_ATTR_COLLATION_ID 499 /* Collation ID */ -#define OCI_ATTR_SQL_ID 504 /* SQL ID in text form */ -#define OCI_ATTR_LOB_REMOTE 520 /* remote lob ? */ -#define OCI_ATTR_CALL_TIMEOUT 531 - -/*------- Temporary attribute value for UCS2/UTF16 character set ID -------- */ - -#define OCI_UCS2ID 1000 /* UCS2 charset ID */ -#define OCI_UTF16ID 1000 /* UTF16 charset ID */ - -/*-------------------------Credential Types----------------------------------*/ - -#define OCI_CRED_RDBMS 1 /* database username/password */ -#define OCI_CRED_EXT 2 /* externally provided credentials */ -#define OCI_CRED_PROXY 3 /* proxy authentication */ - -/*------------------------Error Return Values--------------------------------*/ - -#define OCI_SUCCESS 0 /* maps to SQL_SUCCESS of SAG CLI */ -#define OCI_SUCCESS_WITH_INFO 1 /* maps to SQL_SUCCESS_WITH_INFO */ -#define OCI_NO_DATA 100 /* maps to SQL_NO_DATA */ -#define OCI_ERROR (-1 ) /* maps to SQL_ERROR */ -#define OCI_INVALID_HANDLE (-2) /* maps to SQL_INVALID_HANDLE */ -#define OCI_NEED_DATA 99 /* maps to SQL_NEED_DATA */ -#define OCI_STILL_EXECUTING (-3123 ) /* OCI would block error */ - -/*---------------- Server Handle Attribute Values ---------------------------*/ - -#define OCI_SERVER_NOT_CONNECTED 0x0 -#define OCI_SERVER_NORMAL 0x1 - -/*--------------------- User Callback Return Values -------------------------*/ -#define OCI_CONTINUE (-24200) /* Continue with the body of the OCI function */ - -/*------------------------Attach Modes---------------------------------------*/ - -#define OCI_CPOOL 0x0200 /* Attach using server handle from pool */ - -/*------------------DateTime and Interval check Error codes------------------*/ - -#define OCI_DT_INVALID_DAY 0x1 /* Bad day */ -#define OCI_DT_DAY_BELOW_VALID 0x2 /* Bad DAy Low/high bit (1=low)*/ -#define OCI_DT_INVALID_MONTH 0x4 /* Bad MOnth */ -#define OCI_DT_MONTH_BELOW_VALID 0x8 /* Bad MOnth Low/high bit (1=low) */ -#define OCI_DT_INVALID_YEAR 0x10 /* Bad YeaR */ -#define OCI_DT_YEAR_BELOW_VALID 0x20 /* Bad YeaR Low/high bit (1=low) */ -#define OCI_DT_INVALID_HOUR 0x40 /* Bad HouR */ -#define OCI_DT_HOUR_BELOW_VALID 0x80 /* Bad HouR Low/high bit (1=low) */ -#define OCI_DT_INVALID_MINUTE 0x100 /* Bad MiNute */ -#define OCI_DT_MINUTE_BELOW_VALID 0x200 /*Bad MiNute Low/high bit (1=low) */ -#define OCI_DT_INVALID_SECOND 0x400 /* Bad SeCond */ -#define OCI_DT_SECOND_BELOW_VALID 0x800 /*bad second Low/high bit (1=low)*/ -#define OCI_DT_DAY_MISSING_FROM_1582 0x1000 - -/* Day is one of those "missing" from 1582 */ -#define OCI_DT_YEAR_ZERO 0x2000 /* Year may not equal zero */ -#define OCI_DT_INVALID_TIMEZONE 0x4000 /* Bad Timezone */ -#define OCI_DT_INVALID_FORMAT 0x8000 /* Bad date format input */ - -/*------------------------Scrollable Cursor Fetch Options------------------- - * For non-scrollable cursor, the only valid (and default) orientation is - * OCI_FETCH_NEXT - */ -#define OCI_FETCH_CURRENT 0x01 /* refetching current position */ -#define OCI_FETCH_NEXT 0x02 /* next row */ -#define OCI_FETCH_FIRST 0x04 /* first row of the result set */ -#define OCI_FETCH_LAST 0x08 /* the last row of the result set */ -#define OCI_FETCH_PRIOR 0x10 /* the previous row relative to current */ -#define OCI_FETCH_ABSOLUTE 0x20 /* absolute offset from first */ -#define OCI_FETCH_RELATIVE 0x40 /* offset relative to current */ -#define OCI_FETCH_RESERVED_1 0x80 /* reserved */ - -/*------------------------Parse mode ----------------------------------------*/ - -#define OCI_NTV_SYNTAX 1 /* Use what so ever is the native lang of server */ - -/*------------------------Bind and Define Options----------------------------*/ - -#define OCI_DATA_AT_EXEC 0x00000002 /* data at execute time */ -#define OCI_DYNAMIC_FETCH 0x00000002 /* fetch dynamically */ -#define OCI_PIECEWISE 0x00000004 /* piecewise DMLs or fetch */ -#define OCI_BIND_SOFT 0x00000040 /* soft bind or define */ -#define OCI_DEFINE_SOFT 0x00000080 /* soft bind or define */ - -/*----------------------- Execution Modes -----------------------------------*/ - -#define OCI_BATCH_MODE 0x00000001 /* batch the oci stmt for exec */ -#define OCI_STMT_SCROLLABLE_READONLY \ - 0x00000008 /* if result set is scrollable */ -#define OCI_DESCRIBE_ONLY 0x00000010 /* only describe the statement */ -#define OCI_BATCH_ERRORS 0x00000080 /* batch errors in array dmls */ -#define OCI_PARSE_ONLY 0x00000100 /* only parse the statement */ - -/*----------------------------- Various Modes ------------------------------*/ -#define OCI_DEFAULT 0x00000000 -#define OCI_THREADED 0x00000001 /* appl. in threaded environment */ -#define OCI_OBJECT 0x00000002 /* application in object environment */ -#define OCI_EVENTS 0x00000004 /* application is enabled for events */ -#define OCI_UTF16 0x00004000 /* mode for all UTF16 metadata */ -#define OCI_NCHAR_LITERAL_REPLACE_ON 0x00400000 /* nchar literal replace on */ -#define OCI_NCHAR_LITERAL_REPLACE_OFF 0x00800000 /* nchar literal replace off*/ - -/*------------------------Authentication Modes-------------------------------*/ -#define OCI_SYSDBA 0x00000002 /* for SYSDBA authorization */ -#define OCI_SYSOPER 0x00000004 /* for SYSOPER authorization */ -#define OCI_PRELIM_AUTH 0x00000008 /* for preliminary authorization */ -#define OCI_STMT_CACHE 0x00000040 /* enable OCI Stmt Caching */ - -/*------------------------ Transaction Start Flags --------------------------*/ - -#define OCI_TRANS_NEW 0x00000001 /* starts a new transaction branch */ -#define OCI_TRANS_JOIN 0x00000002 /* join an existing transaction */ -#define OCI_TRANS_RESUME 0x00000004 /* resume this transaction */ -#define OCI_TRANS_STARTMASK 0x000000ff - -#define OCI_TRANS_READONLY 0x00000100 /* starts a readonly transaction */ -#define OCI_TRANS_READWRITE 0x00000200 /* starts a read-write transaction */ -#define OCI_TRANS_SERIALIZABLE 0x00000400 - -/* starts a serializable transaction */ -#define OCI_TRANS_ISOLMASK 0x0000ff00 - -#define OCI_TRANS_LOOSE 0x00010000 /* a loosely coupled branch */ -#define OCI_TRANS_TIGHT 0x00020000 /* a tightly coupled branch */ -#define OCI_TRANS_TYPEMASK 0x000f0000 - -#define OCI_TRANS_NOMIGRATE 0x00100000 /* non migratable transaction */ -#define OCI_TRANS_SEPARABLE 0x00200000 /* separable transaction (8.1.6+) */ -#define OCI_TRANS_OTSRESUME 0x00400000 /* OTS resuming a transaction */ - -/*------------------------ Transaction End Flags ----------------------------*/ - -#define OCI_TRANS_TWOPHASE 0x01000000 /* use two phase commit */ -#define OCI_TRANS_WRITEBATCH 0x00000001 /* force cmt-redo for local txns */ -#define OCI_TRANS_WRITEIMMED 0x00000002 /* no force cmt-redo */ -#define OCI_TRANS_WRITEWAIT 0x00000004 /* no sync cmt-redo */ -#define OCI_TRANS_WRITENOWAIT 0x00000008 /* sync cmt-redo for local txns */ - -/*------------------------Describe Handle Parameter Attributes --------------*/ - -#define OCI_ATTR_DATA_SIZE 1 /* maximum size of the data */ -#define OCI_ATTR_DATA_TYPE 2 /* the SQL type of the column/argument */ -#define OCI_ATTR_DISP_SIZE 3 /* the display size */ -#define OCI_ATTR_NAME 4 /* the name of the column/argument */ -#define OCI_ATTR_PRECISION 5 /* precision if number type */ -#define OCI_ATTR_SCALE 6 /* scale if number type */ -#define OCI_ATTR_IS_NULL 7 /* is it null ? */ -#define OCI_ATTR_TYPE_NAME 8 /* name of the named data type */ -#define OCI_ATTR_SCHEMA_NAME 9 /* the schema name */ -#define OCI_ATTR_SUB_NAME 10 /* type name if package private type */ -#define OCI_ATTR_PACKAGE_NAME 12 /* package name of package type */ - -/*------------------------Other Constants------------------------------------*/ - -#define OCI_ERROR_MAXMSG_SIZE 1024 /* max size of an error message */ -#define OCI_LOBMAXSIZE MINUB4MAXVAL /* maximum lob data size */ -#define OCI_ROWID_LEN 23 - -/*---------------------OCIStmtPrepare2 Modes---------------------------------*/ -#define OCI_PREP2_CACHE_SEARCHONLY 0x0010 /* ONly Search */ -#define OCI_PREP2_GET_PLSQL_WARNINGS 0x0020 /* Get PL/SQL warnings */ -#define OCI_PREP2_RESERVED_1 0x0040 /* reserved */ -#define OCI_PREP2_RESERVED_2 0x0080 /* reserved */ -#define OCI_PREP2_RESERVED_3 0x0100 /* reserved */ -#define OCI_PREP2_RESERVED_4 0x0200 /* reserved */ -#define OCI_PREP2_IMPL_RESULTS_CLIENT 0x0400 /* client for implicit results */ -#define OCI_PREP2_RESERVED_5 0x0800 /* reserved */ -#define OCI_PREP2_RESERVED_6 0x1000 /* reserved */ -#define OCI_PREP2_GET_SQL_ID 0x2000 /* Get SQL_ID for the SQL stmt */ -#define OCI_PREP2_RESERVED_7 0x4000 /* reserved */ -#define OCI_PREP2_RESERVED_8 0x8000 /* reserved */ -#define OCI_PREP2_RESERVED_9 0x10000 /* reserved */ - -/*---------------------OCIStmtRelease Modes----------------------------------*/ -#define OCI_STRLS_CACHE_DELETE 0x0010 /* Delete from Cache */ - -/*-----------------------Handle Definitions----------------------------------*/ -typedef struct OCIEnv OCIEnv; /* OCI environment handle */ -typedef struct OCIError OCIError; /* OCI error handle */ -typedef struct OCISvcCtx OCISvcCtx; /* OCI service handle */ -typedef struct OCIStmt OCIStmt; /* OCI statement handle */ -typedef struct OCIBind OCIBind; /* OCI bind handle */ -typedef struct OCIDefine OCIDefine; /* OCI Define handle */ -typedef struct OCIDescribe OCIDescribe; /* OCI Describe handle */ -typedef struct OCIServer OCIServer; /* OCI Server handle */ -typedef struct OCISession OCISession; /* OCI Authentication handle */ -typedef struct OCIComplexObject OCIComplexObject; /* OCI COR handle */ -typedef struct OCITrans OCITrans; /* OCI Transaction handle */ -typedef struct OCISecurity OCISecurity; /* OCI Security handle */ -typedef struct OCISubscription OCISubscription; /* subscription handle */ - -typedef struct OCICPool OCICPool; /* connection pool handle */ -typedef struct OCISPool OCISPool; /* session pool handle */ -typedef struct OCIAuthInfo OCIAuthInfo; /* auth handle */ -typedef struct OCIAdmin OCIAdmin; /* admin handle */ -typedef struct OCIEvent OCIEvent; /* HA event handle */ - -typedef struct OCIDirPathCtx OCIDirPathCtx; /* DP context */ -typedef struct OCIDirPathColArray OCIDirPathColArray; /* DP column array */ -typedef struct OCIDirPathStream OCIDirPathStream; /* DP stream */ - -typedef struct OCIAQEnqOptions OCIAQEnqOptions; /* AQ Enqueue Options hdl */ -typedef struct OCIAQDeqOptions OCIAQDeqOptions; /* AQ Dequeue Options hdl */ -typedef struct OCIAQMsgProperties OCIAQMsgProperties; /* AQ Mesg Properties */ -typedef struct OCIAQAgent OCIAQAgent; /* AQ Agent descriptor */ -typedef struct OCIAQNfyDescriptor OCIAQNfyDescriptor; /* AQ Nfy descriptor */ -typedef struct OCIAQSignature OCIAQSignature; /* AQ Signature */ -typedef struct OCIAQListenOpts OCIAQListenOpts; /* AQ listen options */ -typedef struct OCIAQLisMsgProps OCIAQLisMsgProps; /* AQ listen msg props */ - -/*---------------------------------------------------------------------------*/ -/*------------------------- OCISessionPoolCreate Modes ----------------------*/ - -#define OCI_SPC_REINITIALIZE 0x0001 /* Reinitialize the session pool */ -#define OCI_SPC_HOMOGENEOUS 0x0002 /* Session pool is homogeneneous */ -#define OCI_SPC_STMTCACHE 0x0004 /* Session pool has stmt cache */ - -/*---------------------------------------------------------------------------*/ -/*--------------------------- OCISessionGet Modes ---------------------------*/ - -#define OCI_SESSGET_SPOOL 0x0001 /* SessionGet called in SPOOL mode */ -#define OCI_SESSGET_CPOOL OCI_CPOOL /* SessionGet called in CPOOL mode */ -#define OCI_SESSGET_STMTCACHE 0x0004 /* Use statement cache */ -#define OCI_SESSGET_CREDPROXY 0x0008 /* SessionGet called in proxy mode */ -#define OCI_SESSGET_CREDEXT 0x0010 -#define OCI_SESSGET_SPOOL_MATCHANY 0x0020 -#define OCI_SESSGET_SYSDBA 0x0100 /* SessionGet with SYSDBA privileges */ - -/*---------------------------------------------------------------------------*/ -/*------------------------ATTR Values for Session Pool-----------------------*/ -/* Attribute values for OCI_ATTR_SPOOL_GETMODE */ -#define OCI_SPOOL_ATTRVAL_WAIT 0 /* block till you get a session */ -#define OCI_SPOOL_ATTRVAL_NOWAIT 1 /* error out if no session available */ -#define OCI_SPOOL_ATTRVAL_FORCEGET 2 /* get session even if max is exceeded */ - -/*---------------------------------------------------------------------------*/ -/*--------------------------- OCISessionRelease Modes -----------------------*/ - -#define OCI_SESSRLS_DROPSESS 0x0001 /* Drop the Session */ -#define OCI_SESSRLS_RETAG 0x0002 /* Retag the session */ - -/*---------------------------------------------------------------------------*/ -/*----------------------- OCISessionPoolDestroy Modes -----------------------*/ - -#define OCI_SPD_FORCE 0x0001 /* Force the sessions to terminate. - Even if there are some busy - sessions close them */ - -/*------------------------ Fail Over Events ---------------------------------*/ -#define OCI_FO_END 0x00000001 -#define OCI_FO_ABORT 0x00000002 -#define OCI_FO_REAUTH 0x00000004 -#define OCI_FO_BEGIN 0x00000008 -#define OCI_FO_ERROR 0x00000010 -/*---------------------------------------------------------------------------*/ - -/*------------------------ Fail Over Callback Return Codes ------------------*/ -#define OCI_FO_RETRY 25410 -/*---------------------------------------------------------------------------*/ - -/*------------------------- Fail Over Types ---------------------------------*/ -#define OCI_FO_NONE 0x00000001 -#define OCI_FO_SESSION 0x00000002 -#define OCI_FO_SELECT 0x00000004 -#define OCI_FO_TXNAL 0x00000008 - -/*--------------------------Failover Callback Structure ---------------------*/ -typedef sb4 (*OCICallbackFailover)(dvoid *svcctx, dvoid *envctx, - dvoid *fo_ctx, ub4 fo_type, - ub4 fo_event); - -typedef struct -{ - OCICallbackFailover callback_function; - dvoid *fo_ctx; -} -OCIFocbkStruct; - -/*--------------------- OCI Thread Object Definitions------------------------*/ - -/* OCIThread Context */ -typedef struct OCIThreadContext OCIThreadContext; - -/* OCIThread Mutual Exclusion Lock */ -typedef struct OCIThreadMutex OCIThreadMutex; - -/* OCIThread Key for Thread-Specific Data */ -typedef struct OCIThreadKey OCIThreadKey; - -/* OCIThread Thread ID */ -typedef struct OCIThreadId OCIThreadId; - -/* OCIThread Thread Handle */ -typedef struct OCIThreadHandle OCIThreadHandle; - -/*--------------------- OCI Collection Object Definitions--------------------*/ - -/* OCIColl - generic collection type */ -typedef struct OCIColl OCIColl; - -/* OCIArray - varray collection type */ -typedef OCIColl OCIArray; - -/* OCITable - nested table collection type */ -typedef OCIColl OCITable; - -/* OCIIter - collection iterator */ -typedef struct OCIIter OCIIter; - -/*-----------------------Descriptor Definitions------------------------------*/ - -typedef struct OCISnapshot OCISnapshot; /* OCI snapshot descriptor */ -typedef struct OCIResult OCIResult; /* OCI Result Set Descriptor */ -typedef struct OCILobLocator OCILobLocator; /* OCI Lob Locator descriptor */ -typedef struct OCIParam OCIParam; /* OCI PARameter descriptor */ -typedef struct OCIDateTime OCIDateTime; /* OCI DateTime descriptor */ -typedef struct OCIInterval OCIInterval; /* OCI Interval descriptor */ -typedef struct OCIRowid OCIRowid; /* OCI ROWID descriptor */ - -/*----------------------------- OBJECT FREE OPTION --------------------------*/ - -#define OCI_OBJECTFREE_FORCE (ub2)0x0001 -#define OCI_OBJECTFREE_NONULL (ub2)0x0002 - -/*-------------------------- OCINumber --------------------------------------*/ - -#define OCI_NUMBER_UNSIGNED 0 /* Unsigned type -- ubX */ -#define OCI_NUMBER_SIGNED 2 /* Signed type -- sbX */ -#define OCI_NUMBER_SIZE 22 - -struct OCINumber -{ - ub1 OCINumberPart[OCI_NUMBER_SIZE]; -}; - -/*-----------------------Objects Definitions---------------------------------*/ - -typedef struct OCIString OCIString; -typedef struct OCIRaw OCIRaw; -typedef struct OCIType OCIType; -typedef struct OCINumber OCINumber; -typedef struct OCIRef OCIRef; - -/*--------------------------- OBJECT INDICATOR ------------------------------*/ - -typedef sb2 OCIInd; - -/* - * OCIInd -- a variable of this type contains (null) indicator information - */ - -#define OCI_IND_NOTNULL (OCIInd)0 /* not NULL */ -#define OCI_IND_NULL (OCIInd)(-1) /* NULL */ -#define OCI_IND_BADNULL (OCIInd)(-2) /* BAD NULL */ -#define OCI_IND_NOTNULLABLE (OCIInd)(-3) /* not NULLable */ - -/*-------------------------Object Ptr Types----------------------------------*/ -#define OCI_OTYPE_NAME 1 /* object name */ -#define OCI_OTYPE_REF 2 /* REF to TDO */ -#define OCI_OTYPE_PTR 3 /* PTR to TDO */ - -/*------------------------ Lob-specific Definitions -------------------------*/ - -typedef ub4 OCILobOffset; -typedef ub4 OCILobLength; - -/*----------------------------Piece Definitions------------------------------*/ - -#define OCI_ONE_PIECE 0 /* one piece */ -#define OCI_FIRST_PIECE 1 /* the first piece */ -#define OCI_NEXT_PIECE 2 /* the next of many pieces */ -#define OCI_LAST_PIECE 3 /* the last piece */ - -/*----------------------- GET OPTIONS FOR TDO ------------------------------*/ - -enum OCITypeGetOpt -{ - OCI_TYPEGET_HEADER, /* load only the header portion of the TDO */ - OCI_TYPEGET_ALL /* load all attribute and method descriptors as well */ -}; -typedef enum OCITypeGetOpt OCITypeGetOpt; - -/*--------------------------- OBJECT PIN OPTION -----------------------------*/ - -enum OCIPinOpt -{ - /* 0 = uninitialized */ - OCI_PIN_DEFAULT = 1, /* default pin option */ - OCI_PIN_ANY = 3, /* pin any copy of the object */ - OCI_PIN_RECENT = 4, /* pin recent copy of the object */ - OCI_PIN_LATEST = 5 /* pin latest copy of the object */ -}; -typedef enum OCIPinOpt OCIPinOpt; - -/*--------------------------- OBJECT LOCK OPTION ----------------------------*/ - -enum OCILockOpt -{ - /* 0 = uninitialized */ - OCI_LOCK_NONE = 1, /* null (same as no lock) */ - OCI_LOCK_X = 2, /* exclusive lock */ - OCI_LOCK_X_NOWAIT = 3 /* exclusive lock, do not wait */ -}; -typedef enum OCILockOpt OCILockOpt; - -/*------------------------- OBJECT MODIFYING OPTION -------------------------*/ - -enum OCIMarkOpt -{ - /* 0 = uninitialized */ - OCI_MARK_DEFAULT = 1, /* default (the same as OCI_MARK_NONE) */ - OCI_MARK_NONE = OCI_MARK_DEFAULT, /* object has not been modified */ - OCI_MARK_UPDATE /* object is to be updated */ -}; -typedef enum OCIMarkOpt OCIMarkOpt; - -/*------------------------------ TYPE CODE ----------------------------------*/ - -/* The OCITypeCode type is interchangeable with the existing SQLT type - which is a ub2 */ -typedef ub2 OCITypeCode; - -/*--------------------------- ORACLE DATE TYPE ----------------------------*/ - -struct OCITime -{ - ub1 OCITimeHH; /* hours; range is 0 <= hours <=23 */ - ub1 OCITimeMI; /* minutes; range is 0 <= minutes <= 59 */ - ub1 OCITimeSS; /* seconds; range is 0 <= seconds <= 59 */ -}; -typedef struct OCITime OCITime; - -struct OCIDate -{ - sb2 OCIDateYYYY; /* gregorian year; range is -4712 <= year <= 9999 */ - ub1 OCIDateMM; /* month; range is 1 <= month < 12 */ - ub1 OCIDateDD; /* day; range is 1 <= day <= 31 */ - OCITime OCIDateTime; /* time */ -}; -typedef struct OCIDate OCIDate; - -/*-------------------------- OBJECT Duration --------------------------------*/ - -typedef ub2 OCIDuration; - -#define OCI_DURATION_BEGIN (OCIDuration)10 - -/* beginning sequence of duration */ -#define OCI_DURATION_NULL (OCIDuration)(OCI_DURATION_BEGIN-1) - -/* null duration */ -#define OCI_DURATION_DEFAULT (OCIDuration)(OCI_DURATION_BEGIN-2) /* default */ -#define OCI_DURATION_NEXT (OCIDuration)(OCI_DURATION_BEGIN-3) - -/* next special duration */ -#define OCI_DURATION_SESSION (OCIDuration)(OCI_DURATION_BEGIN) - -/* the end of user session */ -#define OCI_DURATION_TRANS (OCIDuration)(OCI_DURATION_BEGIN+1) - -/* the end of user transaction */ - -/*-------------------------Object Ptr Types----------------------------------*/ -#define OCI_OTYPE_NAME 1 /* object name */ - -/*--------------------------- OCI Parameter Types ---------------------------*/ -#define OCI_PTYPE_UNK 0 /* unknown */ -#define OCI_PTYPE_TABLE 1 /* table */ -#define OCI_PTYPE_VIEW 2 /* view */ -#define OCI_PTYPE_PROC 3 /* procedure */ -#define OCI_PTYPE_FUNC 4 /* function */ -#define OCI_PTYPE_PKG 5 /* package */ -#define OCI_PTYPE_TYPE 6 /* user-defined type */ -#define OCI_PTYPE_SYN 7 /* synonym */ -#define OCI_PTYPE_SEQ 8 /* sequence */ -#define OCI_PTYPE_COL 9 /* column */ -#define OCI_PTYPE_ARG 10 /* argument */ -#define OCI_PTYPE_LIST 11 /* list */ -#define OCI_PTYPE_TYPE_ATTR 12 /* user-defined type's attribute */ -#define OCI_PTYPE_TYPE_COLL 13 /* collection type's element */ -#define OCI_PTYPE_TYPE_METHOD 14 /* user-defined type's method */ -#define OCI_PTYPE_TYPE_ARG 15 /* user-defined type method's arg */ -#define OCI_PTYPE_TYPE_RESULT 16 /* user-defined type method's result */ -#define OCI_PTYPE_SCHEMA 17 /* schema */ -#define OCI_PTYPE_DATABASE 18 /* database */ -#define OCI_PTYPE_RULE 19 /* rule */ -#define OCI_PTYPE_RULE_SET 20 /* rule set */ -#define OCI_PTYPE_EVALUATION_CONTEXT 21 /* evaluation context */ -#define OCI_PTYPE_TABLE_ALIAS 22 /* table alias */ -#define OCI_PTYPE_VARIABLE_TYPE 23 /* variable type */ -#define OCI_PTYPE_NAME_VALUE 24 /* name value pair */ - -/*------------------------------ TYPE CODE ----------------------------------*/ - - -#define OCI_TYPECODE_VARRAY 247 /* SQL VARRAY OTS PAGED VARRAY */ -#define OCI_TYPECODE_TABLE 248 /* SQL TABLE OTS MULTISET */ -#define OCI_TYPECODE_ITABLE 251 /* PLSQL indexed table */ -#define OCI_TYPECODE_PLS_INTEGER 266 /* type code for PLS_INTEGER */ - -/*------------------------Piece Information----------------------------------*/ -#define OCI_PARAM_IN 0x01 /* in parameter */ -#define OCI_PARAM_OUT 0x02 /* out parameter */ - -/*----------------------- OBJECT PROPERTY ID -------------------------------*/ - -typedef ub1 OCIObjectPropId; -#define OCI_OBJECTPROP_LIFETIME 1 /* persistent or transient or value */ -#define OCI_OBJECTPROP_SCHEMA 2 /* schema name of table containing object */ -#define OCI_OBJECTPROP_TABLE 3 /* table name of table containing object */ -#define OCI_OBJECTPROP_PIN_DURATION 4 /* pin duration of object */ -#define OCI_OBJECTPROP_ALLOC_DURATION 5 /* alloc duration of object */ -#define OCI_OBJECTPROP_LOCK 6 /* lock status of object */ -#define OCI_OBJECTPROP_MARKSTATUS 7 /* mark status of object */ -#define OCI_OBJECTPROP_VIEW 8 /* is object a view object or not? */ - -/*----------------------- OBJECT LIFETIME ----------------------------------*/ - -enum OCIObjectLifetime -{ - /* 0 = uninitialized */ - OCI_OBJECT_PERSISTENT = 1, /* persistent object */ - OCI_OBJECT_TRANSIENT, /* transient object */ - OCI_OBJECT_VALUE /* value object */ -}; -typedef enum OCIObjectLifetime OCIObjectLifetime; - -/*----------------------- OBJECT MARK STATUS -------------------------------*/ - -typedef uword OCIObjectMarkStatus; -#define OCI_OBJECT_NEW 0x0001 /* new object */ -#define OCI_OBJECT_DELETED 0x0002 /* object marked deleted */ -#define OCI_OBJECT_UPDATED 0x0004 /* object marked updated */ - -/*----- values for cflg argument to OCIDirpathColArrayEntrySet --------------*/ - -#define OCI_DIRPATH_COL_COMPLETE 0 /* column data is complete */ -#define OCI_DIRPATH_COL_NULL 1 /* column is null */ -#define OCI_DIRPATH_COL_PARTIAL 2 /* column data is partial */ -#define OCI_DIRPATH_COL_ERROR 3 /* column error, ignore row */ - -/*----- values for action parameter to OCIDirPathDataSave -------------------*/ -#define OCI_DIRPATH_DATASAVE_SAVEONLY 0 /* data save point only */ - -/*------------- Supported Values for Direct Path Date cache -----------------*/ -#define OCI_ATTR_DIRPATH_DCACHE_NUM 303 /* date cache entries */ -#define OCI_ATTR_DIRPATH_DCACHE_SIZE 304 /* date cache limit */ -#define OCI_ATTR_DIRPATH_DCACHE_MISSES 305 /* date cache misses */ -#define OCI_ATTR_DIRPATH_DCACHE_HITS 306 /* date cache hits */ -#define OCI_ATTR_DIRPATH_DCACHE_DISABLE 307 /* on set: disable datecache */ - -/*------------- Supported Values for Direct Path Stream Version -------------*/ - -#define OCI_ATTR_DIRPATH_NOLOG 79 /* nologging option */ -#define OCI_ATTR_DIRPATH_PARALLEL 80 /* parallel (temp seg) option */ - -/*------------------------- Database Startup Flags --------------------------*/ -#define OCI_DBSTARTUPFLAG_FORCE 0x00000001 /* Abort running instance, start */ -#define OCI_DBSTARTUPFLAG_RESTRICT 0x00000002 /* Restrict access to DBA */ - -/*------------------------- Database Shutdown Modes -------------------------*/ -#define OCI_DBSHUTDOWN_TRANSACTIONAL 1 /* Wait for all the transactions */ -#define OCI_DBSHUTDOWN_TRANSACTIONAL_LOCAL 2 /* Wait for local transactions */ -#define OCI_DBSHUTDOWN_IMMEDIATE 3 /* Terminate and roll back */ -#define OCI_DBSHUTDOWN_ABORT 4 /* Terminate and don't roll back */ -#define OCI_DBSHUTDOWN_FINAL 5 /* Orderly shutdown */ - -/*---------------------------OCIPasswordChange-------------------------------*/ -#define OCI_AUTH 0x08 /* Change the password but do not login */ - -/* ------------- DB Change Notification reg handle attributes ---------------*/ -#define OCI_ATTR_CHNF_TABLENAMES 401 /* out: array of table names - * */ -#define OCI_ATTR_CHNF_ROWIDS 402 /* in: rowids needed */ -#define OCI_ATTR_CHNF_OPERATIONS 403 /* in: notification operation - *filter*/ -#define OCI_ATTR_CHNF_CHANGELAG 404 /* txn lag between notifications - * */ - -/* DB Change: Notification Descriptor attributes -----------------------*/ -#define OCI_ATTR_CHDES_DBNAME 405 /* source database */ -#define OCI_ATTR_CHDES_NFYTYPE 406 /* notification type flags */ -#define OCI_ATTR_CHDES_XID 407 /* XID of the transaction */ -#define OCI_ATTR_CHDES_TABLE_CHANGES 408 /* array of table chg - *descriptors */ - -#define OCI_ATTR_CHDES_TABLE_NAME 409 /* table name */ -#define OCI_ATTR_CHDES_TABLE_OPFLAGS 410 /* table operation flags */ -#define OCI_ATTR_CHDES_TABLE_ROW_CHANGES 411 /* array of changed rows */ -#define OCI_ATTR_CHDES_ROW_ROWID 412 /* rowid of changed row */ -#define OCI_ATTR_CHDES_ROW_OPFLAGS 413 /* row operation flags */ - -/* Statement handle attribute for db change notification */ -#define OCI_ATTR_CHNF_REGHANDLE 414 /* IN: subscription handle */ - -/* DB Change: Event types ---------------*/ -#define OCI_EVENT_NONE 0x0 /* None */ -#define OCI_EVENT_STARTUP 0x1 /* Startup database */ -#define OCI_EVENT_SHUTDOWN 0x2 /* Shutdown database */ -#define OCI_EVENT_SHUTDOWN_ANY 0x3 /* Startup instance */ -#define OCI_EVENT_DROP_DB 0x4 /* Drop database */ -#define OCI_EVENT_DEREG 0x5 /* Subscription deregistered */ -#define OCI_EVENT_OBJCHANGE 0x6 /* Object change notification */ - -/* DB Change: Operation types -----------*/ -#define OCI_OPCODE_ALLROWS 0x1 /* all rows invalidated */ -#define OCI_OPCODE_ALLOPS 0x0 /* interested in all operations - **/ -#define OCI_OPCODE_INSERT 0x2 /* INSERT */ -#define OCI_OPCODE_UPDATE 0x4 /* UPDATE */ -#define OCI_OPCODE_DELETE 0x8 /* DELETE */ -#define OCI_OPCODE_ALTER 0x10 /* ALTER */ -#define OCI_OPCODE_DROP 0x20 /* DROP TABLE */ -#define OCI_OPCODE_UNKNOWN 0x40 /* GENERIC/ UNKNOWN*/ - -/*------------------------- Supported Namespaces ---------------------------*/ -#define OCI_SUBSCR_NAMESPACE_ANONYMOUS 0 /* Anonymous Namespace */ -#define OCI_SUBSCR_NAMESPACE_AQ 1 /* Advanced Queues */ -#define OCI_SUBSCR_NAMESPACE_DBCHANGE 2 /* change notification */ -#define OCI_SUBSCR_NAMESPACE_MAX 3 /* Max Name Space Number */ - - - -/* -------------------- HA Event Handle Attributes values------------------- */ -#define OCI_EVENTTYPE_HA 0 /* valid value for OCI_ATTR_EVENTTYPE */ - -/* valid values for OCI_ATTR_HA_SOURCE */ -#define OCI_HA_SOURCE_INSTANCE 0 -#define OCI_HA_SOURCE_DATABASE 1 -#define OCI_HA_SOURCE_NODE 2 -#define OCI_HA_SOURCE_SERVICE 3 -#define OCI_HA_SOURCE_SERVICE_MEMBER 4 -#define OCI_HA_SOURCE_ASM_INSTANCE 5 -#define OCI_HA_SOURCE_SERVICE_PRECONNECT 6 - -#define OCI_HA_STATUS_DOWN 0 /* valid values for OCI_ATTR_HA_STATUS */ -#define OCI_HA_STATUS_UP 1 - -/*------------- Supported Values for protocol for recipient -----------------*/ -#define OCI_SUBSCR_PROTO_OCI 0 /* oci */ -#define OCI_SUBSCR_PROTO_MAIL 1 /* mail */ -#define OCI_SUBSCR_PROTO_SERVER 2 /* server */ -#define OCI_SUBSCR_PROTO_HTTP 3 /* http */ -#define OCI_SUBSCR_PROTO_MAX 4 /* max current protocols */ - -/*------------- Supported Values for presentation for recipient -------------*/ -#define OCI_SUBSCR_PRES_DEFAULT 0 /* default */ -#define OCI_SUBSCR_PRES_XML 1 /* xml */ -#define OCI_SUBSCR_PRES_MAX 2 /* max current presentations */ - - -/* -------------------------- Implicit Result types ------------------------ */ -#define OCI_RESULT_TYPE_SELECT 1 - -/*-------------- Flags corresponding to the column properties----------------*/ -#define OCI_ATTR_COL_PROPERTY_IS_IDENTITY 0x0000000000000001 -#define OCI_ATTR_COL_PROPERTY_IS_GEN_ALWAYS 0x0000000000000002 -#define OCI_ATTR_COL_PROPERTY_IS_GEN_BY_DEF_ON_NULL 0x0000000000000004 -#define OCI_ATTR_COL_PROPERTY_IS_LPART 0x0000000000000008 -#define OCI_ATTR_COL_PROPERTY_IS_CONID 0x0000000000000010 - -/*-----------------Macros to get the various version number components------ */ - -#define OCI_SERVER_RELEASE_REL(v) ((sword)(((v) >> 24) & 0x000000FF)) - /* old: version number */ -/* new: feature release */ -#define OCI_SERVER_RELEASE_REL_UPD(v)\ - ((OCI_SERVER_RELEASE_REL(v) < 18)? \ - ((sword)(((v) >> 20) & 0x0000000F)):\ - ((sword)(((v) >> 16) & 0x000000FF))) /* old: release number */ - /* new: release update */ - -#define OCI_SERVER_RELEASE_REL_UPD_REV(v)\ - ((OCI_SERVER_RELEASE_REL(v) < 18)? \ - ((sword)(((v) >> 12) & 0x000000FF)):\ - ((sword)(((v) >> 12) & 0x0000000F))) - /* old: update number */ - /* new: release update revision */ - -#define OCI_SERVER_RELEASE_REL_UPD_INC(v)\ - ((OCI_SERVER_RELEASE_REL(v) < 18)? \ - ((sword)(((v) >> 8) & 0x0000000F)):\ - ((sword)(((v) >> 4) & 0x0000000FF))) - /* old: porting release number */ - /* new: release update increment */ - -#define OCI_SERVER_RELEASE_EXT(v)\ - ((OCI_SERVER_RELEASE_REL(v) < 18)? \ - ((sword)(((v) >> 0) & 0x000000FF)):\ - ((sword)(((v) >> 0) & 0x0000000F))) - /* old: porting update number */ - /* new: extension */ - - -#endif /* OCILIB_OCI_DEFS_H_INCLUDED */ - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * IMPORTANT NOTICE + * + * THIS FILE CONTAINS CONSTANTS AND STRUCTURES DECLARATIONS THAT WERE + * PICKED UP FROM ORACLE PUBLIC HEADER FILES. + * + * SO THE CONTENT OF THIS FILE MAY BE UNDER ORACLE COPYRIGHT AND THE + * DECLARATIONS REPRODUCED HERE ARE ORIGINALLY WRITTEN BY ORACLE CORPORATION + * + * THE AUTHOR OF OCILIB LIBRARY HAS NOT WRITTEN THE CONTENT OF THIS + * FILE AND HAS PARTIALLY INTEGRATED SOME ORACLE OCI DEFINITIONS TO + * ALLOW COMPILATION OF THIS OPEN SOURCE LIBRARY WITHOUT HAVING + * ORACLE PRODUCTS INSTALLED ON DEVELOPMENT ENVIRONMENTS + * + */ + +#ifndef OCILIB_OCI_DEFS_H_INCLUDED +#define OCILIB_OCI_DEFS_H_INCLUDED + +#include "types.h" + +/*--------------------------------------------------------------------------- + PUBLIC TYPES AND CONSTANTS + ---------------------------------------------------------------------------*/ + +/* input data types */ + +#define SQLT_CHR 1 /* (ORANET TYPE) character string */ +#define SQLT_NUM 2 /* (ORANET TYPE) oracle numeric */ +#define SQLT_INT 3 /* (ORANET TYPE) integer */ +#define SQLT_FLT 4 /* (ORANET TYPE) Floating point number */ +#define SQLT_STR 5 /* zero terminated string */ +#define SQLT_VNU 6 /* NUM with preceding length byte */ +#define SQLT_PDN 7 /* (ORANET TYPE) Packed Decimal Numeric */ +#define SQLT_LNG 8 /* long */ +#define SQLT_VCS 9 /* Variable character string */ +#define SQLT_NON 10 /* Null/empty PCC Descriptor entry */ +#define SQLT_RID 11 /* rowid */ +#define SQLT_DAT 12 /* date in oracle format */ +#define SQLT_VBI 15 /* binary in VCS format */ +#define SQLT_BFLOAT 21 /* Native Binary float*/ +#define SQLT_BDOUBLE 22 /* Native binary double */ +#define SQLT_BIN 23 /* binary data(DTYBIN) */ +#define SQLT_LBI 24 /* long binary */ +#define SQLT_UIN 68 /* unsigned integer */ +#define SQLT_SLS 91 /* Display sign leading separate */ +#define SQLT_LVC 94 /* Longer longs (char) */ +#define SQLT_LVB 95 /* Longer long binary */ +#define SQLT_AFC 96 /* Ansi fixed char */ +#define SQLT_AVC 97 /* Ansi Var char */ +#define SQLT_IBFLOAT 100 /* binary float canonical */ +#define SQLT_IBDOUBLE 101 /* binary double canonical */ +#define SQLT_CUR 102 /* cursor type */ +#define SQLT_RDD 104 /* rowid descriptor */ +#define SQLT_LAB 105 /* label type */ +#define SQLT_OSL 106 /* oslabel type */ + +#define SQLT_NTY 108 /* named object type */ +#define SQLT_REF 110 /* ref type */ +#define SQLT_CLOB 112 /* character lob */ +#define SQLT_BLOB 113 /* binary lob */ +#define SQLT_BFILEE 114 /* binary file lob */ +#define SQLT_CFILEE 115 /* character file lob */ +#define SQLT_RSET 116 /* result set type */ +#define SQLT_NCO 122 /* named collection type (varray or nested table) */ +#define SQLT_VST 155 /* OCIString type */ +#define SQLT_ODT 156 /* OCIDate type */ + +/* datetimes and intervals */ +#define SQLT_DATE 184 /* ANSI Date */ +#define SQLT_TIME 185 /* TIME */ +#define SQLT_TIME_TZ 186 /* TIME WITH TIME ZONE */ +#define SQLT_TIMESTAMP 187 /* TIMESTAMP */ +#define SQLT_TIMESTAMP_TZ 188 /* TIMESTAMP WITH TIME ZONE */ +#define SQLT_INTERVAL_YM 189 /* INTERVAL YEAR TO MONTH */ +#define SQLT_INTERVAL_DS 190 /* INTERVAL DAY TO SECOND */ +#define SQLT_TIMESTAMP_LTZ 232 /* TIMESTAMP WITH LOCAL TZ */ + +/* cxcheng: this has been added for backward compatibility - + it needs to be here because ocidfn.h can get included ahead of sqldef.h */ +#define SQLT_FILE SQLT_BFILEE /* binary file lob */ +#define SQLT_CFILE SQLT_CFILEE +#define SQLT_BFILE SQLT_BFILEE + +#define SQLT_PNTY 241 /* pl/sql representation of named types */ + +/* some pl/sql specific types */ +#define SQLT_REC 250 /* pl/sql 'record' (or %rowtype) */ +#define SQLT_TAB 251 /* pl/sql 'indexed table' */ +#define SQLT_BOL 252 /* pl/sql 'boolean' */ + +/* CHAR/NCHAR/VARCHAR2/NVARCHAR2/CLOB/NCLOB char set "form" information */ +#define SQLCS_IMPLICIT 1 /* for CHAR, VARCHAR2, CLOB w/o a specified set */ +#define SQLCS_NCHAR 2 /* for NCHAR, NCHAR VARYING, NCLOB */ +#define SQLCS_EXPLICIT 3 /* for CHAR, etc, with "CHARACTER SET ..." syntax */ +#define SQLCS_FLEXIBLE 4 /* for PL/SQL "flexible" parameters */ +#define SQLCS_LIT_NULL 5 /* for type check of NULL and empty_clob() */ + +/*-----------------------------Handle Types----------------------------------*/ +/* handle types range from 1 - 49 */ +#define OCI_HTYPE_FIRST 1 /* start value of handle type */ +#define OCI_HTYPE_ENV 1 /* environment handle */ +#define OCI_HTYPE_ERROR 2 /* error handle */ +#define OCI_HTYPE_SVCCTX 3 /* service handle */ +#define OCI_HTYPE_STMT 4 /* statement handle */ +#define OCI_HTYPE_BIND 5 /* bind handle */ +#define OCI_HTYPE_DEFINE 6 /* define handle */ +#define OCI_HTYPE_DESCRIBE 7 /* describe handle */ +#define OCI_HTYPE_SERVER 8 /* server handle */ +#define OCI_HTYPE_SESSION 9 /* authentication handle */ +#define OCI_HTYPE_AUTHINFO OCI_HTYPE_SESSION /* SessionGet auth handle */ +#define OCI_HTYPE_SUBSCRIPTION 13 /* subscription handle */ +#define OCI_HTYPE_DIRPATH_CTX 14 /* direct path context */ +#define OCI_HTYPE_DIRPATH_COLUMN_ARRAY 15 /* direct path column array */ +#define OCI_HTYPE_DIRPATH_STREAM 16 /* direct path stream */ +#define OCI_HTYPE_TRANS 10 /* transaction handle */ +#define OCI_HTYPE_CPOOL 26 /* connection pool handle */ +#define OCI_HTYPE_SPOOL 27 /* session pool handle */ +#define OCI_HTYPE_ADMIN 28 /* admin handle */ + +/*-------------------------Descriptor Types----------------------------------*/ + +#define OCI_DTYPE_LOB 50 /* lob locator */ +#define OCI_DTYPE_PARAM 53 /* a parameter descriptor obtained from ocigparm */ +#define OCI_DTYPE_FILE 56 /* File Lob locator */ +#define OCI_DTYPE_AQENQ_OPTIONS 57 /* enqueue options */ +#define OCI_DTYPE_AQDEQ_OPTIONS 58 /* dequeue options */ +#define OCI_DTYPE_AQMSG_PROPERTIES 59 /* message properties */ +#define OCI_DTYPE_AQAGENT 60 /* aq agent */ +#define OCI_DTYPE_INTERVAL_YM 62 /* Interval year month */ +#define OCI_DTYPE_INTERVAL_DS 63 /* Interval day second */ +#define OCI_DTYPE_AQNFY_DESCRIPTOR 64 /* AQ notify descriptor */ +#define OCI_DTYPE_DATE 65 /* Date */ +#define OCI_DTYPE_TIME 66 /* Time */ +#define OCI_DTYPE_TIME_TZ 67 /* Time with timezone */ +#define OCI_DTYPE_TIMESTAMP 68 /* Timestamp */ +#define OCI_DTYPE_TIMESTAMP_TZ 69 /* Timestamp with timezone */ +#define OCI_DTYPE_TIMESTAMP_LTZ 70 /* Timestamp with local tz */ +#define OCI_DTYPE_CHDES 77 /* Top level change notification + *desc */ +#define OCI_DTYPE_TABLE_CHDES 78 /* Table change descriptor + * */ +#define OCI_DTYPE_ROW_CHDES 79 /* Row change descriptor + * */ + +/*---------------------------------------------------------------------------*/ + +/*--------------------------------LOB types ---------------------------------*/ +#define OCI_TEMP_BLOB 1 /* LOB type - BLOB ------------------ */ +#define OCI_TEMP_CLOB 2 /* LOB type - CLOB ------------------ */ +/*---------------------------------------------------------------------------*/ + +/*--------------------------Attribute Types----------------------------------*/ + +#define OCI_ATTR_OBJECT 2 /* is the environment initialized in object mode */ +#define OCI_ATTR_SQLCODE 4 /* the SQL verb */ +#define OCI_ATTR_ENV 5 /* the environment handle */ +#define OCI_ATTR_SERVER 6 /* the server handle */ +#define OCI_ATTR_SESSION 7 /* the user session handle */ +#define OCI_ATTR_TRANS 8 /* the transaction handle */ +#define OCI_ATTR_ROW_COUNT 9 /* the rows processed so far */ +#define OCI_ATTR_SQLFNCODE 10 /* the SQL verb of the statement */ +#define OCI_ATTR_PREFETCH_ROWS 11 /* sets the number of rows to prefetch */ +#define OCI_ATTR_NESTED_PREFETCH_ROWS 12 /* the prefetch rows of nested table*/ +#define OCI_ATTR_PREFETCH_MEMORY 13 /* memory limit for rows fetched */ +#define OCI_ATTR_NESTED_PREFETCH_MEMORY 14 /* memory limit for nested rows */ +#define OCI_ATTR_PDSCL 16 /* packed decimal scale */ +#define OCI_ATTR_FSPRECISION OCI_ATTR_PDSCL + +/* fs prec for datetime data types */ +#define OCI_ATTR_PDPRC 17 /* packed decimal format */ +#define OCI_ATTR_LFPRECISION OCI_ATTR_PDPRC + +/* fs prec for datetime data types */ + +#define OCI_ATTR_PARAM_COUNT 18 /* number of column in the select list */ +#define OCI_ATTR_ROWID 19 /* the rowid */ +#define OCI_ATTR_CHARSET 20 /* the character set value */ +#define OCI_ATTR_USERNAME 22 /* username attribute */ +#define OCI_ATTR_PASSWORD 23 /* password attribute */ +#define OCI_ATTR_STMT_TYPE 24 /* statement type */ +#define OCI_ATTR_XID 27 /* XOPEN defined global transaction id */ +#define OCI_ATTR_CHARSET_ID 31 /* Character Set ID */ +#define OCI_ATTR_CHARSET_FORM 32 /* Character Set Form */ +#define OCI_ATTR_MAXDATA_SIZE 33 /* Maximumsize of data on the server */ +#define OCI_ATTR_ROWS_RETURNED 42 + +#define OCI_ATTR_FOCBK 43 /* Failover Callback attribute */ + + +/* Number of rows returned in current iter - for Bind handles */ + +#define OCI_ATTR_LOBEMPTY 45 /* empty lob ? */ + +#define OCI_ATTR_VISIBILITY 47 /* visibility */ +#define OCI_ATTR_RELATIVE_MSGID 48 /* relative message id */ +#define OCI_ATTR_SEQUENCE_DEVIATION 49 /* sequence deviation */ + +#define OCI_ATTR_CONSUMER_NAME 50 /* consumer name */ +#define OCI_ATTR_DEQ_MODE 51 /* dequeue mode */ +#define OCI_ATTR_NAVIGATION 52 /* navigation */ +#define OCI_ATTR_WAIT 53 /* wait */ +#define OCI_ATTR_DEQ_MSGID 54 /* dequeue message id */ + +#define OCI_ATTR_PRIORITY 55 /* priority */ +#define OCI_ATTR_DELAY 56 /* delay */ +#define OCI_ATTR_EXPIRATION 57 /* expiration */ +#define OCI_ATTR_CORRELATION 58 /* correlation id */ +#define OCI_ATTR_ATTEMPTS 59 /* # of attempts */ +#define OCI_ATTR_RECIPIENT_LIST 60 /* recipient list */ +#define OCI_ATTR_EXCEPTION_QUEUE 61 /* exception queue name */ +#define OCI_ATTR_ENQ_TIME 62 /* enqueue time (only OCIAttrGet) */ +#define OCI_ATTR_MSG_STATE 63 /* message state (only OCIAttrGet) */ +/* NOTE: 64-66 used below */ +#define OCI_ATTR_AGENT_NAME 64 /* agent name */ +#define OCI_ATTR_AGENT_ADDRESS 65 /* agent address */ +#define OCI_ATTR_AGENT_PROTOCOL 66 /* agent protocol */ +#define OCI_ATTR_USER_PROPERTY 67 /* user property */ +#define OCI_ATTR_SENDER_ID 68 /* sender id */ +#define OCI_ATTR_ORIGINAL_MSGID 69 /* original message id */ +#define OCI_ATTR_QUEUE_NAME 70 /* queue name */ + +#define OCI_ATTR_NUM_DML_ERRORS 73 /* num of errs in array DML */ +#define OCI_ATTR_DML_ROW_OFFSET 74 /* row offset in the array */ + +#define OCI_ATTR_DATEFORMAT 75 /* default date format string */ +#define OCI_ATTR_BUF_ADDR 76 /* buffer address */ +#define OCI_ATTR_BUF_SIZE 77 /* buffer size */ +#define OCI_ATTR_NUM_ROWS 81 /* number of rows in column array */ +#define OCI_ATTR_COL_COUNT 82 /* columns of column array + processed so far. */ + +#define OCI_ATTR_SUBSCR_NAME 94 /* name of subscription */ +#define OCI_ATTR_SUBSCR_CALLBACK 95 /* associated callback */ +#define OCI_ATTR_SUBSCR_CTX 96 /* associated callback context */ +#define OCI_ATTR_SUBSCR_PAYLOAD 97 /* associated payload */ +#define OCI_ATTR_SUBSCR_NAMESPACE 98 /* associated namespace */ + +#define OCI_ATTR_NUM_COLS 102 /* number of columns */ +#define OCI_ATTR_LIST_COLUMNS 103 /* parameter of the column list */ +#define OCI_ATTR_COL_PROPERTIES 104 /* column properties */ +#define OCI_ATTR_REF_TDO 110 /* REF to the type descriptor */ +#define OCI_ATTR_LINK 111 /* the database link name */ +#define OCI_ATTR_NUM_PARAMS 121 /* number of parameters */ + +#define OCI_ATTR_PTYPE 123 /* type of info described by */ +#define OCI_ATTR_PARAM 124 /* parameter descriptor */ +#define OCI_ATTR_PARSE_ERROR_OFFSET 129 /* Parse Error offset */ + +#define OCI_ATTR_SERVER_STATUS 143 /* state of the server hdl */ +#define OCI_ATTR_STATEMENT 144 /* statement txt in stmt hdl */ + +#define OCI_ATTR_SUBSCR_RECPTPROTO 149 /* protocol for recipient */ + +#define OCI_ATTR_CURRENT_POSITION 164 /* for scrollable result sets*/ +#define OCI_ATTR_STMTCACHESIZE 176 /* size of the stmt cache */ + +#define OCI_ATTR_CONN_NOWAIT 178 +#define OCI_ATTR_CONN_BUSY_COUNT 179 +#define OCI_ATTR_CONN_OPEN_COUNT 180 +#define OCI_ATTR_CONN_TIMEOUT 181 +#define OCI_ATTR_STMT_STATE 182 +#define OCI_ATTR_CONN_MIN 183 +#define OCI_ATTR_CONN_MAX 184 +#define OCI_ATTR_CONN_INCR 185 +#define OCI_ATTR_SUBSCR_RECPTPRES 195 +#define OCI_ATTR_ROWS_FETCHED 197 /* rows fetched in last call */ +#define OCI_ATTR_SPOOL_STMTCACHESIZE 208 /*Stmt cache size of pool */ + +#define OCI_ATTR_TYPECODE 216 /* object or collection */ +#define OCI_ATTR_COLLECTION_TYPECODE 217 /* varray or nested table */ +#define OCI_ATTR_IS_PREDEFINED_TYPE 221 /* a predefined type */ + +#define OCI_ATTR_SUBSCR_TIMEOUT 227 /* Timeout */ + +#define OCI_ATTR_COLLECTION_ELEMENT 227 /* has a collection attribute */ +#define OCI_ATTR_NUM_TYPE_ATTRS 228 /* number of attribute types */ +#define OCI_ATTR_LIST_TYPE_ATTRS 229 /* list of type attributes */ + +#define OCI_ATTR_DESC_PUBLIC 250 /* public object */ + +#define OCI_ATTR_IS_SUBTYPE 258 /* Is this a subtype? */ +#define OCI_ATTR_SUPERTYPE_SCHEMA_NAME 259 /* Name of the supertype schema */ +#define OCI_ATTR_SUPERTYPE_NAME 260 /* Name of the supertype */ + +#define OCI_ATTR_CLIENT_IDENTIFIER 278 /* value of client id to set*/ + +#define OCI_ATTR_IS_FINAL_TYPE 279 /* is final type ? */ + +#define OCI_ATTR_CHAR_USED 285 /* char length semantics */ +#define OCI_ATTR_CHAR_SIZE 286 /* char length */ + +#define OCI_ATTR_EVTCBK 304 /* ha callback */ +#define OCI_ATTR_EVTCTX 305 /* ctx for ha callback */ + +#define OCI_ATTR_SPOOL_TIMEOUT 308 /* session timeout */ +#define OCI_ATTR_SPOOL_GETMODE 309 /* session get mode */ +#define OCI_ATTR_SPOOL_BUSY_COUNT 310 /* busy session count */ +#define OCI_ATTR_SPOOL_OPEN_COUNT 311 /* open session count */ +#define OCI_ATTR_SPOOL_MIN 312 /* min session count */ +#define OCI_ATTR_SPOOL_MAX 313 /* max session count */ +#define OCI_ATTR_SPOOL_INCR 314 /* session increment count */ + +#define OCI_ATTR_TRANSACTION_NO 365 /* AQ enq txn number */ + +#define OCI_ATTR_MODULE 366 /* module for tracing */ +#define OCI_ATTR_ACTION 367 /* action for tracing */ +#define OCI_ATTR_CLIENT_INFO 368 /* client info */ + +#define OCI_ATTR_ADMIN_PFILE 389 /* client-side param file */ + +#define OCI_ATTR_SUBSCR_PORTNO 390 /* port no to listen */ + +#define OCI_ATTR_HOSTNAME 390 /* SYS_CONTEXT hostname */ +#define OCI_ATTR_DBNAME 391 /* SYS_CONTEXT dbname */ +#define OCI_ATTR_INSTNAME 392 /* SYS_CONTEXT instance name */ +#define OCI_ATTR_SERVICENAME 393 /* SYS_CONTEXT service name */ +#define OCI_ATTR_INSTSTARTTIME 394 /* v$instance instance start time */ +#define OCI_ATTR_HA_TIMESTAMP 395 /* event time */ +#define OCI_ATTR_DBDOMAIN 399 /* db domain */ +#define OCI_ATTR_EVENTTYPE 400 /* event type */ +#define OCI_ATTR_HA_SOURCE 401 +#define OCI_ATTR_HA_STATUS 402 +#define OCI_ATTR_HA_SRVFIRST 403 +#define OCI_ATTR_HA_SRVNEXT 404 +#define OCI_ATTR_TAF_ENABLED 405 +#define OCI_ATTR_DRIVER_NAME 424 /* Driver Name */ + +#define OCI_ATTR_SEND_TIMEOUT 435 /* NS send timeout */ +#define OCI_ATTR_RECEIVE_TIMEOUT 436 /* NS receive timeout */ + +#define OCI_ATTR_SPOOL_AUTH 460 /* Auth handle on pool handle*/ + +#define OCI_ATTR_IMPLICIT_RESULT_COUNT 463 + + +/*--------- Attributes related to LOB prefetch------------------------------ */ +#define OCI_ATTR_DEFAULT_LOBPREFETCH_SIZE 438 /* default prefetch size */ +#define OCI_ATTR_LOBPREFETCH_SIZE 439 /* prefetch size */ +#define OCI_ATTR_LOBPREFETCH_LENGTH 440 /* prefetch length & chunk */ + +/* session handle attribute */ +#define OCI_ATTR_MAX_OPEN_CURSORS 471 + +/* add attribute for DBOP: DataBase OPeration */ +#define OCI_ATTR_DBOP 485 + +#define OCI_ATTR_COLLATION_ID 499 /* Collation ID */ +#define OCI_ATTR_SQL_ID 504 /* SQL ID in text form */ +#define OCI_ATTR_LOB_REMOTE 520 /* remote lob ? */ +#define OCI_ATTR_CALL_TIMEOUT 531 + +/*------- Temporary attribute value for UCS2/UTF16 character set ID -------- */ + +#define OCI_UCS2ID 1000 /* UCS2 charset ID */ +#define OCI_UTF16ID 1000 /* UTF16 charset ID */ + +/*-------------------------Credential Types----------------------------------*/ + +#define OCI_CRED_RDBMS 1 /* database username/password */ +#define OCI_CRED_EXT 2 /* externally provided credentials */ +#define OCI_CRED_PROXY 3 /* proxy authentication */ + +/*------------------------Error Return Values--------------------------------*/ + +#define OCI_SUCCESS 0 /* maps to SQL_SUCCESS of SAG CLI */ +#define OCI_SUCCESS_WITH_INFO 1 /* maps to SQL_SUCCESS_WITH_INFO */ +#define OCI_NO_DATA 100 /* maps to SQL_NO_DATA */ +#define OCI_ERROR (-1 ) /* maps to SQL_ERROR */ +#define OCI_INVALID_HANDLE (-2) /* maps to SQL_INVALID_HANDLE */ +#define OCI_NEED_DATA 99 /* maps to SQL_NEED_DATA */ +#define OCI_STILL_EXECUTING (-3123 ) /* OCI would block error */ + +/*---------------- Server Handle Attribute Values ---------------------------*/ + +#define OCI_SERVER_NOT_CONNECTED 0x0 +#define OCI_SERVER_NORMAL 0x1 + +/*--------------------- User Callback Return Values -------------------------*/ +#define OCI_CONTINUE (-24200) /* Continue with the body of the OCI function */ + +/*------------------------Attach Modes---------------------------------------*/ + +#define OCI_CPOOL 0x0200 /* Attach using server handle from pool */ + +/*------------------DateTime and Interval check Error codes------------------*/ + +#define OCI_DT_INVALID_DAY 0x1 /* Bad day */ +#define OCI_DT_DAY_BELOW_VALID 0x2 /* Bad DAy Low/high bit (1=low)*/ +#define OCI_DT_INVALID_MONTH 0x4 /* Bad MOnth */ +#define OCI_DT_MONTH_BELOW_VALID 0x8 /* Bad MOnth Low/high bit (1=low) */ +#define OCI_DT_INVALID_YEAR 0x10 /* Bad YeaR */ +#define OCI_DT_YEAR_BELOW_VALID 0x20 /* Bad YeaR Low/high bit (1=low) */ +#define OCI_DT_INVALID_HOUR 0x40 /* Bad HouR */ +#define OCI_DT_HOUR_BELOW_VALID 0x80 /* Bad HouR Low/high bit (1=low) */ +#define OCI_DT_INVALID_MINUTE 0x100 /* Bad MiNute */ +#define OCI_DT_MINUTE_BELOW_VALID 0x200 /*Bad MiNute Low/high bit (1=low) */ +#define OCI_DT_INVALID_SECOND 0x400 /* Bad SeCond */ +#define OCI_DT_SECOND_BELOW_VALID 0x800 /*bad second Low/high bit (1=low)*/ +#define OCI_DT_DAY_MISSING_FROM_1582 0x1000 + +/* Day is one of those "missing" from 1582 */ +#define OCI_DT_YEAR_ZERO 0x2000 /* Year may not equal zero */ +#define OCI_DT_INVALID_TIMEZONE 0x4000 /* Bad Timezone */ +#define OCI_DT_INVALID_FORMAT 0x8000 /* Bad date format input */ + +/*------------------------Scrollable Cursor Fetch Options------------------- + * For non-scrollable cursor, the only valid (and default) orientation is + * OCI_FETCH_NEXT + */ +#define OCI_FETCH_CURRENT 0x01 /* refetching current position */ +#define OCI_FETCH_NEXT 0x02 /* next row */ +#define OCI_FETCH_FIRST 0x04 /* first row of the result set */ +#define OCI_FETCH_LAST 0x08 /* the last row of the result set */ +#define OCI_FETCH_PRIOR 0x10 /* the previous row relative to current */ +#define OCI_FETCH_ABSOLUTE 0x20 /* absolute offset from first */ +#define OCI_FETCH_RELATIVE 0x40 /* offset relative to current */ +#define OCI_FETCH_RESERVED_1 0x80 /* reserved */ + +/*------------------------Parse mode ----------------------------------------*/ + +#define OCI_NTV_SYNTAX 1 /* Use what so ever is the native lang of server */ + +/*------------------------Bind and Define Options----------------------------*/ + +#define OCI_DATA_AT_EXEC 0x00000002 /* data at execute time */ +#define OCI_DYNAMIC_FETCH 0x00000002 /* fetch dynamically */ +#define OCI_PIECEWISE 0x00000004 /* piecewise DMLs or fetch */ +#define OCI_BIND_SOFT 0x00000040 /* soft bind or define */ +#define OCI_DEFINE_SOFT 0x00000080 /* soft bind or define */ + +/*----------------------- Execution Modes -----------------------------------*/ + +#define OCI_BATCH_MODE 0x00000001 /* batch the oci stmt for exec */ +#define OCI_STMT_SCROLLABLE_READONLY \ + 0x00000008 /* if result set is scrollable */ +#define OCI_DESCRIBE_ONLY 0x00000010 /* only describe the statement */ +#define OCI_BATCH_ERRORS 0x00000080 /* batch errors in array dmls */ +#define OCI_PARSE_ONLY 0x00000100 /* only parse the statement */ + +/*----------------------------- Various Modes ------------------------------*/ +#define OCI_DEFAULT 0x00000000 +#define OCI_THREADED 0x00000001 /* appl. in threaded environment */ +#define OCI_OBJECT 0x00000002 /* application in object environment */ +#define OCI_EVENTS 0x00000004 /* application is enabled for events */ +#define OCI_UTF16 0x00004000 /* mode for all UTF16 metadata */ +#define OCI_NCHAR_LITERAL_REPLACE_ON 0x00400000 /* nchar literal replace on */ +#define OCI_NCHAR_LITERAL_REPLACE_OFF 0x00800000 /* nchar literal replace off*/ + +/*------------------------Authentication Modes-------------------------------*/ +#define OCI_SYSDBA 0x00000002 /* for SYSDBA authorization */ +#define OCI_SYSOPER 0x00000004 /* for SYSOPER authorization */ +#define OCI_PRELIM_AUTH 0x00000008 /* for preliminary authorization */ +#define OCI_STMT_CACHE 0x00000040 /* enable OCI Stmt Caching */ + +/*------------------------ Transaction Start Flags --------------------------*/ + +#define OCI_TRANS_NEW 0x00000001 /* starts a new transaction branch */ +#define OCI_TRANS_JOIN 0x00000002 /* join an existing transaction */ +#define OCI_TRANS_RESUME 0x00000004 /* resume this transaction */ +#define OCI_TRANS_STARTMASK 0x000000ff + +#define OCI_TRANS_READONLY 0x00000100 /* starts a readonly transaction */ +#define OCI_TRANS_READWRITE 0x00000200 /* starts a read-write transaction */ +#define OCI_TRANS_SERIALIZABLE 0x00000400 + +/* starts a serializable transaction */ +#define OCI_TRANS_ISOLMASK 0x0000ff00 + +#define OCI_TRANS_LOOSE 0x00010000 /* a loosely coupled branch */ +#define OCI_TRANS_TIGHT 0x00020000 /* a tightly coupled branch */ +#define OCI_TRANS_TYPEMASK 0x000f0000 + +#define OCI_TRANS_NOMIGRATE 0x00100000 /* non migratable transaction */ +#define OCI_TRANS_SEPARABLE 0x00200000 /* separable transaction (8.1.6+) */ +#define OCI_TRANS_OTSRESUME 0x00400000 /* OTS resuming a transaction */ + +/*------------------------ Transaction End Flags ----------------------------*/ + +#define OCI_TRANS_TWOPHASE 0x01000000 /* use two phase commit */ +#define OCI_TRANS_WRITEBATCH 0x00000001 /* force cmt-redo for local txns */ +#define OCI_TRANS_WRITEIMMED 0x00000002 /* no force cmt-redo */ +#define OCI_TRANS_WRITEWAIT 0x00000004 /* no sync cmt-redo */ +#define OCI_TRANS_WRITENOWAIT 0x00000008 /* sync cmt-redo for local txns */ + +/*------------------------Describe Handle Parameter Attributes --------------*/ + +#define OCI_ATTR_DATA_SIZE 1 /* maximum size of the data */ +#define OCI_ATTR_DATA_TYPE 2 /* the SQL type of the column/argument */ +#define OCI_ATTR_DISP_SIZE 3 /* the display size */ +#define OCI_ATTR_NAME 4 /* the name of the column/argument */ +#define OCI_ATTR_PRECISION 5 /* precision if number type */ +#define OCI_ATTR_SCALE 6 /* scale if number type */ +#define OCI_ATTR_IS_NULL 7 /* is it null ? */ +#define OCI_ATTR_TYPE_NAME 8 /* name of the named data type */ +#define OCI_ATTR_SCHEMA_NAME 9 /* the schema name */ +#define OCI_ATTR_SUB_NAME 10 /* type name if package private type */ +#define OCI_ATTR_PACKAGE_NAME 12 /* package name of package type */ + +/*------------------------Other Constants------------------------------------*/ + +#define OCI_ERROR_MAXMSG_SIZE 1024 /* max size of an error message */ +#define OCI_LOBMAXSIZE MINUB4MAXVAL /* maximum lob data size */ +#define OCI_ROWID_LEN 23 + +/*---------------------OCIStmtPrepare2 Modes---------------------------------*/ +#define OCI_PREP2_CACHE_SEARCHONLY 0x0010 /* ONly Search */ +#define OCI_PREP2_GET_PLSQL_WARNINGS 0x0020 /* Get PL/SQL warnings */ +#define OCI_PREP2_RESERVED_1 0x0040 /* reserved */ +#define OCI_PREP2_RESERVED_2 0x0080 /* reserved */ +#define OCI_PREP2_RESERVED_3 0x0100 /* reserved */ +#define OCI_PREP2_RESERVED_4 0x0200 /* reserved */ +#define OCI_PREP2_IMPL_RESULTS_CLIENT 0x0400 /* client for implicit results */ +#define OCI_PREP2_RESERVED_5 0x0800 /* reserved */ +#define OCI_PREP2_RESERVED_6 0x1000 /* reserved */ +#define OCI_PREP2_GET_SQL_ID 0x2000 /* Get SQL_ID for the SQL stmt */ +#define OCI_PREP2_RESERVED_7 0x4000 /* reserved */ +#define OCI_PREP2_RESERVED_8 0x8000 /* reserved */ +#define OCI_PREP2_RESERVED_9 0x10000 /* reserved */ + +/*---------------------OCIStmtRelease Modes----------------------------------*/ +#define OCI_STRLS_CACHE_DELETE 0x0010 /* Delete from Cache */ + +/*-----------------------Handle Definitions----------------------------------*/ +typedef struct OCIEnv OCIEnv; /* OCI environment handle */ +typedef struct OCIError OCIError; /* OCI error handle */ +typedef struct OCISvcCtx OCISvcCtx; /* OCI service handle */ +typedef struct OCIStmt OCIStmt; /* OCI statement handle */ +typedef struct OCIBind OCIBind; /* OCI bind handle */ +typedef struct OCIDefine OCIDefine; /* OCI Define handle */ +typedef struct OCIDescribe OCIDescribe; /* OCI Describe handle */ +typedef struct OCIServer OCIServer; /* OCI Server handle */ +typedef struct OCISession OCISession; /* OCI Authentication handle */ +typedef struct OCIComplexObject OCIComplexObject; /* OCI COR handle */ +typedef struct OCITrans OCITrans; /* OCI Transaction handle */ +typedef struct OCISecurity OCISecurity; /* OCI Security handle */ +typedef struct OCISubscription OCISubscription; /* subscription handle */ + +typedef struct OCICPool OCICPool; /* connection pool handle */ +typedef struct OCISPool OCISPool; /* session pool handle */ +typedef struct OCIAuthInfo OCIAuthInfo; /* auth handle */ +typedef struct OCIAdmin OCIAdmin; /* admin handle */ +typedef struct OCIEvent OCIEvent; /* HA event handle */ + +typedef struct OCIDirPathCtx OCIDirPathCtx; /* DP context */ +typedef struct OCIDirPathColArray OCIDirPathColArray; /* DP column array */ +typedef struct OCIDirPathStream OCIDirPathStream; /* DP stream */ + +typedef struct OCIAQEnqOptions OCIAQEnqOptions; /* AQ Enqueue Options hdl */ +typedef struct OCIAQDeqOptions OCIAQDeqOptions; /* AQ Dequeue Options hdl */ +typedef struct OCIAQMsgProperties OCIAQMsgProperties; /* AQ Mesg Properties */ +typedef struct OCIAQAgent OCIAQAgent; /* AQ Agent descriptor */ +typedef struct OCIAQNfyDescriptor OCIAQNfyDescriptor; /* AQ Nfy descriptor */ +typedef struct OCIAQSignature OCIAQSignature; /* AQ Signature */ +typedef struct OCIAQListenOpts OCIAQListenOpts; /* AQ listen options */ +typedef struct OCIAQLisMsgProps OCIAQLisMsgProps; /* AQ listen msg props */ + +/*---------------------------------------------------------------------------*/ +/*------------------------- OCISessionPoolCreate Modes ----------------------*/ + +#define OCI_SPC_REINITIALIZE 0x0001 /* Reinitialize the session pool */ +#define OCI_SPC_HOMOGENEOUS 0x0002 /* Session pool is homogeneneous */ +#define OCI_SPC_STMTCACHE 0x0004 /* Session pool has stmt cache */ + +/*---------------------------------------------------------------------------*/ +/*--------------------------- OCISessionGet Modes ---------------------------*/ + +#define OCI_SESSGET_SPOOL 0x0001 /* SessionGet called in SPOOL mode */ +#define OCI_SESSGET_CPOOL OCI_CPOOL /* SessionGet called in CPOOL mode */ +#define OCI_SESSGET_STMTCACHE 0x0004 /* Use statement cache */ +#define OCI_SESSGET_CREDPROXY 0x0008 /* SessionGet called in proxy mode */ +#define OCI_SESSGET_CREDEXT 0x0010 +#define OCI_SESSGET_SPOOL_MATCHANY 0x0020 +#define OCI_SESSGET_SYSDBA 0x0100 /* SessionGet with SYSDBA privileges */ + +/*---------------------------------------------------------------------------*/ +/*------------------------ATTR Values for Session Pool-----------------------*/ +/* Attribute values for OCI_ATTR_SPOOL_GETMODE */ +#define OCI_SPOOL_ATTRVAL_WAIT 0 /* block till you get a session */ +#define OCI_SPOOL_ATTRVAL_NOWAIT 1 /* error out if no session available */ +#define OCI_SPOOL_ATTRVAL_FORCEGET 2 /* get session even if max is exceeded */ + +/*---------------------------------------------------------------------------*/ +/*--------------------------- OCISessionRelease Modes -----------------------*/ + +#define OCI_SESSRLS_DROPSESS 0x0001 /* Drop the Session */ +#define OCI_SESSRLS_RETAG 0x0002 /* Retag the session */ + +/*---------------------------------------------------------------------------*/ +/*----------------------- OCISessionPoolDestroy Modes -----------------------*/ + +#define OCI_SPD_FORCE 0x0001 /* Force the sessions to terminate. + Even if there are some busy + sessions close them */ + +/*------------------------ Fail Over Events ---------------------------------*/ +#define OCI_FO_END 0x00000001 +#define OCI_FO_ABORT 0x00000002 +#define OCI_FO_REAUTH 0x00000004 +#define OCI_FO_BEGIN 0x00000008 +#define OCI_FO_ERROR 0x00000010 +/*---------------------------------------------------------------------------*/ + +/*------------------------ Fail Over Callback Return Codes ------------------*/ +#define OCI_FO_RETRY 25410 +/*---------------------------------------------------------------------------*/ + +/*------------------------- Fail Over Types ---------------------------------*/ +#define OCI_FO_NONE 0x00000001 +#define OCI_FO_SESSION 0x00000002 +#define OCI_FO_SELECT 0x00000004 +#define OCI_FO_TXNAL 0x00000008 + +/*--------------------------Failover Callback Structure ---------------------*/ +typedef sb4 (*OCICallbackFailover)(dvoid *svcctx, dvoid *envctx, + dvoid *fo_ctx, ub4 fo_type, + ub4 fo_event); + +typedef struct +{ + OCICallbackFailover callback_function; + dvoid *fo_ctx; +} +OCIFocbkStruct; + +/*--------------------- OCI Thread Object Definitions------------------------*/ + +/* OCIThread Context */ +typedef struct OCIThreadContext OCIThreadContext; + +/* OCIThread Mutual Exclusion Lock */ +typedef struct OCIThreadMutex OCIThreadMutex; + +/* OCIThread Key for Thread-Specific Data */ +typedef struct OCIThreadKey OCIThreadKey; + +/* OCIThread Thread ID */ +typedef struct OCIThreadId OCIThreadId; + +/* OCIThread Thread Handle */ +typedef struct OCIThreadHandle OCIThreadHandle; + +/*--------------------- OCI Collection Object Definitions--------------------*/ + +/* OCIColl - generic collection type */ +typedef struct OCIColl OCIColl; + +/* OCIArray - varray collection type */ +typedef OCIColl OCIArray; + +/* OCITable - nested table collection type */ +typedef OCIColl OCITable; + +/* OCIIter - collection iterator */ +typedef struct OCIIter OCIIter; + +/*-----------------------Descriptor Definitions------------------------------*/ + +typedef struct OCISnapshot OCISnapshot; /* OCI snapshot descriptor */ +typedef struct OCIResult OCIResult; /* OCI Result Set Descriptor */ +typedef struct OCILobLocator OCILobLocator; /* OCI Lob Locator descriptor */ +typedef struct OCIParam OCIParam; /* OCI PARameter descriptor */ +typedef struct OCIDateTime OCIDateTime; /* OCI DateTime descriptor */ +typedef struct OCIInterval OCIInterval; /* OCI Interval descriptor */ +typedef struct OCIRowid OCIRowid; /* OCI ROWID descriptor */ + +/*----------------------------- OBJECT FREE OPTION --------------------------*/ + +#define OCI_OBJECTFREE_FORCE (ub2)0x0001 +#define OCI_OBJECTFREE_NONULL (ub2)0x0002 + +/*-------------------------- OCINumber --------------------------------------*/ + +#define OCI_NUMBER_UNSIGNED 0 /* Unsigned type -- ubX */ +#define OCI_NUMBER_SIGNED 2 /* Signed type -- sbX */ +#define OCI_NUMBER_SIZE 22 + +struct OCINumber +{ + ub1 OCINumberPart[OCI_NUMBER_SIZE]; +}; + +/*-----------------------Objects Definitions---------------------------------*/ + +typedef struct OCIString OCIString; +typedef struct OCIRaw OCIRaw; +typedef struct OCIType OCIType; +typedef struct OCINumber OCINumber; +typedef struct OCIRef OCIRef; + +/*--------------------------- OBJECT INDICATOR ------------------------------*/ + +typedef sb2 OCIInd; + +/* + * OCIInd -- a variable of this type contains (null) indicator information + */ + +#define OCI_IND_NOTNULL (OCIInd)0 /* not NULL */ +#define OCI_IND_NULL (OCIInd)(-1) /* NULL */ +#define OCI_IND_BADNULL (OCIInd)(-2) /* BAD NULL */ +#define OCI_IND_NOTNULLABLE (OCIInd)(-3) /* not NULLable */ + +/*-------------------------Object Ptr Types----------------------------------*/ +#define OCI_OTYPE_NAME 1 /* object name */ +#define OCI_OTYPE_REF 2 /* REF to TDO */ +#define OCI_OTYPE_PTR 3 /* PTR to TDO */ + +/*------------------------ Lob-specific Definitions -------------------------*/ + +typedef ub4 OCILobOffset; +typedef ub4 OCILobLength; + +/*----------------------------Piece Definitions------------------------------*/ + +#define OCI_ONE_PIECE 0 /* one piece */ +#define OCI_FIRST_PIECE 1 /* the first piece */ +#define OCI_NEXT_PIECE 2 /* the next of many pieces */ +#define OCI_LAST_PIECE 3 /* the last piece */ + +/*----------------------- GET OPTIONS FOR TDO ------------------------------*/ + +enum OCITypeGetOpt +{ + OCI_TYPEGET_HEADER, /* load only the header portion of the TDO */ + OCI_TYPEGET_ALL /* load all attribute and method descriptors as well */ +}; +typedef enum OCITypeGetOpt OCITypeGetOpt; + +/*--------------------------- OBJECT PIN OPTION -----------------------------*/ + +enum OCIPinOpt +{ + /* 0 = uninitialized */ + OCI_PIN_DEFAULT = 1, /* default pin option */ + OCI_PIN_ANY = 3, /* pin any copy of the object */ + OCI_PIN_RECENT = 4, /* pin recent copy of the object */ + OCI_PIN_LATEST = 5 /* pin latest copy of the object */ +}; +typedef enum OCIPinOpt OCIPinOpt; + +/*--------------------------- OBJECT LOCK OPTION ----------------------------*/ + +enum OCILockOpt +{ + /* 0 = uninitialized */ + OCI_LOCK_NONE = 1, /* null (same as no lock) */ + OCI_LOCK_X = 2, /* exclusive lock */ + OCI_LOCK_X_NOWAIT = 3 /* exclusive lock, do not wait */ +}; +typedef enum OCILockOpt OCILockOpt; + +/*------------------------- OBJECT MODIFYING OPTION -------------------------*/ + +enum OCIMarkOpt +{ + /* 0 = uninitialized */ + OCI_MARK_DEFAULT = 1, /* default (the same as OCI_MARK_NONE) */ + OCI_MARK_NONE = OCI_MARK_DEFAULT, /* object has not been modified */ + OCI_MARK_UPDATE /* object is to be updated */ +}; +typedef enum OCIMarkOpt OCIMarkOpt; + +/*------------------------------ TYPE CODE ----------------------------------*/ + +/* The OCITypeCode type is interchangeable with the existing SQLT type + which is a ub2 */ +typedef ub2 OCITypeCode; + +/*--------------------------- ORACLE DATE TYPE ----------------------------*/ + +struct OCITime +{ + ub1 OCITimeHH; /* hours; range is 0 <= hours <=23 */ + ub1 OCITimeMI; /* minutes; range is 0 <= minutes <= 59 */ + ub1 OCITimeSS; /* seconds; range is 0 <= seconds <= 59 */ +}; +typedef struct OCITime OCITime; + +struct OCIDate +{ + sb2 OCIDateYYYY; /* gregorian year; range is -4712 <= year <= 9999 */ + ub1 OCIDateMM; /* month; range is 1 <= month < 12 */ + ub1 OCIDateDD; /* day; range is 1 <= day <= 31 */ + OCITime OCIDateTime; /* time */ +}; +typedef struct OCIDate OCIDate; + +/*-------------------------- OBJECT Duration --------------------------------*/ + +typedef ub2 OCIDuration; + +#define OCI_DURATION_BEGIN (OCIDuration)10 + +/* beginning sequence of duration */ +#define OCI_DURATION_NULL (OCIDuration)(OCI_DURATION_BEGIN-1) + +/* null duration */ +#define OCI_DURATION_DEFAULT (OCIDuration)(OCI_DURATION_BEGIN-2) /* default */ +#define OCI_DURATION_NEXT (OCIDuration)(OCI_DURATION_BEGIN-3) + +/* next special duration */ +#define OCI_DURATION_SESSION (OCIDuration)(OCI_DURATION_BEGIN) + +/* the end of user session */ +#define OCI_DURATION_TRANS (OCIDuration)(OCI_DURATION_BEGIN+1) + +/* the end of user transaction */ + +/*-------------------------Object Ptr Types----------------------------------*/ +#define OCI_OTYPE_NAME 1 /* object name */ + +/*--------------------------- OCI Parameter Types ---------------------------*/ +#define OCI_PTYPE_UNK 0 /* unknown */ +#define OCI_PTYPE_TABLE 1 /* table */ +#define OCI_PTYPE_VIEW 2 /* view */ +#define OCI_PTYPE_PROC 3 /* procedure */ +#define OCI_PTYPE_FUNC 4 /* function */ +#define OCI_PTYPE_PKG 5 /* package */ +#define OCI_PTYPE_TYPE 6 /* user-defined type */ +#define OCI_PTYPE_SYN 7 /* synonym */ +#define OCI_PTYPE_SEQ 8 /* sequence */ +#define OCI_PTYPE_COL 9 /* column */ +#define OCI_PTYPE_ARG 10 /* argument */ +#define OCI_PTYPE_LIST 11 /* list */ +#define OCI_PTYPE_TYPE_ATTR 12 /* user-defined type's attribute */ +#define OCI_PTYPE_TYPE_COLL 13 /* collection type's element */ +#define OCI_PTYPE_TYPE_METHOD 14 /* user-defined type's method */ +#define OCI_PTYPE_TYPE_ARG 15 /* user-defined type method's arg */ +#define OCI_PTYPE_TYPE_RESULT 16 /* user-defined type method's result */ +#define OCI_PTYPE_SCHEMA 17 /* schema */ +#define OCI_PTYPE_DATABASE 18 /* database */ +#define OCI_PTYPE_RULE 19 /* rule */ +#define OCI_PTYPE_RULE_SET 20 /* rule set */ +#define OCI_PTYPE_EVALUATION_CONTEXT 21 /* evaluation context */ +#define OCI_PTYPE_TABLE_ALIAS 22 /* table alias */ +#define OCI_PTYPE_VARIABLE_TYPE 23 /* variable type */ +#define OCI_PTYPE_NAME_VALUE 24 /* name value pair */ + +/*------------------------------ TYPE CODE ----------------------------------*/ + + +#define OCI_TYPECODE_VARRAY 247 /* SQL VARRAY OTS PAGED VARRAY */ +#define OCI_TYPECODE_TABLE 248 /* SQL TABLE OTS MULTISET */ +#define OCI_TYPECODE_ITABLE 251 /* PLSQL indexed table */ +#define OCI_TYPECODE_PLS_INTEGER 266 /* type code for PLS_INTEGER */ + +/*------------------------Piece Information----------------------------------*/ +#define OCI_PARAM_IN 0x01 /* in parameter */ +#define OCI_PARAM_OUT 0x02 /* out parameter */ + +/*----------------------- OBJECT PROPERTY ID -------------------------------*/ + +typedef ub1 OCIObjectPropId; +#define OCI_OBJECTPROP_LIFETIME 1 /* persistent or transient or value */ +#define OCI_OBJECTPROP_SCHEMA 2 /* schema name of table containing object */ +#define OCI_OBJECTPROP_TABLE 3 /* table name of table containing object */ +#define OCI_OBJECTPROP_PIN_DURATION 4 /* pin duration of object */ +#define OCI_OBJECTPROP_ALLOC_DURATION 5 /* alloc duration of object */ +#define OCI_OBJECTPROP_LOCK 6 /* lock status of object */ +#define OCI_OBJECTPROP_MARKSTATUS 7 /* mark status of object */ +#define OCI_OBJECTPROP_VIEW 8 /* is object a view object or not? */ + +/*----------------------- OBJECT LIFETIME ----------------------------------*/ + +enum OCIObjectLifetime +{ + /* 0 = uninitialized */ + OCI_OBJECT_PERSISTENT = 1, /* persistent object */ + OCI_OBJECT_TRANSIENT, /* transient object */ + OCI_OBJECT_VALUE /* value object */ +}; +typedef enum OCIObjectLifetime OCIObjectLifetime; + +/*----------------------- OBJECT MARK STATUS -------------------------------*/ + +typedef uword OCIObjectMarkStatus; +#define OCI_OBJECT_NEW 0x0001 /* new object */ +#define OCI_OBJECT_DELETED 0x0002 /* object marked deleted */ +#define OCI_OBJECT_UPDATED 0x0004 /* object marked updated */ + +/*----- values for cflg argument to OCIDirpathColArrayEntrySet --------------*/ + +#define OCI_DIRPATH_COL_COMPLETE 0 /* column data is complete */ +#define OCI_DIRPATH_COL_NULL 1 /* column is null */ +#define OCI_DIRPATH_COL_PARTIAL 2 /* column data is partial */ +#define OCI_DIRPATH_COL_ERROR 3 /* column error, ignore row */ + +/*----- values for action parameter to OCIDirPathDataSave -------------------*/ +#define OCI_DIRPATH_DATASAVE_SAVEONLY 0 /* data save point only */ + +/*------------- Supported Values for Direct Path Date cache -----------------*/ +#define OCI_ATTR_DIRPATH_DCACHE_NUM 303 /* date cache entries */ +#define OCI_ATTR_DIRPATH_DCACHE_SIZE 304 /* date cache limit */ +#define OCI_ATTR_DIRPATH_DCACHE_MISSES 305 /* date cache misses */ +#define OCI_ATTR_DIRPATH_DCACHE_HITS 306 /* date cache hits */ +#define OCI_ATTR_DIRPATH_DCACHE_DISABLE 307 /* on set: disable datecache */ + +/*------------- Supported Values for Direct Path Stream Version -------------*/ + +#define OCI_ATTR_DIRPATH_NOLOG 79 /* nologging option */ +#define OCI_ATTR_DIRPATH_PARALLEL 80 /* parallel (temp seg) option */ + +/*------------------------- Database Startup Flags --------------------------*/ +#define OCI_DBSTARTUPFLAG_FORCE 0x00000001 /* Abort running instance, start */ +#define OCI_DBSTARTUPFLAG_RESTRICT 0x00000002 /* Restrict access to DBA */ + +/*------------------------- Database Shutdown Modes -------------------------*/ +#define OCI_DBSHUTDOWN_TRANSACTIONAL 1 /* Wait for all the transactions */ +#define OCI_DBSHUTDOWN_TRANSACTIONAL_LOCAL 2 /* Wait for local transactions */ +#define OCI_DBSHUTDOWN_IMMEDIATE 3 /* Terminate and roll back */ +#define OCI_DBSHUTDOWN_ABORT 4 /* Terminate and don't roll back */ +#define OCI_DBSHUTDOWN_FINAL 5 /* Orderly shutdown */ + +/*---------------------------OCIPasswordChange-------------------------------*/ +#define OCI_AUTH 0x08 /* Change the password but do not login */ + +/* ------------- DB Change Notification reg handle attributes ---------------*/ +#define OCI_ATTR_CHNF_TABLENAMES 401 /* out: array of table names + * */ +#define OCI_ATTR_CHNF_ROWIDS 402 /* in: rowids needed */ +#define OCI_ATTR_CHNF_OPERATIONS 403 /* in: notification operation + *filter*/ +#define OCI_ATTR_CHNF_CHANGELAG 404 /* txn lag between notifications + * */ + +/* DB Change: Notification Descriptor attributes -----------------------*/ +#define OCI_ATTR_CHDES_DBNAME 405 /* source database */ +#define OCI_ATTR_CHDES_NFYTYPE 406 /* notification type flags */ +#define OCI_ATTR_CHDES_XID 407 /* XID of the transaction */ +#define OCI_ATTR_CHDES_TABLE_CHANGES 408 /* array of table chg + *descriptors */ + +#define OCI_ATTR_CHDES_TABLE_NAME 409 /* table name */ +#define OCI_ATTR_CHDES_TABLE_OPFLAGS 410 /* table operation flags */ +#define OCI_ATTR_CHDES_TABLE_ROW_CHANGES 411 /* array of changed rows */ +#define OCI_ATTR_CHDES_ROW_ROWID 412 /* rowid of changed row */ +#define OCI_ATTR_CHDES_ROW_OPFLAGS 413 /* row operation flags */ + +/* Statement handle attribute for db change notification */ +#define OCI_ATTR_CHNF_REGHANDLE 414 /* IN: subscription handle */ + +/* DB Change: Event types ---------------*/ +#define OCI_EVENT_NONE 0x0 /* None */ +#define OCI_EVENT_STARTUP 0x1 /* Startup database */ +#define OCI_EVENT_SHUTDOWN 0x2 /* Shutdown database */ +#define OCI_EVENT_SHUTDOWN_ANY 0x3 /* Startup instance */ +#define OCI_EVENT_DROP_DB 0x4 /* Drop database */ +#define OCI_EVENT_DEREG 0x5 /* Subscription deregistered */ +#define OCI_EVENT_OBJCHANGE 0x6 /* Object change notification */ + +/* DB Change: Operation types -----------*/ +#define OCI_OPCODE_ALLROWS 0x1 /* all rows invalidated */ +#define OCI_OPCODE_ALLOPS 0x0 /* interested in all operations + **/ +#define OCI_OPCODE_INSERT 0x2 /* INSERT */ +#define OCI_OPCODE_UPDATE 0x4 /* UPDATE */ +#define OCI_OPCODE_DELETE 0x8 /* DELETE */ +#define OCI_OPCODE_ALTER 0x10 /* ALTER */ +#define OCI_OPCODE_DROP 0x20 /* DROP TABLE */ +#define OCI_OPCODE_UNKNOWN 0x40 /* GENERIC/ UNKNOWN*/ + +/*------------------------- Supported Namespaces ---------------------------*/ +#define OCI_SUBSCR_NAMESPACE_ANONYMOUS 0 /* Anonymous Namespace */ +#define OCI_SUBSCR_NAMESPACE_AQ 1 /* Advanced Queues */ +#define OCI_SUBSCR_NAMESPACE_DBCHANGE 2 /* change notification */ +#define OCI_SUBSCR_NAMESPACE_MAX 3 /* Max Name Space Number */ + + + +/* -------------------- HA Event Handle Attributes values------------------- */ +#define OCI_EVENTTYPE_HA 0 /* valid value for OCI_ATTR_EVENTTYPE */ + +/* valid values for OCI_ATTR_HA_SOURCE */ +#define OCI_HA_SOURCE_INSTANCE 0 +#define OCI_HA_SOURCE_DATABASE 1 +#define OCI_HA_SOURCE_NODE 2 +#define OCI_HA_SOURCE_SERVICE 3 +#define OCI_HA_SOURCE_SERVICE_MEMBER 4 +#define OCI_HA_SOURCE_ASM_INSTANCE 5 +#define OCI_HA_SOURCE_SERVICE_PRECONNECT 6 + +#define OCI_HA_STATUS_DOWN 0 /* valid values for OCI_ATTR_HA_STATUS */ +#define OCI_HA_STATUS_UP 1 + +/*------------- Supported Values for protocol for recipient -----------------*/ +#define OCI_SUBSCR_PROTO_OCI 0 /* oci */ +#define OCI_SUBSCR_PROTO_MAIL 1 /* mail */ +#define OCI_SUBSCR_PROTO_SERVER 2 /* server */ +#define OCI_SUBSCR_PROTO_HTTP 3 /* http */ +#define OCI_SUBSCR_PROTO_MAX 4 /* max current protocols */ + +/*------------- Supported Values for presentation for recipient -------------*/ +#define OCI_SUBSCR_PRES_DEFAULT 0 /* default */ +#define OCI_SUBSCR_PRES_XML 1 /* xml */ +#define OCI_SUBSCR_PRES_MAX 2 /* max current presentations */ + + +/* -------------------------- Implicit Result types ------------------------ */ +#define OCI_RESULT_TYPE_SELECT 1 + +/*-------------- Flags corresponding to the column properties----------------*/ +#define OCI_ATTR_COL_PROPERTY_IS_IDENTITY 0x0000000000000001 +#define OCI_ATTR_COL_PROPERTY_IS_GEN_ALWAYS 0x0000000000000002 +#define OCI_ATTR_COL_PROPERTY_IS_GEN_BY_DEF_ON_NULL 0x0000000000000004 +#define OCI_ATTR_COL_PROPERTY_IS_LPART 0x0000000000000008 +#define OCI_ATTR_COL_PROPERTY_IS_CONID 0x0000000000000010 + +/*-----------------Macros to get the various version number components------ */ + +#define OCI_SERVER_RELEASE_REL(v) ((sword)(((v) >> 24) & 0x000000FF)) + /* old: version number */ +/* new: feature release */ +#define OCI_SERVER_RELEASE_REL_UPD(v)\ + ((OCI_SERVER_RELEASE_REL(v) < 18)? \ + ((sword)(((v) >> 20) & 0x0000000F)):\ + ((sword)(((v) >> 16) & 0x000000FF))) /* old: release number */ + /* new: release update */ + +#define OCI_SERVER_RELEASE_REL_UPD_REV(v)\ + ((OCI_SERVER_RELEASE_REL(v) < 18)? \ + ((sword)(((v) >> 12) & 0x000000FF)):\ + ((sword)(((v) >> 12) & 0x0000000F))) + /* old: update number */ + /* new: release update revision */ + +#define OCI_SERVER_RELEASE_REL_UPD_INC(v)\ + ((OCI_SERVER_RELEASE_REL(v) < 18)? \ + ((sword)(((v) >> 8) & 0x0000000F)):\ + ((sword)(((v) >> 4) & 0x0000000FF))) + /* old: porting release number */ + /* new: release update increment */ + +#define OCI_SERVER_RELEASE_EXT(v)\ + ((OCI_SERVER_RELEASE_REL(v) < 18)? \ + ((sword)(((v) >> 0) & 0x000000FF)):\ + ((sword)(((v) >> 0) & 0x0000000F))) + /* old: porting update number */ + /* new: extension */ + + +#endif /* OCILIB_OCI_DEFS_H_INCLUDED */ + diff --git a/src/oci_types.h b/src/oci/types.h similarity index 96% rename from src/oci_types.h rename to src/oci/types.h index 1159fa20..2d4b1f8b 100644 --- a/src/oci_types.h +++ b/src/oci/types.h @@ -1,309 +1,309 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * IMPORTANT NOTICE - * - * THIS FILE CONTAINS CONSTANTS AND STRUCTURES DECLARATIONS THAT WERE - * PICKED UP FROM ORACLE PUBLIC HEADER FILES. - * - * SO THE CONTENT OF THIS FILE MAY BE UNDER ORACLE COPYRIGHT AND THE - * DECLARATIONS REPRODUCED HERE ARE ORIGINALLY WRITTEN BY ORACLE CORPORATION - * - * THE AUTHOR OF OCILIB LIBRARY HAS NOT WRITTEN THE CONTENT OF THIS - * FILE AND HAS PARTIALLY INTEGRATED SOME ORACLE OCI DEFINITIONS TO - * ALLOW COMPILATION OF THIS OPEN SOURCE LIBRARY WITHOUT HAVING - * ORACLE PRODUCTS INSTALLED ON DEVELOPMENT ENVIRONMENTS - * - */ - -#ifndef OCILIB_OCI_TYPES_H_INCLUDED -#define OCILIB_OCI_TYPES_H_INCLUDED - -# define ORATYPES -# define SX_ORACLE -# define SX3_ORACLE - -#ifndef ORASTDDEF - # include - # define ORASTDDEF -#endif - -#ifndef ORALIMITS - # include - # define ORALIMITS -#endif - -#ifndef TRUE - # define TRUE 1 - # define FALSE 0 -#endif - -#ifndef lint -typedef unsigned char ub1; -typedef signed char sb1; -#else - #define ub1 unsigned char - #define sb1 signed char -#endif - -#define UB1MAXVAL ((ub1)UCHAR_MAX) -#define UB1MINVAL ((ub1) 0) -#define SB1MAXVAL ((sb1)SCHAR_MAX) -#define SB1MINVAL ((sb1)SCHAR_MIN) -#define MINUB1MAXVAL ((ub1) 255) -#define MAXUB1MINVAL ((ub1) 0) -#define MINSB1MAXVAL ((sb1) 127) -#define MAXSB1MINVAL ((sb1) -127) - -#ifndef lint -typedef unsigned short ub2; -typedef signed short sb2; -#else - #define ub2 unsigned short - #define sb2 signed short -#endif - -#define UB2MAXVAL ((ub2)USHRT_MAX) -#define UB2MINVAL ((ub2) 0) -#define SB2MAXVAL ((sb2) SHRT_MAX) -#define SB2MINVAL ((sb2) SHRT_MIN) -#define MINUB2MAXVAL ((ub2) 65535) -#define MAXUB2MINVAL ((ub2) 0) -#define MINSB2MAXVAL ((sb2) 32767) -#define MAXSB2MINVAL ((sb2)-32767) - -#ifndef lint -typedef unsigned int ub4; -typedef signed int sb4; -#else - #define eb4 int - #define ub4 unsigned int - #define sb4 signed int -#endif - -#define UB4MAXVAL ((ub4)UINT_MAX) -#define UB4MINVAL ((ub4) 0) -#define SB4MAXVAL ((sb4) INT_MAX) -#define SB4MINVAL ((sb4) INT_MIN) -#define MINUB4MAXVAL ((ub4) 4294967295) -#define MAXUB4MINVAL ((ub4) 0) -#define MINSB4MAXVAL ((sb4) 2147483647) -#define MAXSB4MINVAL ((sb4)-2147483647) - -#define ORAXB8_DEFINED -#ifndef lint - #ifndef __GNUC__ -typedef unsigned __int64 oraub8; -typedef signed __int64 orasb8; - #else -typedef unsigned long long oraub8; -typedef signed long long orasb8; - #endif -typedef oraub8 ub8; -typedef orasb8 sb8; -#else - # define ub8 oraub8 - # define sb8 orasb8 - # define oraub8 unsigned _int64 - # define orasb8 signed _int64 -#endif /* !lint */ - -#define ORAUB8MINVAL ((oraub8)0) -#define ORAUB8MAXVAL ((oraub8)18446744073709551615) -#define ORASB8MINVAL ((orasb8)-9223372036854775808) -#define ORASB8MAXVAL ((orasb8) 9223372036854775807) - -#define MAXORAUB8MINVAL ((oraub8)0) -#define MINORAUB8MAXVAL ((oraub8)18446744073709551615) -#define MAXORASB8MINVAL ((orasb8)-9223372036854775807) -#define MINORASB8MAXVAL ((orasb8) 9223372036854775807) - -#define UB1BITS CHAR_BIT -#define UB1MASK ((1 << ((uword)CHAR_BIT)) - 1) - -#ifdef lint - # define oratext unsigned char -#else -typedef unsigned char oratext; -#endif - -#ifndef lint -typedef char eb1; -typedef short eb2; -typedef int eb4; -#else - # define eb1 char - # define eb2 short - # define eb4 int -#endif - -#define EB1MAXVAL ((eb1)SCHAR_MAX) -#define EB1MINVAL ((eb1) 0) -#define MINEB1MAXVAL ((eb1) 127) -#define MAXEB1MINVAL ((eb1) 0) -#define EB2MAXVAL ((eb2) SHRT_MAX) -#define EB2MINVAL ((eb2) 0) -#define MINEB2MAXVAL ((eb2) 32767) -#define MAXEB2MINVAL ((eb2) 0) -#define EB4MAXVAL ((eb4) INT_MAX) -#define EB4MINVAL ((eb4) 0) -#define MINEB4MAXVAL ((eb4) 2147483647) -#define MAXEB4MINVAL ((eb4) 0) - -#ifndef lint -typedef sb1 b1; -#else - #define b1 sb1 -#endif -#define B1MAXVAL SB1MAXVAL -#define B1MINVAL SB1MINVAL - -#ifndef lint -typedef sb2 b2; -#else - #define b2 sb2 -#endif -#define B2MAXVAL SB2MAXVAL -#define B2MINVAL SB2MINVAL - -#ifndef lint -typedef sb4 b4; -#else - #define b4 sb4 -#endif -# define B4MAXVAL SB4MAXVAL -# define B4MINVAL SB4MINVAL - -#if !defined(LUSEMFC) - # ifdef lint - # define text unsigned char - # else -typedef oratext text; - # endif -#endif - -#ifdef lint - # define OraText unsigned char -#else -typedef oratext OraText; -#endif - -#ifndef lint -typedef int eword; -typedef unsigned int uword; -typedef signed int sword; -#else - #define eword int - #define uword unsigned int - #define sword signed int -#endif - -#define EWORDMAXVAL ((eword) INT_MAX) -#define EWORDMINVAL ((eword) 0) -#define UWORDMAXVAL ((uword)UINT_MAX) -#define UWORDMINVAL ((uword) 0) -#define SWORDMAXVAL ((sword) INT_MAX) -#define SWORDMINVAL ((sword) INT_MIN) -#define MINEWORDMAXVAL ((eword) 2147483647) -#define MAXEWORDMINVAL ((eword) 0) -#define MINUWORDMAXVAL ((uword) 4294967295) -#define MAXUWORDMINVAL ((uword) 0) -#define MINSWORDMAXVAL ((sword) 2147483647) -#define MAXSWORDMINVAL ((sword) -2147483647) - -#ifdef _WIN64 - - #ifndef lint -typedef unsigned __int64 ubig_ora; -typedef signed __int64 sbig_ora; - #else - #define ubig_ora unsigned _int64 - #define sbig_ora signed _int64 - #endif - - #define UBIG_ORAMAXVAL ((ubig_ora)_UI64_MAX) - #define UBIG_ORAMINVAL ((ubig_ora) 0) - #define SBIG_ORAMAXVAL ((sbig_ora) _I64_MAX) - #define SBIG_ORAMINVAL ((sbig_ora) _I64_MIN) - #define MINUBIG_ORAMAXVAL ((ubig_ora) 4294967295) - #define MAXUBIG_ORAMINVAL ((ubig_ora) 0) - #define MINSBIG_ORAMAXVAL ((sbig_ora) 2147483647) - #define MAXSBIG_ORAMINVAL ((sbig_ora)-2147483647) - -#else - - #ifndef lint -typedef unsigned long ubig_ora; -typedef signed long sbig_ora; - #else - #define ubig_ora unsigned long - #define sbig_ora signed long - #endif - - #define UBIG_ORAMAXVAL ((ubig_ora)ULONG_MAX) - #define UBIG_ORAMINVAL ((ubig_ora) 0) - #define SBIG_ORAMAXVAL ((sbig_ora) LONG_MAX) - #define SBIG_ORAMINVAL ((sbig_ora) LONG_MIN) - #define MINUBIG_ORAMAXVAL ((ubig_ora) 4294967295) - #define MAXUBIG_ORAMINVAL ((ubig_ora) 0) - #define MINSBIG_ORAMAXVAL ((sbig_ora) 2147483647) - #define MAXSBIG_ORAMINVAL ((sbig_ora)-2147483647) - -#endif /* _WIN64 */ - -#define UBIGORABITS (UB1BITS * sizeof(ubig_ora)) - -#undef CONST -#define CONST const - -#define dvoid void - -typedef void (*lgenfp_t)( void ); - -#ifndef ORASYS_TYPES - # include - # define ORASYS_TYPES -#endif - -#ifndef boolean - # define boolean int -#endif - -#ifdef sparc - # define SIZE_TMAXVAL SB4MAXVAL -#else - # define SIZE_TMAXVAL UB4MAXVAL -#endif - -#define MINSIZE_TMAXVAL (size_t)4294967295 - -#if !defined(MOTIF) && !defined(LISPL) && !defined(__cplusplus) && !defined(LUSEMFC) -typedef oratext *string; -#endif - -#ifndef lint -typedef unsigned short utext; -#else - #define utext unsigned short -#endif - -#endif /* OCILIB_OCI_TYPES_H_INCLUDED */ - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * IMPORTANT NOTICE + * + * THIS FILE CONTAINS CONSTANTS AND STRUCTURES DECLARATIONS THAT WERE + * PICKED UP FROM ORACLE PUBLIC HEADER FILES. + * + * SO THE CONTENT OF THIS FILE MAY BE UNDER ORACLE COPYRIGHT AND THE + * DECLARATIONS REPRODUCED HERE ARE ORIGINALLY WRITTEN BY ORACLE CORPORATION + * + * THE AUTHOR OF OCILIB LIBRARY HAS NOT WRITTEN THE CONTENT OF THIS + * FILE AND HAS PARTIALLY INTEGRATED SOME ORACLE OCI DEFINITIONS TO + * ALLOW COMPILATION OF THIS OPEN SOURCE LIBRARY WITHOUT HAVING + * ORACLE PRODUCTS INSTALLED ON DEVELOPMENT ENVIRONMENTS + * + */ + +#ifndef OCILIB_OCI_TYPES_H_INCLUDED +#define OCILIB_OCI_TYPES_H_INCLUDED + +# define ORATYPES +# define SX_ORACLE +# define SX3_ORACLE + +#ifndef ORASTDDEF + # include + # define ORASTDDEF +#endif + +#ifndef ORALIMITS + # include + # define ORALIMITS +#endif + +#ifndef TRUE + # define TRUE 1 + # define FALSE 0 +#endif + +#ifndef lint +typedef unsigned char ub1; +typedef signed char sb1; +#else + #define ub1 unsigned char + #define sb1 signed char +#endif + +#define UB1MAXVAL ((ub1)UCHAR_MAX) +#define UB1MINVAL ((ub1) 0) +#define SB1MAXVAL ((sb1)SCHAR_MAX) +#define SB1MINVAL ((sb1)SCHAR_MIN) +#define MINUB1MAXVAL ((ub1) 255) +#define MAXUB1MINVAL ((ub1) 0) +#define MINSB1MAXVAL ((sb1) 127) +#define MAXSB1MINVAL ((sb1) -127) + +#ifndef lint +typedef unsigned short ub2; +typedef signed short sb2; +#else + #define ub2 unsigned short + #define sb2 signed short +#endif + +#define UB2MAXVAL ((ub2)USHRT_MAX) +#define UB2MINVAL ((ub2) 0) +#define SB2MAXVAL ((sb2) SHRT_MAX) +#define SB2MINVAL ((sb2) SHRT_MIN) +#define MINUB2MAXVAL ((ub2) 65535) +#define MAXUB2MINVAL ((ub2) 0) +#define MINSB2MAXVAL ((sb2) 32767) +#define MAXSB2MINVAL ((sb2)-32767) + +#ifndef lint +typedef unsigned int ub4; +typedef signed int sb4; +#else + #define eb4 int + #define ub4 unsigned int + #define sb4 signed int +#endif + +#define UB4MAXVAL ((ub4)UINT_MAX) +#define UB4MINVAL ((ub4) 0) +#define SB4MAXVAL ((sb4) INT_MAX) +#define SB4MINVAL ((sb4) INT_MIN) +#define MINUB4MAXVAL ((ub4) 4294967295) +#define MAXUB4MINVAL ((ub4) 0) +#define MINSB4MAXVAL ((sb4) 2147483647) +#define MAXSB4MINVAL ((sb4)-2147483647) + +#define ORAXB8_DEFINED +#ifndef lint + #ifndef __GNUC__ +typedef unsigned __int64 oraub8; +typedef signed __int64 orasb8; + #else +typedef unsigned long long oraub8; +typedef signed long long orasb8; + #endif +typedef oraub8 ub8; +typedef orasb8 sb8; +#else + # define ub8 oraub8 + # define sb8 orasb8 + # define oraub8 unsigned _int64 + # define orasb8 signed _int64 +#endif /* !lint */ + +#define ORAUB8MINVAL ((oraub8)0) +#define ORAUB8MAXVAL ((oraub8)18446744073709551615) +#define ORASB8MINVAL ((orasb8)-9223372036854775808) +#define ORASB8MAXVAL ((orasb8) 9223372036854775807) + +#define MAXORAUB8MINVAL ((oraub8)0) +#define MINORAUB8MAXVAL ((oraub8)18446744073709551615) +#define MAXORASB8MINVAL ((orasb8)-9223372036854775807) +#define MINORASB8MAXVAL ((orasb8) 9223372036854775807) + +#define UB1BITS CHAR_BIT +#define UB1MASK ((1 << ((uword)CHAR_BIT)) - 1) + +#ifdef lint + # define oratext unsigned char +#else +typedef unsigned char oratext; +#endif + +#ifndef lint +typedef char eb1; +typedef short eb2; +typedef int eb4; +#else + # define eb1 char + # define eb2 short + # define eb4 int +#endif + +#define EB1MAXVAL ((eb1)SCHAR_MAX) +#define EB1MINVAL ((eb1) 0) +#define MINEB1MAXVAL ((eb1) 127) +#define MAXEB1MINVAL ((eb1) 0) +#define EB2MAXVAL ((eb2) SHRT_MAX) +#define EB2MINVAL ((eb2) 0) +#define MINEB2MAXVAL ((eb2) 32767) +#define MAXEB2MINVAL ((eb2) 0) +#define EB4MAXVAL ((eb4) INT_MAX) +#define EB4MINVAL ((eb4) 0) +#define MINEB4MAXVAL ((eb4) 2147483647) +#define MAXEB4MINVAL ((eb4) 0) + +#ifndef lint +typedef sb1 b1; +#else + #define b1 sb1 +#endif +#define B1MAXVAL SB1MAXVAL +#define B1MINVAL SB1MINVAL + +#ifndef lint +typedef sb2 b2; +#else + #define b2 sb2 +#endif +#define B2MAXVAL SB2MAXVAL +#define B2MINVAL SB2MINVAL + +#ifndef lint +typedef sb4 b4; +#else + #define b4 sb4 +#endif +# define B4MAXVAL SB4MAXVAL +# define B4MINVAL SB4MINVAL + +#if !defined(LUSEMFC) + # ifdef lint + # define text unsigned char + # else +typedef oratext text; + # endif +#endif + +#ifdef lint + # define OraText unsigned char +#else +typedef oratext OraText; +#endif + +#ifndef lint +typedef int eword; +typedef unsigned int uword; +typedef signed int sword; +#else + #define eword int + #define uword unsigned int + #define sword signed int +#endif + +#define EWORDMAXVAL ((eword) INT_MAX) +#define EWORDMINVAL ((eword) 0) +#define UWORDMAXVAL ((uword)UINT_MAX) +#define UWORDMINVAL ((uword) 0) +#define SWORDMAXVAL ((sword) INT_MAX) +#define SWORDMINVAL ((sword) INT_MIN) +#define MINEWORDMAXVAL ((eword) 2147483647) +#define MAXEWORDMINVAL ((eword) 0) +#define MINUWORDMAXVAL ((uword) 4294967295) +#define MAXUWORDMINVAL ((uword) 0) +#define MINSWORDMAXVAL ((sword) 2147483647) +#define MAXSWORDMINVAL ((sword) -2147483647) + +#ifdef _WIN64 + + #ifndef lint +typedef unsigned __int64 ubig_ora; +typedef signed __int64 sbig_ora; + #else + #define ubig_ora unsigned _int64 + #define sbig_ora signed _int64 + #endif + + #define UBIG_ORAMAXVAL ((ubig_ora)_UI64_MAX) + #define UBIG_ORAMINVAL ((ubig_ora) 0) + #define SBIG_ORAMAXVAL ((sbig_ora) _I64_MAX) + #define SBIG_ORAMINVAL ((sbig_ora) _I64_MIN) + #define MINUBIG_ORAMAXVAL ((ubig_ora) 4294967295) + #define MAXUBIG_ORAMINVAL ((ubig_ora) 0) + #define MINSBIG_ORAMAXVAL ((sbig_ora) 2147483647) + #define MAXSBIG_ORAMINVAL ((sbig_ora)-2147483647) + +#else + + #ifndef lint +typedef unsigned long ubig_ora; +typedef signed long sbig_ora; + #else + #define ubig_ora unsigned long + #define sbig_ora signed long + #endif + + #define UBIG_ORAMAXVAL ((ubig_ora)ULONG_MAX) + #define UBIG_ORAMINVAL ((ubig_ora) 0) + #define SBIG_ORAMAXVAL ((sbig_ora) LONG_MAX) + #define SBIG_ORAMINVAL ((sbig_ora) LONG_MIN) + #define MINUBIG_ORAMAXVAL ((ubig_ora) 4294967295) + #define MAXUBIG_ORAMINVAL ((ubig_ora) 0) + #define MINSBIG_ORAMAXVAL ((sbig_ora) 2147483647) + #define MAXSBIG_ORAMINVAL ((sbig_ora)-2147483647) + +#endif /* _WIN64 */ + +#define UBIGORABITS (UB1BITS * sizeof(ubig_ora)) + +#undef CONST +#define CONST const + +#define dvoid void + +typedef void (*lgenfp_t)( void ); + +#ifndef ORASYS_TYPES + # include + # define ORASYS_TYPES +#endif + +#ifndef boolean + # define boolean int +#endif + +#ifdef sparc + # define SIZE_TMAXVAL SB4MAXVAL +#else + # define SIZE_TMAXVAL UB4MAXVAL +#endif + +#define MINSIZE_TMAXVAL (size_t)4294967295 + +#if !defined(MOTIF) && !defined(LISPL) && !defined(__cplusplus) && !defined(LUSEMFC) +typedef oratext *string; +#endif + +#ifndef lint +typedef unsigned short utext; +#else + #define utext unsigned short +#endif + +#endif /* OCILIB_OCI_TYPES_H_INCLUDED */ + diff --git a/src/ocilib.c b/src/ocilib.c new file mode 100644 index 00000000..e77bd6f7 --- /dev/null +++ b/src/ocilib.c @@ -0,0 +1,6848 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ocilib.h" + +#include "agent.h" +#include "array.h" +#include "bind.h" +#include "collection.h" +#include "column.h" +#include "connection.h" +#include "database.h" +#include "date.h" +#include "dequeue.h" +#include "dirpath.h" +#include "element.h" +#include "enqueue.h" +#include "error.h" +#include "event.h" +#include "file.h" +#include "handle.h" +#include "hash.h" +#include "interval.h" +#include "iterator.h" +#include "environment.h" +#include "lob.h" +#include "long.h" +#include "message.h" +#include "mutex.h" +#include "number.h" +#include "object.h" +#include "pool.h" +#include "queue.h" +#include "reference.h" +#include "resultset.h" +#include "statement.h" +#include "subscription.h" +#include "thread.h" +#include "threadkey.h" +#include "timestamp.h" +#include "transaction.h" +#include "typeinfo.h" + +void CheckContext() +{ + if (Env.env_mode & OCI_ENV_CONTEXT) + { + ErrorReset(ErrorGet(TRUE, TRUE)); + } +} + +#define CALL_IMPL(impl, ...) \ + CheckContext(); \ + return impl(__VA_ARGS__); \ + + +/* --------------------------------------------------------------------------------------------- * + * agent + * --------------------------------------------------------------------------------------------- */ + +OCI_Agent* OCI_API OCI_AgentCreate +( + OCI_Connection* con, + const otext * name, + const otext * address +) +{ + CALL_IMPL(AgentCreate, con, name, address) +} + +boolean OCI_API OCI_AgentFree +( + OCI_Agent* agent +) +{ + CALL_IMPL(AgentFree, agent) +} + +const otext* OCI_API OCI_AgentGetName +( + OCI_Agent* agent +) +{ + CALL_IMPL(AgentGetName, agent) +} + +boolean OCI_API OCI_AgentSetName +( + OCI_Agent * agent, + const otext* name +) +{ + CALL_IMPL(AgentSetName, agent, name) +} + +const otext* OCI_API OCI_AgentGetAddress +( + OCI_Agent* agent +) +{ + CALL_IMPL(AgentGetAddress, agent) +} + +boolean OCI_API OCI_AgentSetAddress +( + OCI_Agent * agent, + const otext* address +) +{ + CALL_IMPL(AgentSetAddress, agent, address) +} + +/* --------------------------------------------------------------------------------------------- * + * bind + * --------------------------------------------------------------------------------------------- */ + +const otext* OCI_API OCI_BindGetName +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetName, bnd) +} + +unsigned int OCI_API OCI_BindGetType +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetType, bnd) +} + +unsigned int OCI_API OCI_BindGetSubtype +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetSubtype, bnd) +} + +unsigned int OCI_API OCI_BindGetDataCount +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetDataCount, bnd) +} + +void* OCI_API OCI_BindGetData +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetData, bnd) +} + +OCI_Statement* OCI_API OCI_BindGetStatement +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetStatement, bnd) +} + +boolean OCI_API OCI_BindSetDataSize +( + OCI_Bind * bnd, + unsigned int size +) +{ + CALL_IMPL(BindSetDataSize, bnd, size) +} + +boolean OCI_API OCI_BindSetDataSizeAtPos +( + OCI_Bind * bnd, + unsigned int position, + unsigned int size +) +{ + CALL_IMPL(BindSetDataSizeAtPos, bnd, position, size) +} + +unsigned int OCI_API OCI_BindGetDataSize +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetDataSize, bnd) +} + +unsigned int OCI_API OCI_BindGetDataSizeAtPos +( + OCI_Bind * bnd, + unsigned int position +) +{ + CALL_IMPL(BindGetDataSizeAtPos, bnd, position) +} + +boolean OCI_API OCI_BindSetNullAtPos +( + OCI_Bind * bnd, + unsigned int position +) +{ + CALL_IMPL(BindSetNullAtPos, bnd, position) +} + +boolean OCI_API OCI_BindSetNull +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindSetNull, bnd) +} + +boolean OCI_API OCI_BindSetNotNullAtPos +( + OCI_Bind * bnd, + unsigned int position +) +{ + CALL_IMPL(BindSetNotNullAtPos, bnd, position) +} + +boolean OCI_API OCI_BindSetNotNull +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindSetNotNull, bnd) +} + +boolean OCI_API OCI_BindIsNullAtPos +( + OCI_Bind * bnd, + unsigned int position +) +{ + CALL_IMPL(BindIsNullAtPos, bnd, position) +} + +boolean OCI_API OCI_BindIsNull +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindIsNull, bnd) +} + +boolean OCI_API OCI_BindSetCharsetForm +( + OCI_Bind * bnd, + unsigned int csfrm +) +{ + CALL_IMPL(BindSetCharsetForm, bnd, csfrm) +} + +boolean OCI_API OCI_BindSetDirection +( + OCI_Bind * bnd, + unsigned int direction +) +{ + CALL_IMPL(BindSetDirection, bnd, direction) +} + +unsigned int OCI_API OCI_BindGetDirection +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetDirection, bnd) +} + +unsigned int OCI_API OCI_BindGetAllocationMode +( + OCI_Bind* bnd +) +{ + CALL_IMPL(BindGetAllocationMode, bnd) +} + +/* --------------------------------------------------------------------------------------------- * + * collection + * --------------------------------------------------------------------------------------------- */ + +OCI_Coll * OCI_API OCI_CollCreate +( + OCI_TypeInfo *typinf +) +{ + CALL_IMPL(CollectionCreate, typinf) +} + +boolean OCI_API OCI_CollFree +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionFree, coll) +} + +OCI_Coll ** OCI_API OCI_CollArrayCreate +( + OCI_Connection *con, + OCI_TypeInfo *typinf, + unsigned int nbelem +) +{ + CALL_IMPL(CollectionCreateArray, con, typinf, nbelem) +} + +boolean OCI_API OCI_CollArrayFree +( + OCI_Coll **colls +) +{ + CALL_IMPL(CollectionFreeArray, colls) +} + +boolean OCI_API OCI_CollAssign +( + OCI_Coll *coll, + OCI_Coll *coll_src +) +{ + CALL_IMPL(CollectionAssign, coll, coll_src) +} + +unsigned int OCI_API OCI_CollGetType +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionGetType, coll) +} + +unsigned int OCI_API OCI_CollGetMax +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionGetMax, coll) +} + +unsigned int OCI_API OCI_CollGetSize +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionGetSize, coll) +} + +boolean OCI_API OCI_CollTrim +( + OCI_Coll *coll, + unsigned int nb_elem +) +{ + CALL_IMPL(CollectionTrim, coll, nb_elem) +} + +OCI_Elem * OCI_API OCI_CollGetElem +( + OCI_Coll *coll, + unsigned int index +) +{ + CALL_IMPL(CollectionGetElement, coll, index) +} + +boolean OCI_API OCI_CollGetElem2 +( + OCI_Coll *coll, + unsigned int index, + OCI_Elem *elem +) +{ + CALL_IMPL(CollectionGetElement2, coll, index, elem) +} + +boolean OCI_API OCI_CollSetElem +( + OCI_Coll *coll, + unsigned int index, + OCI_Elem *elem +) +{ + CALL_IMPL(CollectionSetElement, coll, index, elem) +} + +boolean OCI_API OCI_CollAppend +( + OCI_Coll *coll, + OCI_Elem *elem +) +{ + CALL_IMPL(CollectionAddElement, coll, elem) +} + +OCI_TypeInfo * OCI_API OCI_CollGetTypeInfo +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionGetTypeInfo, coll) +} + +boolean OCI_API OCI_CollClear +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionClear, coll) +} + +boolean OCI_API OCI_CollDeleteElem +( + OCI_Coll *coll, + unsigned int index +) +{ + CALL_IMPL(CollectionRemoveElement, coll, index) +} + +unsigned int OCI_API OCI_CollGetCount +( + OCI_Coll *coll +) +{ + CALL_IMPL(CollectionGetCount, coll) +} + +boolean OCI_API OCI_CollToText +( + OCI_Coll *coll, + unsigned int *size, + otext *str +) +{ + CALL_IMPL(CollectionToString, coll, size, str) +} + +/* --------------------------------------------------------------------------------------------- * + * column + * --------------------------------------------------------------------------------------------- */ + +const otext* OCI_API OCI_ColumnGetName +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetName, col) +} + +unsigned int OCI_API OCI_ColumnGetType +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetType, col) +} + +unsigned int OCI_API OCI_ColumnGetCharsetForm +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetCharsetForm, col) +} + +unsigned int OCI_API OCI_ColumnGetSize +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetSize, col) +} + +int OCI_API OCI_ColumnGetScale +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetScale, col) +} + +int OCI_API OCI_ColumnGetPrecision +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetPrecision, col) +} + +int OCI_API OCI_ColumnGetFractionalPrecision +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetFractionalPrecision, col) +} + +int OCI_API OCI_ColumnGetLeadingPrecision +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetLeadingPrecision, col) +} + +boolean OCI_API OCI_ColumnGetNullable +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetNullable, col) +} + +boolean OCI_API OCI_ColumnGetCharUsed +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetCharUsed, col) +} + +unsigned int OCI_API OCI_ColumnGetPropertyFlags +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetPropertyFlags, col) +} + +unsigned int OCI_API OCI_ColumnGetCollationID +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetCollationID, col) +} + +const otext* OCI_API OCI_ColumnGetSQLType +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetSqlType, col) +} + +unsigned int OCI_API OCI_ColumnGetFullSQLType +( + OCI_Column * col, + otext * buffer, + unsigned int len +) +{ + CALL_IMPL(ColumnGetFullSqlType, col, buffer, len) +} + +OCI_TypeInfo* OCI_API OCI_ColumnGetTypeInfo +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetTypeInfo, col) +} + +unsigned int OCI_API OCI_ColumnGetSubType +( + OCI_Column* col +) +{ + CALL_IMPL(ColumnGetSubType, col) +} + +/* --------------------------------------------------------------------------------------------- * + * connection + * --------------------------------------------------------------------------------------------- */ + +OCI_Connection * OCI_API OCI_ConnectionCreate +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int mode +) +{ + CALL_IMPL(ConnectionCreate, db, user, pwd, mode) +} + +boolean OCI_API OCI_ConnectionFree +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionFree, con) +} + +boolean OCI_API OCI_Commit +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionCommit, con) +} + +boolean OCI_API OCI_Rollback +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionRollback, con) +} + +boolean OCI_API OCI_SetAutoCommit +( + OCI_Connection *con, + boolean enable +) +{ + CALL_IMPL(ConnectionSetAutoCommit, con, enable) +} + +boolean OCI_API OCI_GetAutoCommit +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetAutoCommit, con) +} + +boolean OCI_API OCI_IsConnected +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionIsConnected, con) +} + +void * OCI_API OCI_GetUserData +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetUserData, con) +} + +boolean OCI_API OCI_SetUserData +( + OCI_Connection *con, + void *data +) +{ + CALL_IMPL(ConnectionSetUserData, con, data) +} + +boolean OCI_API OCI_SetSessionTag +( + OCI_Connection *con, + const otext *tag +) +{ + CALL_IMPL(ConnectionSetSessionTag, con, tag) +} + +const otext * OCI_API OCI_GetSessionTag +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetSessionTag, con) +} + +const otext * OCI_API OCI_GetDatabase +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetConnectionString, con) +} + +const otext * OCI_API OCI_GetUserName +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetUserName, con) +} + +const otext * OCI_API OCI_GetPassword +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetPassword, con) +} + +boolean OCI_API OCI_SetPassword +( + OCI_Connection *con, + const otext *password +) +{ + CALL_IMPL(ConnectionSetPassword, con, password) +} + +unsigned int OCI_API OCI_GetSessionMode +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetSessionMode, con) +} + +const otext * OCI_API OCI_GetVersionServer +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServerVersion, con) +} + +unsigned int OCI_API OCI_GetServerMajorVersion +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServerMajorVersion, con) +} + +unsigned int OCI_API OCI_GetServerMinorVersion +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServerMinorVersion, con) +} + +unsigned int OCI_API OCI_GetServerRevisionVersion +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServerRevisionVersion, con) +} + +OCI_Transaction * OCI_API OCI_GetTransaction +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetTransaction, con) +} + +boolean OCI_API OCI_SetTransaction +( + OCI_Connection *con, + OCI_Transaction *trans +) +{ + CALL_IMPL(ConnectionSetTransaction, con, trans) +} + +unsigned int OCI_API OCI_GetVersionConnection +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetVersion, con) +} + +boolean OCI_API OCI_Break +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionBreak, con) +} + +boolean OCI_API OCI_ServerEnableOutput +( + OCI_Connection *con, + unsigned int bufsize, + unsigned int arrsize, + unsigned int lnsize +) +{ + CALL_IMPL(ConnectionEnableServerOutput, con, bufsize, arrsize, lnsize) +} + +boolean OCI_API OCI_ServerDisableOutput +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionDisableServerOutput, con) +} + +const otext * OCI_API OCI_ServerGetOutput +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServerOutput, con) +} + +boolean OCI_API OCI_SetTrace +( + OCI_Connection *con, + unsigned int trace, + const otext *value +) +{ + CALL_IMPL(ConnectionSetTrace, con, trace, value) +} + +const otext * OCI_API OCI_GetTrace +( + OCI_Connection *con, + unsigned int trace +) +{ + CALL_IMPL(ConnectionGetTrace, con, trace) +} + +boolean OCI_API OCI_Ping +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionPing, con) +} + +boolean OCI_API OCI_SetTimeout +( + OCI_Connection *con, + unsigned int type, + unsigned int value +) +{ + CALL_IMPL(ConnectionSetTimeout, con, type, value) +} + +unsigned int OCI_API OCI_GetTimeout +( + OCI_Connection *con, + unsigned int type +) +{ + CALL_IMPL(ConnectionGetTimeout, con, type) +} + +const otext * OCI_API OCI_GetDBName +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetDatabaseName, con) +} + +const otext * OCI_API OCI_GetInstanceName +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetInstanceName, con) +} + +const otext * OCI_API OCI_GetServiceName +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServiceName, con) +} + +const otext * OCI_API OCI_GetServerName +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetServerName, con) +} + +const otext * OCI_API OCI_GetDomainName +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetDomainName, con) +} + +OCI_Timestamp * OCI_API OCI_GetInstanceStartTime +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetInstanceStartTime, con) +} + +boolean OCI_API OCI_IsTAFCapable +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionIsTAFCapable, con) +} + +boolean OCI_API OCI_SetTAFHandler +( + OCI_Connection *con, + POCI_TAF_HANDLER handler +) +{ + CALL_IMPL(ConnectionSetTAFHandler, con, handler) +} + +unsigned int OCI_API OCI_GetStatementCacheSize +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetStatementCacheSize, con) +} + +boolean OCI_API OCI_SetStatementCacheSize +( + OCI_Connection *con, + unsigned int value +) +{ + CALL_IMPL(ConnectionSetStatementCacheSize, con, value) +} + +unsigned int OCI_API OCI_GetDefaultLobPrefetchSize +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetDefaultLobPrefetchSize, con) +} + +boolean OCI_API OCI_SetDefaultLobPrefetchSize +( + OCI_Connection *con, + unsigned int value +) +{ + CALL_IMPL(ConnectionSetDefaultLobPrefetchSize, con, value) +} + +unsigned int OCI_API OCI_GetMaxCursors +( + OCI_Connection *con +) +{ + CALL_IMPL(ConnectionGetMaxCursors, con) +} + +boolean OCI_Immediate +( + OCI_Connection *con, + const otext *sql, + ... +) +{ + boolean res = FALSE; + va_list args; + + va_start(args, sql); + res = ConnectionExecuteImmediate(con, sql, args); + va_end(args); + + return res; +} + +boolean OCI_ImmediateFmt +( + OCI_Connection *con, + const otext *sql, + ... +) +{ + boolean res = FALSE; + va_list args; + + va_start(args, sql); + res = ConnectionExecuteImmediateFmt(con, sql, args); + va_end(args); + + return res; +} + +/* --------------------------------------------------------------------------------------------- * + * date + * --------------------------------------------------------------------------------------------- */ + +OCI_Date* OCI_API OCI_DateCreate +( + OCI_Connection* con +) +{ + CALL_IMPL(DateCreate, con) +} + +boolean OCI_API OCI_DateFree +( + OCI_Date* date +) +{ + CALL_IMPL(DateFree, date) +} + +OCI_Date** OCI_API OCI_DateArrayCreate +( + OCI_Connection* con, + unsigned int nbelem +) +{ + CALL_IMPL(DateCreateArray, con, nbelem) +} + +boolean OCI_API OCI_DateArrayFree +( + OCI_Date** dates +) +{ + CALL_IMPL(DateFreeArray, dates) +} + +boolean OCI_API OCI_DateAddDays +( + OCI_Date* date, + int nb +) +{ + CALL_IMPL(DateAddDays, date, nb) +} + +boolean OCI_API OCI_DateAddMonths +( + OCI_Date* date, + int nb +) +{ + CALL_IMPL(DateAddMonths, date, nb) +} + +boolean OCI_API OCI_DateAssign +( + OCI_Date* date, + OCI_Date* date_src +) +{ + CALL_IMPL(DateAssign, date, date_src) +} + +int OCI_API OCI_DateCheck +( + OCI_Date* date +) +{ + CALL_IMPL(DateCheck, date) +} + +int OCI_API OCI_DateCompare +( + OCI_Date* date, + OCI_Date* date2 +) +{ + CALL_IMPL(DateCompare, date, date2) +} + +int OCI_API OCI_DateDaysBetween +( + OCI_Date* date, + OCI_Date* date2 +) +{ + CALL_IMPL(DateDaysBetween, date, date2) +} + +boolean OCI_API OCI_DateFromText +( + OCI_Date * date, + const otext* str, + const otext* fmt +) +{ + CALL_IMPL(DateFromString, date, str, fmt) +} + +boolean OCI_API OCI_DateGetDate +( + OCI_Date* date, + int * year, + int * month, + int * day +) +{ + CALL_IMPL(DateGetDate, date, year, month, day) +} + +boolean OCI_API OCI_DateGetTime +( + OCI_Date* date, + int * hour, + int * min, + int * sec +) +{ + CALL_IMPL(DateGetTime, date, hour, min, sec) +} + +boolean OCI_API OCI_DateGetDateTime +( + OCI_Date* date, + int * year, + int * month, + int * day, + int * hour, + int * min, + int * sec +) +{ + CALL_IMPL(DateGetDateTime, date, year, month, day, hour, min, sec) +} + +boolean OCI_API OCI_DateLastDay +( + OCI_Date* date +) +{ + CALL_IMPL(DateLastDay, date) +} + +boolean OCI_API OCI_DateNextDay +( + OCI_Date * date, + const otext* day +) +{ + CALL_IMPL(DateNextDay, date, day) +} + +boolean OCI_API OCI_DateSetDate +( + OCI_Date* date, + int year, + int month, + int day +) +{ + CALL_IMPL(DateSetDate, date, year, month, day) +} + +boolean OCI_API OCI_DateSetTime +( + OCI_Date* date, + int hour, + int min, + int sec +) +{ + CALL_IMPL(DateSetTime, date, hour, min, sec) +} + +boolean OCI_API OCI_DateSetDateTime +( + OCI_Date* date, + int year, + int month, + int day, + int hour, + int min, + int sec +) +{ + CALL_IMPL(DateSetDateTime, date, year, month, day, hour, min,sec) +} + +boolean OCI_API OCI_DateSysDate +( + OCI_Date* date +) +{ + CALL_IMPL(DateSysDate, date) +} + +boolean OCI_API OCI_DateToText +( + OCI_Date * date, + const otext* fmt, + int size, + otext * str +) +{ + CALL_IMPL(DateToString, date, fmt, size, str) +} + +boolean OCI_API OCI_DateZoneToZone +( + OCI_Date * date, + const otext* zone1, + const otext* zone2 +) +{ + CALL_IMPL(DateZoneToZone, date, zone1, zone2) +} + +boolean OCI_API OCI_DateToCTime +( + OCI_Date * date, + struct tm* ptm, + time_t * pt +) +{ + CALL_IMPL(DateToCTime, date, ptm, pt) +} + +boolean OCI_API OCI_DateFromCTime +( + OCI_Date * date, + struct tm* ptm, + time_t t +) +{ + CALL_IMPL(DateFromCTime, date, ptm, t) +} + +/* --------------------------------------------------------------------------------------------- * + * dequeue + * --------------------------------------------------------------------------------------------- */ + +OCI_Dequeue * OCI_API OCI_DequeueCreate +( + OCI_TypeInfo *typinf, + const otext *name +) +{ + CALL_IMPL(DequeueCreate,typinf, name) +} + +boolean OCI_API OCI_DequeueFree +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueFree, dequeue) +} + +OCI_Msg * OCI_API OCI_DequeueGet +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetMessage, dequeue) +} + +boolean OCI_API OCI_DequeueSubscribe +( + OCI_Dequeue *dequeue, + unsigned int port, + unsigned int timeout, + POCI_NOTIFY_AQ callback +) +{ + CALL_IMPL(DequeueSubscribe, dequeue, port, timeout, callback) +} + +boolean OCI_API OCI_DequeueUnsubscribe +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueUnsubscribe, dequeue) +} + +boolean OCI_API OCI_DequeueSetConsumer +( + OCI_Dequeue *dequeue, + const otext *consumer +) +{ + CALL_IMPL(DequeueSetConsumer, dequeue, consumer) +} + +const otext * OCI_API OCI_DequeueGetConsumer +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetConsumer, dequeue) +} + +boolean OCI_API OCI_DequeueSetCorrelation +( + OCI_Dequeue *dequeue, + const otext *pattern +) +{ + CALL_IMPL(DequeueSetCorrelation, dequeue, pattern) +} + +const otext * OCI_API OCI_DequeueGetCorrelation +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetCorrelation, dequeue) +} + +boolean OCI_API OCI_DequeueSetRelativeMsgID +( + OCI_Dequeue *dequeue, + const void *id, + unsigned int len +) +{ + CALL_IMPL(DequeueSetRelativeMsgID, dequeue, id, len) +} + +boolean OCI_API OCI_DequeueGetRelativeMsgID +( + OCI_Dequeue *dequeue, + void *id, + unsigned int *len +) +{ + CALL_IMPL(DequeueGetRelativeMsgID, dequeue, id, len) +} + +boolean OCI_API OCI_DequeueSetVisibility +( + OCI_Dequeue *dequeue, + unsigned int visibility +) +{ + CALL_IMPL(DequeueSetVisibility, dequeue, visibility) +} + +unsigned int OCI_API OCI_DequeueGetVisibility +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetVisibility, dequeue) +} + +boolean OCI_API OCI_DequeueSetMode +( + OCI_Dequeue *dequeue, + unsigned int mode +) +{ + CALL_IMPL(DequeueSetMode, dequeue, mode) +} + +unsigned int OCI_API OCI_DequeueGetMode +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetMode, dequeue) +} + +boolean OCI_API OCI_DequeueSetNavigation +( + OCI_Dequeue *dequeue, + unsigned int position +) +{ + CALL_IMPL(DequeueSetNavigation, dequeue, position) +} + +unsigned int OCI_API OCI_DequeueGetNavigation +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetNavigation, dequeue) +} + +boolean OCI_API OCI_DequeueSetWaitTime +( + OCI_Dequeue *dequeue, + int timeout +) +{ + CALL_IMPL(DequeueSetWaitTime, dequeue, timeout) +} + +int OCI_API OCI_DequeueGetWaitTime +( + OCI_Dequeue *dequeue +) +{ + CALL_IMPL(DequeueGetWaitTime, dequeue) +} + +boolean OCI_API OCI_DequeueSetAgentList +( + OCI_Dequeue *dequeue, + OCI_Agent **consumers, + unsigned int count +) +{ + CALL_IMPL(DequeueSetAgentList, dequeue, consumers, count) +} + +OCI_Agent * OCI_API OCI_DequeueListen +( + OCI_Dequeue *dequeue, + int timeout +) +{ + CALL_IMPL(DequeueListen, dequeue, timeout) +} + +/* --------------------------------------------------------------------------------------------- * + * direct path + * --------------------------------------------------------------------------------------------- */ + +OCI_DirPath* OCI_API OCI_DirPathCreate +( + OCI_TypeInfo* typinf, + const otext * partition, + unsigned int nb_cols, + unsigned int nb_rows +) +{ + CALL_IMPL(DirPathCreate, typinf, partition, nb_cols, nb_rows) +} + +boolean OCI_API OCI_DirPathFree +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathFree, dp) +} + +boolean OCI_API OCI_DirPathSetColumn +( + OCI_DirPath* dp, + unsigned int index, + const otext* name, + unsigned int maxsize, + const otext* format +) +{ + CALL_IMPL(DirPathSetColumn, dp, index, name, maxsize, format) +} + +boolean OCI_API OCI_DirPathPrepare +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathPrepare, dp) +} + +boolean OCI_API OCI_DirPathSetEntry +( + OCI_DirPath* dp, + unsigned int row, + unsigned int index, + void * value, + unsigned size, + boolean complete +) +{ + CALL_IMPL(DirPathSetEntry, dp, row, index, value, size, complete) +} + +unsigned int OCI_API OCI_DirPathConvert +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathConvert, dp) +} + +unsigned int OCI_API OCI_DirPathLoad +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathLoad, dp) +} + +boolean OCI_API OCI_DirPathReset +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathReset, dp) +} + +boolean OCI_API OCI_DirPathFinish +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathFinish, dp) +} + +boolean OCI_API OCI_DirPathAbort +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathAbort, dp) +} + +boolean OCI_API OCI_DirPathSave +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathSave, dp) +} + +boolean OCI_API OCI_DirPathFlushRow +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathFlushRow, dp) +} + +boolean OCI_API OCI_DirPathSetCurrentRows +( + OCI_DirPath* dp, + unsigned int nb_rows +) +{ + CALL_IMPL(DirPathSetCurrentRows, dp, nb_rows) +} + +unsigned int OCI_API OCI_DirPathGetCurrentRows +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathGetCurrentRows, dp) +} + +unsigned int OCI_API OCI_DirPathGetMaxRows +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathGetMaxRows, dp) +} + +boolean OCI_API OCI_DirPathSetDateFormat +( + OCI_DirPath* dp, + const otext* format +) +{ + CALL_IMPL(DirPathSetDateFormat, dp, format) +} + +boolean OCI_API OCI_DirPathSetParallel +( + OCI_DirPath* dp, + boolean value +) +{ + CALL_IMPL(DirPathSetParallel, dp, value) +} + +boolean OCI_API OCI_DirPathSetNoLog +( + OCI_DirPath* dp, + boolean value +) +{ + CALL_IMPL(DirPathSetNoLog, dp, value) +} + +boolean OCI_API OCI_DirPathSetCacheSize +( + OCI_DirPath* dp, + unsigned int size +) +{ + CALL_IMPL(DirPathSetCacheSize, dp, size) +} + +boolean OCI_API OCI_DirPathSetBufferSize +( + OCI_DirPath* dp, + unsigned int size +) +{ + CALL_IMPL(DirPathSetBufferSize, dp, size) +} + +boolean OCI_API OCI_DirPathSetConvertMode +( + OCI_DirPath* dp, + unsigned int mode +) +{ + CALL_IMPL(DirPathSetConvertMode, dp, mode) +} + +unsigned int OCI_API OCI_DirPathGetRowCount +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathGetRowCount, dp) +} + +unsigned int OCI_API OCI_DirPathGetAffectedRows +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathGetAffectedRows, dp) +} + +unsigned int OCI_API OCI_DirPathGetErrorColumn +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathGetErrorColumn, dp) +} + +unsigned int OCI_API OCI_DirPathGetErrorRow +( + OCI_DirPath* dp +) +{ + CALL_IMPL(DirPathGetErrorRow, dp) +} + +/* --------------------------------------------------------------------------------------------- * + * element + * --------------------------------------------------------------------------------------------- */ + +OCI_Elem* OCI_API OCI_ElemCreate +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(ElementCreate, typinf) +} + +boolean OCI_API OCI_ElemFree +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementFree, elem) +} + +boolean OCI_API OCI_ElemGetBoolean +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetBoolean, elem) +} + +OCI_Number* OCI_API OCI_ElemGetNumber +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetNumber, elem) +} + +short OCI_API OCI_ElemGetShort +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetShort, elem) +} + +unsigned short OCI_API OCI_ElemGetUnsignedShort +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetUnsignedShort, elem) +} + +int OCI_API OCI_ElemGetInt +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElemGetInt, elem) +} + +unsigned int OCI_API OCI_ElemGetUnsignedInt +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetUnsignedInt, elem) +} + +big_int OCI_API OCI_ElemGetBigInt +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetBigInt, elem) +} + +big_uint OCI_API OCI_ElemGetUnsignedBigInt +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetUnsignedBigInt, elem) +} + +double OCI_API OCI_ElemGetDouble +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetDouble, elem) +} + +float OCI_API OCI_ElemGetFloat +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetFloat, elem) +} + +const otext* OCI_API OCI_ElemGetString +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetString, elem) +} + +unsigned int OCI_API OCI_ElemGetRaw +( + OCI_Elem * elem, + void * value, + unsigned int len +) +{ + CALL_IMPL(ElementGetRaw, elem, value, len) +} + +unsigned int OCI_API OCI_ElemGetRawSize +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetRawSize, elem) +} + +OCI_Date* OCI_API OCI_ElemGetDate +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetDate, elem) +} + +OCI_Timestamp* OCI_API OCI_ElemGetTimestamp +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetTimestamp, elem) +} + +OCI_Interval* OCI_API OCI_ElemGetInterval +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetInterval, elem) +} + +OCI_Lob* OCI_API OCI_ElemGetLob +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetLob, elem) +} + +OCI_File* OCI_API OCI_ElemGetFile +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetFile, elem) +} + +OCI_Ref* OCI_API OCI_ElemGetRef +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetReference, elem) +} + +OCI_Object* OCI_API OCI_ElemGetObject +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetObject, elem) +} + +OCI_Coll* OCI_API OCI_ElemGetColl +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementGetCollection, elem) +} + +boolean OCI_API OCI_ElemSetBoolean +( + OCI_Elem* elem, + boolean value +) +{ + CALL_IMPL(ElementSetBoolean, elem, value) +} + +boolean OCI_API OCI_ElemSetNumber +( + OCI_Elem * elem, + OCI_Number* value +) +{ + CALL_IMPL(ElementSetNumber, elem, value) +} + +boolean OCI_API OCI_ElemSetShort +( + OCI_Elem* elem, + short value +) +{ + CALL_IMPL(ElementSetShort, elem, value) +} + +boolean OCI_API OCI_ElemSetUnsignedShort +( + OCI_Elem * elem, + unsigned short value +) +{ + CALL_IMPL(ElementSetUnsignedShort, elem, value) +} + +boolean OCI_API OCI_ElemSetInt +( + OCI_Elem* elem, + int value +) +{ + CALL_IMPL(ElementSetInt, elem, value) +} + +boolean OCI_API OCI_ElemSetUnsignedInt +( + OCI_Elem * elem, + unsigned int value +) +{ + CALL_IMPL(ElementSetUnsignedInt, elem, value) +} + +boolean OCI_API OCI_ElemSetBigInt +( + OCI_Elem* elem, + big_int value +) +{ + CALL_IMPL(ElementSetBigInt, elem, value) +} + +boolean OCI_API OCI_ElemSetUnsignedBigInt +( + OCI_Elem* elem, + big_uint value +) +{ + CALL_IMPL(ElementSetUnsignedBigInt, elem, value) +} + +boolean OCI_API OCI_ElemSetDouble +( + OCI_Elem* elem, + double value +) +{ + CALL_IMPL(ElementSetDouble, elem, value) +} + +boolean OCI_API OCI_ElemSetFloat +( + OCI_Elem* elem, + float value +) +{ + CALL_IMPL(ElementSetFloat, elem, value) +} + +boolean OCI_API OCI_ElemSetString +( + OCI_Elem * elem, + const otext* value +) +{ + CALL_IMPL(ElementSetString, elem, value) +} + +boolean OCI_API OCI_ElemSetRaw +( + OCI_Elem * elem, + void * value, + unsigned int len +) +{ + CALL_IMPL(ElementSetRaw, elem, value, len) +} + +boolean OCI_API OCI_ElemSetDate +( + OCI_Elem* elem, + OCI_Date* value +) +{ + CALL_IMPL(ElementSetDate, elem, value) +} + +boolean OCI_API OCI_ElemSetTimestamp +( + OCI_Elem * elem, + OCI_Timestamp* value +) +{ + CALL_IMPL(ElementSetTimestamp, elem, value) +} + +boolean OCI_API OCI_ElemSetInterval +( + OCI_Elem * elem, + OCI_Interval* value +) +{ + CALL_IMPL(ElementSetInterval, elem, value) +} + +boolean OCI_API OCI_ElemSetColl +( + OCI_Elem* elem, + OCI_Coll* value +) +{ + CALL_IMPL(ElementSetCollection, elem, value) +} + +boolean OCI_API OCI_ElemSetObject +( + OCI_Elem * elem, + OCI_Object* value +) +{ + CALL_IMPL(ElementSetObject, elem, value) +} + +boolean OCI_API OCI_ElemSetLob +( + OCI_Elem* elem, + OCI_Lob * value +) +{ + CALL_IMPL(ElementSetLob, elem, value) +} + +boolean OCI_API OCI_ElemSetFile +( + OCI_Elem* elem, + OCI_File* value +) +{ + CALL_IMPL(ElementSetFile, elem, value) +} + +boolean OCI_API OCI_ElemSetRef +( + OCI_Elem* elem, + OCI_Ref * value +) +{ + CALL_IMPL(ElementSetReference, elem, value) +} + +boolean OCI_API OCI_ElemIsNull +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementIsNull, elem) +} + +boolean OCI_API OCI_ElemSetNull +( + OCI_Elem* elem +) +{ + CALL_IMPL(ElementSetNull, elem) +} + +/* --------------------------------------------------------------------------------------------- * + * enqueue + * --------------------------------------------------------------------------------------------- */ + +OCI_Enqueue* OCI_API OCI_EnqueueCreate +( + OCI_TypeInfo* typinf, + const otext * name +) +{ + CALL_IMPL(EnqueueCreate, typinf, name) +} + +boolean OCI_API OCI_EnqueueFree +( + OCI_Enqueue* enqueue +) +{ + CALL_IMPL(EnqueueFree, enqueue) +} + +boolean OCI_API OCI_EnqueuePut +( + OCI_Enqueue* enqueue, + OCI_Msg * msg +) +{ + CALL_IMPL(EnqueuePut, enqueue, msg) +} + +boolean OCI_API OCI_EnqueueSetSequenceDeviation +( + OCI_Enqueue* enqueue, + unsigned int sequence +) +{ + CALL_IMPL(EnqueueSetSequenceDeviation, enqueue, sequence) +} + +unsigned int OCI_API OCI_EnqueueGetSequenceDeviation +( + OCI_Enqueue* enqueue +) +{ + CALL_IMPL(EnqueueGetSequenceDeviation, enqueue) +} + +boolean OCI_API OCI_EnqueueSetVisibility +( + OCI_Enqueue* enqueue, + unsigned int visibility +) +{ + CALL_IMPL(EnqueueSetVisibility, enqueue, visibility) +} + +unsigned int OCI_API OCI_EnqueueGetVisibility +( + OCI_Enqueue* enqueue +) +{ + CALL_IMPL(EnqueueGetVisibility, enqueue) +} + +boolean OCI_API OCI_EnqueueSetRelativeMsgID +( + OCI_Enqueue* enqueue, + const void * id, + unsigned int len +) +{ + CALL_IMPL(EnqueueSetRelativeMsgID, enqueue, id, len) +} + +boolean OCI_API OCI_EnqueueGetRelativeMsgID +( + OCI_Enqueue * enqueue, + void * id, + unsigned int* len +) +{ + CALL_IMPL(EnqueueGetRelativeMsgID, enqueue, id, len) +} + +/* --------------------------------------------------------------------------------------------- * + * error + * --------------------------------------------------------------------------------------------- */ + +const otext* OCI_API OCI_ErrorGetString +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetString, err) +} + +unsigned int OCI_API OCI_ErrorGetType +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetType, err) +} + +int OCI_API OCI_ErrorGetOCICode +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetOCICode, err) +} + +int OCI_API OCI_ErrorGetInternalCode +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetInternalCode, err) +} + +OCI_Connection* OCI_API OCI_ErrorGetConnection +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetConnection, err) +} + +OCI_Statement* OCI_API OCI_ErrorGetStatement +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetStatement, err) +} + +unsigned int OCI_API OCI_ErrorGetRow +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetRow, err) +} + +const otext* OCI_API OCI_ErrorGetLocation +( + OCI_Error* err +) +{ + CALL_IMPL(ErrorGetLocation, err) +} + +/* --------------------------------------------------------------------------------------------- * + * event + * --------------------------------------------------------------------------------------------- */ + +unsigned int OCI_API OCI_EventGetType +( + OCI_Event* event +) +{ + CALL_IMPL(EventGetType, event) +} + +unsigned int OCI_API OCI_EventGetOperation +( + OCI_Event* event +) +{ + CALL_IMPL(EventGetOperation, event) +} + +const otext* OCI_API OCI_EventGetDatabase +( + OCI_Event* event +) +{ + CALL_IMPL(EventGetDatabase, event) +} + +const otext* OCI_API OCI_EventGetObject +( + OCI_Event* event +) +{ + CALL_IMPL(EventGetObject, event) +} + +const otext* OCI_API OCI_EventGetRowid +( + OCI_Event* event +) +{ + CALL_IMPL(EventGetRowid, event) +} + +OCI_Subscription* OCI_API OCI_EventGetSubscription +( + OCI_Event* event +) +{ + CALL_IMPL(EventGetSubscription, event) +} + +/* --------------------------------------------------------------------------------------------- * + * file + * --------------------------------------------------------------------------------------------- */ + +OCI_File* OCI_API OCI_FileCreate +( + OCI_Connection* con, + unsigned int type +) +{ + CALL_IMPL(FileCreate, con, type) +} + +boolean OCI_API OCI_FileFree +( + OCI_File* file +) +{ + CALL_IMPL(FileFree, file) +} + +OCI_File** OCI_API OCI_FileArrayCreate +( + OCI_Connection* con, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(FileCreateArray, con, type, nbelem) +} + +boolean OCI_API OCI_FileArrayFree +( + OCI_File** files +) +{ + CALL_IMPL(FileFreeArray, files) +} + +unsigned int OCI_API OCI_FileGetType +( + OCI_File* file +) +{ + CALL_IMPL(FileGetType, file) +} + +boolean OCI_API OCI_FileSeek +( + OCI_File * file, + big_uint offset, + unsigned int mode +) +{ + CALL_IMPL(FileSeek, file, offset, mode) +} + +big_uint OCI_API OCI_FileGetOffset +( + OCI_File* file +) +{ + CALL_IMPL(FileGetOffset, file) +} + +unsigned int OCI_API OCI_FileRead +( + OCI_File * file, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(FileRead, file, buffer, len) +} + +big_uint OCI_API OCI_FileGetSize +( + OCI_File* file +) +{ + CALL_IMPL(FileGetSize, file) +} + +boolean OCI_API OCI_FileExists +( + OCI_File* file +) +{ + CALL_IMPL(FileExists, file) +} + +boolean OCI_API OCI_FileSetName +( + OCI_File * file, + const otext* dir, + const otext* name +) +{ + CALL_IMPL(FileSetName, file, dir, name) +} + +const otext* OCI_API OCI_FileGetDirectory +( + OCI_File* file +) +{ + CALL_IMPL(FileGetDirectory, file) +} + +const otext* OCI_API OCI_FileGetName +( + OCI_File* file +) +{ + CALL_IMPL(FileGetName, file) +} + +boolean OCI_API OCI_FileOpen +( + OCI_File* file +) +{ + CALL_IMPL(FileOpen, file) +} + +boolean OCI_API OCI_FileIsOpen +( + OCI_File* file +) +{ + CALL_IMPL(FileIsOpen, file) +} + +boolean OCI_API OCI_FileClose +( + OCI_File* file +) +{ + CALL_IMPL(FileClose, file) +} + +boolean OCI_API OCI_FileIsEqual +( + OCI_File* file, + OCI_File* file2 +) +{ + CALL_IMPL(FileIsEqual, file, file2) +} + +boolean OCI_API OCI_FileAssign +( + OCI_File* file, + OCI_File* file_src +) +{ + CALL_IMPL(FileAssign, file, file_src) +} + +OCI_Connection* OCI_API OCI_FileGetConnection +( + OCI_File* file +) +{ + CALL_IMPL(FileGetConnection, file) +} + +/* --------------------------------------------------------------------------------------------- * + * handle + * --------------------------------------------------------------------------------------------- */ + +const void* OCI_API OCI_HandleGetEnvironment +( + void +) +{ + CALL_IMPL(HandleGetEnvironment) +} + +const void* OCI_API OCI_HandleGetContext +( + OCI_Connection* con +) +{ + CALL_IMPL(HandleGetContext, con) +} + +const void* OCI_API OCI_HandleGetServer +( + OCI_Connection* con +) +{ + CALL_IMPL(HandleGetServer, con) +} + +const void* OCI_API OCI_HandleGetError +( + OCI_Connection* con +) +{ + CALL_IMPL(HandleGetError, con) +} + +const void* OCI_API OCI_HandleGetSession +( + OCI_Connection* con +) +{ + CALL_IMPL(HandleGetSession, con) +} + +const void* OCI_API OCI_HandleGetTransaction +( + OCI_Transaction* trans +) +{ + CALL_IMPL(HandleGetTransaction, trans) +} + +const void* OCI_API OCI_HandleGetStatement +( + OCI_Statement* stmt +) +{ + CALL_IMPL(HandleGetStatement, stmt) +} + +const void* OCI_API OCI_HandleGetLob +( + OCI_Lob* lob +) +{ + CALL_IMPL(HandleGetLob, lob) +} + +const void* OCI_API OCI_HandleGetFile +( + OCI_File* file +) +{ + CALL_IMPL(HandleGetFile, file) +} + +const void* OCI_API OCI_HandleGetDate +( + OCI_Date* date +) +{ + CALL_IMPL(HandleGetDate, date) +} + +const void* OCI_API OCI_HandleGetTimestamp +( + OCI_Timestamp* tmsp +) +{ + CALL_IMPL(HandleGetTimestamp, tmsp) +} + +const void* OCI_API OCI_HandleGetInterval +( + OCI_Interval* itv +) +{ + CALL_IMPL(HandleGetInterval, itv) +} + +const void* OCI_API OCI_HandleGetObject +( + OCI_Object* obj +) +{ + CALL_IMPL(HandleGetObject, obj) +} + +const void* OCI_API OCI_HandleGetColl +( + OCI_Coll* coll +) +{ + CALL_IMPL(HandleGetColl, coll) +} + +const void* OCI_API OCI_HandleGetRef +( + OCI_Ref* ref +) +{ + CALL_IMPL(HandleGetReference, ref) +} + +const void* OCI_API OCI_HandleGetMutex +( + OCI_Mutex* mutex +) +{ + CALL_IMPL(HandleGetMutex, mutex) +} + +const void* OCI_API OCI_HandleGetThreadID +( + OCI_Thread* thread +) +{ + CALL_IMPL(HandleGetThreadID, thread) +} + +const void* OCI_API OCI_HandleGetThread +( + OCI_Thread* thread +) +{ + CALL_IMPL(HandleGetThread, thread) +} + +const void* OCI_API OCI_HandleGetDirPathCtx +( + OCI_DirPath* dp +) +{ + CALL_IMPL(HandleGetDirPathCtx, dp) +} + +const void* OCI_API OCI_HandleGetDirPathColArray +( + OCI_DirPath* dp +) +{ + CALL_IMPL(HandleGetDirPathColArray, dp) +} + +const void* OCI_API OCI_HandleGetDirPathStream +( + OCI_DirPath* dp +) +{ + CALL_IMPL(HandleGetDirPathStream, dp) +} + +const void* OCI_API OCI_HandleGetSubscription +( + OCI_Subscription* sub +) +{ + CALL_IMPL(HandleGetSubscription, sub) +} + +/* --------------------------------------------------------------------------------------------- * + * hash + * --------------------------------------------------------------------------------------------- */ + +OCI_HashTable* OCI_API OCI_HashCreate +( + unsigned int size, + unsigned int type +) +{ + CALL_IMPL(HashCreate, size, type) +} + +boolean OCI_API OCI_HashFree +( + OCI_HashTable* table +) +{ + CALL_IMPL(HashFree, table) +} + +unsigned int OCI_API OCI_HashGetSize +( + OCI_HashTable* table +) +{ + CALL_IMPL(HashGetSize, table) +} + +unsigned int OCI_API OCI_HashGetType +( + OCI_HashTable* table +) +{ + CALL_IMPL(HashGetType, table) +} + +boolean OCI_API OCI_HashAddString +( + OCI_HashTable* table, + const otext * key, + const otext * value +) +{ + CALL_IMPL(HashAddString, table, key, value) +} + +const otext* OCI_API OCI_HashGetString +( + OCI_HashTable* table, + const otext * key +) +{ + CALL_IMPL(HashGetString, table, key) +} + +boolean OCI_API OCI_HashAddInt +( + OCI_HashTable* table, + const otext * key, + int value +) +{ + CALL_IMPL(HashAddInt, table, key, value) +} + +int OCI_API OCI_HashGetInt +( + OCI_HashTable* table, + const otext * key +) +{ + CALL_IMPL(HashGetInt, table, key) +} + +boolean OCI_API OCI_HashAddPointer +( + OCI_HashTable* table, + const otext * key, + void * value +) +{ + CALL_IMPL(HashAddPointer, table, key, value) +} + +void* OCI_API OCI_HashGetPointer +( + OCI_HashTable* table, + const otext * key +) +{ + CALL_IMPL(HashGetPointer, table, key) +} + +OCI_HashEntry* OCI_API OCI_HashLookup +( + OCI_HashTable* table, + const otext * key, + boolean create +) +{ + CALL_IMPL(HashLookup, table, key, create) +} + +OCI_HashValue* OCI_API OCI_HashGetValue +( + OCI_HashTable* table, + const otext * key +) +{ + CALL_IMPL(HashGetValue, table, key) +} + +OCI_HashEntry* OCI_API OCI_HashGetEntry +( + OCI_HashTable* table, + unsigned int index +) +{ + CALL_IMPL(HashGetEntry, table, index) +} + +/* --------------------------------------------------------------------------------------------- * + * interval + * --------------------------------------------------------------------------------------------- */ + +OCI_Interval* OCI_API OCI_IntervalCreate +( + OCI_Connection* con, + unsigned int type +) +{ + CALL_IMPL(IntervalCreate, con, type) +} + +boolean OCI_API OCI_IntervalFree +( + OCI_Interval* itv +) +{ + CALL_IMPL(IntervalFree, itv) +} + +OCI_Interval** OCI_API OCI_IntervalArrayCreate +( + OCI_Connection* con, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(IntervalCreateArray, con, type, nbelem) +} + +boolean OCI_API OCI_IntervalArrayFree +( + OCI_Interval** itvs +) +{ + CALL_IMPL(IntervalFreeArray, itvs) +} + +unsigned int OCI_API OCI_IntervalGetType +( + OCI_Interval* itv +) +{ + CALL_IMPL(IntervalGetType, itv) +} + +boolean OCI_API OCI_IntervalAssign +( + OCI_Interval* itv, + OCI_Interval* itv_src +) +{ + CALL_IMPL(IntervalAssign, itv, itv_src) +} + +int OCI_API OCI_IntervalCheck +( + OCI_Interval* itv +) +{ + CALL_IMPL(IntervalCheck, itv) +} + +int OCI_API OCI_IntervalCompare +( + OCI_Interval* itv, + OCI_Interval* itv2 +) +{ + CALL_IMPL(IntervalCompare, itv, itv2) +} + +boolean OCI_API OCI_IntervalFromText +( + OCI_Interval* itv, + const otext * str +) +{ + CALL_IMPL(IntervalFromString, itv, str) +} + +boolean OCI_API OCI_IntervalToText +( + OCI_Interval* itv, + int leading_prec, + int fraction_prec, + int size, + otext * str +) +{ + CALL_IMPL(IntervalToString, itv, leading_prec, fraction_prec, size, str) +} + +boolean OCI_API OCI_IntervalFromTimeZone +( + OCI_Interval* itv, + const otext * str +) +{ + CALL_IMPL(IntervalFromTimeZone, itv, str) +} + +boolean OCI_API OCI_IntervalGetDaySecond +( + OCI_Interval* itv, + int * day, + int * hour, + int * min, + int * sec, + int * fsec +) +{ + CALL_IMPL(IntervalGetDaySecond, itv, day, hour, min, sec, fsec) +} + +boolean OCI_API OCI_IntervalGetYearMonth +( + OCI_Interval* itv, + int * year, + int * month +) +{ + CALL_IMPL(IntervalGetYearMonth, itv, year, month) +} + +boolean OCI_API OCI_IntervalSetDaySecond +( + OCI_Interval* itv, + int day, + int hour, + int min, + int sec, + int fsec +) +{ + CALL_IMPL(IntervalSetDaySecond, itv, day, hour, min, sec, fsec) +} + +boolean OCI_API OCI_IntervalSetYearMonth +( + OCI_Interval* itv, + int year, + int month +) +{ + CALL_IMPL(IntervalSetYearMonth, itv, year, month) +} + +boolean OCI_API OCI_IntervalAdd +( + OCI_Interval* itv, + OCI_Interval* itv2 +) +{ + CALL_IMPL(IntervalAdd, itv, itv2) +} + +boolean OCI_API OCI_IntervalSubtract +( + OCI_Interval* itv, + OCI_Interval* itv2 +) +{ + CALL_IMPL(IntervalSubtract, itv, itv2) +} + +/* --------------------------------------------------------------------------------------------- * + * iterator + * --------------------------------------------------------------------------------------------- */ + +OCI_Iter* OCI_API OCI_IterCreate +( + OCI_Coll* coll +) +{ + CALL_IMPL(IteratorCreate, coll) +} + +boolean OCI_API OCI_IterFree +( + OCI_Iter* iter +) +{ + CALL_IMPL(IteratorFree, iter) +} + +OCI_Elem* OCI_API OCI_IterGetNext +( + OCI_Iter* iter +) +{ + CALL_IMPL(IteratorGetNext, iter) +} + +OCI_Elem* OCI_API OCI_IterGetPrev +( + OCI_Iter* iter +) +{ + CALL_IMPL(IteratorGetPrev, iter) +} + +OCI_Elem* OCI_API OCI_IterGetCurrent +( + OCI_Iter* iter +) +{ + CALL_IMPL(IteratorGetCurrent, iter) +} + +/* --------------------------------------------------------------------------------------------- * + * library + * --------------------------------------------------------------------------------------------- */ + +boolean OCI_API OCI_Initialize +( + POCI_ERROR err_handler, + const otext* lib_path, + unsigned int mode +) +{ + CALL_IMPL(EnvironmentInitialize, err_handler, lib_path, mode) +} + +boolean OCI_API OCI_Cleanup +( + void +) +{ + CALL_IMPL(EnvironmentCleanup) +} + +unsigned int OCI_API OCI_GetOCICompileVersion +( + void +) +{ + CALL_IMPL(EnvironmentGetOCICompileVersion) +} + +unsigned int OCI_API OCI_GetOCIRuntimeVersion +( + void +) +{ + CALL_IMPL(EnvironmentGetOCIRuntimeVersion) +} + +unsigned int OCI_API OCI_GetImportMode +( + void +) +{ + CALL_IMPL(EnvironmentGetOCIRuntimeImportMode) +} + +unsigned int OCI_API OCI_GetCharset +( + void +) +{ + CALL_IMPL(EnvironmentGetCharset) +} + +big_uint OCI_API OCI_GetAllocatedBytes +( + unsigned int mem_type +) +{ + CALL_IMPL(EnvironmentGetAllocatedBytes, mem_type) +} + +OCI_Error* OCI_API OCI_GetLastError +( + void +) +{ + return EnvironmentGetLastError(); +} + +boolean OCI_API OCI_EnableWarnings +( + boolean value +) +{ + CALL_IMPL(EnvironmentEnableWarnings, value) +} + +boolean OCI_API OCI_SetErrorHandler +( + POCI_ERROR handler +) +{ + CALL_IMPL(EnvironmentSetErrorHandler, handler) +} + +boolean OCI_API OCI_DatabaseStartup +( + const otext* db, + const otext* user, + const otext* pwd, + unsigned int sess_mode, + unsigned int start_mode, + unsigned int start_flag, + const otext* spfile +) +{ + CALL_IMPL(DatabaseStartup, db, user, pwd, sess_mode, start_mode, start_flag, spfile) +} + +boolean OCI_API OCI_DatabaseShutdown +( + const otext* db, + const otext* user, + const otext* pwd, + unsigned int sess_mode, + unsigned int shut_mode, + unsigned int shut_flag +) +{ + CALL_IMPL(DatabaseShutdown, db, user, pwd, sess_mode, shut_mode, shut_flag) +} + +boolean OCI_API OCI_SetHAHandler +( + POCI_HA_HANDLER handler +) +{ + CALL_IMPL(EnvironmentSetHAHandler, handler) +} + +boolean OCI_API OCI_SetFormat +( + OCI_Connection* con, + unsigned int type, + const otext * format +) +{ + CALL_IMPL(EnvironmentSetFormat, con, type, format) +} + +const otext* OCI_API OCI_GetFormat +( + OCI_Connection* con, + unsigned int type +) +{ + CALL_IMPL(EnvironmentGetFormat, con, type) +} + +boolean OCI_API OCI_SetUserPassword +( + const otext* db, + const otext* user, + const otext* pwd, + const otext* new_pwd +) +{ + CALL_IMPL(DatabaseSetUserPassword, db, user, pwd, new_pwd); +} + +/* --------------------------------------------------------------------------------------------- * + * lob + * --------------------------------------------------------------------------------------------- */ + +OCI_Lob* OCI_API OCI_LobCreate +( + OCI_Connection* con, + unsigned int type +) +{ + CALL_IMPL(LobCreate, con, type); +} + +boolean OCI_API OCI_LobFree +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobFree, lob); +} + +OCI_Lob** OCI_API OCI_LobArrayCreate +( + OCI_Connection* con, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(LobCreateArray, con, type, nbelem); +} + +boolean OCI_API OCI_LobArrayFree +( + OCI_Lob** lobs +) +{ + CALL_IMPL(LobFreeArray, lobs); +} + +unsigned int OCI_API OCI_LobGetType +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobGetType, lob); +} + +boolean OCI_API OCI_LobSeek +( + OCI_Lob * lob, + big_uint offset, + unsigned int mode +) +{ + CALL_IMPL(LobSeek, lob, offset, mode); +} + +big_uint OCI_API OCI_LobGetOffset +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobGetOffset, lob); +} + +unsigned int OCI_API OCI_LobRead +( + OCI_Lob * lob, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(LobRead, lob, buffer, len); +} + +boolean OCI_API OCI_LobRead2 +( + OCI_Lob * lob, + void * buffer, + unsigned int* char_count, + unsigned int* byte_count +) +{ + CALL_IMPL(LobRead2, lob, buffer, char_count, byte_count); +} + +unsigned int OCI_API OCI_LobWrite +( + OCI_Lob * lob, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(LobWrite, lob, buffer, len); +} + +boolean OCI_API OCI_LobWrite2 +( + OCI_Lob * lob, + void * buffer, + unsigned int* char_count, + unsigned int* byte_count +) +{ + CALL_IMPL(LobWrite2, lob, buffer, char_count, byte_count); +} + +boolean OCI_API OCI_LobTruncate +( + OCI_Lob* lob, + big_uint size +) +{ + CALL_IMPL(LobTruncate, lob, size); +} + +big_uint OCI_API OCI_LobGetLength +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobGetLength, lob); +} + +unsigned int OCI_API OCI_LobGetChunkSize +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobGetChunkSize, lob); +} + +big_uint OCI_API OCI_LobErase +( + OCI_Lob* lob, + big_uint offset, + big_uint len +) +{ + CALL_IMPL(LobErase, lob, offset, len); +} + +unsigned int OCI_API OCI_LobAppend +( + OCI_Lob * lob, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(LobAppend, lob, buffer, len); +} + +boolean OCI_API OCI_LobAppend2 +( + OCI_Lob * lob, + void * buffer, + unsigned int* char_count, + unsigned int* byte_count +) +{ + CALL_IMPL(LobAppend2, lob, buffer, char_count, byte_count); +} + +boolean OCI_API OCI_LobAppendLob +( + OCI_Lob* lob, + OCI_Lob* lob_src +) +{ + CALL_IMPL(LobAppendLob, lob, lob_src); +} + +boolean OCI_API OCI_LobIsTemporary +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobIsTemporary, lob); +} + +boolean OCI_API OCI_LobCopy +( + OCI_Lob* lob, + OCI_Lob* lob_src, + big_uint offset_dst, + big_uint offset_src, + big_uint count +) +{ + CALL_IMPL(LobCopy, lob, lob_src, offset_dst, offset_src, count); +} + +boolean OCI_API OCI_LobCopyFromFile +( + OCI_Lob * lob, + OCI_File* file, + big_uint offset_dst, + big_uint offset_src, + big_uint count +) +{ + CALL_IMPL(LobCopyFromFile, lob, file, offset_dst, offset_src, count); +} + +boolean OCI_API OCI_LobOpen +( + OCI_Lob * lob, + unsigned int mode +) +{ + CALL_IMPL(LobOpen, lob, mode); +} + +boolean OCI_API OCI_LobClose +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobClose, lob); +} + +boolean OCI_API OCI_LobIsEqual +( + OCI_Lob* lob, + OCI_Lob* lob2 +) +{ + CALL_IMPL(LobIsEqual, lob, lob2); +} + +boolean OCI_API OCI_LobAssign +( + OCI_Lob* lob, + OCI_Lob* lob_src +) +{ + CALL_IMPL(LobAssign, lob, lob_src); +} + +big_uint OCI_API OCI_LobGetMaxSize +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobGetMaxSize, lob); +} + +boolean OCI_API OCI_LobFlush +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobFlush, lob); +} + +boolean OCI_API OCI_LobEnableBuffering +( + OCI_Lob* lob, + boolean value +) +{ + CALL_IMPL(LobEnableBuffering, lob, value); +} + +OCI_Connection* OCI_API OCI_LobGetConnection +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobGetConnection, lob); +} + +boolean OCI_API OCI_LobIsRemote +( + OCI_Lob* lob +) +{ + CALL_IMPL(LobIsRemote, lob); +} + +/* --------------------------------------------------------------------------------------------- * + * long + * --------------------------------------------------------------------------------------------- */ + +OCI_Long* OCI_API OCI_LongCreate +( + OCI_Statement* stmt, + unsigned int type +) +{ + CALL_IMPL(LongCreate, stmt, type); +} + +boolean OCI_API OCI_LongFree +( + OCI_Long* lg +) +{ + CALL_IMPL(LongFree, lg); +} + +unsigned int OCI_API OCI_LongGetType +( + OCI_Long* lg +) +{ + CALL_IMPL(LongGetType, lg); +} + +unsigned int OCI_API OCI_LongRead +( + OCI_Long * lg, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(LongRead, lg, buffer, len); +} + +unsigned int OCI_API OCI_LongWrite +( + OCI_Long * lg, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(LongWrite, lg, buffer, len); +} + +unsigned int OCI_API OCI_LongGetSize +( + OCI_Long* lg +) +{ + CALL_IMPL(LongGetSize, lg); +} + +void* OCI_API OCI_LongGetBuffer +( + OCI_Long* lg +) +{ + CALL_IMPL(LongGetBuffer, lg); +} + +/* --------------------------------------------------------------------------------------------- * + * msg + * --------------------------------------------------------------------------------------------- */ + +OCI_Msg* OCI_API OCI_MsgCreate +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(MessageCreate, typinf); +} + +boolean OCI_API OCI_MsgFree +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageFree, msg); +} + +boolean OCI_API OCI_MsgReset +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageReset, msg); +} + +OCI_Object* OCI_API OCI_MsgGetObject +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetObject, msg); +} + +boolean OCI_API OCI_MsgSetObject +( + OCI_Msg * msg, + OCI_Object* obj +) +{ + CALL_IMPL(MessageSetObject, msg, obj); +} + +boolean OCI_API OCI_MsgGetRaw +( + OCI_Msg * msg, + void * raw, + unsigned int* size +) +{ + CALL_IMPL(MessageGetRaw, msg, raw, size); +} + +boolean OCI_API OCI_MsgSetRaw +( + OCI_Msg * msg, + const void * raw, + unsigned int size +) +{ + CALL_IMPL(MessageSetRaw, msg, raw, size); +} + +int OCI_API OCI_MsgGetAttemptCount +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetAttemptCount, msg); +} + +int OCI_API OCI_MsgGetEnqueueDelay +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetEnqueueDelay, msg); +} + +boolean OCI_API OCI_MsgSetEnqueueDelay +( + OCI_Msg* msg, + int value +) +{ + CALL_IMPL(MessageSetEnqueueDelay, msg, value); +} + +OCI_Date* OCI_API OCI_MsgGetEnqueueTime +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetEnqueueTime, msg); +} + +int OCI_API OCI_MsgGetExpiration +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetExpiration, msg); +} + +boolean OCI_API OCI_MsgSetExpiration +( + OCI_Msg* msg, + int value +) +{ + CALL_IMPL(MessageSetExpiration, msg, value); +} + +unsigned int OCI_API OCI_MsgGetState +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetState, msg); +} + +int OCI_API OCI_MsgGetPriority +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetPriority, msg); +} + +boolean OCI_API OCI_MsgSetPriority +( + OCI_Msg* msg, + int value +) +{ + CALL_IMPL(MessageSetPriority, msg, value); +} + +boolean OCI_API OCI_MsgGetID +( + OCI_Msg * msg, + void * id, + unsigned int* len +) +{ + CALL_IMPL(MessageGetID, msg, id, len); +} + +boolean OCI_API OCI_MsgGetOriginalID +( + OCI_Msg * msg, + void * id, + unsigned int* len +) +{ + CALL_IMPL(MessageGetOriginalID, msg, id, len); +} + +boolean OCI_API OCI_MsgSetOriginalID +( + OCI_Msg * msg, + const void * id, + unsigned int len +) +{ + CALL_IMPL(MessageSetOriginalID, msg, id, len); +} + +OCI_Agent* OCI_API OCI_MsgGetSender +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetSender, msg); +} + +boolean OCI_API OCI_MsgSetSender +( + OCI_Msg * msg, + OCI_Agent* sender +) +{ + CALL_IMPL(MessageSetSender, msg, sender); +} + +boolean OCI_API OCI_MsgSetConsumers +( + OCI_Msg * msg, + OCI_Agent ** consumers, + unsigned int count +) +{ + CALL_IMPL(MessageSetConsumers, msg, consumers, count); +} + +const otext* OCI_API OCI_MsgGetCorrelation +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetCorrelation, msg); +} + +boolean OCI_API OCI_MsgSetCorrelation +( + OCI_Msg * msg, + const otext* correlation +) +{ + CALL_IMPL(MessageSetCorrelation, msg, correlation); +} + +const otext* OCI_API OCI_MsgGetExceptionQueue +( + OCI_Msg* msg +) +{ + CALL_IMPL(MessageGetExceptionQueue, msg); +} + +boolean OCI_API OCI_MsgSetExceptionQueue +( + OCI_Msg * msg, + const otext* queue +) +{ + CALL_IMPL(MessageSetExceptionQueue, msg, queue); +} + +/* --------------------------------------------------------------------------------------------- * + * mutex + * --------------------------------------------------------------------------------------------- */ + +OCI_Mutex* OCI_API OCI_MutexCreate +( + void +) +{ + CALL_IMPL(MutexCreate); +} + +boolean OCI_API OCI_MutexFree +( + OCI_Mutex* mutex +) +{ + CALL_IMPL(MutexFree, mutex); +} + +boolean OCI_API OCI_MutexAcquire +( + OCI_Mutex* mutex +) +{ + CALL_IMPL(MutexAcquire, mutex); +} + +boolean OCI_API OCI_MutexRelease +( + OCI_Mutex* mutex +) +{ + CALL_IMPL(MutexRelease, mutex); +} + +/* --------------------------------------------------------------------------------------------- * + * number + * --------------------------------------------------------------------------------------------- */ + +OCI_Number* OCI_API OCI_NumberCreate +( + OCI_Connection* con +) +{ + CALL_IMPL(NumberCreate, con); +} + +boolean OCI_API OCI_NumberFree +( + OCI_Number* number +) +{ + CALL_IMPL(NumberFree, number); +} + +OCI_Number** OCI_API OCI_NumberArrayCreate +( + OCI_Connection* con, + unsigned int nbelem +) +{ + CALL_IMPL(NumberCreateArray, con, nbelem); +} + +boolean OCI_API OCI_NumberArrayFree +( + OCI_Number** numbmers +) +{ + CALL_IMPL(NumberFreeArray, numbmers); +} + +boolean OCI_API OCI_NumberAssign +( + OCI_Number* number, + OCI_Number* number_src +) +{ + CALL_IMPL(NumberAssign, number, number_src); +} + +boolean OCI_API OCI_NumberToText +( + OCI_Number * number, + const otext* fmt, + int size, + otext * str +) +{ + CALL_IMPL(NumberToString, number, fmt, size, str); +} + +boolean OCI_API OCI_NumberFromText +( + OCI_Number * number, + const otext* str, + const otext* fmt +) +{ + CALL_IMPL(NumberFromString, number, str, fmt); +} + +unsigned char* OCI_API OCI_NumberGetContent +( + OCI_Number* number +) +{ + CALL_IMPL(NumberGetContent, number); +} + +boolean OCI_API OCI_NumberSetContent +( + OCI_Number * number, + unsigned char* content +) +{ + CALL_IMPL(NumberSetContent, number, content); +} + +boolean OCI_API OCI_NumberSetValue +( + OCI_Number * number, + unsigned int type, + void * value +) +{ + CALL_IMPL(NumberSetValue, number, type, value); +} + +boolean OCI_API OCI_NumberGetValue +( + OCI_Number * number, + unsigned int type, + void * value +) +{ + CALL_IMPL(NumberGetValue, number, type, value); +} + +boolean OCI_API OCI_NumberAdd +( + OCI_Number * number, + unsigned int type, + void * value +) +{ + CALL_IMPL(NumberAdd, number, type, value); +} + +boolean OCI_API OCI_NumberSub +( + OCI_Number * number, + unsigned int type, + void * value +) +{ + CALL_IMPL(NumberSub, number, type, value); +} + +boolean OCI_API OCI_NumberMultiply +( + OCI_Number * number, + unsigned int type, + void * value +) +{ + CALL_IMPL(NumberMultiply, number, type, value); +} + +boolean OCI_API OCI_NumberDivide +( + OCI_Number * number, + unsigned int type, + void * value +) +{ + CALL_IMPL(NumberDivide, number, type, value); +} + +int OCI_API OCI_NumberCompare +( + OCI_Number* number1, + OCI_Number* number2 +) +{ + CALL_IMPL(NumberCompare, number1, number2); +} + +/* --------------------------------------------------------------------------------------------- * + * object + * --------------------------------------------------------------------------------------------- */ + +OCI_Object* OCI_API OCI_ObjectCreate +( + OCI_Connection* con, + OCI_TypeInfo * typinf +) +{ + CALL_IMPL(ObjectCreate, con, typinf); +} + +boolean OCI_API OCI_ObjectFree +( + OCI_Object* obj +) +{ + CALL_IMPL(ObjectFree, obj); +} + +OCI_Object** OCI_API OCI_ObjectArrayCreate +( + OCI_Connection* con, + OCI_TypeInfo * typinf, + unsigned int nbelem +) +{ + CALL_IMPL(ObjectCreateArray, con,typinf, nbelem); +} + +boolean OCI_API OCI_ObjectArrayFree +( + OCI_Object** objs +) +{ + CALL_IMPL(ObjectFreeArray, objs); +} + +boolean OCI_API OCI_ObjectAssign +( + OCI_Object* obj, + OCI_Object* obj_src +) +{ + CALL_IMPL(ObjectAssign, obj, obj_src); +} + +unsigned int OCI_API OCI_ObjectGetType +( + OCI_Object* obj +) +{ + CALL_IMPL(ObjectGetType, obj); +} + +boolean OCI_API OCI_ObjectGetSelfRef +( + OCI_Object* obj, + OCI_Ref * ref +) +{ + CALL_IMPL(ObjectGetSelfRef, obj, ref); +} + +OCI_TypeInfo* OCI_API OCI_ObjectGetTypeInfo +( + OCI_Object* obj +) +{ + CALL_IMPL(ObjectGetTypeInfo, obj); +} + +boolean OCI_API OCI_ObjectGetBoolean +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetBoolean, obj, attr); +} + +OCI_Number* OCI_API OCI_ObjectGetNumber +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetNumber, obj, attr); +} + +short OCI_API OCI_ObjectGetShort +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetShort, obj, attr); +} + +unsigned short OCI_API OCI_ObjectGetUnsignedShort +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetUnsignedShort, obj, attr); +} + +int OCI_API OCI_ObjectGetInt +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetInt, obj, attr); +} + +unsigned int OCI_API OCI_ObjectGetUnsignedInt +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetUnsignedInt, obj, attr); +} + +big_int OCI_API OCI_ObjectGetBigInt +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetBigInt, obj, attr); +} + +big_uint OCI_API OCI_ObjectGetUnsignedBigInt +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetUnsignedBigInt, obj, attr); +} + +double OCI_API OCI_ObjectGetDouble +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetDouble, obj, attr); +} + +float OCI_API OCI_ObjectGetFloat +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetFloat, obj, attr); +} + +const otext* OCI_API OCI_ObjectGetString +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetString, obj, attr); +} + +int OCI_API OCI_ObjectGetRaw +( + OCI_Object * obj, + const otext* attr, + void * value, + unsigned int len +) +{ + CALL_IMPL(ObjectGetRaw, obj, attr, value, len); +} + +unsigned int OCI_API OCI_ObjectGetRawSize +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetRawSize, obj, attr); +} + +OCI_Date* OCI_API OCI_ObjectGetDate +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetDate, obj, attr); +} + +OCI_Timestamp* OCI_API OCI_ObjectGetTimestamp +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetTimestamp, obj, attr); +} + +OCI_Interval* OCI_API OCI_ObjectGetInterval +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetInterval, obj, attr); +} + +OCI_Coll* OCI_API OCI_ObjectGetColl +( + OCI_Object * obj, + const otext* attr) +{ + CALL_IMPL(ObjectGetColl, obj, attr); +} + +OCI_Ref* OCI_API OCI_ObjectGetRef +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetReference, obj, attr); +} + +OCI_Object* OCI_API OCI_ObjectGetObject +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetObject, obj, attr); +} + +OCI_Lob* OCI_API OCI_ObjectGetLob +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetLob, obj, attr); +} + +OCI_File* OCI_API OCI_ObjectGetFile +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectGetFile, obj, attr); +} + +boolean OCI_API OCI_ObjectSetBoolean +( + OCI_Object * obj, + const otext* attr, + boolean value +) +{ + CALL_IMPL(ObjectSetBoolean, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetNumber +( + OCI_Object * obj, + const otext* attr, + OCI_Number * value +) +{ + CALL_IMPL(ObjectSetNumber, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetShort +( + OCI_Object * obj, + const otext* attr, + short value +) +{ + CALL_IMPL(ObjectSetShort, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetUnsignedShort +( + OCI_Object * obj, + const otext * attr, + unsigned short value +) +{ + CALL_IMPL(ObjectSetUnsignedShort, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetInt +( + OCI_Object * obj, + const otext* attr, + int value +) +{ + CALL_IMPL(ObjectSetInt, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetUnsignedInt +( + OCI_Object * obj, + const otext* attr, + unsigned int value +) +{ + CALL_IMPL(ObjectSetUnsignedInt, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetBigInt +( + OCI_Object * obj, + const otext* attr, + big_int value +) +{ + CALL_IMPL(ObjectSetBigInt, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetUnsignedBigInt +( + OCI_Object * obj, + const otext* attr, + big_uint value +) +{ + CALL_IMPL(ObjectSetUnsignedBigInt, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetDouble +( + OCI_Object * obj, + const otext* attr, + double value +) +{ + CALL_IMPL(ObjectSetDouble, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetFloat +( + OCI_Object * obj, + const otext* attr, + float value +) +{ + CALL_IMPL(ObjectSetFloat, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetString +( + OCI_Object * obj, + const otext* attr, + const otext* value +) +{ + CALL_IMPL(ObjectSetString, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetRaw +( + OCI_Object * obj, + const otext* attr, + void * value, + unsigned int len +) +{ + CALL_IMPL(ObjectSetRaw, obj, attr, value, len); +} + +boolean OCI_API OCI_ObjectSetDate +( + OCI_Object * obj, + const otext* attr, + OCI_Date * value +) +{ + CALL_IMPL(ObjectSetDate, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetTimestamp +( + OCI_Object * obj, + const otext * attr, + OCI_Timestamp* value +) +{ + CALL_IMPL(ObjectSetTimestamp, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetInterval +( + OCI_Object * obj, + const otext * attr, + OCI_Interval* value +) +{ + CALL_IMPL(ObjectSetInterval, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetColl +( + OCI_Object * obj, + const otext* attr, + OCI_Coll * value +) +{ + CALL_IMPL(ObjectSetColl, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetObject +( + OCI_Object * obj, + const otext* attr, + OCI_Object * value +) +{ + CALL_IMPL(ObjectSetObject, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetLob +( + OCI_Object * obj, + const otext* attr, + OCI_Lob * value +) +{ + CALL_IMPL(ObjectSetLob, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetFile +( + OCI_Object * obj, + const otext* attr, + OCI_File * value +) +{ + CALL_IMPL(ObjectSetFile, obj, attr, value); +} + +boolean OCI_API OCI_ObjectSetRef +( + OCI_Object * obj, + const otext* attr, + OCI_Ref * value +) +{ + CALL_IMPL(ObjectSetReference, obj, attr, value); +} + +boolean OCI_API OCI_ObjectIsNull +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectIsNull, obj, attr); +} + +boolean OCI_API OCI_ObjectSetNull +( + OCI_Object * obj, + const otext* attr +) +{ + CALL_IMPL(ObjectSetNull, obj, attr); +} + +boolean OCI_API OCI_ObjectGetStruct +( + OCI_Object* obj, + void ** pp_struct, + void ** pp_ind +) +{ + CALL_IMPL(ObjectGetStruct, obj, pp_struct, pp_ind); +} + +boolean OCI_API OCI_ObjectToText +( + OCI_Object * obj, + unsigned int* size, + otext * str +) +{ + CALL_IMPL(ObjectToString, obj, size, str); +} + +/* --------------------------------------------------------------------------------------------- * + * pool + * --------------------------------------------------------------------------------------------- */ + +OCI_Pool* OCI_API OCI_PoolCreate +( + const otext* db, + const otext* user, + const otext* pwd, + unsigned int type, + unsigned int mode, + unsigned int min_con, + unsigned int max_con, + unsigned int incr_con +) +{ + CALL_IMPL(PoolCreate, db, user, pwd, type, mode, min_con, max_con, incr_con); +} + +boolean OCI_API OCI_PoolFree +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolFree, pool); +} + +OCI_Connection* OCI_API OCI_PoolGetConnection +( + OCI_Pool * pool, + const otext* tag +) +{ + CALL_IMPL(PoolGetConnection, pool, tag); +} + +unsigned int OCI_API OCI_PoolGetTimeout +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetTimeout, pool); +} + +boolean OCI_API OCI_PoolSetTimeout +( + OCI_Pool * pool, + unsigned int value +) +{ + CALL_IMPL(PoolSetTimeout, pool, value); +} + +boolean OCI_API OCI_PoolGetNoWait +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetNoWait, pool); +} + +boolean OCI_API OCI_PoolSetNoWait +( + OCI_Pool* pool, + boolean value +) +{ + CALL_IMPL(PoolSetNoWait, pool, value); +} + +unsigned int OCI_API OCI_PoolGetBusyCount +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetBusyCount, pool); +} + +unsigned int OCI_API OCI_PoolGetOpenedCount +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetOpenedCount, pool); +} + +unsigned int OCI_API OCI_PoolGetMin +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetMin, pool); +} + +unsigned int OCI_API OCI_PoolGetMax +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetMax, pool); +} + +unsigned int OCI_API OCI_PoolGetIncrement +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetIncrement, pool); +} + +unsigned int OCI_API OCI_PoolGetStatementCacheSize +( + OCI_Pool* pool +) +{ + CALL_IMPL(PoolGetStatementCacheSize, pool); +} + +boolean OCI_API OCI_PoolSetStatementCacheSize +( + OCI_Pool * pool, + unsigned int value +) +{ + CALL_IMPL(PoolSetStatementCacheSize, pool, value); +} + +/* --------------------------------------------------------------------------------------------- * + * queue + * --------------------------------------------------------------------------------------------- */ + +boolean OCI_API OCI_QueueCreate +( + OCI_Connection* con, + const otext * queue_name, + const otext * queue_table, + unsigned int queue_type, + unsigned int max_retries, + unsigned int retry_delay, + unsigned int retention_time, + boolean dependency_tracking, + const otext * comment +) +{ + CALL_IMPL(QueueCreate, con, queue_name, queue_table, queue_type, max_retries, + retry_delay, retention_time, dependency_tracking, comment); +} + +boolean OCI_API OCI_QueueAlter +( + OCI_Connection* con, + const otext * queue_name, + unsigned int max_retries, + unsigned int retry_delay, + unsigned int retention_time, + const otext * comment +) +{ + CALL_IMPL(QueueAlter, con, queue_name, max_retries, retry_delay, retention_time, comment); +} + +boolean OCI_API OCI_QueueDrop +( + OCI_Connection* con, + const otext * queue_name +) +{ + CALL_IMPL(QueueDrop, con, queue_name); +} + +boolean OCI_API OCI_QueueStart +( + OCI_Connection* con, + const otext * queue_name, + boolean enqueue, + boolean dequeue +) +{ + CALL_IMPL(QueueStart, con, queue_name, enqueue, dequeue); +} + +boolean OCI_API OCI_QueueStop +( + OCI_Connection* con, + const otext * queue_name, + boolean enqueue, + boolean dequeue, + boolean wait +) +{ + CALL_IMPL(QueueStop, con, queue_name, enqueue, dequeue, wait); +} + +boolean OCI_API OCI_QueueTableCreate +( + OCI_Connection* con, + const otext * queue_table, + const otext * queue_payload_type, + const otext * storage_clause, + const otext * sort_list, + boolean multiple_consumers, + unsigned int message_grouping, + const otext * comment, + unsigned int primary_instance, + unsigned int secondary_instance, + const otext * compatible +) +{ + CALL_IMPL(QueueTableCreate, con, queue_table, queue_payload_type, storage_clause, + sort_list, multiple_consumers, message_grouping, comment, primary_instance, + secondary_instance, compatible); +} + +boolean OCI_API OCI_QueueTableAlter +( + OCI_Connection* con, + const otext * queue_table, + const otext * comment, + unsigned int primary_instance, + unsigned int secondary_instance +) +{ + CALL_IMPL(QueueTableAlter, con, queue_table, comment, primary_instance, secondary_instance); +} + +boolean OCI_API OCI_QueueTableDrop +( + OCI_Connection* con, + const otext * queue_table, + boolean force +) +{ + CALL_IMPL(QueueTableDrop, con, queue_table, force); +} + +boolean OCI_API OCI_QueueTablePurge +( + OCI_Connection* con, + const otext * queue_table, + const otext * purge_condition, + boolean block, + unsigned int delivery_mode +) +{ + CALL_IMPL(QueueTablePurge, con, queue_table, purge_condition, block, delivery_mode); +} + +boolean OCI_API OCI_QueueTableMigrate +( + OCI_Connection* con, + const otext * queue_table, + const otext * compatible +) +{ + CALL_IMPL(QueueTableMigrate, con, queue_table, compatible); +} + +/* --------------------------------------------------------------------------------------------- * + * ref + * --------------------------------------------------------------------------------------------- */ + +OCI_Ref* OCI_API OCI_RefCreate +( + OCI_Connection* con, + OCI_TypeInfo * typinf +) +{ + CALL_IMPL(ReferenceCreate, con, typinf); +} + +boolean OCI_API OCI_RefFree +( + OCI_Ref* ref +) +{ + CALL_IMPL(ReferenceFree, ref); +} + +OCI_Ref** OCI_API OCI_RefArrayCreate +( + OCI_Connection* con, + OCI_TypeInfo * typinf, + unsigned int nbelem +) +{ + CALL_IMPL(ReferenceCreateArray, con, typinf, nbelem); +} + +boolean OCI_API OCI_RefArrayFree +( + OCI_Ref** refs +) +{ + CALL_IMPL(ReferenceFreeArray, refs); +} + +boolean OCI_API OCI_RefAssign +( + OCI_Ref* ref, + OCI_Ref* ref_src +) +{ + CALL_IMPL(ReferenceAssign, ref, ref_src); +} + +OCI_TypeInfo* OCI_API OCI_RefGetTypeInfo +( + OCI_Ref* ref +) +{ + CALL_IMPL(ReferenceGetTypeInfo, ref); +} + +OCI_Object* OCI_API OCI_RefGetObject +( + OCI_Ref* ref +) +{ + CALL_IMPL(ReferenceGetObject, ref); +} + +boolean OCI_API OCI_RefIsNull +( + OCI_Ref* ref +) +{ + CALL_IMPL(ReferenceIsNull, ref); +} + +boolean OCI_API OCI_RefSetNull +( + OCI_Ref* ref +) +{ + CALL_IMPL(ReferenceSetNull, ref); +} + +unsigned int OCI_API OCI_RefGetHexSize +( + OCI_Ref* ref +) +{ + CALL_IMPL(ReferenceGetHexSize, ref); +} + +boolean OCI_API OCI_RefToText +( + OCI_Ref * ref, + unsigned int size, + otext * str +) +{ + CALL_IMPL(ReferenceToString, ref, size, str); +} + +/* --------------------------------------------------------------------------------------------- * + * resultset + * --------------------------------------------------------------------------------------------- */ + +OCI_Resultset* OCI_API OCI_GetResultset +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetResultset, stmt); +} + +OCI_Resultset* OCI_API OCI_GetNextResultset +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetNextResultset, stmt); +} + +boolean OCI_API OCI_FetchPrev +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetFetchPrev, rs); +} + +boolean OCI_API OCI_FetchNext +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetFetchNext, rs); +} + +boolean OCI_API OCI_FetchFirst +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetFetchFirst, rs); +} + +boolean OCI_API OCI_FetchLast +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetFetchLast, rs); +} + +boolean OCI_API OCI_FetchSeek +( + OCI_Resultset* rs, + unsigned int mode, + int offset +) +{ + CALL_IMPL(ResultsetFetchSeek, rs, mode, offset); +} + +unsigned int OCI_API OCI_GetRowCount +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetGetRowCount, rs); +} + +unsigned int OCI_API OCI_GetCurrentRow +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetGetCurrentRow, rs); +} + +unsigned int OCI_API OCI_GetColumnCount +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetGetColumnCount, rs); +} + +OCI_Column* OCI_API OCI_GetColumn +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetColumn, rs, index); +} + +OCI_Column* OCI_API OCI_GetColumn2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetColumn2, rs, name); +} + +unsigned int OCI_API OCI_GetColumnIndex +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetColumnIndex, rs, name); +} + +boolean OCI_API OCI_SetStructNumericType +( + OCI_Resultset* rs, + unsigned int index, + unsigned int type +) +{ + CALL_IMPL(ResultsetSetStructNumericType, rs, index, type); +} + +boolean OCI_API OCI_SetStructNumericType2 +( + OCI_Resultset* rs, + const otext * name, + unsigned int type +) +{ + CALL_IMPL(ResultsetSetStructNumericType2, rs, name, type); +} + +boolean OCI_API OCI_GetStruct +( + OCI_Resultset* rs, + void * row_struct, + void * row_struct_ind +) +{ + CALL_IMPL(ResultsetGetStruct, rs, row_struct, row_struct_ind); +} + +OCI_Number* OCI_API OCI_GetNumber +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetNumber, rs, index); +} + +OCI_Number* OCI_API OCI_GetNumber2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetNumber2, rs, name); +} + +short OCI_API OCI_GetShort +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetShort, rs, index); +} + +short OCI_API OCI_GetShort2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetShort2, rs, name); +} + +unsigned short OCI_API OCI_GetUnsignedShort +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetUnsignedShort, rs, index); +} + +unsigned short OCI_API OCI_GetUnsignedShort2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetUnsignedShort2, rs, name); +} + +int OCI_API OCI_GetInt +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetInt, rs, index); +} + +int OCI_API OCI_GetInt2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetInt2, rs, name); +} + +unsigned int OCI_API OCI_GetUnsignedInt +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetUnsignedInt, rs, index); +} + +unsigned int OCI_API OCI_GetUnsignedInt2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetUnsignedInt2, rs, name); +} + +big_int OCI_API OCI_GetBigInt +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetBigInt, rs, index); +} + +big_int OCI_API OCI_GetBigInt2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetBigInt2, rs, name); +} + +big_uint OCI_API OCI_GetUnsignedBigInt +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetUnsignedBigInt, rs, index); +} + +big_uint OCI_API OCI_GetUnsignedBigInt2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetUnsignedBigInt2, rs, name); +} + +const otext* OCI_API OCI_GetString +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetString, rs, index); +} + +const otext* OCI_API OCI_GetString2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetString2, rs, name); +} + +unsigned int OCI_API OCI_GetRaw +( + OCI_Resultset* rs, + unsigned int index, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(ResultsetGetRaw, rs, index, buffer,len); +} + +unsigned int OCI_API OCI_GetRaw2 +( + OCI_Resultset* rs, + const otext * name, + void * buffer, + unsigned int len +) +{ + CALL_IMPL(ResultsetGetRaw2, rs, name, buffer, len); +} + +double OCI_API OCI_GetDouble +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetDouble, rs, index); +} + +double OCI_API OCI_GetDouble2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetDouble2, rs, name); +} + +float OCI_API OCI_GetFloat +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetFloat, rs, index); +} + +float OCI_API OCI_GetFloat2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetFloat2, rs, name); +} + +OCI_Date* OCI_API OCI_GetDate +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetDate, rs, index); +} + +OCI_Date* OCI_API OCI_GetDate2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetDate2, rs, name); +} + +OCI_Timestamp* OCI_API OCI_GetTimestamp +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetTimestamp, rs, index); +} + +OCI_Timestamp* OCI_API OCI_GetTimestamp2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetTimestamp2, rs, name); +} + +OCI_Interval* OCI_API OCI_GetInterval +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetInterval, rs, index); +} + +OCI_Interval* OCI_API OCI_GetInterval2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetInterval2, rs, name); +} + +OCI_Object* OCI_API OCI_GetObject +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetObject, rs, index); +} + +OCI_Object* OCI_API OCI_GetObject2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetObject2, rs, name); +} + +OCI_Coll* OCI_API OCI_GetColl +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetColl, rs, index); +} + +OCI_Coll* OCI_API OCI_GetColl2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetColl2, rs, name); +} + +OCI_Ref* OCI_API OCI_GetRef +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetReference, rs, index); +} + +OCI_Ref* OCI_API OCI_GetRef2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetReference2, rs, name); +} + +OCI_Statement* OCI_API OCI_GetStatement +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetStatement, rs, index); +} + +OCI_Statement* OCI_API OCI_GetStatement2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetStatement2, rs, name); +} + +OCI_Lob* OCI_API OCI_GetLob +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetLob, rs, index); +} + +OCI_Lob* OCI_API OCI_GetLob2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetLob2, rs, name); +} + +OCI_File* OCI_API OCI_GetFile +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetFile, rs, index); +} + +OCI_File* OCI_API OCI_GetFile2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetFile2, rs, name); +} + +OCI_Long* OCI_API OCI_GetLong +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetLong, rs, index); +} + +OCI_Long* OCI_API OCI_GetLong2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetLong2, rs, name); +} + +unsigned int OCI_API OCI_GetDataSize +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetDataSize, rs, index); +} + +unsigned int OCI_API OCI_GetDataSize2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetGetDataSize2, rs, name); +} + +boolean OCI_API OCI_IsNull +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetIsNull, rs, index); +} + +boolean OCI_API OCI_IsNull2 +( + OCI_Resultset* rs, + const otext * name +) +{ + CALL_IMPL(ResultsetIsNull2, rs, name); +} + +OCI_Statement* OCI_API OCI_ResultsetGetStatement +( + OCI_Resultset* rs +) +{ + CALL_IMPL(ResultsetResultsetGetStatement, rs); +} + +unsigned int OCI_API OCI_GetDataLength +( + OCI_Resultset* rs, + unsigned int index +) +{ + CALL_IMPL(ResultsetGetDataLength, rs, index); +} + +/* --------------------------------------------------------------------------------------------- * + * statement + * --------------------------------------------------------------------------------------------- */ + +OCI_Statement* OCI_API OCI_StatementCreate +( + OCI_Connection* con +) +{ + CALL_IMPL(StatementCreate, con); +} + +boolean OCI_API OCI_StatementFree +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementFree, stmt); +} + +boolean OCI_API OCI_ReleaseResultsets +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementReleaseResultsets, stmt); +} + +boolean OCI_API OCI_Prepare +( + OCI_Statement* stmt, + const otext * sql +) +{ + CALL_IMPL(StatementPrepare, stmt, sql); +} + +boolean OCI_API OCI_Execute +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementExecute, stmt); +} + +boolean OCI_API OCI_ExecuteStmt +( + OCI_Statement* stmt, + const otext * sql +) +{ + CALL_IMPL(StatementExecuteStmt, stmt, sql); +} + +boolean OCI_API OCI_Parse +( + OCI_Statement* stmt, + const otext * sql +) +{ + CALL_IMPL(StatementParse, stmt, sql); +} + +boolean OCI_API OCI_Describe +( + OCI_Statement* stmt, + const otext * sql +) +{ + CALL_IMPL(StatementDescribe, stmt, sql); +} + +boolean OCI_PrepareFmt +( + OCI_Statement* stmt, + const otext * sql, + ... +) +{ + boolean res = FALSE; + va_list args; + + va_start(args, sql); + res = StatementPrepareFmt(stmt, sql, args); + va_end(args); + + return res; +} + +boolean OCI_ExecuteStmtFmt +( + OCI_Statement* stmt, + const otext * sql, + ... +) +{ + boolean res = FALSE; + va_list args; + + va_start(args, sql); + res = StatementExecuteStmtFmt(stmt, sql, args); + va_end(args); + + return res; +} + +boolean OCI_ParseFmt +( + OCI_Statement* stmt, + const otext * sql, + ... +) +{ + boolean res = FALSE; + va_list args; + + va_start(args, sql); + res = StatementParseFmt(stmt, sql, args); + va_end(args); + + return res; +} + +boolean OCI_DescribeFmt +( + OCI_Statement* stmt, + const otext * sql, + ... +) +{ + boolean res = FALSE; + va_list args; + + va_start(args, sql); + res = StatementDescribeFmt(stmt, sql, args); + va_end(args); + + return res; +} + +boolean OCI_API OCI_BindArraySetSize +( + OCI_Statement* stmt, + unsigned int size +) +{ + CALL_IMPL(StatementSetBindArraySize, stmt, size); +} + +unsigned int OCI_API OCI_BindArrayGetSize +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetBindArraySize, stmt); +} + +boolean OCI_API OCI_AllowRebinding +( + OCI_Statement* stmt, + boolean value +) +{ + CALL_IMPL(StatementAllowRebinding, stmt, value); +} + +boolean OCI_API OCI_IsRebindingAllowed +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementIsRebindingAllowed, stmt); +} + +boolean OCI_API OCI_BindBoolean +( + OCI_Statement* stmt, + const otext * name, + boolean * data +) +{ + CALL_IMPL(StatementBindBoolean, stmt, name, data); +} + +boolean OCI_API OCI_BindNumber +( + OCI_Statement* stmt, + const otext * name, + OCI_Number * data +) +{ + CALL_IMPL(StatementBindNumber, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfNumbers +( + OCI_Statement* stmt, + const otext * name, + OCI_Number ** data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfNumbers, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindShort +( + OCI_Statement* stmt, + const otext * name, + short * data +) +{ + CALL_IMPL(StatementBindShort, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfShorts +( + OCI_Statement* stmt, + const otext * name, + short * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfShorts, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindUnsignedShort +( + OCI_Statement * stmt, + const otext * name, + unsigned short* data +) +{ + CALL_IMPL(StatementBindUnsignedShort, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfUnsignedShorts +( + OCI_Statement * stmt, + const otext * name, + unsigned short* data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfUnsignedShorts, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindInt +( + OCI_Statement* stmt, + const otext * name, + int * data +) +{ + CALL_IMPL(StatementBindInt, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfInts +( + OCI_Statement* stmt, + const otext * name, + int * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfInts, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindUnsignedInt +( + OCI_Statement* stmt, + const otext * name, + unsigned int * data +) +{ + CALL_IMPL(StatementBindUnsignedInt, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfUnsignedInts +( + OCI_Statement* stmt, + const otext * name, + unsigned int * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfUnsignedInts, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindBigInt +( + OCI_Statement* stmt, + const otext * name, + big_int * data +) +{ + CALL_IMPL(StatementBindBigInt, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfBigInts +( + OCI_Statement* stmt, + const otext * name, + big_int * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfBigInts, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindUnsignedBigInt +( + OCI_Statement* stmt, + const otext * name, + big_uint * data +) +{ + CALL_IMPL(StatementBindUnsignedBigInt, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfUnsignedBigInts +( + OCI_Statement* stmt, + const otext * name, + big_uint * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfUnsignedBigInts, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindString +( + OCI_Statement* stmt, + const otext * name, + otext * data, + unsigned int len +) +{ + CALL_IMPL(StatementBindString, stmt, name, data, len); +} + +boolean OCI_API OCI_BindArrayOfStrings +( + OCI_Statement* stmt, + const otext * name, + otext * data, + unsigned int len, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfStrings, stmt, name, data, len, nbelem); +} + +boolean OCI_API OCI_BindRaw +( + OCI_Statement* stmt, + const otext * name, + void * data, + unsigned int len +) +{ + CALL_IMPL(StatementBindRaw, stmt, name, data, len); +} + +boolean OCI_API OCI_BindArrayOfRaws +( + OCI_Statement* stmt, + const otext * name, + void * data, + unsigned int len, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfRaws, stmt, name, data, len, nbelem); +} + +boolean OCI_API OCI_BindDouble +( + OCI_Statement* stmt, + const otext * name, + double * data +) +{ + CALL_IMPL(StatementBindDouble, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfDoubles +( + OCI_Statement* stmt, + const otext * name, + double * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfDoubles, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindFloat +( + OCI_Statement* stmt, + const otext * name, + float * data +) +{ + CALL_IMPL(StatementBindFloat, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfFloats +( + OCI_Statement* stmt, + const otext * name, + float * data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfFloats, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindDate +( + OCI_Statement* stmt, + const otext * name, + OCI_Date * data +) +{ + CALL_IMPL(StatementBindDate, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfDates +( + OCI_Statement* stmt, + const otext * name, + OCI_Date ** data, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfDates, stmt, name, data, nbelem); +} + +boolean OCI_API OCI_BindTimestamp +( + OCI_Statement* stmt, + const otext * name, + OCI_Timestamp* data +) +{ + CALL_IMPL(StatementBindTimestamp, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfTimestamps +( + OCI_Statement * stmt, + const otext * name, + OCI_Timestamp** data, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfTimestamps, stmt, name, data, type, nbelem); +} + +boolean OCI_API OCI_BindInterval +( + OCI_Statement* stmt, + const otext * name, + OCI_Interval * data +) +{ + CALL_IMPL(StatementBindInterval, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfIntervals +( + OCI_Statement* stmt, + const otext * name, + OCI_Interval** data, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfIntervals, stmt, name, data, type, nbelem); +} + +boolean OCI_API OCI_BindObject +( + OCI_Statement* stmt, + const otext * name, + OCI_Object * data +) +{ + CALL_IMPL(StatementBindObject, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfObjects +( + OCI_Statement* stmt, + const otext * name, + OCI_Object ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfObjects, stmt, name, data, typinf, nbelem); +} + +boolean OCI_API OCI_BindLob +( + OCI_Statement* stmt, + const otext * name, + OCI_Lob * data +) +{ + CALL_IMPL(StatementBindLob, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfLobs +( + OCI_Statement* stmt, + const otext * name, + OCI_Lob ** data, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfLobs, stmt, name, data, type, nbelem); +} + +boolean OCI_API OCI_BindFile +( + OCI_Statement* stmt, + const otext * name, + OCI_File * data +) +{ + CALL_IMPL(StatementBindFile, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfFiles +( + OCI_Statement* stmt, + const otext * name, + OCI_File ** data, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfFiles, stmt, name, data, type, nbelem); +} + +boolean OCI_API OCI_BindRef +( + OCI_Statement* stmt, + const otext * name, + OCI_Ref * data +) +{ + CALL_IMPL(StatementBindReference, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfRefs +( + OCI_Statement* stmt, + const otext * name, + OCI_Ref ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfReferences, stmt, name, data, typinf, nbelem); +} + +boolean OCI_API OCI_BindColl +( + OCI_Statement* stmt, + const otext * name, + OCI_Coll * data +) +{ + CALL_IMPL(StatementBindCollection, stmt, name, data); +} + +boolean OCI_API OCI_BindArrayOfColls +( + OCI_Statement* stmt, + const otext * name, + OCI_Coll ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +) +{ + CALL_IMPL(StatementBindArrayOfCollections, stmt, name, data, typinf, nbelem); +} + +boolean OCI_API OCI_BindStatement +( + OCI_Statement* stmt, + const otext * name, + OCI_Statement* data +) +{ + CALL_IMPL(StatementBindStatement, stmt, name, data); +} + +boolean OCI_API OCI_BindLong +( + OCI_Statement* stmt, + const otext * name, + OCI_Long * data, + unsigned int size +) +{ + CALL_IMPL(StatementBindLong, stmt, name, data, size); +} + +boolean OCI_API OCI_RegisterNumber +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterNumber, stmt, name); +} + +boolean OCI_API OCI_RegisterShort +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterShort, stmt, name); +} + +boolean OCI_API OCI_RegisterUnsignedShort +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterUnsignedShort, stmt, name); +} + +boolean OCI_API OCI_RegisterInt +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterInt, stmt, name); +} + +boolean OCI_API OCI_RegisterUnsignedInt +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterUnsignedInt, stmt, name); +} + +boolean OCI_API OCI_RegisterBigInt +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterBigInt, stmt, name); +} + +boolean OCI_API OCI_RegisterUnsignedBigInt +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterUnsignedBigInt, stmt, name); +} + +boolean OCI_API OCI_RegisterString +( + OCI_Statement* stmt, + const otext * name, + unsigned int len +) +{ + CALL_IMPL(StatementRegisterString, stmt, name, len); +} + +boolean OCI_API OCI_RegisterRaw +( + OCI_Statement* stmt, + const otext * name, + unsigned int len +) +{ + CALL_IMPL(StatementRegisterRaw, stmt, name, len); +} + +boolean OCI_API OCI_RegisterDouble +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterDouble, stmt, name); +} + +boolean OCI_API OCI_RegisterFloat +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterFloat, stmt, name); +} + +boolean OCI_API OCI_RegisterDate +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementRegisterDate, stmt, name); +} + +boolean OCI_API OCI_RegisterTimestamp +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +) +{ + CALL_IMPL(StatementRegisterTimestamp, stmt, name, type); +} + +boolean OCI_API OCI_RegisterInterval +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +) +{ + CALL_IMPL(StatementRegisterInterval, stmt, name, type); +} + +boolean OCI_API OCI_RegisterObject +( + OCI_Statement* stmt, + const otext * name, + OCI_TypeInfo * typinf +) +{ + CALL_IMPL(StatementRegisterObject, stmt, name, typinf); +} + +boolean OCI_API OCI_RegisterLob +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +) +{ + CALL_IMPL(StatementRegisterLob, stmt, name, type); +} + +boolean OCI_API OCI_RegisterFile +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +) +{ + CALL_IMPL(StatementRegisterFile, stmt, name, type); +} + +boolean OCI_API OCI_RegisterRef +( + OCI_Statement* stmt, + const otext * name, + OCI_TypeInfo * typinf +) +{ + CALL_IMPL(StatementRegisterReference, stmt, name, typinf); +} + +unsigned int OCI_API OCI_GetStatementType +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetStatementType, stmt); +} + +boolean OCI_API OCI_SetFetchMode +( + OCI_Statement* stmt, + unsigned int mode +) +{ + CALL_IMPL(StatementSetFetchMode, stmt, mode); +} + +unsigned int OCI_API OCI_GetFetchMode +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetFetchMode, stmt); +} + +boolean OCI_API OCI_SetBindMode +( + OCI_Statement* stmt, + unsigned int mode +) +{ + CALL_IMPL(StatementSetBindMode, stmt, mode); +} + +unsigned int OCI_API OCI_GetBindMode +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetBindMode, stmt); +} + +boolean OCI_API OCI_SetBindAllocation +( + OCI_Statement* stmt, + unsigned int mode +) +{ + CALL_IMPL(StatementSetBindAllocation, stmt, mode); +} + +unsigned int OCI_API OCI_GetBindAllocation +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetBindAllocation, stmt); +} + +boolean OCI_API OCI_SetFetchSize +( + OCI_Statement* stmt, + unsigned int size +) +{ + CALL_IMPL(StatementSetFetchSize, stmt, size); +} + +unsigned int OCI_API OCI_GetFetchSize +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetFetchSize, stmt); +} + +boolean OCI_API OCI_SetPrefetchSize +( + OCI_Statement* stmt, + unsigned int size +) +{ + CALL_IMPL(StatementSetPrefetchSize, stmt, size); +} + +unsigned int OCI_API OCI_GetPrefetchSize +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetPrefetchSize, stmt); +} + +boolean OCI_API OCI_SetPrefetchMemory +( + OCI_Statement* stmt, + unsigned int size +) +{ + CALL_IMPL(StatementSetPrefetchMemory, stmt, size); +} + +unsigned int OCI_API OCI_GetPrefetchMemory +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetPrefetchMemory, stmt); +} + +boolean OCI_API OCI_SetLongMaxSize +( + OCI_Statement* stmt, + unsigned int size +) +{ + CALL_IMPL(StatementSetLongMaxSize, stmt, size); +} + +unsigned int OCI_API OCI_GetLongMaxSize +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetLongMaxSize, stmt); +} + +boolean OCI_API OCI_SetLongMode +( + OCI_Statement* stmt, + unsigned int mode +) +{ + CALL_IMPL(StatementSetLongMode, stmt, mode); +} + +unsigned int OCI_API OCI_GetLongMode +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetLongMode, stmt); +} + +OCI_Connection* OCI_API OCI_StatementGetConnection +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetConnection, stmt); +} + +const otext* OCI_API OCI_GetSql +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetSql, stmt); +} + +const otext* OCI_API OCI_GetSqlIdentifier +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetSqlIdentifier, stmt); +} + +unsigned int OCI_API OCI_GetSqlErrorPos +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetSqlErrorPos, stmt); +} + +unsigned int OCI_API OCI_GetAffectedRows +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetAffectedRows, stmt); +} + +unsigned int OCI_API OCI_GetBindCount +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetBindCount, stmt); +} + +OCI_Bind* OCI_API OCI_GetBind +( + OCI_Statement* stmt, + unsigned int index +) +{ + CALL_IMPL(StatementGetBind, stmt, index); +} + +OCI_Bind* OCI_API OCI_GetBind2 +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementGetBind2, stmt, name); +} + +unsigned int OCI_API OCI_GetBindIndex +( + OCI_Statement* stmt, + const otext * name +) +{ + CALL_IMPL(StatementGetBindIndex, stmt, name); +} + +unsigned int OCI_API OCI_GetSQLCommand +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetSqlCommand, stmt); +} + +const otext* OCI_API OCI_GetSQLVerb +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetSqlVerb, stmt); +} + +OCI_Error* OCI_API OCI_GetBatchError +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetBatchError, stmt); +} + +unsigned int OCI_API OCI_GetBatchErrorCount +( + OCI_Statement* stmt +) +{ + CALL_IMPL(StatementGetBatchErrorCount, stmt); +} + +/* --------------------------------------------------------------------------------------------- * + * subscription + * --------------------------------------------------------------------------------------------- */ + +OCI_Subscription* OCI_API OCI_SubscriptionRegister +( + OCI_Connection* con, + const otext * name, + unsigned int type, + POCI_NOTIFY handler, + unsigned int port, + unsigned int timeout +) +{ + CALL_IMPL(SubscriptionRegister, con, name, type, handler, port, timeout); +} + +boolean OCI_API OCI_SubscriptionUnregister +( + OCI_Subscription* sub +) +{ + CALL_IMPL(SubscriptionUnregister, sub); +} + +boolean OCI_API OCI_SubscriptionAddStatement +( + OCI_Subscription* sub, + OCI_Statement * stmt +) +{ + CALL_IMPL(SubscriptionAddStatement, sub, stmt); +} + +const otext* OCI_API OCI_SubscriptionGetName +( + OCI_Subscription* sub +) +{ + CALL_IMPL(SubscriptionGetName, sub); +} + +unsigned int OCI_API OCI_SubscriptionGetPort +( + OCI_Subscription* sub +) +{ + CALL_IMPL(SubscriptionGetPort, sub); +} + +unsigned int OCI_API OCI_SubscriptionGetTimeout +( + OCI_Subscription* sub +) +{ + CALL_IMPL(SubscriptionGetTimeout, sub); +} + +OCI_Connection* OCI_API OCI_SubscriptionGetConnection +( + OCI_Subscription* sub +) +{ + CALL_IMPL(SubscriptionGetConnection, sub); +} + +/* --------------------------------------------------------------------------------------------- * + * timestamp + * --------------------------------------------------------------------------------------------- */ + +OCI_Timestamp* OCI_API OCI_TimestampCreate +( + OCI_Connection* con, + unsigned int type +) +{ + CALL_IMPL(TimestampCreate, con, type); +} + +boolean OCI_API OCI_TimestampFree +( + OCI_Timestamp* tmsp +) +{ + CALL_IMPL(TimestampFree, tmsp); +} + +OCI_Timestamp** OCI_API OCI_TimestampArrayCreate +( + OCI_Connection* con, + unsigned int type, + unsigned int nbelem +) +{ + CALL_IMPL(TimestampCreateArray, con, type, nbelem); +} + +boolean OCI_API OCI_TimestampArrayFree +( + OCI_Timestamp** tmsps +) +{ + CALL_IMPL(TimestampFreeArray, tmsps); +} + +unsigned int OCI_API OCI_TimestampGetType +( + OCI_Timestamp* tmsp +) +{ + CALL_IMPL(TimestampGetType, tmsp); +} + +boolean OCI_API OCI_TimestampAssign +( + OCI_Timestamp* tmsp, + OCI_Timestamp* tmsp_src +) +{ + CALL_IMPL(TimestampAssign, tmsp, tmsp_src); +} + +int OCI_API OCI_TimestampCheck +( + OCI_Timestamp* tmsp +) +{ + CALL_IMPL(TimestampCheck, tmsp); +} + +int OCI_API OCI_TimestampCompare +( + OCI_Timestamp* tmsp, + OCI_Timestamp* tmsp2 +) +{ + CALL_IMPL(TimestampCompare, tmsp, tmsp2); +} + +boolean OCI_API OCI_TimestampConstruct +( + OCI_Timestamp* tmsp, + int year, + int month, + int day, + int hour, + int min, + int sec, + int fsec, + const otext * time_zone +) +{ + CALL_IMPL(TimestampConstruct, tmsp, year, month, day, hour, min, sec,fsec, time_zone); +} + +boolean OCI_API OCI_TimestampConvert +( + OCI_Timestamp* tmsp, + OCI_Timestamp* tmsp_src +) +{ + CALL_IMPL(TimestampConvert, tmsp, tmsp_src); +} + +boolean OCI_API OCI_TimestampFromText +( + OCI_Timestamp* tmsp, + const otext * str, + const otext * fmt +) +{ + CALL_IMPL(TimestampFromString, tmsp, str, fmt); +} + +boolean OCI_API OCI_TimestampToText +( + OCI_Timestamp* tmsp, + const otext * fmt, + int size, + otext * str, + int precision +) +{ + CALL_IMPL(TimestampToString, tmsp, fmt, size, str, precision); +} + +boolean OCI_API OCI_TimestampGetDate +( + OCI_Timestamp* tmsp, + int * year, + int * month, + int * day +) +{ + CALL_IMPL(TimestampGetDate, tmsp, year, month, day); +} + +boolean OCI_API OCI_TimestampGetTime +( + OCI_Timestamp* tmsp, + int * hour, + int * min, + int * sec, + int * fsec +) +{ + CALL_IMPL(TimestampGetTime, tmsp, hour, min, sec, fsec); +} + +boolean OCI_API OCI_TimestampGetDateTime +( + OCI_Timestamp* tmsp, + int * year, + int * month, + int * day, + int * hour, + int * min, + int * sec, + int * fsec +) +{ + CALL_IMPL(TimestampGetDateTime, tmsp, year, month, day, hour, min, sec, fsec); +} + +boolean OCI_API OCI_TimestampGetTimeZoneName +( + OCI_Timestamp* tmsp, + int size, + otext * str +) +{ + CALL_IMPL(TimestampGetTimeZoneName, tmsp, size, str); +} + +boolean OCI_API OCI_TimestampGetTimeZoneOffset +( + OCI_Timestamp* tmsp, + int * hour, + int * min +) +{ + CALL_IMPL(TimestampGetTimeZoneOffset, tmsp, hour,min); +} + +boolean OCI_API OCI_TimestampIntervalAdd +( + OCI_Timestamp* tmsp, + OCI_Interval * itv +) +{ + CALL_IMPL(TimestampIntervalAdd, tmsp, itv); +} + +boolean OCI_API OCI_TimestampIntervalSub +( + OCI_Timestamp* tmsp, + OCI_Interval * itv +) +{ + CALL_IMPL(TimestampIntervalSub, tmsp, itv); +} + +boolean OCI_API OCI_TimestampSubtract +( + OCI_Timestamp* tmsp, + OCI_Timestamp* tmsp2, + OCI_Interval * itv +) +{ + CALL_IMPL(TimestampSubtract, tmsp, tmsp2, itv); +} + +boolean OCI_API OCI_TimestampSysTimestamp +( + OCI_Timestamp* tmsp +) +{ + CALL_IMPL(TimestampSysTimestamp, tmsp); +} + +boolean OCI_API OCI_TimestampToCTime +( + OCI_Timestamp* tmsp, + struct tm * ptm, + time_t * pt +) +{ + CALL_IMPL(TimestampToCTime, tmsp, ptm, pt); +} + +boolean OCI_API OCI_TimestampFromCTime +( + OCI_Timestamp* tmsp, + struct tm * ptm, + time_t t +) +{ + CALL_IMPL(TimestampFromCTime, tmsp, ptm, t); +} + +/* --------------------------------------------------------------------------------------------- * + * thread + * --------------------------------------------------------------------------------------------- */ + +OCI_Thread* OCI_API OCI_ThreadCreate +( + void +) +{ + CALL_IMPL(ThreadCreate); +} + +boolean OCI_API OCI_ThreadFree +( + OCI_Thread* thread +) +{ + CALL_IMPL(ThreadFree, thread); +} + +boolean OCI_API OCI_ThreadRun +( + OCI_Thread* thread, + POCI_THREAD proc, + void * arg +) +{ + CALL_IMPL(ThreadRun, thread, proc, arg); +} + +boolean OCI_API OCI_ThreadJoin +( + OCI_Thread* thread +) +{ + CALL_IMPL(ThreadJoin, thread); +} + +/* --------------------------------------------------------------------------------------------- * + * thread key + * --------------------------------------------------------------------------------------------- */ + +boolean OCI_API OCI_ThreadKeyCreate +( + const otext * name, + POCI_THREADKEYDEST destfunc +) +{ + CALL_IMPL(ThreadKeyCreate, name, destfunc); +} + +boolean OCI_API OCI_ThreadKeySetValue +( + const otext* name, + void * value +) +{ + CALL_IMPL(ThreadKeySetValue, name, value); +} + +void* OCI_API OCI_ThreadKeyGetValue +( + const otext* name +) +{ + CALL_IMPL(ThreadKeyGetValue, name); +} + +/* --------------------------------------------------------------------------------------------- * + * transaction + * --------------------------------------------------------------------------------------------- */ + +OCI_Transaction* OCI_API OCI_TransactionCreate +( + OCI_Connection* con, + unsigned int timeout, + unsigned int mode, + OCI_XID * pxid +) +{ + CALL_IMPL(TransactionCreate, con, timeout, mode, pxid); +} + +boolean OCI_API OCI_TransactionFree +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionFree, trans); +} + +boolean OCI_API OCI_TransactionStart +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionStart, trans); +} + +boolean OCI_API OCI_TransactionStop +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionStop, trans); +} + +boolean OCI_API OCI_TransactionResume +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionResume, trans); +} + +boolean OCI_API OCI_TransactionPrepare +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionPrepare, trans); +} + +boolean OCI_API OCI_TransactionForget +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionForget, trans); +} + +unsigned int OCI_API OCI_TransactionGetMode +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionGetMode, trans); +} + +unsigned int OCI_API OCI_TransactionGetTimeout +( + OCI_Transaction* trans +) +{ + CALL_IMPL(TransactionGetTimeout, trans); +} + +/* --------------------------------------------------------------------------------------------- * + * type info + * --------------------------------------------------------------------------------------------- */ + +OCI_TypeInfo* OCI_API OCI_TypeInfoGet +( + OCI_Connection* con, + const otext * name, + unsigned int type +) +{ + CALL_IMPL(TypeInfoGet, con, name, type); +} + +unsigned int OCI_API OCI_TypeInfoGetType +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoGetType, typinf); +} + +OCI_Connection* OCI_API OCI_TypeInfoGetConnection +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoGetConnection, typinf); +} + +boolean OCI_API OCI_TypeInfoFree +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoFree, typinf); +} + +unsigned int OCI_API OCI_TypeInfoGetColumnCount +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoGetColumnCount, typinf); +} + +OCI_Column* OCI_API OCI_TypeInfoGetColumn +( + OCI_TypeInfo* typinf, + unsigned int index +) +{ + CALL_IMPL(TypeInfoGetColumn, typinf, index); +} + +const otext* OCI_API OCI_TypeInfoGetName +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoGetName, typinf); +} + +boolean OCI_API OCI_TypeInfoIsFinalType +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoIsFinalType, typinf); +} + +OCI_TypeInfo* OCI_API OCI_TypeInfoGetSuperType +( + OCI_TypeInfo* typinf +) +{ + CALL_IMPL(TypeInfoGetSuperType, typinf); +} diff --git a/src/ocilib_checks.h b/src/ocilib_checks.h deleted file mode 100644 index 999afc65..00000000 --- a/src/ocilib_checks.h +++ /dev/null @@ -1,538 +0,0 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OCILIB_OCILIB_CHECKS_H_INCLUDED -#define OCILIB_OCILIB_CHECKS_H_INCLUDED - -/* ********************************************************************************************* * - MACROS FOR CHECKING OCI CALLS - * ********************************************************************************************* */ - -#define OCI_RETVAL call_retval -#define OCI_STATUS ((ctx)->call_status) - -#define OCI_EXEC(fct) \ - if (OCI_STATUS) \ - { \ - OCI_STATUS = fct; \ - if (OCI_FAILURE(OCI_STATUS)) \ - { \ - OCI_STATUS = (OCI_SUCCESS_WITH_INFO == OCI_STATUS); \ - OCI_ExceptionOCI(ctx->oci_err, ctx->lib_con, \ - ctx->lib_stmt, OCI_STATUS); \ - } \ - else \ - { \ - OCI_STATUS = TRUE; \ - } \ - } - - -#define OCI_GET_ATTRIB(htype, atype, handle, value, size) \ - \ - OCI_EXEC \ - ( \ - OCIAttrGet((void*) (handle), (ub4) (htype), (void*) (value), \ - (ub4*) (size), (ub4) (atype), (ctx)->oci_err) \ - ) \ - -#define OCI_SET_ATTRIB(htype, atype, handle, value, size) \ - \ - OCI_EXEC \ - ( \ - OCIAttrSet((void*) (handle), (ub4) (htype), (void*) (value), \ - (ub4) (size), (ub4) (atype), (ctx)->oci_err) \ - ) \ - - - -/* ********************************************************************************************* * - PARAMETER CHECKING MACROS - * ********************************************************************************************* */ - -/** - * @brief - * Internal general purpose expression checking - * - * @param exp - Expression - * @param ret - Return value if 'exp' is true - * - * @note - * Does not throw an exception. - * - */ - -#define OCI_CHECK(exp, ret) if (exp) return (ret); - -/** - * @brief - * Checks if a pointer passed to public function is NULL - * - * @param type - Pointer type - * @param ptr - Pointer - * - * @note - * Throws an exception if the pointer is null. - * - */ - -#define OCI_CALL_CHECK_PTR(type, ptr) \ - \ - if (!(ptr)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNullPointer(type)) \ - } - -/** - * @brief - * Checks if the parameters of a bind call are valid - * - * @param stmt - Statement handle - * @param name - Bind name/literal position - * @param data - Input pointer to bind - * @param type - Input pointer type - * @param ext_only - is it an external bind to check to input checking - * - * @note - * Throws an exception if one of the parameters is invalid and then returns - * FALSE. - * - */ - -#define OCI_CALL_CHECK_BIND(stmt, name, data, type, ext_only) \ - \ - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) \ - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) \ - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) \ - { \ - const boolean ext_only_value = (ext_only); \ - if ((ext_only_value) && \ - (OCI_BAM_INTERNAL == (stmt)->bind_alloc_mode) && \ - ((data) != NULL)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionExternalBindingNotAllowed(stmt, name)) \ - } \ - \ - if ((ext_only_value) || OCI_BAM_EXTERNAL == (stmt)->bind_alloc_mode) \ - { \ - OCI_CALL_CHECK_PTR(type, data) \ - } \ - } \ - -/** - * @brief - * Checks if the parameters of a register call are valid - * - * @param stmt - Statement handle - * @param name - Bind name/literal position - * - * @note - * Throws an exception if one of the parameters is invalid and returns FALSE. - * - */ -#define OCI_CALL_CHECK_REGISTER(stmt, name) \ - \ - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) \ - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) \ - -/* ********************************************************************************************* * - MISCELLANEOUS CHECKING MACROS - * ********************************************************************************************* */ - -/** - * @brief - * Checks if an integer parameter value fits into the given bounds - * - * @param con - Connection handle - * @param v - Integer value - * @param b1 - Lower bound - * @param b2 - Upper bound - * - * @note - * Throws an exception if the input value is out of bounds. - * - */ - -#define OCI_CALL_CHECK_BOUND(con, v, b1, b2) \ - \ - if (((v) < (b1)) || ((v) > (b2))) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionOutOfBounds((con), (v))) \ - } - -/** - * @brief - * Checks if an integer parameter value is >= minimum provided value - * - * @param con - Connection handle - * @param stmt - Statement handle - * @param v - Integer value - * @param m - Minimum value - * - * @note - * Throws an exception if the input value is < < m. - * - */ - -#define OCI_CALL_CHECK_MIN(con, stmt, v, m) \ - \ - if ((v) < (m)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionMinimumValue((con), (stmt), (m))) \ - } - -/** - * @brief - * Checks if two expressions are compatible - * - * @param con - Connection handle - * @param exp - Equality expression - * - * @note - * Throws an exception if the 2 expressions are not compatible. - * - */ - -#define OCI_CALL_CHECK_COMPAT(con, exp) \ - \ - if (!(exp)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionTypeNotCompatible((con))) \ - } - -/* ********************************************************************************************* * - INTERNAL STATES/ATTRIBUTES CHECKING MACROS - * ********************************************************************************************* */ - -/** - * @brief - * Checks if the input OCILIB object was fetched and not discartable - * - * @param obj - OCILIB object handle - * @param ret - Return value - * - * @note - * Returns the value 'ret' if the object was fetched from a sql statement - * - */ - -#define OCI_CALL_CHECK_OBJECT_FETCHED(obj) \ - \ - if (OCI_OBJECT_FETCHED_CLEAN == (obj)->hstate) \ - OCI_CALL_JUMP_EXIT() - - -/** - * @brief - * Checks if the status of a OCILIB statement matches the provided one - * - * @param st - Statement handle - * @param v - Status to compare - * - * @note - * Throws an exception if the status of the statement equals the provided one. - * - */ - -#define OCI_CALL_CHECK_STMT_STATUS(st, v) \ - \ - if ((((st)->status) & (v)) == 0) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionStatementState((st), v)) \ - } \ - - -/** - * @brief - * Checks if the given statement is scrollable - * - * @param st - Statement handle - * - * @note - * Throws an exception if the statement is not scrollable. - * - */ - -#define OCI_CALL_CHECK_SCROLLABLE_CURSOR_ACTIVATED(st) \ - \ - if (((st)->nb_rbinds > 0) || \ - ((st)->exec_mode != OCI_STMT_SCROLLABLE_READONLY)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionStatementNotScrollable(st)) \ - } - -/** - * @brief - * Checks if the status of a OCILIB direct path handle is compatible with the - * given one - * - * @param dp - Direct path handle - * @param v - Status to compare - * - * @note - * Throws an exception if the status of the direct path handle is different than - * the provided one. - * - */ -#define OCI_CALL_CHECK_DIRPATH_STATUS(dp, v) \ - \ - if ((dp)->status != (v)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionDirPathState((dp), (dp)->status)) \ - } - -/* ********************************************************************************************* * - INTERNAL FEATURES AVAILABILITY CHECKING MACROS - * ********************************************************************************************* */ - -/** - * @brief - * Checks the library has been initialized - * - * @note - * Returns 'ret' if the library has not been initialized - * - */ - -#define OCI_CALL_CHECK_INITIALIZED() \ - \ - if (!OCILib.loaded) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotInitialized()) \ - } - -/** - * @brief - * Internal check for various features - * - * @param con - Connection handle - * @param feat - Feature to check - * @param ver - OCI version that introduced the feature - * - * @note - * Throws an exception the given feature is not available - * - */ - -#define OCI_CALL_CHECK_FEATURE(con, feat, ver) \ - \ - if (OCILib.version_runtime < (ver) || ((con) && (con)->ver_num < (ver))) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable(con, feat)) \ - } - -/** - * @brief - * Checks if multithreading mode is activated - * - * @note - * Throws an exception the library has not been initialized with multithreading - * mode - * - */ - -#define OCI_CALL_CHECK_THREAD_ENABLED() \ - \ - if (!(OCI_LIB_THREADED)) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotMultithreaded()) \ - } - -/** - * @brief - * Checks if the timestamp datatype is supported by the connection - * - * @param con - Connection handle - * - * @note - * Throws an exception if the connection (client and server versions) does not - * support timestamps - * - */ - -#define OCI_CALL_CHECK_TIMESTAMP_ENABLED(con) \ - \ - OCI_CALL_CHECK_FEATURE(con, OCI_FEATURE_TIMESTAMP, OCI_9_0) - -/** - * @brief - * Checks if the interval datatype is supported by the connection - * - * @param con - Connection handle - * - * @note - * Throws an exception if the connection (client and server versions) does not - * support intervals - * - */ - -#define OCI_CALL_CHECK_INTERVAL_ENABLED OCI_CALL_CHECK_TIMESTAMP_ENABLED - -/** - * @brief - * Checks if the connection supports scrollable cursors - * - * @param con - Connection handle - * - * @note - * Throws an exception if the connection (client and server versions) does not - * support scrollable cursors - * - */ - -#define OCI_CALL_CHECK_SCROLLABLE_CURSOR_ENABLED(con) \ - \ - OCI_CALL_CHECK_FEATURE(con, OCI_FEATURE_SCROLLABLE_CURSOR, OCI_9_0) - - -/** -* @brief -* Checks if the runtime OCI version supports PL SQL Boolean, Records and Index Tables -* -* @note -* Throws an exception if the connection (client and server versions) does not support it -* -*/ - -#define OCI_CALL_CHECK_EXTENDED_PLSQLTYPES_ENABLED(con) \ - \ - OCI_CALL_CHECK_FEATURE(con, OCI_FEATURE_EXTENDED_PLSQLTYPES, OCI_12_1) - -/** - * @brief - * Checks if the runtime OCI client supports statement caching - * - * @note - * Throws an exception if the OCI client does not - * support statement caching - * - */ - -#define OCI_CALL_CHECK_STATEMENT_CACHING_ENABLED() \ - \ - if (OCILib.version_runtime < OCI_9_2) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable((dp)->con, \ - OCI_FEATURE_STATEMENT_CACHING)) \ - } - -/** - * @brief - * Checks if the direct path date caching is available - * - * @param dp - Direct path handle - * - * @note - * Throws an exception if the Oracle client does not support date caching - * - */ - -#define OCI_CALL_CHECK_DIRPATH_DATE_CACHE_ENABLED(dp) \ - \ - if (OCILib.version_runtime < OCI_9_2) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable((dp)->con, \ - OCI_FEATURE_DIRPATH_DATE_CACHE) \ - } - -/** - * @brief - * Checks if the current OCI client supports remote database startup/shutdown - * - * @note - * Throws an exception if the Oracle client is < 10g R2 - * - */ - -#define OCI_CALL_CHECK_REMOTE_DBS_CONTROL_ENABLED() \ - \ - if (OCILib.version_runtime < OCI_10_2) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable(NULL, \ - OCI_FEATURE_REMOTE_DBS_CONTROL)) \ - } - -/** - * @brief - * Checks if the current OCI client supports database notifications - * - * @note - * Throws an exception if the Oracle client is < 10g R2 - * - */ - -#define OCI_CALL_CHECK_DATABASE_NOTIFY_ENABLED() \ - \ - if (OCILib.version_runtime < OCI_10_2) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable(NULL, \ - OCI_FEATURE_DATABASE_NOTIFY)) \ - } - -/** - * @brief - * Checks if the runtime OCI version supports Oracle high availability - * - * @note - * Throws an exception if the client version does not - * support Oracle high availability - * - */ - -#define OCI_CALL_CHECK_HIGH_AVAILABILITY_ENABLED() \ - \ - if (OCILib.version_runtime < OCI_10_2) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable(NULL, \ - OCI_FEATURE_HIGH_AVAILABILITY)) \ - } - -/** - * @brief - * Checks if the OCILIB runtime version supports Oracle XA - * - * @note - * Throws an exception if the OCILIB that not support XA connections - * - */ - -#define OCI_CALL_CHECK_XA_ENABLED(mode) \ - \ - if ( ((mode) & OCI_SESSION_XA) && (!OCILib.use_xa) ) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionNotAvailable(NULL, OCI_FEATURE_XA)) \ - } - -#define OCI_CALL_CHECK_ENUM_VALUE(con, stmt, mode, values, name) \ - { \ - size_t ii = 0, nn = sizeof(values) / sizeof((values)[0]); \ - for (; ii < nn; ii++) { if ((mode) == (values)[ii]) break; } \ - if (ii >= nn) \ - { \ - OCI_RAISE_EXCEPTION(OCI_ExceptionArgInvalidValue(con, stmt, \ - name, mode)) \ - } \ - } - - - -#endif /* OCILIB_OCILIB_CHECKS_H_INCLUDED */ - - diff --git a/src/ocilib_defs.h b/src/ocilib_defs.h deleted file mode 100644 index d357baca..00000000 --- a/src/ocilib_defs.h +++ /dev/null @@ -1,607 +0,0 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OCILIB_OCILIB_DEFS_H_INCLUDED -#define OCILIB_OCILIB_DEFS_H_INCLUDED - -#include "ocilib.h" -#include "oci_import.h" - -/* ********************************************************************************************* * - ORACLE VERSION DETECTION - * ********************************************************************************************* */ - -#ifdef OCI_IMPORT_RUNTIME - - /* for runtime loading, set compile time version to the highest minimum - version needed by OCILIB encapsulation of OCI */ - - #define OCI_VERSION_COMPILE OCI_18_3 - - /* set runtime version to unknown, it will be guessed from symbols loading */ - - #define OCI_VERSION_RUNTIME OCI_UNKNOWN - -#else - - #if defined(OCI_MAJOR_VERSION) - - #define OCI_VERSION_COMPILE OCI_VER_MAKE(OCI_MAJOR_VERSION, OCI_MINOR_VERSION, 0) - #if OCI_VERSION_COMPILE == OCI_VER_MAKE(18, 0, 0) /* Oracle headers not updated for Windows 18.3 release ! */ - #undef OCI_VERSION_COMPILE - #define OCI_VERSION_COMPILE OCI_18_3 - #endif - - #elif defined(OCI_FNCODE_SODAOPERKEYSSET) /* = OCI_18_3 */ - - #define OCI_VERSION_COMPILE OCI_18_3 - - #elif defined(OCI_FNCODE_SERVERRELEASE2) /* = OCI_18_1 */ - - #define OCI_VERSION_COMPILE OCI_18_1 - - #elif defined(OCI_FNCODE_LOBGETCHUNKSIZE) /* = OCI_12_2 */ - - #define OCI_VERSION_COMPILE OCI_12_2 - - #elif defined(OCI_FNCODE_BINDBYPOS2) /* = OCI_12_1 */ - - #define OCI_VERSION_COMPILE OCI_12_1 - - #elif defined(OCI_FNCODE_LOBGETCONTENTTYPE) /* = OCI_11_2 */ - - #define OCI_VERSION_COMPILE OCI_11_2 - - #elif defined(OCI_FNCODE_LOBGETOPT) /* = OCI_11_1 */ - - #define OCI_VERSION_COMPILE OCI_11_1 - - #elif defined(OCI_FNCODE_DBSHUTDOWN) /* = OCI_10_2 */ - - #define OCI_VERSION_COMPILE OCI_10_2 - - #elif defined(OCI_FNCODE_LOBREAD2) /* = OCI_10_1 */ - - #define OCI_VERSION_COMPILE OCI_10_1 - - #elif defined(OCI_FNCODE_STMTPREPARE2) /* = OCI_9_2 */ - - #define OCI_VERSION_COMPILE OCI_9_2 - - #elif defined(OCI_FNCODE_CPOOLCREATE) /* = OCI_9_0 */ - - #define OCI_VERSION_COMPILE OCI_9_0 - - #elif defined(OCIThreadHandle) /* = OCI_8_1 */ - - #define OCI_VERSION_COMPILE OCI_8_1 - - #elif defined(OCIEnv) /* = OCI_8_0 */ - - #define OCI_VERSION_COMPILE OCI_8_0 - - #else /* OCI_UNKNOWN */ - - #define OCI_VERSION_COMPILE OCI_UNKNOWN - - #endif - - #define OCI_VERSION_RUNTIME OCI_VERSION_COMPILE - -#endif - -/* tries to enable Oracle 10g support for lobs > 4Go with OCILobxxx2() calls */ - -#if defined(OCI_BIG_UINT_ENABLED) && defined(ORAXB8_DEFINED) - - #define OCI_LOB2_API_ENABLED - -#endif - -/* ********************************************************************************************* * - CHARSET AND STRING TYPES DETECTION - * ********************************************************************************************* */ - -/* otext is public character types for all string types - We need to handle as well an internal oracle string type because : - - - wchar_t is not the same type on all platforms (that is such a pain !), - - OCI, in Unicode mode, uses Fixed length UTF16 encoding (2 bytes) - - So, dbtext was added to represent internal oracle string type. - - The following checks find out the real types and size of dbtext -*/ - -#if defined (OCI_CHARSET_ANSI) - - typedef otext dbtext; - -#else - - typedef unsigned short dbtext; - -#endif - -/* ********************************************************************************************* * - INTERNAL CONSTANTS - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * Default environment mode - * --------------------------------------------------------------------------------------------- */ - -#ifdef OCI_CHARSET_WIDE - - #define OCI_ENV_MODE OCI_UTF16 - -#else - - #define OCI_ENV_MODE OCI_DEFAULT - -#endif - -/* --------------------------------------------------------------------------------------------- * - * Internal Pointer Codes - * --------------------------------------------------------------------------------------------- */ - -/* -- external C pointers ---- */ - -#define OCI_IPC_ORACLE (-1) -#define OCI_IPC_BOOLEAN 0 -#define OCI_IPC_VOID 1 -#define OCI_IPC_SHORT 2 -#define OCI_IPC_INT 3 -#define OCI_IPC_BIGINT 4 -#define OCI_IPC_DOUBLE 5 -#define OCI_IPC_FLOAT 6 -#define OCI_IPC_STRING 7 -#define OCI_IPC_PROC 8 - -/* -- external OCILIB handles - */ - -#define OCI_IPC_ERROR 9 -#define OCI_IPC_TYPE_INFO 10 -#define OCI_IPC_CONNECTION 11 -#define OCI_IPC_POOL 12 -#define OCI_IPC_TRANSACTION 13 -#define OCI_IPC_STATEMENT 14 -#define OCI_IPC_RESULTSET 15 -#define OCI_IPC_COLUMN 16 -#define OCI_IPC_DATE 17 -#define OCI_IPC_TIMESTAMP 18 -#define OCI_IPC_INTERVAL 19 -#define OCI_IPC_LOB 20 -#define OCI_IPC_FILE 21 -#define OCI_IPC_LONG 22 -#define OCI_IPC_OBJECT 23 -#define OCI_IPC_COLLECTION 24 -#define OCI_IPC_ITERATOR 25 -#define OCI_IPC_ELEMENT 26 -#define OCI_IPC_NUMBER 27 -#define OCI_IPC_HASHTABLE 28 -#define OCI_IPC_THREAD 29 -#define OCI_IPC_MUTEX 30 -#define OCI_IPC_BIND 31 -#define OCI_IPC_REF 32 -#define OCI_IPC_DIRPATH 33 -#define OCI_IPC_NOTIFY 34 -#define OCI_IPC_EVENT 35 -#define OCI_IPC_ARRAY 36 -#define OCI_IPC_MSG 37 -#define OCI_IPC_ENQUEUE 38 -#define OCI_IPC_DEQUEUE 39 -#define OCI_IPC_AGENT 40 - -/* ---- Internal pointers ----- */ - -#define OCI_IPC_LIST 41 -#define OCI_IPC_LIST_ITEM 42 -#define OCI_IPC_BIND_ARRAY 43 -#define OCI_IPC_DEFINE 44 -#define OCI_IPC_DEFINE_ARRAY 45 -#define OCI_IPC_HASHENTRY 46 -#define OCI_IPC_HASHENTRY_ARRAY 47 -#define OCI_IPC_HASHVALUE 48 -#define OCI_IPC_THREADKEY 49 -#define OCI_IPC_OCIDATE 50 -#define OCI_IPC_TM 51 -#define OCI_IPC_RESULTSET_ARRAY 52 -#define OCI_IPC_PLS_SIZE_ARRAY 53 -#define OCI_IPC_PLS_RCODE_ARRAY 54 -#define OCI_IPC_SERVER_OUPUT 55 -#define OCI_IPC_INDICATOR_ARRAY 56 -#define OCI_IPC_LEN_ARRAY 57 -#define OCI_IPC_BUFF_ARRAY 58 -#define OCI_IPC_LONG_BUFFER 59 -#define OCI_IPC_TRACE_INFO 60 -#define OCI_IPC_DP_COL_ARRAY 61 -#define OCI_IPC_BATCH_ERRORS 62 -#define OCI_IPC_STATEMENT_ARRAY 63 - -#define OCI_IPC_COUNT (OCI_IPC_STATEMENT_ARRAY + 2) - -/* --------------------------------------------------------------------------------------------- * - * Oracle conditional features - * --------------------------------------------------------------------------------------------- */ - -#define OCI_FEATURE_WIDE_USERDATA 1 -#define OCI_FEATURE_TIMESTAMP 2 -#define OCI_FEATURE_DIRPATH_DATE_CACHE 3 -#define OCI_FEATURE_STATEMENT_CACHING 4 -#define OCI_FEATURE_SCROLLABLE_CURSOR 5 -#define OCI_FEATURE_DATABASE_NOTIFY 6 -#define OCI_FEATURE_REMOTE_DBS_CONTROL 7 -#define OCI_FEATURE_HIGH_AVAILABILITY 8 -#define OCI_FEATURE_XA 9 -#define OCI_FEATURE_EXTENDED_PLSQLTYPES 10 - -#define OCI_FEATURE_COUNT OCI_FEATURE_EXTENDED_PLSQLTYPES - -/* --------------------------------------------------------------------------------------------- * - * handle types - * --------------------------------------------------------------------------------------------- */ - -#define OCI_HDLE_HANDLE 1 -#define OCI_HDLE_DESCRIPTOR 2 -#define OCI_HDLE_OBJECT 3 - -#define OCI_HDLE_COUNT OCI_HDLE_OBJECT - -/* --------------------------------------------------------------------------------------------- * - * statement status - * --------------------------------------------------------------------------------------------- */ - -#define OCI_STMT_CLOSED 1 -#define OCI_STMT_PARSED 2 -#define OCI_STMT_PREPARED 4 -#define OCI_STMT_DESCRIBED 8 -#define OCI_STMT_EXECUTED 16 - -#define OCI_STMT_STATES_COUNT 5 - -/* --------------------------------------------------------------------------------------------- * - * connection states - * --------------------------------------------------------------------------------------------- */ - -#define OCI_CONN_ALLOCATED 1 -#define OCI_CONN_ATTACHED 2 -#define OCI_CONN_LOGGED 3 - -/* --------------------------------------------------------------------------------------------- * - * objects status - * --------------------------------------------------------------------------------------------- */ - -#define OCI_OBJECT_ALLOCATED 1 -#define OCI_OBJECT_FETCHED_CLEAN 2 -#define OCI_OBJECT_FETCHED_DIRTY 3 -#define OCI_OBJECT_ALLOCATED_ARRAY 4 -#define OCI_OBJECT_ALLOCATED_BIND_STMT 5 - -/* --------------------------------------------------------------------------------------------- * - * bind type - * --------------------------------------------------------------------------------------------- */ - -#define OCI_BIND_INPUT 1 -#define OCI_BIND_OUTPUT 2 - -/* --------------------------------------------------------------------------------------------- * - * Type of schema describing - * --------------------------------------------------------------------------------------------- */ - -#define OCI_DESC_RESULTSET 1 -#define OCI_DESC_TABLE 2 -#define OCI_DESC_TYPE 3 -#define OCI_DESC_COLLECTION 4 - -/* --------------------------------------------------------------------------------------------- * - * Direct path object status - * --------------------------------------------------------------------------------------------- */ - -#define OCI_DPS_NOT_PREPARED 1 -#define OCI_DPS_PREPARED 2 -#define OCI_DPS_CONVERTED 3 -#define OCI_DPS_TERMINATED 4 - -#define OCI_DPS_COUNT OCI_DPS_TERMINATED - -/* --------------------------------------------------------------------------------------------- * - * internal statement fetch direction - * --------------------------------------------------------------------------------------------- */ - -#define OCI_SFD_NEXT 0x02 -#define OCI_SFD_FIRST 0x04 -#define OCI_SFD_LAST 0x08 -#define OCI_SFD_PREV 0x10 - -/* --------------------------------------------------------------------------------------------- * - * internal direct path column types - * --------------------------------------------------------------------------------------------- */ - -#define OCI_DDT_TEXT 1 -#define OCI_DDT_BINARY 2 -#define OCI_DDT_NUMBER 3 -#define OCI_DDT_OTHERS 4 - -/* --------------------------------------------------------------------------------------------- * - * output buffer server line size - * --------------------------------------------------------------------------------------------- */ - -#define OCI_OUPUT_LSIZE 255 -#define OCI_OUPUT_LSIZE_10G 32767 - -/* --------------------------------------------------------------------------------------------- * -* Undocumented OCI SQL TYPES -* --------------------------------------------------------------------------------------------- */ - -#define SQLT_UNDOCUMENTED_REC 245 -#define SQLT_UNDOCUMENTED_BIN_INTEGER 265 - -/* --------------------------------------------------------------------------------------------- * - * Unicode constants - * --------------------------------------------------------------------------------------------- */ - -/* OCI unicode flag */ - -#ifndef OCI_UTF16ID - - #define OCI_UTF16ID OCI_UCS2ID - -#endif - - -#define OCI_UTF8_BYTES_PER_CHAR 4 -#define OCI_SIZE_TMP_CVT 128 - -/* --------------------------------------------------------------------------------------------- * - * Local helper macros - * --------------------------------------------------------------------------------------------- */ - -/* check OCI status */ - -#define OCI_FAILURE(res) ((res) != OCI_SUCCESS) -#define OCI_SUCCESSFUL(res) ((res) == OCI_SUCCESS) - -/* memory management helpers */ - -#define OCI_FREE(ptr) { OCI_MemFree(ptr), (ptr) = NULL; } - -/* indicator and nullity handlers */ - -#define OCI_IND(exp) (sb2) ((exp) ? 0 : -1) - -#define OCI_NOT_USED(p) (p) = (p); - -/* miscellaneous */ - -#define OCI_NB_ARG_VERSION 3 - -#define OCI_LIB_THREADED (OCILib.env_mode & OCI_ENV_THREADED) - -#define OCI_CALL_DECLARE_CONTEXT(status) \ - \ - OCI_Context ctx_obj = { NULL, NULL, NULL, NULL, FALSE }; \ - OCI_Context* ctx = &ctx_obj; \ - ctx_obj.oci_err = OCILib.err; \ - ctx_obj.call_status = (status); \ - -#define OCI_CALL_DECLARE_VARIABLES(type, value, status) \ - \ - type call_retval = (type) (value); \ - OCI_CALL_DECLARE_CONTEXT(status); \ - -#define OCI_CALL_CONTEXT_ENTER(mode) \ - \ - if ((mode) & OCI_ENV_CONTEXT) \ - { \ - ctx->call_err = OCI_ErrorGet(FALSE, FALSE); \ - OCI_CallEnter(ctx); \ - } - -#define OCI_CALL_CONTEXT_EXIT(mode) \ - \ - if ((mode) & OCI_ENV_CONTEXT) \ - { \ - OCI_CallExit(ctx); \ - } - -#define OCI_CALL_ENTER(type, value) \ - \ - OCI_CALL_DECLARE_VARIABLES(type, value, TRUE) \ - OCI_CALL_CONTEXT_ENTER(OCILib.env_mode) \ - -#define OCI_CALL_EXIT() \ - \ - ExitCall: \ - OCI_CALL_CONTEXT_EXIT(OCILib.env_mode) \ - return call_retval; - -#define OCI_CALL_JUMP_EXIT() \ - \ - goto ExitCall; \ - -#define OCI_CALL_CONTEXT_SET(c, s, e) \ - ctx->lib_con = (c); \ - ctx->lib_stmt = (s); \ - ctx->oci_err = (e) ? (e) : OCILib.err; \ - -#define OCI_CALL_CONTEXT_SET_FROM_CONN(con) OCI_CALL_CONTEXT_SET((con), NULL, ((con) ? (con)->err : OCILib.err)) -#define OCI_CALL_CONTEXT_SET_FROM_OBJ(obj) OCI_CALL_CONTEXT_SET(((obj)->con), NULL, ((obj)->err)) -#define OCI_CALL_CONTEXT_SET_FROM_ERR(err) OCI_CALL_CONTEXT_SET(NULL, NULL, (err)) -#define OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) OCI_CALL_CONTEXT_SET(((stmt)->con), (stmt), ((stmt)->con->err)) - -#define OCI_RAISE_EXCEPTION(exp) \ - \ - exp; \ - OCI_STATUS = FALSE; \ - OCI_CALL_JUMP_EXIT() \ - -#define OCI_IS_PLSQL_STMT(type) \ - ((OCI_CST_BEGIN == (type)) || (OCI_CST_DECLARE == (type)) || (OCI_CST_CALL == (type))) - -#define OCI_IS_OCI_NUMBER(type, subtype) \ - (OCI_CDT_NUMERIC == (type) && OCI_NUM_NUMBER == (subtype)) - -#define OCI_IS_OCILIB_OBJECT(type, subtype) \ - ( (OCI_IS_OCI_NUMBER(type, subtype)) || \ - (OCI_CDT_TEXT != (type) && \ - OCI_CDT_RAW != (type) && \ - OCI_CDT_BOOLEAN != (type))) - -#define OCI_GET_PROP(type, value, obj_type, obj, prop, con, stmt, err) \ - \ - OCI_CALL_ENTER(type, value) \ - OCI_CALL_CHECK_PTR(obj_type, obj) \ - OCI_CALL_CONTEXT_SET((con),(stmt), (err)) \ - OCI_RETVAL = (type) ((obj)->prop); \ - OCI_CALL_EXIT() \ - -#define OCI_SET_PROP(type, obj_type, obj, prop, value, con, stmt, err) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_PTR(obj_type, obj) \ - OCI_CALL_CONTEXT_SET((con),(stmt), (err)) \ - (obj)->prop = (type) (value); \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() \ - -#define OCI_SET_PROP_ENUM(type, obj_type, obj, prop, value, enums, msg, con, stmt, err)\ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_PTR(obj_type, obj) \ - OCI_CALL_CONTEXT_SET((con),(stmt), (err)) \ - OCI_CALL_CHECK_ENUM_VALUE((con),(stmt), (value), (enums), (msg)) \ - (obj)->prop = (type) (value); \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() \ - -#define OCI_GET_LIB_PROP(type, value, prop) \ - \ - OCI_CALL_ENTER(type, value) \ - OCI_CALL_CHECK_INITIALIZED() \ - OCI_RETVAL = (type) (prop); \ - OCI_CALL_EXIT() \ - -#define OCI_SET_LIB_PROP(prop, value) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_INITIALIZED() \ - (prop) = (value); \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() \ - -#define OCI_ALLOCATE_BUFFER(type, ptr, size, count) \ - \ - if (OCI_STATUS && !(ptr)) \ - { \ - (ptr) = OCI_MemAlloc(type, size, (size_t) (count), TRUE); \ - \ - OCI_STATUS = (NULL != (ptr)); \ - } \ - -#define OCI_REALLOCATE_BUFFER(type, ptr, size, current, allocated, requested) \ - \ - if (OCI_STATUS) \ - { \ - if (!(ptr)) \ - { \ - (ptr) = OCI_MemAlloc(type, size, (size_t) (requested), TRUE); \ - if (ptr) (allocated) = (requested); \ - } \ - else if ((current) >= (allocated)) \ - { \ - (ptr) = OCI_MemRealloc(ptr, type, size, (size_t) (requested), TRUE);\ - if (ptr) (allocated) = (requested); \ - } \ - \ - OCI_STATUS = (NULL != (ptr)); \ - } \ - - -#define OCI_ALLOCATE_DATA(type, ptr, count) \ - \ - OCI_ALLOCATE_BUFFER(type, ptr, sizeof(*(ptr)), count) - -#define OCI_REALLOCATE_DATA(type, ptr, cur, alloc, inc) \ - \ - OCI_REALLOCATE_BUFFER(type, ptr, sizeof(*(ptr)), cur, alloc, inc) - -#define OCI_ARRAY_GET_AT(ptr, size, offset) (((ub1 *) (ptr)) + (size_t)((size)*i)) -#define OCI_ARRAY_SET_AT(ptr, type, offset, value) *(type*)(OCI_ARRAY_GET_AT(ptr, sizeof(type), i)) = (type) (value); - - -#define OCI_STRING_VALID(s) ((s) && ((s)[0])) - -#ifdef _WINDOWS - - #define OCI_CVT_CHAR 1 - -#else - - #define OCI_CVT_CHAR 0 - -#endif - -#define OCI_SQLCMD_COUNT 239 - -#define OCI_FMT_COUNT 6 - -#define OCI_ERR_MSG_SIZE 512 - -#define OCI_BIND_ARRAY_GROWTH_FACTOR 128 - -#define OCI_DEF_ALIGN sizeof(void *) - -#define ROUNDUP(amount, align) \ - \ - (((unsigned long)(amount)+((align)-1))&~((align)-1)) - -#define osizeof(s) (sizeof(s) / sizeof(otext)) - -#define ocharcount(l) ((l) / sizeof(otext)) -#define dbcharcount(l) ((l) / sizeof(dbtext)) - -#define OCI_ERR_AQ_LISTEN_TIMEOUT 25254 -#define OCI_ERR_AQ_DEQUEUE_TIMEOUT 25228 -#define OCI_ERR_SUB_BUG_OCI_UTF16 24915 - -#define OCI_DEFAUT_STMT_CACHE_SIZE 20 - -#define WCHAR_2_BYTES 0xFFFF -#define WCHAR_4_BYTES 0x7FFFFFFF - -#define SCALE_FLOAT (-127) - -#define OCI_VARS_COUNT 1 - -#define OCI_VARS_TRUE_VALUE "TRUE" - -#define OCI_VARS_WORKAROUND_UTF16_COLUMN_NAME 0 - -#ifndef min - #define min(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef max - #define max(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#endif /* OCILIB_OCILIB_DEFS_H_INCLUDED */ - diff --git a/src/ocilib_internal.h b/src/ocilib_internal.h deleted file mode 100644 index c8e98903..00000000 --- a/src/ocilib_internal.h +++ /dev/null @@ -1,1264 +0,0 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OCILIB_OCILIB_INTERNAL_H_INCLUDED -#define OCILIB_OCILIB_INTERNAL_H_INCLUDED - -#include "ocilib_types.h" -#include "ocilib_checks.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* ********************************************************************************************* * - PRIVATE FUNCTIONS PROTOTYPES - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * agent.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Agent * OCI_AgentInit -( - OCI_Connection *con, - OCI_Agent *agent, - OCIAQAgent *handle, - const otext *name, - const otext *address -); - -/* --------------------------------------------------------------------------------------------- * - * array.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_ArrayInit -( - OCI_Array *arr, - OCI_TypeInfo *typinf -); - -boolean OCI_ArrayCleanup -( - OCI_Array *arr -); - -OCI_Array * OCI_ArrayCreate -( - OCI_Connection *con, - unsigned int nb_elem, - unsigned int elem_type, - unsigned int elem_subtype, - unsigned int elem_size, - unsigned int struct_size, - unsigned int handle_type, - OCI_TypeInfo *typinf -); - -boolean OCI_ArrayClose -( - OCI_Array *arr -); - -boolean OCI_ArrayFreeFromHandles -( - void ** handles -); - -/* --------------------------------------------------------------------------------------------- * - * bind.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Bind* OCI_BindCreate -( - OCI_Context *ctx, - OCI_Statement *stmt, - void *data, - const otext *name, - unsigned int mode, - ub4 size, - ub1 type, - unsigned int code, - unsigned int subtype, - OCI_TypeInfo *typinf, - unsigned int nbelem -); - -boolean OCI_BindFree -( - OCI_Bind *bnd -); - -boolean OCI_BindAllocData -( - OCI_Bind *bnd -); - -/* --------------------------------------------------------------------------------------------- * - * callback.c - * --------------------------------------------------------------------------------------------- */ - -sb4 OCI_ProcInBind -( - dvoid *ictxp, - OCIBind *bindp, - ub4 iter, - ub4 index, - dvoid **bufpp, - ub4 *alenp, - ub1 *piecep, - dvoid **indp -); - -sb4 OCI_ProcOutBind -( - dvoid *octxp, - OCIBind *bindp, - ub4 iter, - ub4 index, - dvoid **bufpp, - ub4 **alenp, - ub1 *piecep, - void **indp, - ub2 **rcodep -); - -ub4 OCI_ProcNotifyChanges -( - void *ctx, - OCISubscription *subscrhp, - void *payload, - ub4 paylen, - void *desc, - ub4 mode -); - -ub4 OCI_ProcNotifyMessages -( - void *ctx, - OCISubscription *subscrhp, - void *payload, - ub4 paylen, - void *desc, - ub4 mode -); - -sb4 OCI_ProcFailOver -( - dvoid *svchp, - dvoid *envhp, - dvoid *fo_ctx, - ub4 fo_type, - ub4 fo_event -); - -void OCI_ProcHAEvent -( - dvoid *evtctx, - dvoid *eventptr -); - -/* --------------------------------------------------------------------------------------------- * - * collection.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Coll * OCI_CollInit -( - OCI_Connection *con, - OCI_Coll *Coll, - void *handle, - OCI_TypeInfo *typeinf -); - -/* --------------------------------------------------------------------------------------------- * - * column.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_ColumnMap -( - OCI_Column *col, - OCI_Statement *stmt -); - -boolean OCI_ColumnDescribe -( - OCI_Column *col, - OCI_Connection *con, - OCI_Statement *stmt, - void *handle, - int index, - int ptype -); - -boolean OCI_ColumnGetAttrInfo -( - OCI_Column *col, - unsigned int count, - unsigned int index, - size_t *p_size, - size_t *p_align -); - -/* --------------------------------------------------------------------------------------------- * - * connection.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Connection * OCI_ConnectionCreateInternal -( - OCI_Pool *pool, - const otext *db, - const otext *user, - const otext *pwd, - unsigned int mode, - const otext *tag -); - -boolean OCI_ConnectionClose -( - OCI_Connection *con -); - -unsigned int OCI_ConnectionGetMinSupportedVersion -( - OCI_Connection *con -); - -boolean OCI_ConnectionIsVersionSupported -( - OCI_Connection *con, - unsigned int version -); - -/* --------------------------------------------------------------------------------------------- * - * date.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Date * OCI_DateInit -( - OCI_Connection *con, - OCI_Date *date, - OCIDate *buffer, - boolean allocate, - boolean ansi -); - -/* --------------------------------------------------------------------------------------------- * - * define.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Define * OCI_GetDefine -( - OCI_Resultset *rs, - unsigned int index -); - -int OCI_GetDefineIndex -( - OCI_Resultset *rs, - const otext *name -); - -boolean OCI_DefineGetNumber -( - OCI_Resultset *rs, - unsigned int index, - void *value, - uword type -); - -boolean OCI_DefineAlloc -( - OCI_Define *def -); - -boolean OCI_DefineDef -( - OCI_Define *def, - ub4 position -); - -void * OCI_DefineGetData -( - OCI_Define *def -); - -boolean OCI_DefineIsDataNotNull -( - OCI_Define *def -); - -/* --------------------------------------------------------------------------------------------- * - * element.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Elem * OCI_ElemInit -( - OCI_Connection *con, - OCI_Elem *elem, - void *handle, - OCIInd *pind, - OCI_TypeInfo *typeinf -); - -boolean OCI_ElemSetNullIndicator -( - OCI_Elem *elem, - OCIInd value -); - -/* --------------------------------------------------------------------------------------------- * - * error.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Error * OCI_ErrorCreate -( - void -); - -void OCI_ErrorFree -( - OCI_Error *err -); - -void OCI_ErrorReset -( - OCI_Error *err -); - -OCI_Error * OCI_ErrorGet -( - boolean check, - boolean reset -); - -/* --------------------------------------------------------------------------------------------- * - * event.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_EventReset -( - OCI_Event *event -); - -/* --------------------------------------------------------------------------------------------- * - * exception.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Error * OCI_ExceptionGetError -( - void -); - -void OCI_ExceptionRaise -( - OCI_Error *err -); - -void OCI_ExceptionOCI -( - OCIError *p_err, - OCI_Connection *con, - OCI_Statement *stmt, - boolean warning -); - -void OCI_ExceptionMemory -( - int type, - size_t nb_bytes, - OCI_Connection *con, - OCI_Statement *stmt -); - -void OCI_ExceptionNotAvailable -( - OCI_Connection *con, - int feature -); - -void OCI_ExceptionNullPointer -( - int type -); - -void OCI_ExceptionDatatypeNotSupported -( - OCI_Connection *con, - OCI_Statement *stmt, - int code -); - -void OCI_ExceptionParsingToken -( - OCI_Connection *con, - OCI_Statement *stmt, - otext token -); - -void OCI_ExceptionMappingArgument -( - OCI_Connection *con, - OCI_Statement *stmt, - int arg -); - -void OCI_ExceptionNotInitialized -( - void -); - -void OCI_ExceptionLoadingSharedLib -( - void -); - -void OCI_ExceptionLoadingSymbols -( - void -); - -void OCI_ExceptionNotMultithreaded -( - void -); - -void OCI_ExceptionOutOfBounds -( - OCI_Connection *con, - int value -); - -void OCI_ExceptionUnfreedData -( - int type_elem, - int nb_elem -); - -void OCI_ExceptionMaxBind -( - OCI_Statement *stmt -); - -void OCI_ExceptionAttributeNotFound -( - OCI_Connection *con, - const otext *attr -); - -void OCI_ExceptionMinimumValue -( - OCI_Connection *con, - OCI_Statement *stmt, - int min -); - -void OCI_ExceptionTypeNotCompatible -( - OCI_Connection *con -); - -void OCI_ExceptionStatementState -( - OCI_Statement *stmt, - int state -); - -void OCI_ExceptionStatementNotScrollable -( - OCI_Statement *stmt -); - -void OCI_ExceptionBindAlreadyUsed -( - OCI_Statement *stmt, - const otext *bind -); - -void OCI_ExceptionBindArraySize -( - OCI_Statement *stmt, - unsigned int maxsize, - unsigned int cursize, - unsigned int newsize -); - -void OCI_ExceptionDirPathColNotFound -( - OCI_DirPath *dp, - const otext *column, - const otext *table -); - -void OCI_ExceptionDirPathState -( - OCI_DirPath *dp, - int state -); - -void OCI_ExceptionOCIEnvironment -( - void -); - -void OCI_ExceptionRebindBadDatatype -( - OCI_Statement *stmt, - const otext *bind -); - -void OCI_ExceptionTypeInfoWrongType -( - OCI_Connection *con, - const otext *name -); - -void OCI_ExceptionItemNotFound -( - OCI_Connection *con, - OCI_Statement *stmt, - const otext *name, - unsigned int type -); - -void OCI_ExceptionArgInvalidValue -( - OCI_Connection *con, - OCI_Statement *stmt, - const otext *name, - unsigned int value -); - -void OCI_ExceptionEnvFromXaString -( - const otext *value -); - -void OCI_ExceptionConnFromXaString -( - const otext *value -); - -void OCI_ExceptionExternalBindingNotAllowed -( - OCI_Statement *stmt, - const otext *bind -); - -/* --------------------------------------------------------------------------------------------- * - * file.c - * --------------------------------------------------------------------------------------------- */ - -OCI_File * OCI_FileInit -( - OCI_Connection *con, - OCI_File *file, - OCILobLocator *handle, - ub4 type -); - -boolean OCI_FileGetInfo -( - OCI_File *file -); - -/* --------------------------------------------------------------------------------------------- * - * format.c - * --------------------------------------------------------------------------------------------- */ - -int OCI_ParseSqlFmt -( - OCI_Statement *stmt, - otext *buffer, - const otext *format, - va_list *pargs -); - -/* --------------------------------------------------------------------------------------------- * - * hash.c - * --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_HashCompute -( - OCI_HashTable *table, - const otext *str -); - -boolean OCI_HashAdd -( - OCI_HashTable *table, - const otext *key, - OCI_Variant value, - unsigned int type -); - -/* --------------------------------------------------------------------------------------------- * - * interval.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Interval * OCI_IntervalInit -( - OCI_Connection *con, - OCI_Interval *itv, - OCIInterval *buffer, - ub4 type -); - -/* --------------------------------------------------------------------------------------------- * - * library.c - * --------------------------------------------------------------------------------------------- */ - -void OCI_CallEnter -( - OCI_Context *ctx -); - -void OCI_CallExit -( - OCI_Context *ctx -); - -boolean OCI_KeyMapFree -( - void -); - -unsigned int OCI_ExternalSubTypeToSQLType -( - unsigned int type, - unsigned int subtype -); - -unsigned int OCI_ExternalSubTypeToHandleType -( - unsigned int type, - unsigned int subtype -); - -boolean OCI_FreeObjectFromType -( - void *obj, - unsigned int type -); - -boolean OCI_GetStringAttribute -( - OCI_Connection *con, - void *handle, - unsigned int type, - unsigned int attr, - otext **str, - unsigned int *size -); - -boolean OCI_SetStringAttribute -( - OCI_Connection *con, - void *handle, - unsigned int type, - unsigned int attr, - otext **str, - const otext *value -); - -char * OCI_GetEnvironmentVariable -( - const char *name -); - - -/* --------------------------------------------------------------------------------------------- * - * list.c - * --------------------------------------------------------------------------------------------- */ - -OCI_List * OCI_ListCreate -( - int type -); - -boolean OCI_ListFree -( - OCI_List *list -); - -void * OCI_ListAppend -( - OCI_List *list, - int size -); - -boolean OCI_ListClear -( - OCI_List *list -); - -typedef void (*POCI_LIST_FOR_EACH)(void *data); - -boolean OCI_ListForEach -( - OCI_List *list, - POCI_LIST_FOR_EACH proc -); - -typedef void(*POCI_LIST_FOR_EACH_WITH_PARAM)(void *data, void *param); - -boolean OCI_ListForEachWithParam -( - OCI_List *list, - void *param, - POCI_LIST_FOR_EACH_WITH_PARAM proc -); - -boolean OCI_ListRemove -( - OCI_List *list, - void *data -); - -boolean OCI_ListExists -( - OCI_List *list, - void *data -); - -typedef boolean(*POCI_LIST_FIND)(void *data, void *param); - -void * OCI_ListFind -( - OCI_List *list, - POCI_LIST_FIND proc, - void *param -); - -/* --------------------------------------------------------------------------------------------- * - * lob.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Lob * OCI_LobInit -( - OCI_Connection *con, - OCI_Lob *lob, - OCILobLocator *handle, - ub4 type -); - -/* --------------------------------------------------------------------------------------------- * - * long.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Long * OCI_LongInit -( - OCI_Statement *stmt, - OCI_Long *lg, - OCI_Define *def, - unsigned int type -); - -/* --------------------------------------------------------------------------------------------- * - * memory.c - * --------------------------------------------------------------------------------------------- */ - -void * OCI_MemAlloc -( - int ptr_type, - size_t block_size, - size_t block_count, - boolean zero_fill -); - -void * OCI_MemRealloc -( - void * ptr_mem, - int ptr_type, - size_t block_size, - size_t block_count, - boolean zero_fill -); - -void OCI_MemFree -( - void * ptr_mem -); - -boolean OCI_HandleAlloc -( - CONST dvoid *parenth, - dvoid **hndlpp, - ub4 type -); - -boolean OCI_HandleFree -( - dvoid *hndlp, - ub4 type -); - -boolean OCI_DescriptorAlloc -( - CONST dvoid *parenth, - dvoid **descpp, - ub4 type -); - -boolean OCI_DescriptorArrayAlloc -( - CONST dvoid *parenth, - dvoid **descpp, - ub4 type, - ub4 nb_elem - ); - -boolean OCI_DescriptorFree -( - void *descp, - ub4 type -); - -boolean OCI_DescriptorArrayFree -( - void **descp, - ub4 type, - ub4 nb_elem -); - -sword OCI_ObjectNew -( - OCIEnv *env, - OCIError *err, - CONST OCISvcCtx *svc, - OCITypeCode typecode, - OCIType *tdo, - dvoid *table, - OCIDuration duration, - boolean value, - dvoid **instance -); - -sword OCI_OCIObjectFree -( - OCIEnv *env, - OCIError *err, - dvoid *instance, - ub2 flags -); - -void * OCI_MemAllocOracleClient -( - void *ctxp, - size_t size -); - -void * OCI_MemReallocOracleClient -( - void *ctxp, - void *memptr, - size_t newsize -); - -void OCI_MemFreeOracleClient -( - void *ctxp, - void *memptr -); - -void OCI_MemUpdateBytes -( - int type, - big_int size -); - -/* --------------------------------------------------------------------------------------------- * - * mutex.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Mutex * OCI_MutexCreateInternal -( - void -); - -/* --------------------------------------------------------------------------------------------- * - * number.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_TranslateNumericValue -( - OCI_Connection *con, - void *in_value, - uword in_type, - void *out_value, - uword out_type -); - -OCI_Number * OCI_NumberInit -( - OCI_Connection *con, - OCI_Number *number, - OCINumber *buffer -); - -boolean OCI_NumberFromString -( - OCI_Connection *con, - void *out_value, - uword type, - const otext *in_value, - const otext * fmt -); - -boolean OCI_NumberToString -( - OCI_Connection *con, - void *number, - unsigned int type, - otext *out_value, - int out_value_size, - const otext * fmt -); - -/* --------------------------------------------------------------------------------------------- * - * object.c - * --------------------------------------------------------------------------------------------- */ - -void OCI_ObjectGetUserStructSize -( - OCI_TypeInfo *typinf, - size_t *p_size, - size_t *p_align -); - -OCI_Object * OCI_ObjectInit -( - OCI_Connection *con, - OCI_Object *obj, - void *handle, - OCI_TypeInfo *typinf, - OCI_Object *parent, - int index, - boolean reset -); - -/* --------------------------------------------------------------------------------------------- * - * pool.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_PoolClose -( - OCI_Pool *pool -); - -/* --------------------------------------------------------------------------------------------- * - * ref.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Ref * OCI_RefInit -( - OCI_Connection *con, - OCI_TypeInfo *typeinf, - OCI_Ref *ref, - void *handle -); - -boolean OCI_RefPin -( - OCI_Ref *ref -); - -boolean OCI_RefUnpin -( - OCI_Ref *ref -); - -/* --------------------------------------------------------------------------------------------- * - * resultset.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Resultset * OCI_ResultsetCreate -( - OCI_Statement *stmt, - int size -); - -boolean OCI_ResultsetInit -( - OCI_Resultset *rs -); - -boolean OCI_ResultsetFree -( - OCI_Resultset *rs -); - -/* --------------------------------------------------------------------------------------------- * - * statement.c - * --------------------------------------------------------------------------------------------- */ - -int OCI_BindGetInternalIndex -( - OCI_Statement *stmt, - const otext *name -); - -boolean OCI_FetchIntoUserVariables -( - OCI_Statement *stmt, - va_list args -); - -boolean OCI_StatementClose -( - OCI_Statement *stmt -); - -OCI_Statement * OCI_StatementInit -( - OCI_Connection *con, - OCI_Statement *stmt, - OCIStmt *handle, - boolean is_desc, - const otext *sql -); - -boolean OCI_API OCI_PrepareInternal -( - OCI_Statement *stmt, - const otext *sql -); - -boolean OCI_API OCI_ExecuteInternal -( - OCI_Statement *stmt, - ub4 mode -); - -/* --------------------------------------------------------------------------------------------- * - * string.c - * --------------------------------------------------------------------------------------------- */ - -size_t OCI_StringLength -( - void const *ptr, - size_t size_elem -); - -unsigned int OCI_StringBinaryToString -( - const unsigned char *binary, - unsigned int binary_size, - otext *buffer -); - -boolean OCI_StringRequestBuffer -( - otext **buffer, - unsigned int *buffer_size, - unsigned int request_size -); - -void OCI_StringTranslate -( - void *src, - void *dst, - int len, - size_t size_char_in, - size_t size_char_out -); - -#define OCI_StringAnsiToNative(s, d, l) \ - OCI_StringTranslate( (void *) (s), (void *) (d), l, sizeof(char), sizeof(otext) ) - -#define OCI_StringNativeToAnsi(s, d, l) \ - OCI_StringTranslate( (void *) (s), (void *) (d), l, sizeof(otext), sizeof(char) ) - -#define OCI_StringUTF16ToUTF32(s, d, l) \ - OCI_StringTranslate( (void *) (s), (void *) (d), l, sizeof(short), sizeof(int) ) - -#define OCI_StringUTF32ToUTF16(s, d, l) \ - OCI_StringTranslate( (void *) (s), (void *) (d), l, sizeof(int), sizeof(short) ) - -#define OCI_StringOracleToNative(s, d, l) \ - OCI_StringTranslate( (void *) (s), (void *) (d), l, sizeof(dbtext), sizeof(otext) ) - -#define OCI_StringRawCopy(s, d, l) \ - OCI_StringTranslate( (void *) (s), (void *) (d), l, sizeof(otext), sizeof(otext) ) - -dbtext * OCI_StringGetOracleString -( - const otext *src, - int *len -); - -void OCI_StringReleaseOracleString -( - dbtext *str -); - -int OCI_StringCopyOracleStringToNativeString -( - const dbtext *src, - otext *dst, - int len -); - -otext * OCI_StringDuplicateFromOracleString -( - const dbtext *src, - int len -); - -otext * OCI_StringFromStringPtr -( - OCIEnv *env, - OCIString *str, - otext **buffer, - unsigned int *buffer_size -); - -boolean OCI_StringToStringPtr -( - OCIEnv *env, - OCIString **str, - OCIError *err, - const otext *value -); - -boolean OCI_StringFreeStringPtr -( - OCIEnv *env, - OCIString **str, - OCIError *err -); - -unsigned int OCI_StringGetFromType -( - OCI_Connection *con, - OCI_Column *col, - void *data, - unsigned int data_size, - otext *buffer, - unsigned int buffer_size, - boolean quote -); - -unsigned int OCI_StringAddToBuffer -( - otext *buffer, - unsigned int offset, - const otext *str, - unsigned int length, - boolean check_quote -); - -unsigned int OCI_StringGetTypeName -( - const otext *source, - otext *dest, - unsigned int length -); - -unsigned int OCI_StringGetFullTypeName -( - const otext *schema, - const otext *package, - const otext *type, - const otext *link, - otext *name, - unsigned int length -); - -/* --------------------------------------------------------------------------------------------- * - * subscription.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_SubscriptionClose -( - OCI_Subscription *sub -); - -/* --------------------------------------------------------------------------------------------- * - * thread.c - * --------------------------------------------------------------------------------------------- */ - -void OCI_ThreadProc -( - dvoid *arg -); - -/* --------------------------------------------------------------------------------------------- * - * threadkey.c - * --------------------------------------------------------------------------------------------- */ - -OCI_ThreadKey * OCI_ThreadKeyCreateInternal -( - POCI_THREADKEYDEST destfunc -); - -boolean OCI_ThreadKeyFree -( - OCI_ThreadKey *key -); - -boolean OCI_ThreadKeySet -( - OCI_ThreadKey *key, - void *value -); - -boolean OCI_ThreadKeyGet -( - OCI_ThreadKey* key, - void **value -); - -/* --------------------------------------------------------------------------------------------- * - * timestamp.c - * --------------------------------------------------------------------------------------------- */ - -OCI_Timestamp * OCI_TimestampInit -( - OCI_Connection *con, - OCI_Timestamp *tmsp, - OCIDateTime *buffer, - ub4 type -); - -/* --------------------------------------------------------------------------------------------- * - * transaction.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_TransactionClose -( - OCI_Transaction * trans -); - -/* --------------------------------------------------------------------------------------------- * - * typeinf.c - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_TypeInfoClose -( - OCI_TypeInfo *typeinf -); - -#ifdef __cplusplus -} -#endif - -#endif /* OCILIB_OCILIB_TYPES_H_INCLUDED */ - diff --git a/src/pool.c b/src/pool.c index 67f6aaa7..1b91d363 100644 --- a/src/pool.c +++ b/src/pool.c @@ -18,36 +18,36 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "pool.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "connection.h" +#include "list.h" +#include "macros.h" +#include "strings.h" -static unsigned int PoolTypeValues[] = { OCI_POOL_CONNECTION, OCI_POOL_SESSION }; - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static unsigned int PoolTypeValues[] = +{ + OCI_POOL_CONNECTION, OCI_POOL_SESSION +}; /* --------------------------------------------------------------------------------------------- * - * OCI_PoolClose + * PoolDispose * --------------------------------------------------------------------------------------------- */ -boolean OCI_PoolClose +boolean PoolDispose ( OCI_Pool *pool ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == pool, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_POOL, pool + ) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err); - - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0) + if (Env.version_runtime >= OCI_9_0) { /* close pool handle */ @@ -55,37 +55,49 @@ boolean OCI_PoolClose { if (OCI_HTYPE_CPOOL == pool->htype) { - OCI_EXEC(OCIConnectionPoolDestroy((OCICPool *) pool->handle, pool->err, (ub4) OCI_DEFAULT)) + CHECK_OCI + ( + pool->err, + OCIConnectionPoolDestroy, + (OCICPool *) pool->handle, + pool->err, (ub4) OCI_DEFAULT + ) } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { - OCI_EXEC(OCISessionPoolDestroy((OCISPool *) pool->handle, pool->err, (ub4) OCI_SPD_FORCE)) + CHECK_OCI + ( + pool->err, + OCISessionPoolDestroy, + (OCISPool*)pool->handle, + pool->err, (ub4)OCI_SPD_FORCE + ) } - #endif + #endif - OCI_HandleFree((void *) pool->handle, (ub4) pool->htype); + MemoryFreeHandle((void *) pool->handle, (ub4) pool->htype); } - #if OCI_VERSION_COMPILE >= OCI_11_2 + #if OCI_VERSION_COMPILE >= OCI_11_2 /* close authentication handle */ - if (pool->authp) + if (NULL != pool->authp) { - OCI_HandleFree((void *) pool->authp, OCI_HTYPE_AUTHINFO); + MemoryFreeHandle((void *) pool->authp, OCI_HTYPE_AUTHINFO); } - #endif + #endif /* close error handle */ - if (pool->err) + if (NULL != pool->err) { - OCI_HandleFree((void *) pool->err, OCI_HTYPE_ERROR); + MemoryFreeHandle((void *) pool->err, OCI_HTYPE_ERROR); } } @@ -97,23 +109,21 @@ boolean OCI_PoolClose /* free strings */ - OCI_FREE(pool->name) - OCI_FREE(pool->db) - OCI_FREE(pool->user) - OCI_FREE(pool->pwd) + FREE(pool->name) + FREE(pool->db) + FREE(pool->user) + FREE(pool->pwd) - return OCI_STATUS; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_PoolCreate + * PoolCreate * --------------------------------------------------------------------------------------------- */ -OCI_Pool * OCI_API OCI_PoolCreate +OCI_Pool * PoolCreate ( const otext *db, const otext *user, @@ -125,35 +135,47 @@ OCI_Pool * OCI_API OCI_PoolCreate unsigned int incr_con ) { - OCI_Pool *pool = NULL; - - OCI_CALL_ENTER(OCI_Pool*, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_ENUM_VALUE(NULL, NULL, type, PoolTypeValues, OTEXT("Pool Type")) - OCI_CALL_CHECK_MIN(NULL, NULL, max_con, 1) - - OCI_STATUS = FALSE; + ENTER_FUNC + ( + /* returns */ OCI_Pool*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + + dbtext *dbstr = NULL; + dbtext* dbstr_name = NULL; + dbtext* dbstr_db = NULL; + dbtext* dbstr_user = NULL; + dbtext* dbstr_pwd = NULL; + + int dbsize = -1; + int dbsize_name = -1; + int dbsize_db = -1; + int dbsize_user = -1; + int dbsize_pwd = -1; + + OCI_Pool* pool = NULL; + + CHECK_INITIALIZED() + CHECK_ENUM_VALUE( type, PoolTypeValues, OTEXT("Pool Type")) + CHECK_MIN(max_con, 1) /* make sure that we do not have a XA session flag */ - + mode &= ~OCI_SESSION_XA; - + /* create pool object */ - pool = OCI_ListAppend(OCILib.pools, sizeof(*pool)); - OCI_STATUS = (NULL != pool); + pool = ListAppend(Env.pools, sizeof(*pool)); + CHECK_NULL(pool) - if (OCI_STATUS) - { - pool->mode = mode; - pool->min = min_con; - pool->max = max_con; - pool->incr = incr_con; - - pool->db = ostrdup(db ? db : OTEXT("")); - pool->user = ostrdup(user ? user : OTEXT("")); - pool->pwd = ostrdup(pwd ? pwd : OTEXT("")); - } + pool->mode = mode; + pool->min = min_con; + pool->max = max_con; + pool->incr = incr_con; + + pool->db = ostrdup(db ? db : OTEXT("")); + pool->user = ostrdup(user ? user : OTEXT("")); + pool->pwd = ostrdup(pwd ? pwd : OTEXT("")); #if OCI_VERSION_COMPILE < OCI_9_2 @@ -163,147 +185,140 @@ OCI_Pool * OCI_API OCI_PoolCreate #if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCI_STATUS) + if (OCI_POOL_CONNECTION == type) { - if (OCI_POOL_CONNECTION == type) - { - pool->htype = OCI_HTYPE_CPOOL; - } - - #if OCI_VERSION_COMPILE >= OCI_9_2 - - else - { - pool->htype = OCI_HTYPE_SPOOL; - } - - #endif - + pool->htype = OCI_HTYPE_CPOOL; } - if (OCILib.version_runtime >= OCI_9_0) + #if OCI_VERSION_COMPILE >= OCI_9_2 + + else { - int dbsize_name = -1; - int dbsize_db = -1; + pool->htype = OCI_HTYPE_SPOOL; + } - dbtext *dbstr_name = NULL; - dbtext *dbstr_db = NULL; + #endif + if (Env.version_runtime >= OCI_9_0) + { /* allocate error handle */ - OCI_STATUS = OCI_STATUS && OCI_HandleAlloc((dvoid *)OCILib.env, (dvoid **)(void *)&pool->err, OCI_HTYPE_ERROR); + CHECK(MemoryAllocHandle((dvoid *)Env.env, + (dvoid **)(void *)&pool->err, + OCI_HTYPE_ERROR)) /* allocate pool handle */ - OCI_STATUS = OCI_STATUS && OCI_HandleAlloc((dvoid *)OCILib.env, (dvoid **)(void *)&pool->handle, (ub4)pool->htype); + CHECK(MemoryAllocHandle((dvoid *)Env.env, + (dvoid **)(void *)&pool->handle, + (ub4)pool->htype)) /* allocate authentication handle only if needed */ - #if OCI_VERSION_COMPILE >= OCI_11_1 - - if (OCI_STATUS) - { - if ((OCI_HTYPE_SPOOL == pool->htype) && (OCILib.version_runtime >= OCI_11_1)) - { - int dbsize = -1; - dbtext *dbstr = NULL; - - otext driver_version[OCI_SIZE_FORMAT]; - - osprintf(driver_version, - osizeof(driver_version) - (size_t)1, - OTEXT("%s : %d.%d.%d"), - OCILIB_DRIVER_NAME, - OCILIB_MAJOR_VERSION, - OCILIB_MINOR_VERSION, - OCILIB_REVISION_VERSION); - - dbstr = OCI_StringGetOracleString(driver_version, &dbsize); - - /* allocate authentication handle */ + #if OCI_VERSION_COMPILE >= OCI_11_1 - OCI_STATUS = OCI_HandleAlloc((dvoid *)OCILib.env, (dvoid **)(void *)&pool->authp, OCI_HTYPE_AUTHINFO); - - /* set OCILIB driver layer name attribute only for session pools here - For standalone connections and connection pool this attribute is set - in OCI_ConnectionLogon() */ - - OCI_SET_ATTRIB(OCI_HTYPE_AUTHINFO, OCI_ATTR_DRIVER_NAME, pool->authp, dbstr, dbsize) - - OCI_StringReleaseOracleString(dbstr); - - /* set authentication handle on the session pool */ - - OCI_SET_ATTRIB(OCI_HTYPE_SPOOL, OCI_ATTR_SPOOL_AUTH, pool->handle, pool->authp, sizeof(pool->authp)) - } + if ((OCI_HTYPE_SPOOL == pool->htype) && (Env.version_runtime >= OCI_11_1)) + { + otext driver_version[OCI_SIZE_FORMAT]; + + osprintf(driver_version, + osizeof(driver_version) - (size_t)1, + OTEXT("%s : %d.%d.%d"), + OCILIB_DRIVER_NAME, + OCILIB_MAJOR_VERSION, + OCILIB_MINOR_VERSION, + OCILIB_REVISION_VERSION); + + dbstr = StringGetDBString(driver_version, &dbsize); + + /* allocate authentication handle */ + + CHECK(MemoryAllocHandle((dvoid *)Env.env, + (dvoid **)(void *)&pool->authp, + OCI_HTYPE_AUTHINFO)) + + /* set OCILIB driver layer name attribute only for session pools here + For standalone connections and connection pool this attribute is set + in OCI_ConnectionLogon() */ + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_AUTHINFO, OCI_ATTR_DRIVER_NAME, + pool->authp, dbstr, dbsize, + pool->err + ) + + /* set authentication handle on the session pool */ + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SPOOL, OCI_ATTR_SPOOL_AUTH, + pool->handle, pool->authp, + sizeof(pool->authp), + pool->err + ) } - #endif + #endif /* create the pool */ - if (OCI_STATUS) + dbstr_db = StringGetDBString(pool->db, &dbsize_db); + dbstr_user = StringGetDBString(pool->user, &dbsize_user); + dbstr_pwd = StringGetDBString(pool->pwd, &dbsize_pwd); + + if (OCI_HTYPE_CPOOL == pool->htype) { - dbtext *dbstr_user = NULL; - dbtext *dbstr_pwd = NULL; - int dbsize_user = -1; - int dbsize_pwd = -1; - - dbstr_db = OCI_StringGetOracleString(pool->db, &dbsize_db); - dbstr_user = OCI_StringGetOracleString(pool->user, &dbsize_user); - dbstr_pwd = OCI_StringGetOracleString(pool->pwd, &dbsize_pwd); + CHECK_OCI + ( + pool->err, + OCIConnectionPoolCreate, + Env.env, pool->err, (OCICPool *)pool->handle, + (OraText **) (dvoid *) &dbstr_name, + (sb4*) &dbsize_name, + (OraText *) dbstr_db, (sb4) dbsize_db, + (ub4)pool->min, (ub4)pool->max, + (ub4)pool->incr, (OraText *) dbstr_user, + (sb4) dbsize_user, (OraText *) dbstr_pwd, + (sb4) dbsize_pwd, (ub4) OCI_DEFAULT + ) + } - if (OCI_HTYPE_CPOOL == pool->htype) - { - OCI_EXEC - ( - OCIConnectionPoolCreate(OCILib.env, pool->err, (OCICPool *) pool->handle, - (OraText **) (dvoid *) &dbstr_name, - (sb4*) &dbsize_name, - (OraText *) dbstr_db, (sb4) dbsize_db, - (ub4) pool->min, (ub4) pool->max, - (ub4) pool->incr, (OraText *) dbstr_user, - (sb4) dbsize_user, (OraText *) dbstr_pwd, - (sb4) dbsize_pwd, (ub4) OCI_DEFAULT) - ) - } + #if OCI_VERSION_COMPILE >= OCI_9_2 - #if OCI_VERSION_COMPILE >= OCI_9_2 + else + { + ub4 sess_mode = OCI_DEFAULT; - else + if (!(pool->mode & OCI_SESSION_SYSDBA) && + IS_STRING_VALID(pool->user) && + IS_STRING_VALID(pool->pwd)) { - ub4 sess_mode = OCI_DEFAULT; - - if (!(pool->mode & OCI_SESSION_SYSDBA) && OCI_STRING_VALID(pool->user) && OCI_STRING_VALID(pool->pwd)) - { - sess_mode |= OCI_SPC_HOMOGENEOUS; - } - - OCI_EXEC - ( - OCISessionPoolCreate(OCILib.env, pool->err, (OCISPool *) pool->handle, - (OraText **) (dvoid *) &dbstr_name, - (ub4*) &dbsize_name, - (OraText *) dbstr_db, (sb4) dbsize_db, - (ub4) pool->min, (ub4) pool->max, - (ub4) pool->incr, (OraText *) dbstr_user, - (sb4) dbsize_user, (OraText *) dbstr_pwd, - (sb4) dbsize_pwd, (ub4) sess_mode) - ) + sess_mode |= OCI_SPC_HOMOGENEOUS; } - #endif - - OCI_StringReleaseOracleString(dbstr_db); - OCI_StringReleaseOracleString(dbstr_user); - OCI_StringReleaseOracleString(dbstr_pwd); + CHECK_OCI + ( + pool->err, + OCISessionPoolCreate, + Env.env, pool->err, (OCISPool *)pool->handle, + (OraText **) (dvoid *) &dbstr_name, + (ub4*) &dbsize_name, + (OraText *) dbstr_db, (sb4) dbsize_db, + (ub4)pool->min, (ub4)pool->max, + (ub4)pool->incr, (OraText *) dbstr_user, + (sb4) dbsize_user, (OraText *) dbstr_pwd, + (sb4) dbsize_pwd, (ub4) sess_mode + ) } - if (OCI_STATUS && dbstr_name) + #endif + + if (NULL != dbstr_name) { - pool->name = OCI_StringDuplicateFromOracleString(dbstr_name, dbcharcount(dbsize_name)); + pool->name = StringDuplicateFromDBString(dbstr_name, dbcharcount(dbsize_name)); - OCI_STATUS = (NULL != pool->name); + CHECK(NULL != pool->name) } } @@ -312,116 +327,125 @@ OCI_Pool * OCI_API OCI_PoolCreate /* on success, we allocate internal OCI connection objects for pool minimum size */ - if (OCI_STATUS) - { - - #if OCI_VERSION_COMPILE >= OCI_9_0 +#if OCI_VERSION_COMPILE >= OCI_9_0 - /* retrieve statement cache size */ + /* retrieve statement cache size */ - OCI_PoolGetStatementCacheSize(pool); + CHECK(PoolGetStatementCacheSize(pool)) - /* for connection pools that do not handle the statement cache - attribute, let's set the value with documented default cache size */ + /* for connection pools that do not handle the statement cache + attribute, let's set the value with documented default cache size */ - if (pool->cache_size == 0) - { - OCI_PoolSetStatementCacheSize(pool, OCI_DEFAUT_STMT_CACHE_SIZE); - } + if (pool->cache_size == 0) + { + CHECK(PoolSetStatementCacheSize(pool, OCI_DEFAUT_STMT_CACHE_SIZE)) + } - #endif +#endif - } + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + StringReleaseDBString(dbstr_db); + StringReleaseDBString(dbstr_user); + StringReleaseDBString(dbstr_pwd); - if (OCI_STATUS) - { - OCI_RETVAL = pool; - } - else if (pool) - { - OCI_PoolFree(pool); - } + if (FAILURE) + { + PoolFree(pool); + pool = NULL; + } - OCI_CALL_EXIT() + SET_RETVAL(pool) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolFree + * PoolFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_PoolFree +boolean PoolFree ( OCI_Pool *pool ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_POOL, pool + ) - OCI_STATUS = OCI_PoolClose(pool); + CHECK_PTR(OCI_IPC_POOL, pool) - OCI_ListRemove(OCILib.pools, pool); + PoolDispose(pool); + ListRemove(Env.pools, pool); - OCI_FREE(pool) + FREE(pool) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetConnection + * PoolGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_PoolGetConnection +OCI_Connection * PoolGetConnection ( OCI_Pool *pool, const otext *tag ) { - OCI_CALL_ENTER(OCI_Connection*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + ENTER_FUNC + ( + /* returns */ OCI_Connection*, NULL, + /* context */ OCI_IPC_POOL, pool + ) + + CHECK_PTR(OCI_IPC_POOL, pool) - OCI_RETVAL = OCI_ConnectionCreateInternal(pool, pool->db, pool->user, pool->pwd, pool->mode, tag); + OCI_Connection *con = ConnectionCreateInternal(pool, pool->db, pool->user, pool->pwd, pool->mode, tag); + CHECK_NULL(con) - /* for regular connection pool, set the statement cache size to + /* for regular connection pool, set the statement cache size to retrieved connection */ - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCI_RETVAL) - { - const unsigned int cache_size = OCI_PoolGetStatementCacheSize(pool); + const unsigned int cache_size = PoolGetStatementCacheSize(pool); - OCI_SetStatementCacheSize(OCI_RETVAL, cache_size); - } + CHECK(ConnectionSetStatementCacheSize(con, cache_size)) #endif - OCI_STATUS = (NULL != OCI_RETVAL); - - OCI_CALL_EXIT() + SET_RETVAL(con) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetTimeout + * PoolGetTimeout * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetTimeout +unsigned int PoolGetTimeout ( OCI_Pool *pool ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_POOL, pool + ) + ub4 value = 0; - OCI_CALL_ENTER(unsigned int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + CHECK_PTR(OCI_IPC_POOL, pool) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0) + if (Env.version_runtime >= OCI_9_0) { ub4 attr = 0; @@ -430,42 +454,51 @@ unsigned int OCI_API OCI_PoolGetTimeout attr = OCI_ATTR_CONN_TIMEOUT; } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { attr = OCI_ATTR_SPOOL_TIMEOUT; } - #endif + #endif - OCI_GET_ATTRIB(pool->htype, attr, pool->handle, &value, NULL) + CHECK_ATTRIB_GET + ( + pool->htype, attr, + pool->handle, &value, NULL, + pool->err + ) } #endif - OCI_RETVAL = (unsigned int)value; + SET_RETVAL((unsigned int)value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolSetTimeout + * PoolSetTimeout * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_PoolSetTimeout +boolean PoolSetTimeout ( OCI_Pool *pool, unsigned int value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_POOL, pool + ) + + CHECK_PTR(OCI_IPC_POOL, pool) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0) + if (Env.version_runtime >= OCI_9_0) { ub4 timeout = value; ub4 attr = 0; @@ -475,43 +508,52 @@ boolean OCI_API OCI_PoolSetTimeout attr = OCI_ATTR_CONN_TIMEOUT; } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { attr = OCI_ATTR_SPOOL_TIMEOUT; } - #endif + #endif - OCI_SET_ATTRIB(pool->htype, attr, pool->handle, &timeout, sizeof(timeout)) + CHECK_ATTRIB_SET + ( + pool->htype, attr, pool->handle, + &timeout, sizeof(timeout), + pool->err + ) } #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetNoWait + * PoolGetNoWait * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_PoolGetNoWait +boolean PoolGetNoWait ( OCI_Pool *pool ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_POOL, pool + ) + ub1 value = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + CHECK_PTR(OCI_IPC_POOL, pool) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0) + if (Env.version_runtime >= OCI_9_0) { ub4 attr = 0; @@ -520,7 +562,7 @@ boolean OCI_API OCI_PoolGetNoWait attr = OCI_ATTR_CONN_NOWAIT; } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { @@ -528,35 +570,44 @@ boolean OCI_API OCI_PoolGetNoWait } - #endif + #endif - OCI_GET_ATTRIB(pool->htype, attr, pool->handle, &value, NULL) + CHECK_ATTRIB_GET + ( + pool->htype, attr, + pool->handle, &value, NULL, + pool->err + ) } #endif - OCI_RETVAL = (boolean)value; + SET_RETVAL((boolean)value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolSetNoWait + * PoolSetNoWait * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_PoolSetNoWait +boolean PoolSetNoWait ( OCI_Pool *pool, boolean value ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_POOL, pool + ) - #if OCI_VERSION_COMPILE >= OCI_9_0 + CHECK_PTR(OCI_IPC_POOL, pool) - if (OCILib.version_runtime >= OCI_9_0) +#if OCI_VERSION_COMPILE >= OCI_9_0 + + if (Env.version_runtime >= OCI_9_0) { ub1 nowait = (ub1) value; ub4 attr = 0; @@ -566,7 +617,7 @@ boolean OCI_API OCI_PoolSetNoWait attr = OCI_ATTR_CONN_NOWAIT; } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { @@ -576,214 +627,263 @@ boolean OCI_API OCI_PoolSetNoWait } - #endif + #endif - OCI_SET_ATTRIB(pool->htype, attr, pool->handle, &nowait, sizeof(nowait)) + CHECK_ATTRIB_SET + ( + pool->htype, attr, + pool->handle, &nowait, sizeof(nowait), + pool->err + ) } #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetBusyCount + * PoolGetBusyCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetBusyCount +unsigned int PoolGetBusyCount ( OCI_Pool *pool ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_POOL, pool + ) + ub4 value = 0; - OCI_CALL_ENTER(unsigned int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + CHECK_PTR(OCI_IPC_POOL, pool) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0) + if (Env.version_runtime >= OCI_9_0) { - ub4 attr = 0; + ub4 attr = 0; if (OCI_HTYPE_CPOOL == pool->htype) { attr = (ub4) OCI_ATTR_CONN_BUSY_COUNT; } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { attr = (ub4) OCI_ATTR_SPOOL_BUSY_COUNT; } - #endif + #endif - OCI_GET_ATTRIB(pool->htype, attr, pool->handle, &value, NULL) + CHECK_ATTRIB_GET + ( + pool->htype, attr, + pool->handle, &value, NULL, + pool->err + ) } #endif - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetOpenedCount + * PoolGetOpenedCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetOpenedCount +unsigned int PoolGetOpenedCount ( OCI_Pool *pool ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_POOL, pool + ) + ub4 value = 0; - OCI_CALL_ENTER(unsigned int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + CHECK_PTR(OCI_IPC_POOL, pool) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (OCILib.version_runtime >= OCI_9_0) + if (Env.version_runtime >= OCI_9_0) { - ub4 attr = 0; + ub4 attr = 0; if (OCI_HTYPE_CPOOL == pool->htype) { - attr = OCI_ATTR_CONN_OPEN_COUNT; + attr = OCI_ATTR_CONN_OPEN_COUNT; } - #if OCI_VERSION_COMPILE >= OCI_9_2 + #if OCI_VERSION_COMPILE >= OCI_9_2 else { attr = OCI_ATTR_SPOOL_OPEN_COUNT; } - #endif + #endif - OCI_GET_ATTRIB(pool->htype, attr, pool->handle, &value, NULL) + CHECK_ATTRIB_GET + ( + pool->htype, attr, + pool->handle, &value, NULL, + pool->err + ) } #endif - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetMin + * PoolGetMin * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetMin +unsigned int PoolGetMin ( OCI_Pool *pool ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_POOL, pool, min, NULL, NULL, pool->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_POOL, pool, + min + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetMax + * PoolGetMax * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetMax +unsigned int PoolGetMax ( OCI_Pool *pool ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_POOL, pool, max, NULL, NULL, pool->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_POOL, pool, + max + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetIncrement + * PoolGetIncrement * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetIncrement +unsigned int PoolGetIncrement ( OCI_Pool *pool ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_POOL, pool, incr, NULL, NULL, pool->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_POOL, pool, + incr + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolSetStatementCacheSize + * PoolSetStatementCacheSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_PoolSetStatementCacheSize +boolean PoolSetStatementCacheSize ( - OCI_Pool *pool, - unsigned int value + OCI_Pool *pool, + unsigned int value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_POOL, pool + ) + ub4 cache_size = value; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + CHECK_PTR(OCI_IPC_POOL, pool) - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCILib.version_runtime >= OCI_10_1) + if (Env.version_runtime >= OCI_10_1) { if (OCI_HTYPE_SPOOL == pool->htype) { - OCI_SET_ATTRIB(pool->htype, OCI_ATTR_SPOOL_STMTCACHESIZE, pool->handle, &cache_size, sizeof(cache_size)) + CHECK_ATTRIB_SET + ( + pool->htype, OCI_ATTR_SPOOL_STMTCACHESIZE, + pool->handle, &cache_size, sizeof(cache_size), + pool->err + ) } } #endif - if (OCI_STATUS) - { - pool->cache_size = cache_size; - } + pool->cache_size = cache_size; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PoolGetStatementCacheSize + * PoolGetStatementCacheSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_PoolGetStatementCacheSize +unsigned int PoolGetStatementCacheSize ( OCI_Pool *pool ) { + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_POOL, pool + ) ub4 cache_size = 0; - OCI_CALL_ENTER(unsigned int, cache_size) - OCI_CALL_CHECK_PTR(OCI_IPC_POOL, pool) - OCI_CALL_CONTEXT_SET_FROM_ERR(pool->err) + CHECK_PTR(OCI_IPC_POOL, pool) - #if OCI_VERSION_COMPILE >= OCI_10_1 +#if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCILib.version_runtime >= OCI_10_1) + if (Env.version_runtime >= OCI_10_1) { if (OCI_HTYPE_SPOOL == pool->htype) { - OCI_GET_ATTRIB(pool->htype, OCI_ATTR_SPOOL_STMTCACHESIZE, pool->handle, &cache_size, NULL) + CHECK_ATTRIB_GET + ( + pool->htype, OCI_ATTR_SPOOL_STMTCACHESIZE, + pool->handle, &cache_size, NULL, + pool->err + ) } else { cache_size = pool->cache_size; } - - if (OCI_STATUS) - { - pool->cache_size = cache_size; - } + + pool->cache_size = cache_size; } #else @@ -792,11 +892,7 @@ unsigned int OCI_API OCI_PoolGetStatementCacheSize #endif - if (OCI_STATUS) - { - OCI_RETVAL = pool->cache_size; - } + SET_RETVAL(pool->cache_size) - OCI_CALL_EXIT() + EXIT_FUNC() } - diff --git a/src/pool.h b/src/pool.h new file mode 100644 index 00000000..2353fc41 --- /dev/null +++ b/src/pool.h @@ -0,0 +1,112 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_POOL_H_INCLUDED +#define OCILIB_POOL_H_INCLUDED + +#include "types.h" + +boolean PoolDispose +( + OCI_Pool *pool +); + +OCI_Pool * PoolCreate +( + const otext *db, + const otext *user, + const otext *pwd, + unsigned int type, + unsigned int mode, + unsigned int min_con, + unsigned int max_con, + unsigned int incr_con +); + +boolean PoolFree +( + OCI_Pool *pool +); + +OCI_Connection * PoolGetConnection +( + OCI_Pool *pool, + const otext *tag +); + +unsigned int PoolGetTimeout +( + OCI_Pool *pool +); + +boolean PoolSetTimeout +( + OCI_Pool *pool, + unsigned int value +); + +boolean PoolGetNoWait +( + OCI_Pool *pool +); + +boolean PoolSetNoWait +( + OCI_Pool *pool, + boolean value +); + +unsigned int PoolGetBusyCount +( + OCI_Pool *pool +); + +unsigned int PoolGetOpenedCount +( + OCI_Pool *pool +); + +unsigned int PoolGetMin +( + OCI_Pool *pool +); + +unsigned int PoolGetMax +( + OCI_Pool *pool +); + +unsigned int PoolGetIncrement +( + OCI_Pool *pool +); + +boolean PoolSetStatementCacheSize +( + OCI_Pool *pool, + unsigned int value +); + +unsigned int PoolGetStatementCacheSize +( + OCI_Pool *pool +); + +#endif /* OCILIB_POOL_H_INCLUDED */ diff --git a/src/queue.c b/src/queue.c index 3f8dc8fe..29df3bd9 100644 --- a/src/queue.c +++ b/src/queue.c @@ -18,25 +18,36 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "queue.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "macros.h" +#include "statement.h" -static unsigned int DeliveryModeValues[] = { OCI_APM_BUFFERED, OCI_APM_PERSISTENT, OCI_APM_ALL }; -static unsigned int GroupingModeValues[] = { OCI_AGM_NONE, OCI_AGM_TRANSACTIONNAL }; -static unsigned int QueueTypeValues[ ] = { OCI_AQT_NORMAL, OCI_AQT_EXCEPTION, OCI_AQT_NON_PERSISTENT }; +static unsigned int DeliveryModeValues[] = +{ + OCI_APM_BUFFERED, + OCI_APM_PERSISTENT, + OCI_APM_ALL +}; + +static unsigned int GroupingModeValues[] = +{ + OCI_AGM_NONE, + OCI_AGM_TRANSACTIONNAL +}; -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ +static unsigned int QueueTypeValues[] = +{ + OCI_AQT_NORMAL, + OCI_AQT_EXCEPTION, + OCI_AQT_NON_PERSISTENT +}; /* --------------------------------------------------------------------------------------------- * - * OCI_QueueCreate + QueueCreate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueCreate +boolean QueueCreate ( OCI_Connection *con, const otext *queue_name, @@ -49,66 +60,75 @@ boolean OCI_API OCI_QueueCreate const otext *comment ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_name) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_table) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, queue_type, QueueTypeValues, OTEXT("Queue type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("DECLARE ") - OTEXT(" v_dependency_tracking BOOLEAN := FALSE; ") - OTEXT("BEGIN ") - OTEXT(" IF (:dependency_tracking = 1) then ") - OTEXT(" v_dependency_tracking := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" DBMS_AQADM.CREATE_QUEUE ") - OTEXT(" (") - OTEXT(" queue_name => :queue_name, ") - OTEXT(" queue_table => :queue_table, ") - OTEXT(" queue_type => :queue_type, ") - OTEXT(" max_retries => :max_retries, ") - OTEXT(" retry_delay => :retry_delay, ") - OTEXT(" retention_time => :retention_time, ") - OTEXT(" dependency_tracking => v_dependency_tracking, ") - OTEXT(" comment => :comment ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_table"), (otext *) queue_table, 0); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":queue_type"), &queue_type); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":max_retries"), &max_retries); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":retry_delay"), &retry_delay); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":retention_time"), &retention_time); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":dependency_tracking"), &dependency_tracking); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":comment"), (otext *) (comment ? comment : OCI_STRING_EMPTY), 0); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_name) + CHECK_PTR(OCI_IPC_STRING, queue_table) + CHECK_ENUM_VALUE(queue_type, QueueTypeValues, OTEXT("Queue type")) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("DECLARE ") + OTEXT(" v_dependency_tracking BOOLEAN := FALSE; ") + OTEXT("BEGIN ") + OTEXT(" IF (:dependency_tracking = 1) then ") + OTEXT(" v_dependency_tracking := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" DBMS_AQADM.CREATE_QUEUE ") + OTEXT(" (") + OTEXT(" queue_name => :queue_name, ") + OTEXT(" queue_table => :queue_table, ") + OTEXT(" queue_type => :queue_type, ") + OTEXT(" max_retries => :max_retries, ") + OTEXT(" retry_delay => :retry_delay, ") + OTEXT(" retention_time => :retention_time, ") + OTEXT(" dependency_tracking => v_dependency_tracking, ") + OTEXT(" comment => :comment ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0)) + CHECK(StatementBindString(st, OTEXT(":queue_table"), (otext *) queue_table, 0)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":queue_type"), &queue_type)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":max_retries"), &max_retries)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":retry_delay"), &retry_delay)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":retention_time"), &retention_time)) + CHECK(StatementBindInt(st, OTEXT(":dependency_tracking"), &dependency_tracking)) + CHECK(StatementBindString(st, OTEXT(":comment"), (otext *) (comment ? comment : OCI_STRING_EMPTY), 0)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueAlter + * QueueAlter * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueAlter +boolean QueueAlter ( OCI_Connection *con, const otext *queue_name, @@ -118,97 +138,115 @@ boolean OCI_API OCI_QueueAlter const otext *comment ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_name) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("BEGIN ") - OTEXT(" DBMS_AQADM.ALTER_QUEUE ") - OTEXT(" (") - OTEXT(" queue_name => :queue_name, ") - OTEXT(" max_retries => :max_retries, ") - OTEXT(" retry_delay => :retry_delay, ") - OTEXT(" retention_time => :retention_time, ") - OTEXT(" comment => :comment ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":max_retries"), &max_retries); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":retry_delay"), &retry_delay); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":retention_time"), &retention_time); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":comment"), (otext *) (comment ? comment : OCI_STRING_EMPTY), 0); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_name) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("BEGIN ") + OTEXT(" DBMS_AQADM.ALTER_QUEUE ") + OTEXT(" (") + OTEXT(" queue_name => :queue_name, ") + OTEXT(" max_retries => :max_retries, ") + OTEXT(" retry_delay => :retry_delay, ") + OTEXT(" retention_time => :retention_time, ") + OTEXT(" comment => :comment ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":max_retries"), &max_retries)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":retry_delay"), &retry_delay)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":retention_time"), &retention_time)) + CHECK(StatementBindString(st, OTEXT(":comment"), (otext *) (comment ? comment : OCI_STRING_EMPTY), 0)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueDestroy + * QueueDrop * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueDrop +boolean QueueDrop ( OCI_Connection *con, const otext *queue_name ) { - OCI_Statement *st = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_name) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + OCI_Statement *st = NULL; - st = OCI_StatementCreate(con); + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_name) - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("BEGIN ") - OTEXT(" DBMS_AQADM.DROP_QUEUE ") - OTEXT(" (") - OTEXT(" queue_name => :queue_name ") - OTEXT(" ); ") - OTEXT("END; ") - ); + st = StatementCreate(con); + CHECK_NULL(st) - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0); + CHECK + ( + StatementPrepare + ( + st, + OTEXT("BEGIN ") + OTEXT(" DBMS_AQADM.DROP_QUEUE ") + OTEXT(" (") + OTEXT(" queue_name => :queue_name ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) - OCI_STATUS = OCI_STATUS && OCI_Execute(st); + CHECK(StatementBindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0)) - OCI_StatementFree(st); - } + CHECK(StatementExecute(st)) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueStart + * QueueStart * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueStart +boolean QueueStart ( OCI_Connection *con, const otext *queue_name, @@ -216,58 +254,67 @@ boolean OCI_API OCI_QueueStart boolean dequeue ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_name) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("DECLARE ") - OTEXT(" v_enqueue BOOLEAN := FALSE; ") - OTEXT(" v_dequeue BOOLEAN := FALSE; ") - OTEXT("BEGIN ") - OTEXT(" IF (:enqueue = 1) then ") - OTEXT(" v_enqueue := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" IF (:dequeue = 1) then ") - OTEXT(" v_dequeue := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" DBMS_AQADM.START_QUEUE ") - OTEXT(" (") - OTEXT(" queue_name => :queue_name, ") - OTEXT(" enqueue => v_enqueue, ") - OTEXT(" dequeue => v_dequeue ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":enqueue"), &enqueue); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":dequeue"), &dequeue); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_name) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("DECLARE ") + OTEXT(" v_enqueue BOOLEAN := FALSE; ") + OTEXT(" v_dequeue BOOLEAN := FALSE; ") + OTEXT("BEGIN ") + OTEXT(" IF (:enqueue = 1) then ") + OTEXT(" v_enqueue := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" IF (:dequeue = 1) then ") + OTEXT(" v_dequeue := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" DBMS_AQADM.START_QUEUE ") + OTEXT(" (") + OTEXT(" queue_name => :queue_name, ") + OTEXT(" enqueue => v_enqueue, ") + OTEXT(" dequeue => v_dequeue ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0)) + CHECK(StatementBindInt(st, OTEXT(":enqueue"), &enqueue)) + CHECK(StatementBindInt(st, OTEXT(":dequeue"), &dequeue)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueStop + * QueueStop * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueStop +boolean QueueStop ( OCI_Connection *con, const otext *queue_name, @@ -276,64 +323,73 @@ boolean OCI_API OCI_QueueStop boolean wait ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_name) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("DECLARE ") - OTEXT(" v_enqueue BOOLEAN := FALSE; ") - OTEXT(" v_dequeue BOOLEAN := FALSE; ") - OTEXT(" v_wait BOOLEAN := FALSE; ") - OTEXT("BEGIN ") - OTEXT(" IF (:enqueue = 1) then ") - OTEXT(" v_enqueue := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" IF (:dequeue = 1) then ") - OTEXT(" v_dequeue := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" IF (:wait = 1) then ") - OTEXT(" v_wait := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" DBMS_AQADM.STOP_QUEUE ") - OTEXT(" (") - OTEXT(" queue_name => :queue_name, ") - OTEXT(" enqueue => v_enqueue, ") - OTEXT(" dequeue => v_dequeue, ") - OTEXT(" wait => v_wait ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":enqueue"), &enqueue); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":dequeue"), &dequeue); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":wait"), &wait); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_name) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("DECLARE ") + OTEXT(" v_enqueue BOOLEAN := FALSE; ") + OTEXT(" v_dequeue BOOLEAN := FALSE; ") + OTEXT(" v_wait BOOLEAN := FALSE; ") + OTEXT("BEGIN ") + OTEXT(" IF (:enqueue = 1) then ") + OTEXT(" v_enqueue := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" IF (:dequeue = 1) then ") + OTEXT(" v_dequeue := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" IF (:wait = 1) then ") + OTEXT(" v_wait := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" DBMS_AQADM.STOP_QUEUE ") + OTEXT(" (") + OTEXT(" queue_name => :queue_name, ") + OTEXT(" enqueue => v_enqueue, ") + OTEXT(" dequeue => v_dequeue, ") + OTEXT(" wait => v_wait ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_name"), (otext *) queue_name, 0)) + CHECK(StatementBindInt(st, OTEXT(":enqueue"), &enqueue)) + CHECK(StatementBindInt(st, OTEXT(":dequeue"), &dequeue)) + CHECK(StatementBindInt(st, OTEXT(":wait"), &wait)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueTableCreate + * QueueTableCreate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueTableCreate +boolean QueueTableCreate ( OCI_Connection *con, const otext *queue_table, @@ -348,71 +404,79 @@ boolean OCI_API OCI_QueueTableCreate const otext *compatible ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_table) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_payload_type) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, message_grouping, GroupingModeValues, OTEXT("Grouping mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("DECLARE ") - OTEXT(" v_multiple_consumers BOOLEAN := FALSE; ") - OTEXT("BEGIN ") - OTEXT(" IF (:multiple_consumers = 1) then ") - OTEXT(" v_multiple_consumers := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" DBMS_AQADM.CREATE_QUEUE_TABLE ") - OTEXT(" (") - OTEXT(" queue_table => :queue_table, ") - OTEXT(" queue_payload_type => :queue_payload_type, ") - OTEXT(" storage_clause => :storage_clause, ") - OTEXT(" sort_list => :sort_list, ") - OTEXT(" multiple_consumers => v_multiple_consumers, ") - OTEXT(" message_grouping => :message_grouping, ") - OTEXT(" comment => :comment, ") - OTEXT(" primary_instance => :primary_instance, ") - OTEXT(" secondary_instance => :secondary_instance, ") - OTEXT(" compatible => :compatible") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_table"), (otext *) queue_table, 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_payload_type"), (otext *) queue_payload_type, 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":storage_clause"), (otext *) (storage_clause ? storage_clause : OCI_STRING_EMPTY), 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":sort_list"), (otext *) (sort_list ? sort_list : OCI_STRING_EMPTY), 0); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":multiple_consumers"), &multiple_consumers); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":message_grouping"), &message_grouping); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":comment"), (otext *)( comment ? comment : OCI_STRING_EMPTY), 0); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":primary_instance"), &primary_instance); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":secondary_instance"), &secondary_instance); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":compatible"), (otext *) (compatible ? compatible : OCI_STRING_EMPTY), 0); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_table) + CHECK_PTR(OCI_IPC_STRING, queue_payload_type) + CHECK_ENUM_VALUE(message_grouping, GroupingModeValues, OTEXT("Grouping mode")) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("DECLARE ") + OTEXT(" v_multiple_consumers BOOLEAN := FALSE; ") + OTEXT("BEGIN ") + OTEXT(" IF (:multiple_consumers = 1) then ") + OTEXT(" v_multiple_consumers := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" DBMS_AQADM.CREATE_QUEUE_TABLE ") + OTEXT(" (") + OTEXT(" queue_table => :queue_table, ") + OTEXT(" queue_payload_type => :queue_payload_type, ") + OTEXT(" storage_clause => :storage_clause, ") + OTEXT(" sort_list => :sort_list, ") + OTEXT(" multiple_consumers => v_multiple_consumers, ") + OTEXT(" message_grouping => :message_grouping, ") + OTEXT(" comment => :comment, ") + OTEXT(" primary_instance => :primary_instance, ") + OTEXT(" secondary_instance => :secondary_instance, ") + OTEXT(" compatible => :compatible") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_table"), (otext *) queue_table, 0)) + CHECK(StatementBindString(st, OTEXT(":queue_payload_type"), (otext *) queue_payload_type, 0)) + CHECK(StatementBindString(st, OTEXT(":storage_clause"), (otext *) (storage_clause ? storage_clause : OCI_STRING_EMPTY), 0)) + CHECK(StatementBindString(st, OTEXT(":sort_list"), (otext *) (sort_list ? sort_list : OCI_STRING_EMPTY), 0)) + CHECK(StatementBindInt(st, OTEXT(":multiple_consumers"), &multiple_consumers)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":message_grouping"), &message_grouping)) + CHECK(StatementBindString(st, OTEXT(":comment"), (otext *)( comment ? comment : OCI_STRING_EMPTY), 0)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":primary_instance"), &primary_instance)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":secondary_instance"), &secondary_instance)) + CHECK(StatementBindString(st, OTEXT(":compatible"), (otext *) (compatible ? compatible : OCI_STRING_EMPTY), 0)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueTableAlter + * QueueTableAlter * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueTableAlter +boolean QueueTableAlter ( OCI_Connection *con, const otext *queue_table, @@ -421,103 +485,121 @@ boolean OCI_API OCI_QueueTableAlter unsigned int secondary_instance ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_table) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("BEGIN ") - OTEXT(" DBMS_AQADM.ALTER_QUEUE_TABLE ") - OTEXT(" (") - OTEXT(" queue_table => :queue_table, ") - OTEXT(" comment => :comment, ") - OTEXT(" primary_instance => :primary_instance, ") - OTEXT(" secondary_instance => :secondary_instance ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_table"), (otext *) queue_table, 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":comment"), (otext *) (comment ? comment: OCI_STRING_EMPTY), 0); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":primary_instance"), &primary_instance); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":secondary_instance"), &secondary_instance); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_table) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("BEGIN ") + OTEXT(" DBMS_AQADM.ALTER_QUEUE_TABLE ") + OTEXT(" (") + OTEXT(" queue_table => :queue_table, ") + OTEXT(" comment => :comment, ") + OTEXT(" primary_instance => :primary_instance, ") + OTEXT(" secondary_instance => :secondary_instance ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_table"), (otext *) queue_table, 0)) + CHECK(StatementBindString(st, OTEXT(":comment"), (otext *) (comment ? comment : OCI_STRING_EMPTY), 0)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":primary_instance"), &primary_instance)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":secondary_instance"), &secondary_instance)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueTableDrop + * QueueTableDrop * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueTableDrop +boolean QueueTableDrop ( OCI_Connection *con, const otext *queue_table, boolean force ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + OCI_Statement *st = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_table) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("DECLARE ") - OTEXT(" v_force BOOLEAN := FALSE; ") - OTEXT("BEGIN ") - OTEXT(" IF (:force = 1) then ") - OTEXT(" v_force := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" DBMS_AQADM.DROP_QUEUE_TABLE ") - OTEXT(" (") - OTEXT(" queue_table => :queue_table, ") - OTEXT(" force => v_force ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_table"), (otext *)queue_table, 0); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":force"), &force); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_table) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("DECLARE ") + OTEXT(" v_force BOOLEAN := FALSE; ") + OTEXT("BEGIN ") + OTEXT(" IF (:force = 1) then ") + OTEXT(" v_force := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" DBMS_AQADM.DROP_QUEUE_TABLE ") + OTEXT(" (") + OTEXT(" queue_table => :queue_table, ") + OTEXT(" force => v_force ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_table"), (otext *)queue_table, 0)) + CHECK(StatementBindInt(st, OTEXT(":force"), &force)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueTablePurge + * QueueTablePurge * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueTablePurge +boolean QueueTablePurge ( OCI_Connection *con, const otext *queue_table, @@ -526,106 +608,117 @@ boolean OCI_API OCI_QueueTablePurge unsigned int delivery_mode ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_table) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, delivery_mode, DeliveryModeValues, OTEXT("Delivery mode")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - if (con->ver_num >= OCI_10_1) - { - OCI_Statement *st = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - st = OCI_StatementCreate(con); + OCI_Statement *st = NULL; - if (st) + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_table) + CHECK_ENUM_VALUE(delivery_mode, DeliveryModeValues, OTEXT("Delivery mode")) + CHECK(con->ver_num >= OCI_10_1) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("DECLARE ") + OTEXT(" v_purge_options DBMS_AQADM.AQ$_PURGE_OPTIONS_T; ") + OTEXT(" v_block BOOLEAN := FALSE; ") + OTEXT("BEGIN ") + OTEXT(" v_purge_options.block := FALSE; ") + OTEXT(" v_purge_options.delivery_mode := :delivery_mode; ") + OTEXT(" IF (:block = 1) then ") + OTEXT(" v_purge_options.block := TRUE; ") + OTEXT(" END IF; ") + OTEXT(" DBMS_AQADM.PURGE_QUEUE_TABLE ") + OTEXT(" (") + OTEXT(" queue_table => :queue_table, ") + OTEXT(" purge_condition => :purge_condition, ") + OTEXT(" purge_options => v_purge_options ") + OTEXT(" ); ") + OTEXT("END; ") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_table"), (otext *)queue_table, 0)) + CHECK(StatementBindString(st, OTEXT(":purge_condition"), (otext *) (purge_condition ? purge_condition : OCI_STRING_EMPTY), 0)) + CHECK(StatementBindInt(st, OTEXT(":block"), &block)) + CHECK(StatementBindUnsignedInt(st, OTEXT(":delivery_mode"), &delivery_mode)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("DECLARE ") - OTEXT(" v_purge_options DBMS_AQADM.AQ$_PURGE_OPTIONS_T; ") - OTEXT(" v_block BOOLEAN := FALSE; ") - OTEXT("BEGIN ") - OTEXT(" v_purge_options.block := FALSE; ") - OTEXT(" v_purge_options.delivery_mode := :delivery_mode; ") - OTEXT(" IF (:block = 1) then ") - OTEXT(" v_purge_options.block := TRUE; ") - OTEXT(" END IF; ") - OTEXT(" DBMS_AQADM.PURGE_QUEUE_TABLE ") - OTEXT(" (") - OTEXT(" queue_table => :queue_table, ") - OTEXT(" purge_condition => :purge_condition, ") - OTEXT(" purge_options => v_purge_options ") - OTEXT(" ); ") - OTEXT("END; ") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_table"), (otext *)queue_table, 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":purge_condition"), - (otext *) (purge_condition ? purge_condition : OCI_STRING_EMPTY), 0); - OCI_STATUS = OCI_STATUS && OCI_BindInt(st, OTEXT(":block"), &block); - OCI_STATUS = OCI_STATUS && OCI_BindUnsignedInt(st, OTEXT(":delivery_mode"), &delivery_mode); - - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); + StatementFree(st); } - - OCI_RETVAL = OCI_STATUS; - } - else - { - OCI_RETVAL = FALSE; - } - - OCI_CALL_EXIT() + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_QueueTableMigrate + * QueueTableMigrate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_QueueTableMigrate +boolean QueueTableMigrate ( OCI_Connection *con, const otext *queue_table, const otext *compatible ) { - OCI_Statement *st = NULL; - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, queue_table) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, compatible) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - st = OCI_StatementCreate(con); - - if (st) - { - OCI_STATUS = OCI_Prepare - ( - st, - OTEXT("BEGIN ") - OTEXT(" DBMS_AQADM.MIGRATE_QUEUE_TABLE") - OTEXT(" (") - OTEXT(" queue_table => :queue_table, ") - OTEXT(" compatible => :compatible ") - OTEXT(" );") - OTEXT("END;") - ); - - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":queue_table"), (otext *)queue_table, 0); - OCI_STATUS = OCI_STATUS && OCI_BindString(st, OTEXT(":compatible"), (otext *)compatible, 0); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_STATUS = OCI_STATUS && OCI_Execute(st); - - OCI_StatementFree(st); - } - - OCI_RETVAL = OCI_STATUS; + OCI_Statement *st = NULL; - OCI_CALL_EXIT() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, queue_table) + CHECK_PTR(OCI_IPC_STRING, compatible) + + st = StatementCreate(con); + CHECK_NULL(st) + + CHECK + ( + StatementPrepare + ( + st, + OTEXT("BEGIN ") + OTEXT(" DBMS_AQADM.MIGRATE_QUEUE_TABLE") + OTEXT(" (") + OTEXT(" queue_table => :queue_table, ") + OTEXT(" compatible => :compatible ") + OTEXT(" );") + OTEXT("END;") + ) + ) + + CHECK(StatementBindString(st, OTEXT(":queue_table"), (otext *)queue_table, 0)) + CHECK(StatementBindString(st, OTEXT(":compatible"), (otext *)compatible, 0)) + + CHECK(StatementExecute(st)) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != st) + { + StatementFree(st); + } + ) } diff --git a/src/queue.h b/src/queue.h new file mode 100644 index 00000000..c2626361 --- /dev/null +++ b/src/queue.h @@ -0,0 +1,119 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_QUEUE_H_INCLUDED +#define OCILIB_QUEUE_H_INCLUDED + +#include "types.h" + +boolean QueueCreate +( + OCI_Connection *con, + const otext *queue_name, + const otext *queue_table, + unsigned int queue_type, + unsigned int max_retries, + unsigned int retry_delay, + unsigned int retention_time, + boolean dependency_tracking, + const otext *comment +); + +boolean QueueAlter +( + OCI_Connection *con, + const otext *queue_name, + unsigned int max_retries, + unsigned int retry_delay, + unsigned int retention_time, + const otext *comment +); + +boolean QueueDrop +( + OCI_Connection *con, + const otext *queue_name +); + +boolean QueueStart +( + OCI_Connection *con, + const otext *queue_name, + boolean enqueue, + boolean dequeue +); + +boolean QueueStop +( + OCI_Connection *con, + const otext *queue_name, + boolean enqueue, + boolean dequeue, + boolean wait +); + +boolean QueueTableCreate +( + OCI_Connection *con, + const otext *queue_table, + const otext *queue_payload_type, + const otext *storage_clause, + const otext *sort_list, + boolean multiple_consumers, + unsigned int message_grouping, + const otext *comment, + unsigned int primary_instance, + unsigned int secondary_instance, + const otext *compatible +); + +boolean QueueTableAlter +( + OCI_Connection *con, + const otext *queue_table, + const otext *comment, + unsigned int primary_instance, + unsigned int secondary_instance +); + +boolean QueueTableDrop +( + OCI_Connection *con, + const otext *queue_table, + boolean force +); + +boolean QueueTablePurge +( + OCI_Connection *con, + const otext *queue_table, + const otext *purge_condition, + boolean block, + unsigned int delivery_mode +); + +boolean QueueTableMigrate +( + OCI_Connection *con, + const otext *queue_table, + const otext *compatible +); + +#endif /* OCILIB_QUEUE_H_INCLUDED */ diff --git a/src/ref.c b/src/ref.c deleted file mode 100644 index 1f24716b..00000000 --- a/src/ref.c +++ /dev/null @@ -1,441 +0,0 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefInit - * --------------------------------------------------------------------------------------------- */ - -OCI_Ref * OCI_RefInit -( - OCI_Connection *con, - OCI_TypeInfo *typinf, - OCI_Ref *ref, - void *handle -) -{ - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_ALLOCATE_DATA(OCI_IPC_REF, ref, 1); - - if (OCI_STATUS) - { - ref->handle = handle; - ref->con = con; - ref->typinf = typinf; - - if (!ref->handle || (OCI_OBJECT_ALLOCATED_ARRAY == ref->hstate)) - { - /* allocates handle for non fetched object */ - - if (OCI_OBJECT_ALLOCATED_ARRAY != ref->hstate) - { - ref->hstate = OCI_OBJECT_ALLOCATED; - } - - OCI_EXEC - ( - OCI_ObjectNew(ref->con->env, ref->con->err, ref->con->cxt, - (OCITypeCode) SQLT_REF, - (OCIType*) NULL, - (dvoid *) NULL, - (OCIDuration) OCI_DURATION_SESSION, - (boolean) FALSE, - (dvoid **) &ref->handle) - ) - } - else - { - ref->hstate = OCI_OBJECT_FETCHED_CLEAN; - - OCI_RefUnpin(ref); - } - } - - /* check for failure */ - - if (!OCI_STATUS && ref) - { - OCI_RefFree(ref); - ref = NULL; - } - - return ref; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefPin - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_RefPin -( - OCI_Ref *ref -) -{ - void *obj_handle = NULL; - - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == ref, FALSE) - - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con); - - OCI_RefUnpin(ref); - - OCI_EXEC - ( - OCIObjectPin(ref->con->env, ref->con->err, ref->handle, (OCIComplexObject *) 0, - OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, &obj_handle) - ) - - if (OCI_STATUS) - { - ref->obj = OCI_ObjectInit(ref->con, (OCI_Object *) ref->obj, obj_handle, ref->typinf, NULL, -1, TRUE); - - OCI_STATUS = ref->pinned = (NULL != ref->obj); - } - - return OCI_STATUS; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefUnpin - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_RefUnpin -( - OCI_Ref *ref -) -{ - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == ref, FALSE) - OCI_CHECK(NULL == ref->obj, TRUE) - - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con); - - if (ref->pinned) - { - OCI_EXEC(OCIObjectUnpin(ref->con->env, ref->con->err, ref->obj->handle)) - - ref->pinned = FALSE; - } - - if (ref->obj) - { - ref->obj->hstate = OCI_OBJECT_FETCHED_DIRTY; - OCI_ObjectFree(ref->obj); - ref->obj = NULL; - } - - return OCI_STATUS; -} - -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefCreate - * --------------------------------------------------------------------------------------------- */ - -OCI_Ref * OCI_API OCI_RefCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf -) -{ - OCI_CALL_ENTER(OCI_Ref *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_RETVAL = OCI_RefInit(con, typinf, NULL, NULL); - OCI_STATUS = (NULL != OCI_RETVAL); - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefFree - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_RefFree -( - OCI_Ref *ref -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CHECK_OBJECT_FETCHED(ref) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - OCI_RefUnpin(ref); - - if ((OCI_OBJECT_ALLOCATED == ref->hstate) || (OCI_OBJECT_ALLOCATED_ARRAY == ref->hstate)) - { - OCI_OCIObjectFree(ref->con->env, ref->con->err, ref->handle, OCI_DEFAULT); - } - - if (OCI_OBJECT_ALLOCATED_ARRAY != ref->hstate) - { - OCI_FREE(ref) - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefArrayCreate - * --------------------------------------------------------------------------------------------- */ - -OCI_Ref ** OCI_API OCI_RefArrayCreate -( - OCI_Connection *con, - OCI_TypeInfo *typinf, - unsigned int nbelem -) -{ - OCI_Array *arr = NULL; - - OCI_CALL_ENTER(OCI_Ref **, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_REF, 0, sizeof(OCIRef *), sizeof(OCI_Ref), 0, typinf); - OCI_STATUS = (NULL != arr); - - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Ref **) arr->tab_obj; - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefArrayFree - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_RefArrayFree -( - OCI_Ref **refs -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, refs) - - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **)refs); - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefGetObject - * --------------------------------------------------------------------------------------------- */ - -OCI_Object * OCI_API OCI_RefGetObject -( - OCI_Ref *ref -) -{ - OCI_CALL_ENTER(OCI_Object*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - if (!OCI_RefIsNull(ref)) - { - OCI_STATUS = OCI_RefPin(ref); - - if (OCI_STATUS) - { - OCI_RETVAL = ref->obj; - } - } - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefAssign - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_RefAssign -( - OCI_Ref *ref, - OCI_Ref *ref_src -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref_src) - OCI_CALL_CHECK_COMPAT(ref->con, ref->typinf->tdo == ref_src->typinf->tdo) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - OCI_EXEC(OCIRefAssign(ref->con->env, ref->con->err, ref_src->handle, &ref->handle)) - - if (OCI_STATUS) - { - if (ref->obj) - { - OCI_ObjectFree(ref->obj); - ref->obj = NULL; - } - - ref->typinf = ref_src->typinf; - ref->pinned = ref_src->pinned; - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefIsNull - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_RefIsNull -( - OCI_Ref *ref -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - OCI_RETVAL = OCIRefIsNull(ref->con->env, ref->handle); - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefSetNull - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_RefSetNull -( - OCI_Ref *ref -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - OCI_STATUS = OCI_RefUnpin(ref); - - if (OCI_STATUS) - { - OCIRefClear(ref->con->env, ref->handle); - - if (ref->obj) - { - OCI_ObjectFree(ref->obj); - ref->obj = NULL; - } - } - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefToText - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_RefToText -( - OCI_Ref *ref, - unsigned int size, - otext *str -) -{ - dbtext *dbstr = NULL; - int dbsize = (int) size * (int) sizeof(otext); - - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - /* initialize output buffer in case of OCI failure */ - - str[0] = 0; - - dbstr = OCI_StringGetOracleString(str, &dbsize); - - OCI_EXEC(OCIRefToHex(ref->con->env, ref->con->err, ref->handle, (OraText *) dbstr, (ub4 *) &dbsize)) - - OCI_StringCopyOracleStringToNativeString(dbstr, str, dbcharcount(dbsize)); - OCI_StringReleaseOracleString(dbstr); - - /* set null string terminator */ - - str[dbcharcount(dbsize)] = 0; - - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_RefGetHexSize - * --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_API OCI_RefGetHexSize -( - OCI_Ref *ref -) -{ - ub4 size = 0; - - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_REF, ref) - OCI_CALL_CONTEXT_SET_FROM_CONN(ref->con) - - size = OCIRefHexSize(ref->con->env, (const OCIRef *)ref->handle) / (ub4) sizeof(dbtext); - - OCI_RETVAL = size; - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_CollRefGetTypeInfo - * --------------------------------------------------------------------------------------------- */ - -OCI_TypeInfo * OCI_API OCI_RefGetTypeInfo -( - OCI_Ref *ref -) -{ - OCI_GET_PROP(OCI_TypeInfo*, NULL, OCI_IPC_REF, ref, typinf, ref->con, NULL, ref->con->err) -} - diff --git a/src/reference.c b/src/reference.c new file mode 100644 index 00000000..651bca15 --- /dev/null +++ b/src/reference.c @@ -0,0 +1,497 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "reference.h" + +#include "array.h" +#include "macros.h" +#include "memory.h" +#include "object.h" +#include "strings.h" + +/* --------------------------------------------------------------------------------------------- * + * ReferenceInitialize + * --------------------------------------------------------------------------------------------- */ + +OCI_Ref * ReferenceInitialize +( + OCI_Connection *con, + OCI_TypeInfo *typinf, + OCI_Ref *ref, + void *handle +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Ref*, ref, + /* context */ OCI_IPC_CONNECTION, con + ) + + ALLOC_DATA(OCI_IPC_REF, ref, 1); + + ref->handle = handle; + ref->con = con; + ref->typinf = typinf; + + if (NULL == ref->handle || (OCI_OBJECT_ALLOCATED_ARRAY == ref->hstate)) + { + /* allocates handle for non fetched object */ + + if (OCI_OBJECT_ALLOCATED_ARRAY != ref->hstate) + { + ref->hstate = OCI_OBJECT_ALLOCATED; + } + + CHECK(MemoryAllocateObject(ref->con->env, + ref->con->err, + ref->con->cxt, + (OCITypeCode) SQLT_REF, + (OCIType*) NULL, + (dvoid *) NULL, + (OCIDuration) OCI_DURATION_SESSION, + (boolean) FALSE, + (dvoid **) &ref->handle)) + } + else + { + ref->hstate = OCI_OBJECT_FETCHED_CLEAN; + + CHECK(ReferenceUnpin(ref)) + } + + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ReferenceFree(ref); + ref = NULL; + } + + SET_RETVAL(ref) + ) +} + +/* --------------------------------------------------------------------------------------------- * + * ReferencePin + * --------------------------------------------------------------------------------------------- */ + +boolean ReferencePin +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + void *obj_handle = NULL; + + CHECK_PTR(OCI_IPC_REF, ref) + + CHECK(ReferenceUnpin(ref)) + + CHECK_OCI + ( + ref->con->err, + OCIObjectPin, + ref->con->env, ref->con->err, ref->handle, (OCIComplexObject *) 0, + OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, &obj_handle + ) + + ref->obj = ObjectInitialize(ref->con, (OCI_Object *) ref->obj, + obj_handle, ref->typinf, NULL, + -1, TRUE); + + CHECK_NULL(ref->obj) + + ref->pinned = TRUE; + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceUnpin + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceUnpin +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + + if (NULL != ref->obj) + { + if (ref->pinned) + { + CHECK_OCI + ( + ref->con->err, + OCIObjectUnpin, + ref->con->env, ref->con->err, + ref->obj->handle + ) + + ref->pinned = FALSE; + } + + ref->obj->hstate = OCI_OBJECT_FETCHED_DIRTY; + ObjectFree(ref->obj); + ref->obj = NULL; + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceCreate + * --------------------------------------------------------------------------------------------- */ + +OCI_Ref * ReferenceCreate +( + OCI_Connection *con, + OCI_TypeInfo *typinf +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Ref*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + + SET_RETVAL(ReferenceInitialize(con, typinf, NULL, NULL)) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceFree + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceFree +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + CHECK_OBJECT_FETCHED(ref) + + CHECK(ReferenceUnpin(ref)) + + if ((OCI_OBJECT_ALLOCATED == ref->hstate) || (OCI_OBJECT_ALLOCATED_ARRAY == ref->hstate)) + { + MemoryFreeObject(ref->con->env, ref->con->err, ref->handle, OCI_DEFAULT); + } + + if (OCI_OBJECT_ALLOCATED_ARRAY != ref->hstate) + { + FREE(ref) + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceCreateArray + * --------------------------------------------------------------------------------------------- */ + +OCI_Ref ** ReferenceCreateArray +( + OCI_Connection *con, + OCI_TypeInfo *typinf, + unsigned int nbelem +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Ref**, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + OCI_Array *arr = NULL; + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_TYPE_INFO, con) + + arr = ArrayCreate(con, nbelem, OCI_CDT_REF, 0, + sizeof(OCIRef *), sizeof(OCI_Ref), + 0, typinf); + + CHECK_NULL(arr) + + SET_RETVAL((OCI_Ref**)arr->tab_obj) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceFreeArray + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceFreeArray +( + OCI_Ref **refs +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_PTR(OCI_IPC_ARRAY, refs) + + SET_RETVAL(ArrayFreeFromHandles((void **)refs)) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceGetObject + * --------------------------------------------------------------------------------------------- */ + +OCI_Object * ReferenceGetObject +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Object*, NULL, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + CHECK(!ReferenceIsNull(ref)) + CHECK(ReferencePin(ref)) + + SET_RETVAL(ref->obj) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceAssign + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceAssign +( + OCI_Ref *ref, + OCI_Ref *ref_src +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + CHECK_PTR(OCI_IPC_REF, ref_src) + CHECK_COMPAT(ref->typinf->tdo == ref_src->typinf->tdo) + + CHECK_OCI + ( + ref->con->err, + OCIRefAssign, + ref->con->env, ref->con->err, + ref_src->handle, &ref->handle + ) + + if (NULL != ref->obj) + { + ObjectFree(ref->obj); + ref->obj = NULL; + } + + ref->typinf = ref_src->typinf; + ref->pinned = ref_src->pinned; + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceIsNull + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceIsNull +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + + SET_RETVAL(OCIRefIsNull(ref->con->env, ref->handle)) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceSetNull + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceSetNull +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + + CHECK(ReferenceUnpin(ref)) + + OCIRefClear(ref->con->env, ref->handle); + + if (NULL != ref->obj) + { + ObjectFree(ref->obj); + ref->obj = NULL; + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceToString + * --------------------------------------------------------------------------------------------- */ + +boolean ReferenceToString +( + OCI_Ref *ref, + unsigned int size, + otext *str +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_REF, ref + ) + + dbtext *dbstr = NULL; + int dbsize = (int) size * (int) sizeof(otext); + + CHECK_PTR(OCI_IPC_REF, ref) + CHECK_PTR(OCI_IPC_STRING, str) + + /* initialize output buffer in case of OCI failure */ + + str[0] = 0; + + dbstr = StringGetDBString(str, &dbsize); + + CHECK_OCI + ( + ref->con->err, + OCIRefToHex, + ref->con->env, ref->con->err, ref->handle, + (OraText *) dbstr, (ub4 *) &dbsize + ) + + StringCopyDBStringToNativeString(dbstr, str, dbcharcount(dbsize)); + + /* set null string terminator */ + + str[dbcharcount(dbsize)] = 0; + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) +} + +/* --------------------------------------------------------------------------------------------- * + * ReferenceGetHexSize + * --------------------------------------------------------------------------------------------- */ + +unsigned int ReferenceGetHexSize +( + OCI_Ref *ref +) +{ + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_REF, ref + ) + + CHECK_PTR(OCI_IPC_REF, ref) + + SET_RETVAL((unsigned int) OCIRefHexSize(ref->con->env, (const OCIRef*)ref->handle) / (ub4)sizeof(dbtext)) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * OCI_CollRefGetTypeInfo + * --------------------------------------------------------------------------------------------- */ + +OCI_TypeInfo * ReferenceGetTypeInfo +( + OCI_Ref *ref +) +{ + GET_PROP + ( + OCI_TypeInfo*, NULL, + OCI_IPC_REF, ref, + typinf + ) +} diff --git a/src/reference.h b/src/reference.h new file mode 100644 index 00000000..9d954a64 --- /dev/null +++ b/src/reference.h @@ -0,0 +1,105 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_REF_H_INCLUDED +#define OCILIB_REF_H_INCLUDED + +#include "types.h" + +OCI_Ref * ReferenceInitialize +( + OCI_Connection *con, + OCI_TypeInfo *typinf, + OCI_Ref *ref, + void *handle +); + +boolean ReferencePin +( + OCI_Ref* ref +); + +boolean ReferenceUnpin +( + OCI_Ref* ref +); + +OCI_Ref * ReferenceCreate +( + OCI_Connection *con, + OCI_TypeInfo *typinf +); + +boolean ReferenceFree +( + OCI_Ref *ref +); + +OCI_Ref ** ReferenceCreateArray +( + OCI_Connection *con, + OCI_TypeInfo *typinf, + unsigned int nbelem +); + +boolean ReferenceFreeArray +( + OCI_Ref **refs +); + +OCI_Object * ReferenceGetObject +( + OCI_Ref *ref +); + +boolean ReferenceAssign +( + OCI_Ref *ref, + OCI_Ref *ref_src +); + +boolean ReferenceIsNull +( + OCI_Ref *ref +); + +boolean ReferenceSetNull +( + OCI_Ref *ref +); + +boolean ReferenceToString +( + OCI_Ref *ref, + unsigned int size, + otext *str +); + +unsigned int ReferenceGetHexSize +( + OCI_Ref *ref +); + +OCI_TypeInfo * ReferenceGetTypeInfo +( + OCI_Ref *ref +); + +#endif /* OCILIB_REF_H_INCLUDED */ diff --git a/src/resultset.c b/src/resultset.c index 45895c8c..51adc40d 100644 --- a/src/resultset.c +++ b/src/resultset.c @@ -18,262 +18,314 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ - -static unsigned int SeekModeValues[] = { OCI_SFD_ABSOLUTE, OCI_SFD_RELATIVE }; - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -#define OCI_MATCHING_TYPE(def, type) \ - ((def) && OCI_DefineIsDataNotNull(def) && ((type) == (def)->col.datatype)) - - -#define OCI_GET_BY_NAME(rs, name, func, type, res) \ - int index = -1; \ - OCI_CALL_ENTER(type, res) \ - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) \ - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) \ - OCI_CALL_CONTEXT_SET_FROM_STMT((rs)->stmt) \ - OCI_STATUS = FALSE; \ - index = OCI_GetDefineIndex(rs, name); \ - if (index > 0) \ - { \ - if (!ctx->call_err) ctx->call_err = OCI_ErrorGet(FALSE, FALSE); \ - OCI_RETVAL = func(rs, (unsigned int) index); \ - OCI_STATUS = !ctx->call_err->raise; \ - } \ - OCI_CALL_EXIT() - - -#define OCI_GET_NUMBER(rs, index, num_type, type, res) \ - OCI_CALL_ENTER(type, res) \ - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) \ - OCI_CALL_CHECK_BOUND((rs)->stmt->con, index, 1, (rs)->nb_defs) \ - OCI_CALL_CONTEXT_SET_FROM_STMT((rs)->stmt) \ - OCI_STATUS = OCI_DefineGetNumber(rs, index, &OCI_RETVAL, num_type); \ - OCI_CALL_EXIT() - - -#define OCI_GET_HANDLE(rs, index, type, res, lib_type, func) \ - OCI_Define *def = NULL; \ - OCI_CALL_ENTER(type, res) \ - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) \ - OCI_CALL_CHECK_BOUND((rs)->stmt->con, index, 1, (rs)->nb_defs) \ - OCI_CALL_CONTEXT_SET_FROM_STMT((rs)->stmt) \ - OCI_STATUS = FALSE; \ - def = OCI_GetDefine(rs, index); \ - if (OCI_MATCHING_TYPE(def, lib_type)) \ - { \ - def->obj = OCI_RETVAL = func; \ - OCI_STATUS = (NULL != OCI_RETVAL); \ - } \ - OCI_CALL_EXIT() - -/* --------------------------------------------------------------------------------------------- * - * OCI_ResultsetCreate - * --------------------------------------------------------------------------------------------- */ - -OCI_Resultset * OCI_ResultsetCreate +#include "resultset.h" + +#include "collection.h" +#include "column.h" +#include "date.h" +#include "define.h" +#include "error.h" +#include "exception.h" +#include "file.h" +#include "hash.h" +#include "helpers.h" +#include "interval.h" +#include "lob.h" +#include "long.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "statement.h" +#include "strings.h" +#include "timestamp.h" + +static unsigned int SeekModeValues[] = +{ + OCI_SFD_ABSOLUTE, + OCI_SFD_RELATIVE +}; + +#define MATCHING_TYPE(def, type) \ + \ + ((def) && DefineIsDataNotNull(def) && ((type) == (def)->col.datatype)) + +#define GET_BY_NAME(rs, name, func, type, res) \ + \ + ENTER_FUNC(type, res, OCI_IPC_RESULTSET, rs) \ + \ + CHECK_PTR(OCI_IPC_RESULTSET, rs) \ + CHECK_PTR(OCI_IPC_STRING, name) \ + \ + int index = DefineGetIndex(rs, name); \ + CHECK(index >= 0) \ + \ + OCI_Error *err = ErrorGet(TRUE, TRUE); \ + \ + type tmp = func(rs, (unsigned int) index); \ + \ + CHECK_ERROR(err) \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +#define GET_NUMBER(rs, index, num_type, type, res) \ + \ + ENTER_FUNC(type, res, OCI_IPC_RESULTSET, rs) \ + \ + CHECK_PTR(OCI_IPC_RESULTSET, rs) \ + CHECK_BOUND(index, 1, (rs)->nb_defs) \ + \ + type tmp = res; \ + \ + CHECK(DefineGetNumber(rs, index, &tmp, num_type)) \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +#define GET_HANDLE(rs, index, type, res, lib_type, func) \ + \ + ENTER_FUNC(type, res, OCI_IPC_RESULTSET, rs) \ + \ + OCI_Define *def = NULL; \ + \ + CHECK_PTR(OCI_IPC_RESULTSET, rs) \ + CHECK_BOUND(index, 1, (rs)->nb_defs) \ + \ + def = DefineGet(rs, index); \ + CHECK_NULL(def) \ + \ + type tmp = res; \ + \ + if (MATCHING_TYPE(def, lib_type)) \ + { \ + def->obj = func; \ + CHECK_NULL(def->obj) \ + tmp = def->obj; \ + } \ + \ + SET_RETVAL(tmp) \ + \ + EXIT_FUNC() + +/* --------------------------------------------------------------------------------------------- * + * ResultsetCreate + * --------------------------------------------------------------------------------------------- */ + +OCI_Resultset * ResultsetCreate ( OCI_Statement *stmt, int size ) { - OCI_Resultset* rs = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Resultset*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(stmt == NULL, NULL) + OCI_Resultset* rs = NULL; - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) /* allocate resultset structure */ - OCI_ALLOCATE_DATA(OCI_IPC_RESULTSET, rs, 1) + ALLOC_DATA(OCI_IPC_RESULTSET, rs, 1) /* set attributes */ - if (OCI_STATUS) - { - ub4 nb = 0; - ub4 i; + ub4 nb = 0; + ub4 i; - rs->stmt = stmt; - rs->bof = TRUE; - rs->eof = FALSE; - rs->fetch_size = size; - rs->fetch_status = OCI_SUCCESS; - rs->row_count = 0; - rs->row_cur = 0; - rs->row_abs = 0; + rs->stmt = stmt; + rs->bof = TRUE; + rs->eof = FALSE; + rs->fetch_size = size; + rs->fetch_status = OCI_SUCCESS; + rs->row_count = 0; + rs->row_cur = 0; + rs->row_abs = 0; - /* is the resultset created from a SQL select statement ? */ + /* is the resultset created from a SQL select statement ? */ - if (OCI_CST_SELECT == stmt->type) - { - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_PARAM_COUNT, stmt->stmt, &nb, NULL) - } - else - { - nb = stmt->nb_rbinds; - } + if (OCI_CST_SELECT == stmt->type) + { + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_PARAM_COUNT, + stmt->stmt, &nb, NULL, + rs->stmt->con->err + ) + } + else + { + nb = stmt->nb_rbinds; + } - /* allocate columns array */ + /* allocate columns array */ - OCI_ALLOCATE_DATA(OCI_IPC_DEFINE, rs->defs, nb) + ALLOC_DATA(OCI_IPC_DEFINE, rs->defs, nb) - /* describe select list */ + /* describe select list */ - if (OCI_STATUS && (OCI_CST_SELECT == stmt->type)) - { - /* Compute columns information */ + if (OCI_CST_SELECT == stmt->type) + { + /* Compute columns information */ - for (i = 0; (i < nb) && OCI_STATUS; i++) - { - OCI_Define *def = &rs->defs[i]; + for (i = 0; i < nb; i++) + { + OCI_Define *def = &rs->defs[i]; - def->buf.count = size; - def->buf.sizelen = sizeof(ub2); + def->buf.count = size; + def->buf.sizelen = sizeof(ub2); - def->rs = rs; + def->rs = rs; - rs->nb_defs++; + rs->nb_defs++; - /* get column description */ + /* get column description */ - OCI_STATUS = OCI_ColumnDescribe(&def->col, rs->stmt->con, - rs->stmt, rs->stmt->stmt, - i + 1, OCI_DESC_RESULTSET); + CHECK(ColumnRetrieveInfo(&def->col, rs->stmt->con, + rs->stmt, rs->stmt->stmt, + i + 1, OCI_DESC_RESULTSET)) - /* mapping to OCILIB internal types */ + /* mapping to OCILIB internal types */ - OCI_STATUS = OCI_STATUS && OCI_ColumnMap(&def->col, rs->stmt); + CHECK(ColumnMapInfo(&def->col, rs->stmt)) - #if defined(OCI_STMT_SCROLLABLE_READONLY) +#if defined(OCI_STMT_SCROLLABLE_READONLY) - if (OCI_SFM_SCROLLABLE == rs->stmt->exec_mode) + if (OCI_SFM_SCROLLABLE == rs->stmt->exec_mode) + { + if (OCI_CDT_CURSOR == def->col.datatype) { - if (OCI_CDT_CURSOR == def->col.datatype) - { - rs->fetch_size = 1; - } + rs->fetch_size = 1; } + } - #endif +#endif - } + } - /* allocation internal buffers if needed */ + /* allocation internal buffers if needed */ - if (OCI_STATUS && !(rs->stmt->exec_mode & OCI_DESCRIBE_ONLY) && !(rs->stmt->exec_mode & OCI_PARSE_ONLY)) + if (!(rs->stmt->exec_mode & OCI_DESCRIBE_ONLY) && !(rs->stmt->exec_mode & OCI_PARSE_ONLY)) + { + for (i = 0; i < nb; i++) { - for (i = 0; (i < nb) && OCI_STATUS; i++) - { - OCI_Define *def = &rs->defs[i]; + OCI_Define *def = &rs->defs[i]; - /* allocation of internal buffers for resultset content and - register OCILIB result buffers to OCI */ + CHECK_NULL(def) - OCI_STATUS = OCI_DefineAlloc(def) && OCI_DefineDef(def, i + 1); - } + /* allocation of internal buffers for resultset content and + register OCILIB result buffers to OCI */ + + CHECK(DefineAlloc( def)) + CHECK(DefineDef(def, i + 1)) } } - else if (rs->defs) - { - /* get info from register binds */ + } + else if (NULL != rs->defs) + { + /* get info from register binds */ - for (i=0; i < stmt->nb_rbinds; i++) - { - OCI_Bind *bnd = stmt->rbinds[i]; - OCI_Define *def = &rs->defs[bnd->dynpos]; + for (i = 0; i < stmt->nb_rbinds; i++) + { + OCI_Bind *bnd = stmt->rbinds[i]; + OCI_Define *def = &rs->defs[bnd->dynpos]; - def->buf.count = size; - def->buf.sizelen = sizeof(ub4); + def->buf.count = size; + def->buf.sizelen = sizeof(ub4); - def->rs = rs; + def->rs = rs; - rs->nb_defs++; + rs->nb_defs++; - /* columns info */ + /* columns info */ - def->col.sqlcode = bnd->code; - def->col.libcode = bnd->code; - def->col.name = ostrdup(bnd->name); - def->col.size = (ub2) bnd->size; - def->col.datatype = bnd->type; - def->col.subtype = bnd->subtype; - def->col.typinf = bnd->typinf; + def->col.sqlcode = bnd->code; + def->col.libcode = bnd->code; + def->col.name = ostrdup(bnd->name); + def->col.size = (ub2) bnd->size; + def->col.datatype = bnd->type; + def->col.subtype = bnd->subtype; + def->col.typinf = bnd->typinf; - switch (def->col.datatype) + switch (def->col.datatype) + { + case OCI_CDT_LOB: { - case OCI_CDT_LOB: + /* check national attribute for national character large objects */ + if (OCI_NCLOB == def->col.subtype) { - /* check national attribute for national character large objects */ - if (OCI_NCLOB == def->col.subtype) - { - def->col.csfrm = SQLCS_NCHAR; - } - break; + def->col.csfrm = SQLCS_NCHAR; } - case OCI_CDT_TEXT: - { - /* adjust column size from bind attributes */ - def->col.size = (ub2) (def->col.size / ((ub2) sizeof(otext)) - 1); - break; - } - case OCI_CDT_NUMERIC: + break; + } + case OCI_CDT_TEXT: + { + /* adjust column size from bind attributes */ + def->col.size = (ub2) (def->col.size / ((ub2) sizeof(otext)) - 1); + break; + } + case OCI_CDT_NUMERIC: + { + /* for integer types, set the buffer size here in order to + retrieve later the integer type (short, integer, big_int) + depending on the integer size */ + def->col.bufsize = def->col.size; + break; + } + case OCI_CDT_DATETIME: + { + /* preset buffer size here to let OCI_ColumnMap() know we don't + want the column to mapped to SQLT_ODT */ + if (SQLT_DAT == def->col.sqlcode) { - /* for integer types, set the buffer size here in order to - retrieve later the integer type (short, integer, big_int) - depending on the integer size */ def->col.bufsize = def->col.size; - break; - } - case OCI_CDT_DATETIME: - { - /* preset buffer size here to let OCI_ColumnMap() know we don't - want the column to mapped to SQLT_ODT */ - if (SQLT_DAT == def->col.sqlcode) - { - def->col.bufsize = def->col.size; - } - break; } + break; } + } - /* map column and allocation of internal buffers for resultset content **/ + /* map column and allocation of internal buffers for resultset content **/ - OCI_STATUS = OCI_ColumnMap(&def->col, rs->stmt) && OCI_DefineAlloc(def); - } + CHECK(ColumnMapInfo(&def->col, rs->stmt)) + CHECK(DefineAlloc(def)) } } - if (!OCI_STATUS && rs) - { - OCI_ResultsetFree(rs); - rs = NULL; - } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ResultsetFree(rs); + rs = NULL; + } - return rs; + SET_RETVAL(rs) + ) } - /* --------------------------------------------------------------------------------------------- * - * OCI_ResultsetExpandStrings + * ResultsetExpandStrings * --------------------------------------------------------------------------------------------- */ -boolean OCI_ResultsetExpandStrings +boolean ResultsetExpandStrings ( OCI_Resultset *rs ) { - OCI_CHECK(NULL == rs, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) for (ub4 i = 0; i < rs->nb_defs; i++) { @@ -285,32 +337,36 @@ boolean OCI_ResultsetExpandStrings { ub1 * tmpbuf = ((ub1*) def->buf.data) + (def->col.bufsize * j); - OCI_StringUTF16ToUTF32(tmpbuf, tmpbuf, (def->col.bufsize / sizeof(otext) ) -1); + StringUTF16ToUTF32(tmpbuf, tmpbuf, (def->col.bufsize / sizeof(otext) ) -1); } } } - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchPieces + * FetchPieces * --------------------------------------------------------------------------------------------- */ -boolean OCI_FetchPieces +boolean FetchPieces ( OCI_Resultset *rs ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + ub4 type, dx; ub1 in_out; ub4 i, j; - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == rs, FALSE) - - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt); + CHECK_PTR(OCI_IPC_RESULTSET, rs) /* reset long objects */ @@ -322,14 +378,14 @@ boolean OCI_FetchPieces { for (j = 0; j < def->buf.count; j++) { - def->buf.data[j] = OCI_LongInit(rs->stmt, (OCI_Long *)def->buf.data[j], def, def->col.subtype); + def->buf.data[j] = LongInitialize(rs->stmt, (OCI_Long *)def->buf.data[j], def, def->col.subtype); } } } /* dynamic fetch */ - while (OCI_STATUS && (OCI_NEED_DATA == rs->fetch_status)) + while (OCI_NEED_DATA == rs->fetch_status) { ub1 piece = OCI_NEXT_PIECE; ub4 iter = 0; @@ -337,11 +393,18 @@ boolean OCI_FetchPieces /* get piece information */ - OCI_EXEC(OCIStmtGetPieceInfo(rs->stmt->stmt, rs->stmt->con->err, &handle, &type, &in_out, &iter, &dx, &piece)) + CHECK_OCI + ( + rs->stmt->con->err, + OCIStmtGetPieceInfo, + rs->stmt->stmt, rs->stmt->con->err, + &handle, &type, &in_out, + &iter, &dx, &piece + ) /* search for the given column */ - for (i = 0; OCI_STATUS && (i < rs->nb_defs); i++) + for (i = 0; i < rs->nb_defs; i++) { OCI_Define *def = &(rs->defs[i]); @@ -382,48 +445,48 @@ boolean OCI_FetchPieces { lg->maxsize = bufsize; - OCI_ALLOCATE_DATA(OCI_IPC_LONG_BUFFER, lg->buffer, lg->maxsize) + ALLOC_DATA(OCI_IPC_LONG_BUFFER, lg->buffer, lg->maxsize) } else if ((lg->size*char_fact) >= (lg->maxsize - trailing_size)) { lg->maxsize = (lg->size + trailing_size + bufsize) * char_fact; - lg->buffer = (ub1 *) OCI_MemRealloc(lg->buffer, (size_t) OCI_IPC_LONG_BUFFER, (size_t) lg->maxsize, 1, TRUE); + lg->buffer = (ub1 *) MemoryRealloc(lg->buffer, (size_t) OCI_IPC_LONG_BUFFER, + (size_t) lg->maxsize, 1, TRUE); } /* update piece info */ - if (OCI_STATUS) - { - lg->piecesize = bufsize; + lg->piecesize = bufsize; - if (OCI_CLONG == lg->type) - { - lg->piecesize /= sizeof(otext); - lg->piecesize *= sizeof(dbtext); - lg->piecesize -= (ub4) sizeof(dbtext); - } - - OCI_EXEC - ( - OCIStmtSetPieceInfo((dvoid *) handle, - (ub4) OCI_HTYPE_DEFINE, - lg->stmt->con->err, - (dvoid *) (lg->buffer + (size_t) lg->size), - &lg->piecesize, piece, - lg->def->buf.inds, (ub2 *) NULL) - ) + if (OCI_CLONG == lg->type) + { + lg->piecesize /= sizeof(otext); + lg->piecesize *= sizeof(dbtext); + lg->piecesize -= (ub4) sizeof(dbtext); } + CHECK_OCI + ( + rs->stmt->con->err, + OCIStmtSetPieceInfo, + (dvoid *) handle, + (ub4) OCI_HTYPE_DEFINE, + lg->stmt->con->err, + (dvoid *) (lg->buffer + (size_t) lg->size), + &lg->piecesize, piece, + lg->def->buf.inds, (ub2 *) NULL + ) + break; } } /* fetch data */ - #if defined(OCI_STMT_SCROLLABLE_READONLY) +#if defined(OCI_STMT_SCROLLABLE_READONLY) - if (OCILib.use_scrollable_cursors) + if (Env.use_scrollable_cursors) { rs->fetch_status = OCIStmtFetch2(rs->stmt->stmt, rs->stmt->con->err, rs->fetch_size, (ub2) OCI_FETCH_NEXT, @@ -431,7 +494,7 @@ boolean OCI_FetchPieces } else - #endif +#endif { rs->fetch_status = OCIStmtFetch(rs->stmt->stmt, rs->stmt->con->err, @@ -443,13 +506,11 @@ boolean OCI_FetchPieces if (OCI_ERROR == rs->fetch_status) { - OCI_ExceptionOCI(rs->stmt->con->err, rs->stmt->con, rs->stmt, FALSE); - OCI_STATUS = FALSE; + THROW(ExceptionOCI, rs->stmt->con->err, rs->fetch_status) } else if (OCI_SUCCESS_WITH_INFO == rs->fetch_status) { - OCI_ExceptionOCI(rs->stmt->con->err, rs->stmt->con, rs->stmt, TRUE); - OCI_STATUS = TRUE; + ExceptionOCI(&call_context, rs->stmt->con->err, rs->fetch_status); } else { @@ -487,29 +548,37 @@ boolean OCI_FetchPieces if (lg->buffer) { - const int len = (int) ( lg->size / sizeof(dbtext) ); + const int len = (int) ( lg->size / sizeof(dbtext) ); ((dbtext *)lg->buffer)[len] = 0; - if (OCILib.use_wide_char_conv) + if (Env.use_wide_char_conv) { - OCI_StringUTF16ToUTF32(lg->buffer, lg->buffer, len); + StringUTF16ToUTF32(lg->buffer, lg->buffer, len); } } } } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ClearFetchedObjectInstances + * ClearFetchedObjectInstances * --------------------------------------------------------------------------------------------- */ -boolean OCI_ClearFetchedObjectInstances(OCI_Resultset *rs) +boolean ClearFetchedObjectInstances(OCI_Resultset *rs) { - OCI_CHECK(NULL == rs, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) for (ub4 i = 0; i < rs->nb_defs; i++) { @@ -528,38 +597,39 @@ boolean OCI_ClearFetchedObjectInstances(OCI_Resultset *rs) } } - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchData + * FetchData * --------------------------------------------------------------------------------------------- */ -boolean OCI_FetchData +boolean FetchData ( OCI_Resultset *rs, int mode, - int offset, - boolean *success + int offset ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == rs, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt); + CHECK_PTR(OCI_IPC_RESULTSET, rs) /* let's initialize the success flag to FALSE until the process completes */ - *success = FALSE; - - OCI_ClearFetchedObjectInstances(rs); + CHECK(ClearFetchedObjectInstances(rs)) /* internal fetch */ - #if defined(OCI_STMT_SCROLLABLE_READONLY) +#if defined(OCI_STMT_SCROLLABLE_READONLY) - if (OCILib.use_scrollable_cursors) + if (Env.use_scrollable_cursors) { rs->fetch_status = OCIStmtFetch2(rs->stmt->stmt, rs->stmt->con->err, rs->fetch_size, (ub2) mode, (sb4) offset, @@ -575,108 +645,114 @@ boolean OCI_FetchData (ub4) OCI_DEFAULT); } - if (OCI_ERROR == rs->fetch_status) { /* failure */ - OCI_ExceptionOCI(rs->stmt->con->err, rs->stmt->con, rs->stmt, FALSE); - OCI_STATUS = FALSE; + THROW(ExceptionOCI, rs->stmt->con->err, rs->fetch_status) } else if (OCI_SUCCESS_WITH_INFO == rs->fetch_status) { - OCI_ExceptionOCI(rs->stmt->con->err, rs->stmt->con, rs->stmt, TRUE); - OCI_STATUS = TRUE; + ExceptionOCI(&call_context, rs->stmt->con->err, rs->fetch_status); } else if (OCI_NEED_DATA == rs->fetch_status) { /* need to do a piecewise fetch */ - OCI_STATUS = OCI_FetchPieces(rs); + CHECK(FetchPieces(rs)) } /* check string buffer for Unicode builds that need buffer expansion */ - if (OCILib.use_wide_char_conv) + if (Env.use_wide_char_conv) { - OCI_ResultsetExpandStrings(rs); + CHECK(ResultsetExpandStrings(rs)) } - /* check for success */ + /* update internal fetch status and variables */ - OCI_STATUS = (OCI_STATUS && ((OCI_SUCCESS == rs->fetch_status) || - (OCI_NO_DATA == rs->fetch_status) || - (OCI_SUCCESS_WITH_INFO == rs->fetch_status))); + ub4 row_count = 0; + ub4 row_fetched = 0; - /* update internal fetch status and variables */ +#if defined(OCI_STMT_SCROLLABLE_READONLY) - if (OCI_STATUS) + if (OCI_SFM_SCROLLABLE == rs->stmt->exec_mode) { - ub4 row_count = 0; - ub4 row_fetched = 0; + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_CURRENT_POSITION, + rs->stmt->stmt, &row_count, NULL, + rs->stmt->con->err + ) + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_ROWS_FETCHED, + rs->stmt->stmt, &row_fetched, NULL, + rs->stmt->con->err + ) + } + else - #if defined(OCI_STMT_SCROLLABLE_READONLY) +#endif - if (OCI_SFM_SCROLLABLE == rs->stmt->exec_mode) - { - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_CURRENT_POSITION, rs->stmt->stmt, &row_count, NULL) - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_ROWS_FETCHED, rs->stmt->stmt, &row_fetched, NULL) - } - else + { + row_count = StatementGetAffectedRows(rs->stmt); + row_fetched = row_count - rs->row_count; + } - #endif + if (rs->row_count < row_count) + { + rs->row_count = row_count; + } - { - row_count = OCI_GetAffectedRows(rs->stmt); - row_fetched = row_count - rs->row_count; - } + if (row_fetched > 0) + { + rs->row_fetched = row_fetched; + } - if (rs->row_count < row_count) - { - rs->row_count = row_count; - } + /* so far, no OCI error occurred, let's clear the error flag */ - if (row_fetched > 0) + /* check if internal fetch was successful */ + + if ((OCI_NO_DATA == rs->fetch_status) && (row_fetched == 0)) + { + if ((OCI_SFD_NEXT == mode) || (offset > 0)) { - rs->row_fetched = row_fetched; + rs->eof = TRUE; } - /* so far, no OCI error occurred, let's clear the error flag */ - - *success = TRUE; - - /* check if internal fetch was successful */ - - if ((OCI_NO_DATA == rs->fetch_status) && (row_fetched == 0)) + if (offset < 0) { - if ((OCI_SFD_NEXT == mode) || (offset > 0)) - { - rs->eof = TRUE; - } - - if (offset < 0) - { - rs->bof = TRUE; - } - - OCI_STATUS = FALSE; + rs->bof = TRUE; } + + CHECK(FALSE) } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchCustom + * FetchCustom * --------------------------------------------------------------------------------------------- */ -boolean OCI_FetchCustom +boolean FetchCustom ( OCI_Resultset *rs, int mode, - int offset, - boolean *err + int offset ) { - boolean res = TRUE; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + + boolean result = FALSE; switch (mode) { @@ -686,7 +762,7 @@ boolean OCI_FetchCustom ((offset < 0) && (rs->bof)) || (offset == 0)) { - res = FALSE; + result = FALSE; } else { @@ -695,9 +771,9 @@ boolean OCI_FetchCustom offset = offset - (int) (rs->row_fetched + rs->row_cur); rs->row_cur = 1; - res = OCI_FetchData(rs, mode, offset, err); + result = FetchData(rs, mode, offset); - if (res) + if (result) { rs->row_abs += offset_save; } @@ -709,16 +785,16 @@ boolean OCI_FetchCustom { if (offset == 0) { - res = FALSE; + result = FALSE; } else { rs->row_abs = 1; rs->row_cur = 1; - res = OCI_FetchData(rs, mode, offset, err); + result = FetchData(rs, mode, offset); - if (res) + if (result) { rs->row_abs = offset; @@ -731,21 +807,23 @@ boolean OCI_FetchCustom } default: { - res = FALSE; + result = FALSE; break; } } - return res; + SET_RETVAL(result) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ResultsetInit + * ResultsetInitialize * --------------------------------------------------------------------------------------------- */ -boolean OCI_ResultsetInit +boolean ResultsetInitialize ( -OCI_Resultset *rs + OCI_Resultset *rs ) { rs->bof = TRUE; @@ -760,17 +838,23 @@ OCI_Resultset *rs } /* --------------------------------------------------------------------------------------------- * - * OCI_ResultsetFree + * ResultsetFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_ResultsetFree +boolean ResultsetFree ( -OCI_Resultset *rs + OCI_Resultset *rs ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + ub4 j; - OCI_CHECK(NULL == rs, FALSE) + CHECK_PTR(OCI_IPC_RESULTSET, rs) for (ub4 i = 0; i < rs->nb_defs; i++) { @@ -786,12 +870,12 @@ OCI_Resultset *rs if (OCI_CDT_CURSOR == def->col.datatype) { - OCI_StatementClose((OCI_Statement *)def->obj); - OCI_FREE(def->obj) + StatementDispose((OCI_Statement *)def->obj); + FREE(def->obj) } else { - OCI_FreeObjectFromType(def->obj, def->col.datatype); + FreeObjectFromType(def->obj, def->col.datatype); } def->obj = NULL; @@ -807,13 +891,13 @@ OCI_Resultset *rs { for (j = 0; j < def->buf.count; j++) { - OCI_HandleFree((dvoid *)def->buf.data[j], (ub4)def->col.handletype); + MemoryFreeHandle((dvoid *)def->buf.data[j], (ub4)def->col.handletype); } } } else { - OCI_DescriptorArrayFree((dvoid *)def->buf.data, (ub4)def->col.handletype, (ub4)def->buf.count); + MemoryFreeDescriptorArray((dvoid *)def->buf.data, (ub4)def->col.handletype, (ub4)def->buf.count); } } @@ -827,295 +911,219 @@ OCI_Resultset *rs { ((OCI_Datatype *)def->buf.data[j])->hstate = OCI_OBJECT_FETCHED_DIRTY; - OCI_LongFree((OCI_Long *)def->buf.data[j]); + LongFree((OCI_Long *)def->buf.data[j]); } } } /* free object instances from object cache */ - OCI_ClearFetchedObjectInstances(rs); + ClearFetchedObjectInstances(rs); /* free column pointers */ - OCI_FREE(def->col.name) + FREE(def->col.name) /* free buffer pointers */ - OCI_FREE(def->buf.data) - OCI_FREE(def->buf.inds) - OCI_FREE(def->buf.obj_inds) - OCI_FREE(def->buf.lens) - OCI_FREE(def->buf.tmpbuf) + FREE(def->buf.data) + FREE(def->buf.inds) + FREE(def->buf.obj_inds) + FREE(def->buf.lens) + FREE(def->buf.tmpbuf) } /* free column map */ - if (rs->map) + if (NULL != rs->map) { - OCI_HashFree(rs->map); + HashFree(rs->map); } /* free defines (column array) */ - OCI_FREE(rs->defs) + FREE(rs->defs) - OCI_FREE(rs) + FREE(rs) - return TRUE; + EXIT_FUNC() } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_GetResultset + * ResultsetFetchPrev * --------------------------------------------------------------------------------------------- */ -OCI_Resultset * OCI_API OCI_GetResultset +boolean ResultsetFetchPrev ( - OCI_Statement *stmt + OCI_Resultset *rs ) { - OCI_CALL_ENTER(OCI_Resultset*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_DESCRIBED) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) - /* if the sql statement does not return a result, we just return NULL and not - throwing any exception - statements that can return a resultset are "SELECT..." and "... RETURNING INTO..." - */ + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) + CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) - if ((OCI_CST_SELECT == stmt->type) || (stmt->nb_rbinds > 0) || (stmt->nb_stmt > 0)) - { - /* if the resultset exists, let's use it */ +#if OCI_VERSION_COMPILE >= OCI_9_0 - if (stmt->rsts && stmt->rsts[0]) - { - OCI_RETVAL = stmt->rsts[0]; - } + CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) - /* allocate resultset for select statements only */ + CHECK(!rs->bof) - if (!OCI_RETVAL && (OCI_CST_SELECT == stmt->type)) + if (rs->row_cur == 1) + { + if (rs->row_abs == 1) + { + rs->bof = TRUE; + } + else { - /* allocate memory for one resultset handle */ + int offset = 0; - OCI_ALLOCATE_DATA(OCI_IPC_RESULTSET_ARRAY, stmt->rsts, 1) - - if (OCI_STATUS) + if (rs->fetch_size > rs->row_abs) { - stmt->nb_rs = 1; - stmt->cur_rs = 0; + offset = 1 - (int) rs->row_abs; + } + else + { + offset = 1 - (int) (rs->fetch_size + rs->row_fetched); + } - /* create resultset object */ + CHECK(FetchData(rs, OCI_SFD_RELATIVE, offset)) - OCI_RETVAL = stmt->rsts[0] = OCI_ResultsetCreate(stmt, stmt->fetch_size); + if (rs->fetch_size > rs->row_abs) + { + rs->row_cur = rs->row_abs-1; + } + else + { + rs->row_cur = rs->fetch_size; } + rs->row_abs--; } - - OCI_STATUS = (NULL != OCI_RETVAL); + } + else + { + rs->row_cur--; + rs->row_abs--; } - OCI_CALL_EXIT() -} + rs->eof = FALSE; -/* --------------------------------------------------------------------------------------------- * - * OCI_GetNextResultset - * --------------------------------------------------------------------------------------------- */ + CHECK(!rs->bof) -OCI_Resultset * OCI_API OCI_GetNextResultset -( - OCI_Statement *stmt -) -{ - OCI_CALL_ENTER(OCI_Resultset*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_DESCRIBED) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + SET_SUCCESS() - if (stmt->cur_rs < (stmt->nb_rs-1)) - { - OCI_RETVAL = stmt->rsts[++stmt->cur_rs]; - } +#endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchPrev + * ResultsetFetchNext * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FetchPrev +boolean ResultsetFetchNext ( OCI_Resultset *rs ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) -#if OCI_VERSION_COMPILE >= OCI_9_0 + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK(!rs->eof) - if (!rs->bof) + if (rs->stmt->nb_rbinds == 0) { - OCI_RETVAL = TRUE; + /* for regular resultsets */ - if (rs->row_cur == 1) + if (rs->row_cur == rs->row_fetched) { - if (rs->row_abs == 1) + if (OCI_NO_DATA == rs->fetch_status) { - rs->bof = TRUE; + rs->eof = TRUE; } else { - int offset = 0; + CHECK(FetchData(rs, OCI_SFD_NEXT, 0)) - if (rs->fetch_size > rs->row_abs) - { - offset = 1 - (int) rs->row_abs; - } - else - { - offset = 1 - (int) (rs->fetch_size + rs->row_fetched); - } - - OCI_RETVAL = OCI_FetchData(rs, OCI_SFD_RELATIVE, offset, &OCI_STATUS); - - if (OCI_RETVAL) - { - if (rs->fetch_size > rs->row_abs) - { - rs->row_cur = rs->row_abs-1; - } - else - { - rs->row_cur = rs->fetch_size; - } + rs->bof = FALSE; + rs->row_cur = 1; - rs->row_abs--; - } + rs->row_abs++; } } else { - rs->row_cur--; - rs->row_abs--; + rs->row_cur++; + rs->row_abs++; } - - rs->eof = FALSE; - - OCI_RETVAL = OCI_RETVAL && !rs->bof; } - -#endif - - OCI_CALL_EXIT() -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_FetchNext - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_API OCI_FetchNext -( - OCI_Resultset *rs -) -{ - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) - - if (!rs->eof) + else { - OCI_RETVAL = TRUE; + /* for resultset from returning into clause */ - if (rs->stmt->nb_rbinds == 0) + if (rs->row_abs == 0) { - /* for regular resultsets */ + /* check string buffer once for Unicode build */ - if (rs->row_cur == rs->row_fetched) + if (Env.use_wide_char_conv) { - if (OCI_NO_DATA == rs->fetch_status) - { - rs->eof = TRUE; - } - else - { - OCI_RETVAL = OCI_FetchData(rs, OCI_SFD_NEXT, 0, &OCI_STATUS); - - if (OCI_RETVAL) - { - rs->bof = FALSE; - rs->row_cur = 1; - - rs->row_abs++; - } - } - } - else - { - rs->row_cur++; - rs->row_abs++; + ResultsetExpandStrings(rs); } } + + if (rs->row_abs >= rs->row_count) + { + rs->eof = TRUE; + } else { - /* for resultset from returning into clause */ - - if (rs->row_abs == 0) - { - /* check string buffer once for Unicode build */ - - if (OCILib.use_wide_char_conv) - { - OCI_ResultsetExpandStrings(rs); - } - } - - if (rs->row_abs >= rs->row_count) - { - rs->eof = TRUE; - } - else - { - rs->row_cur++; - rs->row_abs++; - } + rs->row_cur++; + rs->row_abs++; } - - OCI_RETVAL = OCI_RETVAL && !rs->eof; } - OCI_CALL_EXIT() + CHECK(!rs->eof) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchFirst + * ResultsetFetchFirst * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FetchFirst +boolean ResultsetFetchFirst ( OCI_Resultset *rs ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) + CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) rs->bof = FALSE; rs->eof = FALSE; @@ -1123,31 +1131,41 @@ boolean OCI_API OCI_FetchFirst rs->row_abs = 1; rs->row_cur = 1; - OCI_RETVAL = (OCI_FetchData(rs, OCI_SFD_FIRST, 0, &OCI_STATUS) && !rs->bof); + CHECK(FetchData(rs, OCI_SFD_FIRST, 0)) + + CHECK(!rs->bof) + + SET_SUCCESS() #endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchLast + * ResultsetFetchLast * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FetchLast +boolean ResultsetFetchLast ( OCI_Resultset *rs ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) + CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) + + boolean result = FALSE; #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) rs->bof = FALSE; rs->eof = FALSE; @@ -1155,38 +1173,51 @@ boolean OCI_API OCI_FetchLast rs->row_abs = 0; rs->row_cur = 1; - OCI_RETVAL = (OCI_FetchData(rs, OCI_SFD_LAST, 0, &OCI_STATUS) && !rs->eof); + result = FetchData(rs, OCI_SFD_LAST, 0); + + if (result) + { + result = !rs->eof; + } rs->row_abs = rs->row_count; #endif - OCI_CALL_EXIT() + SET_RETVAL(result) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchSeek + * ResultsetFetchSeek * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_FetchSeek +boolean ResultsetFetchSeek ( OCI_Resultset *rs, unsigned int mode, int offset ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_STMT_STATUS(rs->stmt, OCI_STMT_EXECUTED) + CHECK_SCROLLABLE_CURSOR_ENABLED(rs->stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) - OCI_CALL_CHECK_ENUM_VALUE(rs->stmt->con, rs->stmt, mode, SeekModeValues, OTEXT("Fetch Seek Mode")) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) + CHECK_ENUM_VALUE(mode, SeekModeValues, OTEXT("Fetch Seek Mode")) + + CHECK(FetchCustom(rs, (int)mode, offset)) - OCI_RETVAL = OCI_FetchCustom(rs, (int)mode, offset, &OCI_STATUS); + SET_SUCCESS() #else @@ -1195,197 +1226,218 @@ boolean OCI_API OCI_FetchSeek #endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetRowCount + * ResultsetGetRowCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetRowCount +unsigned int ResultsetGetRowCount ( OCI_Resultset *rs ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_RESULTSET, rs, row_count, rs->stmt->con, rs->stmt, rs->stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_RESULTSET, rs, + row_count + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetRowCount + * ResultsetGetRowCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetCurrentRow +unsigned int ResultsetGetCurrentRow ( OCI_Resultset *rs ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_RESULTSET, rs, row_abs, rs->stmt->con, rs->stmt, rs->stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_RESULTSET, rs, + row_abs + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetColumnCount + * ResultsetGetColumnCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetColumnCount +unsigned int ResultsetGetColumnCount ( OCI_Resultset *rs ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_RESULTSET, rs, nb_defs, rs->stmt->con, rs->stmt, rs->stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_RESULTSET, rs, + nb_defs + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetColumn + * ResultsetGetColumn * --------------------------------------------------------------------------------------------- */ -OCI_Column * OCI_API OCI_GetColumn +OCI_Column * ResultsetGetColumn ( OCI_Resultset *rs, unsigned int index ) { - OCI_CALL_ENTER(OCI_Column*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + ENTER_FUNC + ( + /* returns */ OCI_Column*, NULL, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_BOUND(index, 1, rs->nb_defs) - OCI_RETVAL = &rs->defs[index - 1].col; + SET_RETVAL(&rs->defs[index - 1].col) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetColumn2 + * ResultsetGetColumn2 * --------------------------------------------------------------------------------------------- */ -OCI_Column * OCI_API OCI_GetColumn2 +OCI_Column * ResultsetGetColumn2 ( OCI_Resultset *rs, const otext *name ) { - int index = -1; - - OCI_CALL_ENTER(OCI_Column*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + ENTER_FUNC + ( + /* returns */ OCI_Column*, NULL, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_STRING, name) - index = OCI_GetDefineIndex(rs, name); + const int index = DefineGetIndex(rs, name); + CHECK(index >= 0) - if (index >= 0) - { - OCI_RETVAL = &rs->defs[index - 1].col; - OCI_STATUS = TRUE; - } + SET_RETVAL(&rs->defs[index - 1].col) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetColumnIndex + * ResultsetGetColumnIndex * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetColumnIndex +unsigned int ResultsetGetColumnIndex ( OCI_Resultset *rs, const otext *name ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_STRING, name) - OCI_STATUS = FALSE; + const int index = DefineGetIndex(rs, name); + CHECK(index >= 0) - index = OCI_GetDefineIndex(rs, name); + SET_RETVAL((unsigned int) index) - if (index >= 0) - { - OCI_RETVAL = (unsigned int) index; - OCI_STATUS = TRUE; - } - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetStructNumericType + * ResultsetSetStructNumericType * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetStructNumericType +boolean ResultsetSetStructNumericType ( OCI_Resultset *rs, unsigned int index, unsigned int type ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CHECK_COMPAT(rs->stmt->con, OCI_CDT_NUMERIC == rs->defs[index - 1].col.datatype); - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_BOUND(index, 1, rs->nb_defs) + CHECK_COMPAT(OCI_CDT_NUMERIC == rs->defs[index - 1].col.datatype); rs->defs[index-1].col.struct_subtype = (ub2) type; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SetStructNumericType2 + * ResultsetSetStructNumericType2 * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetStructNumericType2 +boolean ResultsetSetStructNumericType2 ( OCI_Resultset *rs, const otext *name, unsigned int type ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_STRING, name) - OCI_STATUS = FALSE; + const int index = DefineGetIndex(rs, name); + CHECK(index >= 0) - index = OCI_GetDefineIndex(rs, name); + CHECK(ResultsetSetStructNumericType(rs, (unsigned int)index, type)) - if (index >= 0) - { - OCI_RETVAL = OCI_STATUS = OCI_SetStructNumericType(rs, (unsigned int)index, type); - } + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetStruct + * ResultsetGetStruct * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_GetStruct +boolean ResultsetGetStruct ( OCI_Resultset *rs, void *row_struct, void *row_struct_ind ) { - char *ptr = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) + + char *ptr = NULL; boolean *inds = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, row_struct) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_VOID, row_struct) ptr = (char *) row_struct; inds = (boolean *) row_struct_ind; @@ -1402,23 +1454,23 @@ boolean OCI_API OCI_GetStruct { OCI_Define *def = &rs->defs[i - 1]; - const boolean is_not_null = OCI_DefineIsDataNotNull(def); + const boolean is_not_null = DefineIsDataNotNull(def); if (i == 1) { - OCI_ColumnGetAttrInfo(&def->col, rs->nb_defs, i - 1, &size1, &align); + ColumnGetAttributeInfo(&def->col, rs->nb_defs, i - 1, &size1, &align); } else { size1 = size2; - } + } - OCI_ColumnGetAttrInfo(&rs->defs[i].col, rs->nb_defs, i, &size2, &align); + ColumnGetAttributeInfo(&rs->defs[i].col, rs->nb_defs, i, &size2, &align); size += size1; size = ROUNDUP(size, align); - + memset(ptr, 0, size1); if (is_not_null) @@ -1433,69 +1485,69 @@ boolean OCI_API OCI_GetStruct type = def->col.subtype; } - OCI_DefineGetNumber(rs, i, ptr, type); + DefineGetNumber(rs, i, ptr, type); break; } case OCI_CDT_TEXT: { - *((otext **) ptr) = (otext * ) OCI_GetString(rs, i); + *((otext **) ptr) = (otext * ) ResultsetGetString(rs, i); break; } case OCI_CDT_RAW: { - *((void **) ptr) = OCI_DefineGetData(def); + *((void **) ptr) = DefineGetData(def); break; } case OCI_CDT_LONG: { - *((OCI_Long **) ptr) = OCI_GetLong(rs, i); + *((OCI_Long **) ptr) = ResultsetGetLong(rs, i); break; } case OCI_CDT_DATETIME: { - *((OCI_Date **) ptr) = OCI_GetDate(rs, i); + *((OCI_Date **) ptr) = ResultsetGetDate(rs, i); break; } case OCI_CDT_CURSOR: { - *((OCI_Statement **) ptr) = OCI_GetStatement(rs, i); + *((OCI_Statement **) ptr) = ResultsetGetStatement(rs, i); break; } case OCI_CDT_LOB: { - *((OCI_Lob **) ptr) = OCI_GetLob(rs, i); + *((OCI_Lob **) ptr) = ResultsetGetLob(rs, i); break; } case OCI_CDT_FILE: { - *((OCI_File **) ptr) = OCI_GetFile(rs, i); + *((OCI_File **) ptr) = ResultsetGetFile(rs, i); break; } case OCI_CDT_TIMESTAMP: { - *((OCI_Timestamp **) ptr) = OCI_GetTimestamp(rs, i); + *((OCI_Timestamp **) ptr) = ResultsetGetTimestamp(rs, i); break; } case OCI_CDT_INTERVAL: { - *((OCI_Interval **) ptr) = OCI_GetInterval(rs, i); + *((OCI_Interval **) ptr) = ResultsetGetInterval(rs, i); break; } case OCI_CDT_OBJECT: { - *((OCI_Object **) ptr) = OCI_GetObject(rs, i); + *((OCI_Object **) ptr) = ResultsetGetObject(rs, i); break; } case OCI_CDT_COLLECTION: { - *((OCI_Coll **) ptr) = OCI_GetColl(rs, i); + *((OCI_Coll **) ptr) = ResultsetGetColl(rs, i); break; } case OCI_CDT_REF: { - *((OCI_Ref **) ptr) = OCI_GetRef(rs, i); + *((OCI_Ref **) ptr) = ResultsetGetReference(rs, i); break; } } @@ -1512,228 +1564,231 @@ boolean OCI_API OCI_GetStruct } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_GetNumber +* ResultsetGetNumber * --------------------------------------------------------------------------------------------- */ -OCI_Number * OCI_API OCI_GetNumber +OCI_Number * ResultsetGetNumber ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( rs, index, OCI_Number *, NULL, OCI_CDT_NUMERIC, - OCI_NumberInit(rs->stmt->con, (OCI_Number *) def->obj, (OCINumber *) OCI_DefineGetData(def)) + NumberInitialize(rs->stmt->con, (OCI_Number *) def->obj, (OCINumber *) DefineGetData(def)) ) } -/* --------------------------------------------------------------------------------------------- * - * OCI_GetNumber2 +/* --------------------------------------------------------------------------------------------- * + * ResultsetGetNumber2 * --------------------------------------------------------------------------------------------- */ -OCI_Number * OCI_API OCI_GetNumber2 +OCI_Number * ResultsetGetNumber2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetNumber, OCI_Number *, NULL) + GET_BY_NAME(rs, name, ResultsetGetNumber, OCI_Number *, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetShort + * ResultsetGetShort * --------------------------------------------------------------------------------------------- */ -short OCI_API OCI_GetShort +short ResultsetGetShort ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_SHORT, short, 0) + GET_NUMBER(rs, index, OCI_NUM_SHORT, short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetShort2 + * ResultsetGetShort2 * --------------------------------------------------------------------------------------------- */ -short OCI_API OCI_GetShort2 +short ResultsetGetShort2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetShort, short, 0) + GET_BY_NAME(rs, name, ResultsetGetShort, short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUnsignedShort + * ResultsetGetUnsignedShort * --------------------------------------------------------------------------------------------- */ -unsigned short OCI_API OCI_GetUnsignedShort +unsigned short ResultsetGetUnsignedShort ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_USHORT, unsigned short, 0) + GET_NUMBER(rs, index, OCI_NUM_USHORT, unsigned short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUnsignedShort2 + * ResultsetGetUnsignedShort2 * --------------------------------------------------------------------------------------------- */ -unsigned short OCI_API OCI_GetUnsignedShort2 +unsigned short ResultsetGetUnsignedShort2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetUnsignedShort, unsigned short, 0) + GET_BY_NAME(rs, name, ResultsetGetUnsignedShort, unsigned short, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetInt + * ResultsetGetInt * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_GetInt +int ResultsetGetInt ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_INT, int, 0) + GET_NUMBER(rs, index, OCI_NUM_INT, int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetInt2 + * ResultsetGetInt2 * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_GetInt2 +int ResultsetGetInt2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetInt, int, 0) + GET_BY_NAME(rs, name, ResultsetGetInt, int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUnsignedInt + * ResultsetGetUnsignedInt * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetUnsignedInt +unsigned int ResultsetGetUnsignedInt ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_UINT, unsigned int, 0) + GET_NUMBER(rs, index, OCI_NUM_UINT, unsigned int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUnsignedInt2 + * ResultsetGetUnsignedInt2 * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetUnsignedInt2 +unsigned int ResultsetGetUnsignedInt2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetUnsignedInt, unsigned int, 0) + GET_BY_NAME(rs, name, ResultsetGetUnsignedInt, unsigned int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBigInt + * ResultsetGetBigInt * --------------------------------------------------------------------------------------------- */ -big_int OCI_API OCI_GetBigInt +big_int ResultsetGetBigInt ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_BIGINT, big_int, 0) + GET_NUMBER(rs, index, OCI_NUM_BIGINT, big_int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBigInt2 + * ResultsetGetBigInt2 * --------------------------------------------------------------------------------------------- */ -big_int OCI_API OCI_GetBigInt2 +big_int ResultsetGetBigInt2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetBigInt, big_int, 0) + GET_BY_NAME(rs, name, ResultsetGetBigInt, big_int, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUnsignedBigInt + * ResultsetGetUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_GetUnsignedBigInt +big_uint ResultsetGetUnsignedBigInt ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_BIGUINT, big_uint, 0) + GET_NUMBER(rs, index, OCI_NUM_BIGUINT, big_uint, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetUnsignedInt2 + * ResultsetGetUnsignedInt2 * --------------------------------------------------------------------------------------------- */ -big_uint OCI_API OCI_GetUnsignedBigInt2 +big_uint ResultsetGetUnsignedBigInt2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetUnsignedBigInt, big_uint, 0) + GET_BY_NAME(rs, name, ResultsetGetUnsignedBigInt, big_uint, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetString + * ResultsetGetString * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetString +const otext * ResultsetGetString ( OCI_Resultset *rs, unsigned int index ) { + ENTER_FUNC + ( + /* returns */ otext *, NULL, + /* context */ OCI_IPC_RESULTSET, rs + ) + OCI_Define *def = NULL; - OCI_CALL_ENTER(otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_BOUND(index, 1, rs->nb_defs) - OCI_STATUS = FALSE; + def = DefineGet(rs, index); + CHECK_NULL(def) - def = OCI_GetDefine(rs, index); + otext *result = NULL; - if (def && OCI_DefineIsDataNotNull(def)) + if (DefineIsDataNotNull(def)) { void *data = NULL; - OCI_STATUS = TRUE; - if (OCI_CDT_TEXT == def->col.datatype) { - OCI_RETVAL = (otext *)OCI_DefineGetData(def); + result = (otext *)DefineGetData(def); /* for long mapped to string, the zero terminal character is not always added by Oracle ? or OCILIB issue ? Anyway we check the @@ -1743,195 +1798,192 @@ const otext * OCI_API OCI_GetString { ub2* lens = (ub2 *)def->buf.lens; - OCI_RETVAL[lens[rs->row_cur - 1]] = 0; + result[lens[rs->row_cur - 1]] = 0; } } else if ((OCI_CDT_LONG == def->col.datatype) && (OCI_CLONG == def->col.subtype)) { - OCI_Long *lg = OCI_GetLong(rs, index); + OCI_Long *lg = ResultsetGetLong(rs, index); if (lg) { - OCI_RETVAL = (otext *)OCI_LongGetBuffer(lg); + result = (otext *)LongGetBuffer(lg); } } else { - OCI_Error *err = OCI_ErrorGet(TRUE, TRUE); + OCI_Error *err = ErrorGet(TRUE, TRUE); - unsigned int bufsize = OCI_SIZE_TMP_CVT; + unsigned int bufsize = OCI_SIZE_TMP_CVT; unsigned int data_size = 0; switch (def->col.datatype) { - case OCI_CDT_NUMERIC: - { - data = OCI_DefineGetData(def); - break; - } - case OCI_CDT_DATETIME: - { - data = OCI_GetDate(rs, index); - break; - } - case OCI_CDT_TIMESTAMP: - { - data = OCI_GetTimestamp(rs, index); - break; - } - case OCI_CDT_INTERVAL: - { - data = OCI_GetInterval(rs, index); - break; - } - case OCI_CDT_RAW: - { - data = OCI_DefineGetData(def); - data_size = ((ub2*)def->buf.lens)[def->rs->row_cur - 1]; - break; - } - case OCI_CDT_REF: - { - data = OCI_GetRef(rs, index); - break; - } - case OCI_CDT_LONG: - { - OCI_Long *lg = OCI_GetLong(rs, index); - - if (lg) + case OCI_CDT_NUMERIC: + { + data = DefineGetData(def); + break; + } + case OCI_CDT_DATETIME: + { + data = ResultsetGetDate(rs, index); + break; + } + case OCI_CDT_TIMESTAMP: + { + data = ResultsetGetTimestamp(rs, index); + break; + } + case OCI_CDT_INTERVAL: { - bufsize = OCI_LongGetSize(lg); + data = ResultsetGetInterval(rs, index); + break; + } + case OCI_CDT_RAW: + { + data = DefineGetData(def); + data_size = ((ub2*)def->buf.lens)[def->rs->row_cur - 1]; + break; + } + case OCI_CDT_REF: + { + data = ResultsetGetReference(rs, index); + break; + } + case OCI_CDT_LONG: + { + OCI_Long *lg = ResultsetGetLong(rs, index); - if (OCI_BLONG == def->col.subtype) + if (lg) { - /* here we have binary long, it will be output in hexadecimal */ - bufsize *= 2; - } - } + bufsize = LongGetSize(lg); - data = lg; - break; - } + if (OCI_BLONG == def->col.subtype) + { + /* here we have binary long, it will be output in hexadecimal */ + bufsize *= 2; + } + } - case OCI_CDT_LOB: - { - OCI_Lob *lob = OCI_GetLob(rs, index); + data = lg; + break; + } - if (lob) + case OCI_CDT_LOB: { - bufsize = (unsigned int)OCI_LobGetLength(lob); + OCI_Lob *lob = ResultsetGetLob(rs, index); - if (OCI_BLOB == def->col.subtype) + if (lob) { - /* here we have binary blob, it will be output in hexadecimal */ - bufsize *= 2; + bufsize = (unsigned int)LobGetLength(lob); + + if (OCI_BLOB == def->col.subtype) + { + /* here we have binary blob, it will be output in hexadecimal */ + bufsize *= 2; + } } + + data = lob; + break; } + case OCI_CDT_FILE: + { + /* directory / name will be output */ - data = lob; - break; - } - case OCI_CDT_FILE: - { - /* directory / name will be output */ + OCI_File * file = ResultsetGetFile(rs, index); - OCI_File * file = OCI_GetFile(rs, index); + if (file) + { + bufsize = (unsigned int) ostrlen(OTEXT("/")); - if (file) - { - bufsize = (unsigned int) ostrlen(OTEXT("/")); + FileGetInfo(file); - OCI_FileGetInfo(file); + bufsize += (unsigned int) (file->dir ? ostrlen(file->dir) : 0); + bufsize += (unsigned int) (file->name ? ostrlen(file->name) : 0); + } - bufsize += (unsigned int) (file->dir ? ostrlen(file->dir) : 0); - bufsize += (unsigned int) (file->name ? ostrlen(file->name) : 0); + data = file; + break; } + case OCI_CDT_OBJECT: + { + OCI_Object *obj = ResultsetGetObject(rs, index); - data = file; - break; - } - case OCI_CDT_OBJECT: - { - OCI_Object *obj = OCI_GetObject(rs, index); + if (obj) + { + CHECK(ObjectToString(obj, &bufsize, NULL)) + } - if (obj) - { - OCI_STATUS = OCI_ObjectToText(obj, &bufsize, NULL); + data = obj; + break; } + case OCI_CDT_COLLECTION: + { + OCI_Coll *coll = ResultsetGetColl(rs, index); - data = obj; - break; - } - case OCI_CDT_COLLECTION: - { - OCI_Coll *coll = OCI_GetColl(rs, index); + if (coll) + { + CHECK(CollectionToString(coll, &bufsize, NULL)) + } - if (coll) - { - OCI_STATUS = OCI_CollToText(coll, &bufsize, NULL); + data = coll; + break; } + case OCI_CDT_CURSOR: + { + OCI_Statement *stmt = ResultsetGetStatement(rs, index); - data = coll; - break; - } - case OCI_CDT_CURSOR: - { - OCI_Statement *stmt = OCI_GetStatement(rs, index); + if (stmt && stmt->sql) + { + bufsize = (unsigned int) ostrlen(stmt->sql); + } - if (stmt && stmt->sql) + data = stmt; + break; + } + default: { - bufsize = (unsigned int) ostrlen(stmt->sql); + break; } - - data = stmt; - break; - } - default: - { - break; - } } - OCI_STATUS = (NULL == err || OCI_UNKNOWN == err->type); + CHECK(NULL == err || OCI_UNKNOWN == err->type) - OCI_STATUS = OCI_STATUS && OCI_StringRequestBuffer(&def->buf.tmpbuf, &def->buf.tmpsize, bufsize); + CHECK(StringRequestBuffer(&def->buf.tmpbuf, &def->buf.tmpsize, bufsize)) - if (OCI_STATUS) - { - OCI_StringGetFromType(rs->stmt->con, &def->col, data, data_size, def->buf.tmpbuf, def->buf.tmpsize, FALSE); - - OCI_STATUS = (NULL == err || OCI_UNKNOWN == err->type); + CHECK(StringGetFromType(rs->stmt->con, &def->col, data, data_size, + def->buf.tmpbuf, def->buf.tmpsize, FALSE)) - if (OCI_STATUS) - { - OCI_RETVAL = def->buf.tmpbuf; - } - } + CHECK(NULL == err || OCI_UNKNOWN == err->type) + + result = def->buf.tmpbuf; } } - OCI_CALL_EXIT() + SET_RETVAL(result) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetString2 + * ResultsetGetString2 * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetString2 +const otext * ResultsetGetString2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetString, const otext *, NULL) + GET_BY_NAME(rs, name, ResultsetGetString, const otext *, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetRaw + * ResultsetGetRaw * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetRaw +unsigned int ResultsetGetRaw ( OCI_Resultset *rs, unsigned int index, @@ -1939,39 +1991,43 @@ unsigned int OCI_API OCI_GetRaw unsigned int len ) { - OCI_Define *def = NULL; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, buffer); - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_VOID, buffer); + CHECK_BOUND(index, 1, rs->nb_defs) - OCI_STATUS = TRUE; + OCI_Define*def = DefineGet(rs, index); + CHECK_NULL(def) - def = OCI_GetDefine(rs, index); + unsigned int result = 0; - if (OCI_MATCHING_TYPE(def, OCI_CDT_RAW)) + if (MATCHING_TYPE(def, OCI_CDT_RAW)) { unsigned int size = (unsigned int)(ub2)((ub2*)def->buf.lens)[def->rs->row_cur - 1]; - OCI_RETVAL = size < len ? size : len; - OCI_STATUS = TRUE; + result = size < len ? size : len; /* for RAWs, we copy the data in the destination buffer instead of returning internal buffer as we do for strings */ - memcpy(buffer, OCI_DefineGetData(def), (size_t)OCI_RETVAL); + memcpy(buffer, DefineGetData(def), (size_t)result); } - OCI_CALL_EXIT() + SET_RETVAL(result) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetRaw2 + * ResultsetGetRaw2 * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetRaw2 +unsigned int ResultsetGetRaw2 ( OCI_Resultset *rs, const otext *name, @@ -1979,572 +2035,580 @@ unsigned int OCI_API OCI_GetRaw2 unsigned int len ) { - OCI_Define *def = NULL; - int index = -1; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_VOID, buffer) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_VOID, buffer) + CHECK_PTR(OCI_IPC_STRING, name) - OCI_STATUS = FALSE; + const int index = DefineGetIndex(rs, name); + CHECK(index >= 0) - index = OCI_GetDefineIndex(rs, name); - if (index > 0) - { - def = OCI_GetDefine(rs, index); + OCI_Define*def = DefineGet(rs, index); + CHECK_NULL(def) - if (OCI_MATCHING_TYPE(def, OCI_CDT_RAW)) - { - unsigned int size = (unsigned int)(ub2)((ub2*)def->buf.lens)[def->rs->row_cur - 1]; + unsigned int result = 0; - OCI_RETVAL = size < len ? size : len; - OCI_STATUS = TRUE; + if (MATCHING_TYPE(def, OCI_CDT_RAW)) + { + unsigned int size = (unsigned int)(ub2)((ub2*)def->buf.lens)[def->rs->row_cur - 1]; - /* for RAWs, we copy the data in the destination buffer instead of - returning internal buffer as we do for strings */ + result = size < len ? size : len; - memcpy(buffer, OCI_DefineGetData(def), (size_t)OCI_RETVAL); - } + /* for RAWs, we copy the data in the destination buffer instead of + returning internal buffer as we do for strings */ + + memcpy(buffer, DefineGetData(def), (size_t)result); } - OCI_CALL_EXIT() + SET_RETVAL(result) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDouble + * ResultsetGetDouble * --------------------------------------------------------------------------------------------- */ -double OCI_API OCI_GetDouble +double ResultsetGetDouble ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_DOUBLE, double, 0.0) + GET_NUMBER(rs, index, OCI_NUM_DOUBLE, double, 0.0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDouble2 + * ResultsetGetDouble2 * --------------------------------------------------------------------------------------------- */ -double OCI_API OCI_GetDouble2 +double ResultsetGetDouble2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetDouble, double, 0.0) + GET_BY_NAME(rs, name, ResultsetGetDouble, double, 0.0) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetFloat + * ResultsetGetFloat * --------------------------------------------------------------------------------------------- */ -float OCI_API OCI_GetFloat +float ResultsetGetFloat ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_NUMBER(rs, index, OCI_NUM_FLOAT, float, 0.0f) + GET_NUMBER(rs, index, OCI_NUM_FLOAT, float, 0.0f) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetFloat2 + * ResultsetGetFloat2 * --------------------------------------------------------------------------------------------- */ -float OCI_API OCI_GetFloat2 +float ResultsetGetFloat2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetFloat, float, 0.0f) + GET_BY_NAME(rs, name, ResultsetGetFloat, float, 0.0f) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDate + * ResultsetGetDate * --------------------------------------------------------------------------------------------- */ -OCI_Date * OCI_API OCI_GetDate +OCI_Date * ResultsetGetDate ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( rs, index, OCI_Date *, NULL, OCI_CDT_DATETIME, - OCI_DateInit(rs->stmt->con, (OCI_Date *) def->obj, - (OCIDate *) OCI_DefineGetData(def), FALSE, - (SQLT_DAT == def->col.libcode)) + DateInitialize(rs->stmt->con, (OCI_Date *) def->obj, + (OCIDate *)DefineGetData(def), FALSE, + (SQLT_DAT == def->col.libcode)) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDate2 + * ResultsetGetDate2 * --------------------------------------------------------------------------------------------- */ -OCI_Date * OCI_API OCI_GetDate2 +OCI_Date * ResultsetGetDate2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetDate, OCI_Date *, NULL) + GET_BY_NAME(rs, name, ResultsetGetDate, OCI_Date *, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetTimestamp + * ResultsetGetTimestamp * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_API OCI_GetTimestamp +OCI_Timestamp * ResultsetGetTimestamp ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( rs, index, OCI_Timestamp *, NULL, OCI_CDT_TIMESTAMP, - OCI_TimestampInit(rs->stmt->con, (OCI_Timestamp *) def->obj, - (OCIDateTime *) OCI_DefineGetData(def), def->col.subtype) + TimestampInitialize(rs->stmt->con, (OCI_Timestamp *) def->obj, + (OCIDateTime *) DefineGetData(def), def->col.subtype) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetTimestamp2 + * ResultsetGetTimestamp2 * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_API OCI_GetTimestamp2 +OCI_Timestamp * ResultsetGetTimestamp2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetTimestamp, OCI_Timestamp*, NULL) + GET_BY_NAME(rs, name, ResultsetGetTimestamp, OCI_Timestamp*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetInterval + * ResultsetGetInterval * --------------------------------------------------------------------------------------------- */ -OCI_Interval * OCI_API OCI_GetInterval +OCI_Interval * ResultsetGetInterval ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Interval *, NULL, OCI_CDT_INTERVAL, + rs, index, OCI_Interval *, NULL, OCI_CDT_INTERVAL, - OCI_IntervalInit(rs->stmt->con, (OCI_Interval *) def->obj, - (OCIInterval *) OCI_DefineGetData(def), def->col.subtype) + IntervalInitialize(rs->stmt->con, (OCI_Interval *) def->obj, + (OCIInterval *) DefineGetData(def), def->col.subtype) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetInterval2 + * ResultsetGetInterval2 * --------------------------------------------------------------------------------------------- */ -OCI_Interval * OCI_API OCI_GetInterval2 +OCI_Interval * ResultsetGetInterval2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetInterval, OCI_Interval*, NULL) + GET_BY_NAME(rs, name, ResultsetGetInterval, OCI_Interval*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_Object + * ResultsetObject * --------------------------------------------------------------------------------------------- */ -OCI_Object * OCI_API OCI_GetObject +OCI_Object * ResultsetGetObject ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Object *, NULL, OCI_CDT_OBJECT, + rs, index, OCI_Object *, NULL, OCI_CDT_OBJECT, - OCI_ObjectInit(rs->stmt->con, (OCI_Object *) def->obj, - OCI_DefineGetData(def), def->col.typinf, - NULL, -1, TRUE) + ObjectInitialize(rs->stmt->con, (OCI_Object *) def->obj, + DefineGetData(def), def->col.typinf, + NULL, -1, TRUE) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetObject2 + * ResultsetGetObject2 * --------------------------------------------------------------------------------------------- */ -OCI_Object * OCI_API OCI_GetObject2 +OCI_Object * ResultsetGetObject2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetObject, OCI_Object*, NULL) + GET_BY_NAME(rs, name, ResultsetGetObject, OCI_Object*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetColl + * ResultsetGetColl * --------------------------------------------------------------------------------------------- */ -OCI_Coll * OCI_API OCI_GetColl +OCI_Coll * ResultsetGetColl ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Coll *, NULL, OCI_CDT_COLLECTION, + rs, index, OCI_Coll *, NULL, OCI_CDT_COLLECTION, - OCI_CollInit(rs->stmt->con, (OCI_Coll *) def->obj, OCI_DefineGetData(def), def->col.typinf) + CollectionInitialize(rs->stmt->con, (OCI_Coll *) def->obj, DefineGetData(def), def->col.typinf) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetColl2 + * ResultsetGetColl2 * --------------------------------------------------------------------------------------------- */ -OCI_Coll * OCI_API OCI_GetColl2 +OCI_Coll * ResultsetGetColl2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetColl, OCI_Coll*, NULL) + GET_BY_NAME(rs, name, ResultsetGetColl, OCI_Coll*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetRef + * ResultsetGetReference * --------------------------------------------------------------------------------------------- */ -OCI_Ref * OCI_API OCI_GetRef +OCI_Ref * ResultsetGetReference ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Ref *, NULL, OCI_CDT_REF, + rs, index, OCI_Ref *, NULL, OCI_CDT_REF, - OCI_RefInit(rs->stmt->con, def->col.typinf, (OCI_Ref *) def->obj, OCI_DefineGetData(def)) + ReferenceInitialize(rs->stmt->con, def->col.typinf, (OCI_Ref *) def->obj, DefineGetData(def)) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetRef2 + * ResultsetGetReference2 * --------------------------------------------------------------------------------------------- */ -OCI_Ref * OCI_API OCI_GetRef2 +OCI_Ref * ResultsetGetReference2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetRef, OCI_Ref*, NULL) + GET_BY_NAME(rs, name, ResultsetGetReference, OCI_Ref*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetStatement + * ResultsetGetStatement * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_API OCI_GetStatement +OCI_Statement * ResultsetGetStatement ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Statement *, NULL, OCI_CDT_CURSOR, + rs, index, OCI_Statement *, NULL, OCI_CDT_CURSOR, - OCI_StatementInit(rs->stmt->con,(OCI_Statement *) def->obj, - (OCIStmt *) OCI_DefineGetData(def), TRUE, def->col.name) + StatementInitialize(rs->stmt->con,(OCI_Statement *) def->obj, + (OCIStmt *) DefineGetData(def), TRUE, def->col.name) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetStatement2 + * ResultsetGetStatement2 * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_API OCI_GetStatement2 +OCI_Statement * ResultsetGetStatement2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetStatement, OCI_Statement*, NULL) + GET_BY_NAME(rs, name, ResultsetGetStatement, OCI_Statement*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLob + * ResultsetGetLob * --------------------------------------------------------------------------------------------- */ -OCI_Lob * OCI_API OCI_GetLob +OCI_Lob * ResultsetGetLob ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Lob *, NULL, OCI_CDT_LOB, + rs, index, OCI_Lob *, NULL, OCI_CDT_LOB, - OCI_LobInit(rs->stmt->con,(OCI_Lob *) def->obj, - (OCILobLocator *) OCI_DefineGetData(def), - def->col.subtype) + LobInitialize(rs->stmt->con,(OCI_Lob *) def->obj, + (OCILobLocator *) DefineGetData(def), + def->col.subtype) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLob2 + * ResultsetGetLob2 * --------------------------------------------------------------------------------------------- */ -OCI_Lob * OCI_API OCI_GetLob2 +OCI_Lob * ResultsetGetLob2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetLob, OCI_Lob*, NULL) + GET_BY_NAME(rs, name, ResultsetGetLob, OCI_Lob*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetFile + * ResultsetGetFile * --------------------------------------------------------------------------------------------- */ -OCI_File * OCI_API OCI_GetFile +OCI_File * ResultsetGetFile ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_File *, NULL, OCI_CDT_FILE, + rs, index, OCI_File *, NULL, OCI_CDT_FILE, - OCI_FileInit(rs->stmt->con, (OCI_File *) def->obj, - (OCILobLocator *) OCI_DefineGetData(def), - def->col.subtype) + FileInitialize(rs->stmt->con, (OCI_File *) def->obj, + (OCILobLocator *) DefineGetData(def), + def->col.subtype) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetFile2 + * ResultsetGetFile2 * --------------------------------------------------------------------------------------------- */ -OCI_File * OCI_API OCI_GetFile2 +OCI_File * ResultsetGetFile2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetFile, OCI_File*, NULL) + GET_BY_NAME(rs, name, ResultsetGetFile, OCI_File*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLong + * ResultsetGetLong * --------------------------------------------------------------------------------------------- */ -OCI_Long * OCI_API OCI_GetLong +OCI_Long * ResultsetGetLong ( OCI_Resultset *rs, unsigned int index ) { - OCI_GET_HANDLE + GET_HANDLE ( - rs, index, OCI_Long *, NULL, OCI_CDT_LONG, + rs, index, OCI_Long *, NULL, OCI_CDT_LONG, - (OCI_Long *) OCI_DefineGetData(def) + (OCI_Long *) DefineGetData(def) ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLong2 + * ResultsetGetLong2 * --------------------------------------------------------------------------------------------- */ -OCI_Long * OCI_API OCI_GetLong2 +OCI_Long * ResultsetGetLong2 ( OCI_Resultset *rs, const otext *name ) { - OCI_GET_BY_NAME(rs, name, OCI_GetLong, OCI_Long*, NULL) + GET_BY_NAME(rs, name, ResultsetGetLong, OCI_Long*, NULL) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDataSize + * ResultsetGetDataSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetDataSize +unsigned int ResultsetGetDataSize ( OCI_Resultset *rs, unsigned int index ) { - OCI_Define *def = NULL; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_RESULTSET, rs + ) + + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_BOUND(index, 1, rs->nb_defs) - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) - - def = OCI_GetDefine(rs, index); + OCI_Define* def = DefineGet(rs, index); + CHECK_NULL(def) - if (def && OCI_DefineIsDataNotNull(def)) + unsigned int size = 0; + + if (DefineIsDataNotNull(def)) { ub2* lens = (ub2 *)def->buf.lens; if (lens) { - OCI_RETVAL = lens[rs->row_cur - 1]; + size = lens[rs->row_cur - 1]; if (OCI_CDT_TEXT == def->col.datatype) { - OCI_RETVAL /= sizeof(otext); + size /= sizeof(otext); } } } - OCI_CALL_EXIT() + SET_RETVAL(size) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDataSize2 + * ResultsetGetDataSize2 * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetDataSize2 +unsigned int ResultsetGetDataSize2 ( OCI_Resultset *rs, const otext *name ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_STRING, name) - OCI_STATUS = FALSE; + const int index = DefineGetIndex(rs, name); + CHECK(index >= 0) - index = OCI_GetDefineIndex(rs, name); + SET_RETVAL(ResultsetGetDataSize(rs, (unsigned int)index)) - if (index >= 0) - { - OCI_RETVAL = OCI_GetDataSize(rs, (unsigned int)index); - OCI_STATUS = TRUE; - } - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IsNull + * ResultsetIsNull * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IsNull +boolean ResultsetIsNull ( OCI_Resultset *rs, unsigned int index ) { - OCI_Define *def = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(boolean, TRUE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_BOUND(index, 1, rs->nb_defs) - def = OCI_GetDefine(rs, index); + OCI_Define *def = DefineGet(rs, index); + CHECK_NULL(def) - OCI_STATUS = (NULL != def); - OCI_RETVAL = !OCI_DefineIsDataNotNull(def); + SET_RETVAL(!DefineIsDataNotNull(def)) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_IsNull2 + * ResultsetIsNull2 * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IsNull2 +boolean ResultsetIsNull2 ( OCI_Resultset *rs, const otext *name ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ boolean, TRUE, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_CALL_ENTER(boolean, TRUE) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_PTR(OCI_IPC_STRING, name) - OCI_STATUS = FALSE; + const int index = DefineGetIndex(rs, name); + CHECK(index >= 0) - index = OCI_GetDefineIndex(rs, name); + SET_RETVAL(ResultsetIsNull(rs, (unsigned int)index)) - if (index >= 0) - { - OCI_RETVAL = OCI_IsNull(rs, (unsigned int)index); - OCI_STATUS = TRUE; - } - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ResultsetGetStatement + * ResultsetResultsetGetStatement * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_API OCI_ResultsetGetStatement +OCI_Statement * ResultsetResultsetGetStatement ( OCI_Resultset *rs ) { - OCI_GET_PROP(OCI_Statement *, NULL, OCI_IPC_RESULTSET, rs, stmt, rs->stmt->con, rs->stmt, rs->stmt->con->err) + GET_PROP + ( + OCI_Statement *, NULL, + OCI_IPC_RESULTSET, rs, + stmt + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetDataLength + * ResultsetGetDataLength * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetDataLength +unsigned int ResultsetGetDataLength ( OCI_Resultset *rs, unsigned int index ) { - OCI_Define *def = NULL; - - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_RESULTSET, rs) - OCI_CALL_CHECK_BOUND(rs->stmt->con, index, 1, rs->nb_defs) - OCI_CALL_CONTEXT_SET_FROM_STMT(rs->stmt) + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_RESULTSET, rs + ) - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_RESULTSET, rs) + CHECK_BOUND(index, 1, rs->nb_defs) - def = OCI_GetDefine(rs, index); + OCI_Define *def = DefineGet(rs, index); + CHECK_NULL(def) + CHECK(rs->row_cur > 0) - if (def && (rs->row_cur > 0)) - { - OCI_RETVAL = (unsigned int)((ub2 *)def->buf.lens)[rs->row_cur - 1]; - OCI_STATUS = TRUE; - } + SET_RETVAL((unsigned int)((ub2 *)def->buf.lens)[rs->row_cur - 1]) - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/resultset.h b/src/resultset.h new file mode 100644 index 00000000..150a646a --- /dev/null +++ b/src/resultset.h @@ -0,0 +1,414 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_RESULTSET_H_INCLUDED +#define OCILIB_RESULTSET_H_INCLUDED + +#include "types.h" + +boolean ResultsetInitialize +( + OCI_Resultset* rs +); + +OCI_Resultset* ResultsetCreate +( + OCI_Statement * stmt, + int size +); + +boolean ResultsetFree +( + OCI_Resultset* rs +); + +boolean ResultsetFetchPrev +( + OCI_Resultset* rs +); + +boolean ResultsetFetchNext +( + OCI_Resultset* rs +); + +boolean ResultsetFetchFirst +( + OCI_Resultset* rs +); + +boolean ResultsetFetchLast +( + OCI_Resultset* rs +); + +boolean ResultsetFetchSeek +( + OCI_Resultset* rs, + unsigned int mode, + int offset +); + +unsigned int ResultsetGetRowCount +( + OCI_Resultset* rs +); + +unsigned int ResultsetGetCurrentRow +( + OCI_Resultset* rs +); + +unsigned int ResultsetGetColumnCount +( + OCI_Resultset* rs +); + +OCI_Column* ResultsetGetColumn +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Column* ResultsetGetColumn2 +( + OCI_Resultset* rs, + const otext * name +); + +unsigned int ResultsetGetColumnIndex +( + OCI_Resultset* rs, + const otext * name +); + +boolean ResultsetSetStructNumericType +( + OCI_Resultset* rs, + unsigned int index, + unsigned int type +); + +boolean ResultsetSetStructNumericType2 +( + OCI_Resultset* rs, + const otext * name, + unsigned int type +); + +boolean ResultsetGetStruct +( + OCI_Resultset* rs, + void * row_struct, + void * row_struct_ind +); + +OCI_Number* ResultsetGetNumber +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Number* ResultsetGetNumber2 +( + OCI_Resultset* rs, + const otext * name +); + +short ResultsetGetShort +( + OCI_Resultset* rs, + unsigned int index +); + +short ResultsetGetShort2 +( + OCI_Resultset* rs, + const otext * name +); + +unsigned short ResultsetGetUnsignedShort +( + OCI_Resultset* rs, + unsigned int index +); + +unsigned short ResultsetGetUnsignedShort2 +( + OCI_Resultset* rs, + const otext * name +); + +int ResultsetGetInt +( + OCI_Resultset* rs, + unsigned int index +); + +int ResultsetGetInt2 +( + OCI_Resultset* rs, + const otext * name +); + +unsigned int ResultsetGetUnsignedInt +( + OCI_Resultset* rs, + unsigned int index +); + +unsigned int ResultsetGetUnsignedInt2 +( + OCI_Resultset* rs, + const otext * name +); + +big_int ResultsetGetBigInt +( + OCI_Resultset* rs, + unsigned int index +); + +big_int ResultsetGetBigInt2 +( + OCI_Resultset* rs, + const otext * name +); + +big_uint ResultsetGetUnsignedBigInt +( + OCI_Resultset* rs, + unsigned int index +); + +big_uint ResultsetGetUnsignedBigInt2 +( + OCI_Resultset* rs, + const otext * name +); + +const otext* ResultsetGetString +( + OCI_Resultset* rs, + unsigned int index +); + +const otext* ResultsetGetString2 +( + OCI_Resultset* rs, + const otext * name +); + +unsigned int ResultsetGetRaw +( + OCI_Resultset* rs, + unsigned int index, + void * buffer, + unsigned int len +); + +unsigned int ResultsetGetRaw2 +( + OCI_Resultset* rs, + const otext * name, + void * buffer, + unsigned int len +); + +double ResultsetGetDouble +( + OCI_Resultset* rs, + unsigned int index +); + +double ResultsetGetDouble2 +( + OCI_Resultset* rs, + const otext * name +); + +float ResultsetGetFloat +( + OCI_Resultset* rs, + unsigned int index +); + +float ResultsetGetFloat2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Date* ResultsetGetDate +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Date* ResultsetGetDate2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Timestamp* ResultsetGetTimestamp +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Timestamp* ResultsetGetTimestamp2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Interval* ResultsetGetInterval +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Interval* ResultsetGetInterval2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Object* ResultsetGetObject +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Object* ResultsetGetObject2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Coll* ResultsetGetColl +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Coll* ResultsetGetColl2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Ref* ResultsetGetReference +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Ref* ResultsetGetReference2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Statement* ResultsetGetStatement +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Statement* ResultsetGetStatement2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Lob* ResultsetGetLob +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Lob* ResultsetGetLob2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_File* ResultsetGetFile +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_File* ResultsetGetFile2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Long* ResultsetGetLong +( + OCI_Resultset* rs, + unsigned int index +); + +OCI_Long* ResultsetGetLong2 +( + OCI_Resultset* rs, + const otext * name +); + +unsigned int ResultsetGetDataSize +( + OCI_Resultset* rs, + unsigned int index +); + +unsigned int ResultsetGetDataSize2 +( + OCI_Resultset* rs, + const otext * name +); + +boolean ResultsetIsNull +( + OCI_Resultset* rs, + unsigned int index +); + +boolean ResultsetIsNull2 +( + OCI_Resultset* rs, + const otext * name +); + +OCI_Statement* ResultsetResultsetGetStatement +( + OCI_Resultset* rs +); + +unsigned int ResultsetGetDataLength +( + OCI_Resultset* rs, + unsigned int index +); + +#endif /* OCILIB_RESULTSET_H_INCLUDED */ diff --git a/src/statement.c b/src/statement.c index 366ecd9d..86e3cd87 100644 --- a/src/statement.c +++ b/src/statement.c @@ -18,210 +18,283 @@ * limitations under the License. */ -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "statement.h" + +#include "bind.h" +#include "collection.h" +#include "connection.h" +#include "date.h" +#include "error.h" +#include "exception.h" +#include "file.h" +#include "format.h" +#include "hash.h" +#include "helpers.h" +#include "interval.h" +#include "list.h" +#include "lob.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "resultset.h" +#include "strings.h" +#include "timestamp.h" #if OCI_VERSION_COMPILE >= OCI_9_0 -static unsigned int TimestampTypeValues[] = { OCI_TIMESTAMP, OCI_TIMESTAMP_TZ, OCI_TIMESTAMP_LTZ }; -static unsigned int IntervalTypeValues[] = { OCI_INTERVAL_YM, OCI_INTERVAL_DS }; -#endif -static unsigned int LobTypeValues[] = { OCI_CLOB, OCI_NCLOB, OCI_BLOB }; -static unsigned int FileTypeValues[] = { OCI_CFILE, OCI_BFILE }; - -static unsigned int FetchModeValues[] = { OCI_SFM_DEFAULT, OCI_SFM_SCROLLABLE }; -static unsigned int BindModeValues[] = { OCI_BIND_BY_POS, OCI_BIND_BY_NAME }; -static unsigned int BindAllocationValues[] = { OCI_BAM_EXTERNAL, OCI_BAM_INTERNAL }; -static unsigned int LongModeValues[] = { OCI_LONG_EXPLICIT, OCI_LONG_IMPLICIT }; - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -#define SET_ARG_NUM(type, func) \ - type src = func(rs, i), *dst = ( type *) va_arg(args, type *); \ - if (dst) \ - { \ - *dst = src; \ - } \ - -#define SET_ARG_HANDLE(type, func, assign) \ - type *src = func(rs, i), *dst = (type *) va_arg(args, type *); \ - if (src && dst) \ - { \ - res = assign(dst, src); \ - } \ - -#define OCI_BIND_DATA(...) \ - OCI_STATUS = OCI_BindCreate(ctx, stmt, data, name, OCI_BIND_INPUT, __VA_ARGS__) != NULL; \ - -#define OCI_REGISTER_DATA(...) \ - OCI_STATUS = OCI_BindCreate(ctx, stmt, NULL, name, OCI_BIND_OUTPUT, __VA_ARGS__) != NULL; \ - - -#define OCI_BIND_CALL(type, check, ...) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_BIND(stmt, name, data, type, check) \ - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) \ - OCI_BIND_DATA(__VA_ARGS__) \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() \ - -#define OCI_BIND_CALL_NULL_ALLOWED(type, ...) \ - OCI_BIND_CALL(type, FALSE, __VA_ARGS__) - -#define OCI_BIND_CALL_NULL_FORBIDDEN(type, ...) \ - OCI_BIND_CALL(type, TRUE, __VA_ARGS__) +static unsigned int TimestampTypeValues[] = +{ + OCI_TIMESTAMP, + OCI_TIMESTAMP_TZ, OCI_TIMESTAMP_LTZ +}; -#define OCI_REGISTER_CALL(...) \ - \ - OCI_CALL_ENTER(boolean, FALSE) \ - OCI_CALL_CHECK_REGISTER(stmt, name) \ - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) \ - OCI_REGISTER_DATA(__VA_ARGS__) \ - OCI_RETVAL = OCI_STATUS; \ - OCI_CALL_EXIT() \ +static unsigned int IntervalTypeValues[] = +{ + OCI_INTERVAL_YM, + OCI_INTERVAL_DS +}; -#define OCI_BIND_GET_SCALAR(s, t, i) (bnd->is_array ? ((t *) (s)) + (i) : (t *) (s)) -#define OCI_BIND_GET_HANDLE(s, t, i) (bnd->is_array ? ((t **) (s))[i] : (t *) (s)) -#define OCI_BIND_GET_BUFFER(d, t, i) ((t *)((d) + (i) * sizeof(t))) +#endif -/* --------------------------------------------------------------------------------------------- * - * OCI_BindGetInternalIndex - * --------------------------------------------------------------------------------------------- */ +static unsigned int LobTypeValues[] = +{ + OCI_CLOB, + OCI_NCLOB, OCI_BLOB +}; -int OCI_BindGetInternalIndex -( - OCI_Statement *stmt, - const otext *name -) +static unsigned int FileTypeValues[] = { - OCI_HashEntry *he = NULL; - int index = -1; + OCI_CFILE, + OCI_BFILE +}; - if (stmt->map) - { - he = OCI_HashLookup(stmt->map, name, FALSE); +static unsigned int FetchModeValues[] = +{ + OCI_SFM_DEFAULT, + OCI_SFM_SCROLLABLE +}; - while (he) - { - /* no more entries or key matched => so we got it ! */ +static unsigned int BindModeValues[] = +{ + OCI_BIND_BY_POS, + OCI_BIND_BY_NAME +}; - if (!he->next || ostrcasecmp(he->key, name) == 0) - { - /* in order to use the same map for user binds and - register binds : - - user binds are stored as positive values - - registers binds are stored as negatives values - */ +static unsigned int BindAllocationValues[] = +{ + OCI_BAM_EXTERNAL, + OCI_BAM_INTERNAL +}; - index = he->values->value.num; +static unsigned int LongModeValues[] = +{ + OCI_LONG_EXPLICIT, + OCI_LONG_IMPLICIT +}; + +#define CHECK_BIND(stmt, name, data, type, ext_only) \ + \ + CHECK_PTR(OCI_IPC_STATEMENT, stmt) \ + CHECK_PTR(OCI_IPC_STRING, name) \ + CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) \ + { \ + const boolean ext_only_value = (ext_only); \ + if ((ext_only_value) && \ + (OCI_BAM_INTERNAL == (stmt)->bind_alloc_mode) && \ + ((data) != NULL)) \ + { \ + THROW(ExceptionExternalBindingNotAllowed, (name)) \ + } \ + \ + if ((ext_only_value) || OCI_BAM_EXTERNAL == (stmt)->bind_alloc_mode) \ + { \ + CHECK_PTR(type, data) \ + } \ + } \ + +#define CHECK_REGISTER(stmt, name) \ + \ + CHECK_PTR(OCI_IPC_STATEMENT, stmt) \ + CHECK_PTR(OCI_IPC_STRING, name) \ + + +#define SET_ARG_NUM(type, func) \ + \ + type src = func(rs, i), *dst = ( type *) va_arg(args, type *); \ + if (dst) \ + { \ + *dst = src; \ + } \ + +#define SET_ARG_HANDLE(type, func, assign) \ + \ + type *src = func(rs, i), *dst = (type *) va_arg(args, type *); \ + if (src && dst) \ + { \ + res = assign(dst, src); \ + } \ + +#define BIND_DATA(...) \ + \ + CHECK_NULL(BindCreate(stmt, data, name, \ + OCI_BIND_INPUT, __VA_ARGS__)) \ + +#define REGISTER_DATA(...) \ + \ + CHECK_NULL(BindCreate(stmt, NULL, name, \ + OCI_BIND_OUTPUT, __VA_ARGS__)) \ + + +#define OCI_BIND_CALL(type, check, ...) \ + \ + ENTER_FUNC(boolean, FALSE, OCI_IPC_STATEMENT, stmt) \ + \ + CHECK_BIND(stmt, name, data, type, check) \ + \ + BIND_DATA(__VA_ARGS__) \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() \ + +#define BIND_CALL_NULL_ALLOWED(type, ...) \ + \ + OCI_BIND_CALL(type, FALSE, __VA_ARGS__) - if (index < 0) - { - index = -index; - } +#define BIND_CALL_NULL_FORBIDDEN(type, ...) \ + \ + OCI_BIND_CALL(type, TRUE, __VA_ARGS__) - break; - } - } - } +#define REGISTER_CALL(...) \ + \ + ENTER_FUNC(boolean, FALSE, OCI_IPC_STATEMENT, stmt) \ + \ + CHECK_REGISTER(stmt, name) \ + \ + REGISTER_DATA(__VA_ARGS__) \ + \ + SET_SUCCESS() \ + \ + EXIT_FUNC() \ - return index; -} +#define OCI_BIND_GET_SCALAR(s, t, i) (bnd->is_array ? ((t *) (s)) + (i) : (t *) (s)) +#define OCI_BIND_GET_HANDLE(s, t, i) (bnd->is_array ? ((t **) (s))[i] : (t *) (s)) +#define OCI_BIND_GET_BUFFER(d, t, i) ((t *)((d) + (i) * sizeof(t))) /* --------------------------------------------------------------------------------------------- * - * OCI_BatchErrorClear + * StatementBatchErrorClear * --------------------------------------------------------------------------------------------- */ -boolean OCI_BatchErrorClear +boolean StatementBatchErrorClear ( OCI_Statement *stmt ) { - if (stmt->batch) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + if (NULL != stmt->batch) { /* free internal array of OCI_Errors */ - OCI_FREE(stmt->batch->errs) + FREE(stmt->batch->errs) /* free batch structure */ - OCI_FREE(stmt->batch) + FREE(stmt->batch) } - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindFreeAll + * StatementFreeAllBinds * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindFreeAll +boolean StatementFreeAllBinds ( OCI_Statement *stmt ) { - int i; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CHECK(NULL == stmt, FALSE); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + int i; /* free user binds */ - if (stmt->ubinds) + if (NULL != stmt->ubinds) { for(i = 0; i < stmt->nb_ubinds; i++) { - OCI_BindFree(stmt->ubinds[i]); + BindFree(stmt->ubinds[i]); } - OCI_FREE(stmt->ubinds) + FREE(stmt->ubinds) } /* free register binds */ - if (stmt->rbinds) + if (NULL != stmt->rbinds) { for(i = 0; i < stmt->nb_rbinds; i++) { - OCI_BindFree(stmt->rbinds[i]); + BindFree(stmt->rbinds[i]); } - OCI_FREE(stmt->rbinds) + FREE(stmt->rbinds) } stmt->nb_ubinds = 0; stmt->nb_rbinds = 0; - return TRUE; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_StatementReset + * StatementReset * --------------------------------------------------------------------------------------------- */ -boolean OCI_StatementReset +boolean StatementReset ( OCI_Statement *stmt ) { - ub4 mode = OCI_DEFAULT; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + ub4 mode = OCI_DEFAULT; #if OCI_VERSION_COMPILE >= OCI_9_2 - if ((OCILib.version_runtime >= OCI_9_2) && (stmt->nb_rbinds > 0)) + if ((Env.version_runtime >= OCI_9_2) && (stmt->nb_rbinds > 0)) { /* if we had registered binds, we must delete the statement from the cache. Because, if we execute another sql with "returning into clause", OCI_ProcInBind won't be called by OCI. Nice Oracle bug ! */ - const unsigned int cache_size = OCI_GetStatementCacheSize(stmt->con); + const unsigned int cache_size = ConnectionGetStatementCacheSize(stmt->con); if (cache_size > 0) { @@ -229,7 +302,6 @@ boolean OCI_StatementReset } } - #else OCI_NOT_USED(mode) @@ -238,89 +310,93 @@ boolean OCI_StatementReset /* reset batch errors */ - OCI_STATUS = OCI_BatchErrorClear(stmt); + CHECK(StatementBatchErrorClear(stmt)) /* free resultsets */ - OCI_STATUS = OCI_STATUS && OCI_ReleaseResultsets(stmt); + CHECK(StatementReleaseResultsets(stmt)) /* free in/out binds */ - OCI_STATUS = OCI_STATUS && OCI_BindFreeAll(stmt); + CHECK(StatementFreeAllBinds(stmt)) /* free bind map */ - if (stmt->map) + if (NULL != stmt->map) { - OCI_STATUS = OCI_STATUS && OCI_HashFree(stmt->map); + CHECK(HashFree(stmt->map)) } /* free handle if needed */ - if (OCI_STATUS && stmt->stmt) + if (NULL != stmt->stmt) { if (OCI_OBJECT_ALLOCATED == stmt->hstate) { - #if OCI_VERSION_COMPILE >= OCI_9_2 +#if OCI_VERSION_COMPILE >= OCI_9_2 - if (OCILib.version_runtime >= OCI_9_2) + if (Env.version_runtime >= OCI_9_2) { - OCI_EXEC(OCIStmtRelease(stmt->stmt, stmt->con->err, NULL, 0, mode)) + CHECK_OCI + ( + stmt->con->err, + OCIStmtRelease, + stmt->stmt, stmt->con->err, NULL, 0, mode + ) } else - #endif +#endif { - OCI_STATUS = OCI_HandleFree((dvoid *)stmt->stmt, OCI_HTYPE_STMT); + MemoryFreeHandle((dvoid*)stmt->stmt, OCI_HTYPE_STMT); } stmt->stmt = NULL; } else if (OCI_OBJECT_ALLOCATED_BIND_STMT == stmt->hstate) { - OCI_STATUS = OCI_HandleFree((dvoid *) stmt->stmt, OCI_HTYPE_STMT); + MemoryFreeHandle((dvoid*)stmt->stmt, OCI_HTYPE_STMT); stmt->stmt = NULL; } } - if (OCI_STATUS) - { - /* free sql statement */ + /* free sql statement */ - OCI_FREE(stmt->sql) - OCI_FREE(stmt->sql_id) + FREE(stmt->sql) + FREE(stmt->sql_id) - stmt->rsts = NULL; - stmt->stmts = NULL; - stmt->sql = NULL; - stmt->sql_id = NULL; - stmt->map = NULL; - stmt->batch = NULL; + stmt->rsts = NULL; + stmt->stmts = NULL; + stmt->sql = NULL; + stmt->sql_id = NULL; + stmt->map = NULL; + stmt->batch = NULL; - stmt->nb_rs = 0; - stmt->nb_stmt = 0; + stmt->nb_rs = 0; + stmt->nb_stmt = 0; - stmt->status = OCI_STMT_CLOSED; - stmt->type = OCI_UNKNOWN; - stmt->bind_array = FALSE; + stmt->status = OCI_STMT_CLOSED; + stmt->type = OCI_UNKNOWN; + stmt->bind_array = FALSE; - stmt->nb_iters = 1; - stmt->nb_iters_init = 1; - stmt->dynidx = 0; - stmt->err_pos = 0; - } + stmt->nb_iters = 1; + stmt->nb_iters_init = 1; + stmt->dynidx = 0; + stmt->err_pos = 0; - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_BindCheck +* StatementBindCheck * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindCheck +boolean StatementBindCheck ( OCI_Bind *bnd, ub1 *src, @@ -328,19 +404,19 @@ boolean OCI_BindCheck unsigned int index ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - if (!bnd || !dst) - { - return FALSE; - } + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_PTR(OCI_IPC_VOID, dst) - // Non-scalar type binds + /* Non-scalar type binds */ if (bnd->alloc && src) { - // OCI_Number binds + /* OCI_Number binds */ if ((OCI_CDT_NUMERIC == bnd->type) && (SQLT_VNU == bnd->code)) { if (OCI_NUM_NUMBER & bnd->subtype) @@ -352,7 +428,13 @@ boolean OCI_BindCheck if (src_num) { - OCI_EXEC(OCINumberAssign(bnd->stmt->con->err, src_num->handle, dst_num)) + CHECK_OCI + ( + bnd->stmt->con->err, + OCINumberAssign, + bnd->stmt->con->err, + src_num->handle, dst_num + ) } } } @@ -361,10 +443,12 @@ boolean OCI_BindCheck big_int *src_bint = OCI_BIND_GET_SCALAR(src, big_int, index); OCINumber *dst_num = OCI_BIND_GET_BUFFER(dst, OCINumber, index); - OCI_STATUS = OCI_TranslateNumericValue(bnd->stmt->con, src_bint, bnd->subtype, dst_num, OCI_NUM_NUMBER); + CHECK(NumberTranslateValue(bnd->stmt->con, src_bint, + bnd->subtype, dst_num, OCI_NUM_NUMBER)) } } - // OCI_Date binds + + /* OCI_Date binds */ else if (OCI_CDT_DATETIME == bnd->type) { OCI_Date *src_date = OCI_BIND_GET_HANDLE(src, OCI_Date, index); @@ -372,22 +456,30 @@ boolean OCI_BindCheck if (src_date) { - OCI_EXEC(OCIDateAssign(bnd->stmt->con->err, src_date->handle, dst_date)) + CHECK_OCI + ( + bnd->stmt->con->err, + OCIDateAssign, + bnd->stmt->con->err, + src_date->handle, dst_date + ) } } - // String binds that may required conversion on systems where wchar_t is UTF32 + + /* String binds that may required conversion on systems where wchar_t is UTF32 */ else if (OCI_CDT_TEXT == bnd->type) { - if (OCILib.use_wide_char_conv) + if (Env.use_wide_char_conv) { const int max_chars = (int) (bnd->size / sizeof(dbtext)); const size_t src_offset = index * max_chars * sizeof(otext); const size_t dst_offset = index * max_chars * sizeof(dbtext); - OCI_StringUTF32ToUTF16(src + src_offset, dst + dst_offset, max_chars - 1); + StringUTF32ToUTF16(src + src_offset, dst + dst_offset, max_chars - 1); } } - // otherwise we have an ocilib handle based type + + /* otherwise we have an ocilib handle based type */ else { OCI_Datatype *src_handle = OCI_BIND_GET_HANDLE(src, OCI_Datatype, index); @@ -401,7 +493,7 @@ boolean OCI_BindCheck /* for handles, check anyway the value for null data */ - if (OCI_IS_OCILIB_OBJECT(bnd->type, bnd->subtype) && OCI_CDT_OBJECT != bnd->type) + if (IS_OCILIB_OBJECT(bnd->type, bnd->subtype) && OCI_CDT_OBJECT != bnd->type) { if (bnd->buffer.inds[index] != OCI_IND_NULL) { @@ -428,30 +520,34 @@ boolean OCI_BindCheck } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_BindUpdate +* StatementBindUpdate * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindUpdate +boolean StatementBindUpdate ( OCI_Bind *bnd, ub1 *src, ub1 *dst, - unsigned int index) + unsigned int index +) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - if (!bnd || !src || !dst) - { - return FALSE; - } + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_BIND, bnd + ) - OCI_CALL_CONTEXT_SET_FROM_STMT(bnd->stmt) + CHECK_PTR(OCI_IPC_BIND, bnd) + CHECK_PTR(OCI_IPC_VOID, src) + CHECK_PTR(OCI_IPC_VOID, dst) - // OCI_Number binds + /* OCI_Number binds */ if ((OCI_CDT_NUMERIC == bnd->type) && (SQLT_VNU == bnd->code)) { if (OCI_NUM_NUMBER & bnd->subtype) @@ -463,22 +559,30 @@ boolean OCI_BindUpdate if (dst_num) { - OCI_EXEC(OCINumberAssign(bnd->stmt->con->err, src_num, dst_num->handle)) + CHECK_OCI + ( + bnd->stmt->con->err, + OCINumberAssign, + bnd->stmt->con->err, + src_num, dst_num->handle + ) } } } else if (OCI_NUM_BIGINT & bnd->subtype) { OCINumber *src_number = OCI_BIND_GET_BUFFER(src, OCINumber, index); - big_int *dst_bint = OCI_BIND_GET_SCALAR(dst, big_int, index); + big_int *dst_bint = OCI_BIND_GET_SCALAR(dst, big_int, index); if (dst_bint) { - OCI_STATUS = OCI_TranslateNumericValue(bnd->stmt->con, src_number, OCI_NUM_NUMBER, dst_bint, bnd->subtype); + CHECK(NumberTranslateValue(bnd->stmt->con, src_number, + OCI_NUM_NUMBER, dst_bint, bnd->subtype)) } } } - // OCI_Date binds + + /* OCI_Date binds */ else if (OCI_CDT_DATETIME == bnd->type) { OCIDate *src_date = OCI_BIND_GET_BUFFER(src, OCIDate, index); @@ -486,19 +590,26 @@ boolean OCI_BindUpdate if (dst_date) { - OCI_EXEC(OCIDateAssign(bnd->stmt->con->err, src_date, dst_date->handle)) + CHECK_OCI + ( + bnd->stmt->con->err, + OCIDateAssign, + bnd->stmt->con->err, src_date, + dst_date->handle + ) } } - // String binds that may required conversion on systems where wchar_t is UTF32 + + /* String binds that may required conversion on systems where wchar_t is UTF32 */ else if (OCI_CDT_TEXT == bnd->type) { - if (OCILib.use_wide_char_conv) + if (Env.use_wide_char_conv) { const int max_chars = (int) (bnd->size / sizeof(dbtext)); const size_t src_offset = index * max_chars * sizeof(dbtext); const size_t dst_offset = index * max_chars * sizeof(otext); - OCI_StringUTF16ToUTF32(src + src_offset, dst + dst_offset, max_chars - 1); + StringUTF16ToUTF32(src + src_offset, dst + dst_offset, max_chars - 1); } } else if (OCI_CDT_OBJECT == bnd->type) @@ -513,26 +624,31 @@ boolean OCI_BindUpdate } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindCheckAll + * StatementBindCheckAll * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindCheckAll +boolean StatementBindCheckAll ( OCI_Statement *stmt ) { - ub4 j; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) + ub4 j; - OCI_CHECK(NULL == stmt, FALSE) - OCI_CHECK(NULL == stmt->ubinds, TRUE); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) - for (ub4 i = 0; i < stmt->nb_ubinds && OCI_STATUS; i++) + for (ub4 i = 0; i < stmt->nb_ubinds; i++) { OCI_Bind *bnd = stmt->ubinds[i]; @@ -540,22 +656,30 @@ boolean OCI_BindCheckAll { OCI_Statement *bnd_stmt = (OCI_Statement *) bnd->buffer.data; - OCI_StatementReset(bnd_stmt); + StatementReset(bnd_stmt); bnd_stmt->hstate = OCI_OBJECT_ALLOCATED_BIND_STMT; /* allocate statement handle */ - OCI_STATUS = OCI_HandleAlloc((dvoid *)bnd_stmt->con->env, (dvoid **)(void *)&bnd_stmt->stmt, OCI_HTYPE_STMT); + CHECK + ( + MemoryAllocHandle + ( + (dvoid *)bnd_stmt->con->env, + (dvoid **)(void *)&bnd_stmt->stmt, + OCI_HTYPE_STMT + ) + ) - OCI_STATUS = OCI_STATUS && OCI_SetPrefetchSize(stmt, stmt->prefetch_size); - OCI_STATUS = OCI_STATUS && OCI_SetFetchSize(stmt, stmt->fetch_size); + CHECK(StatementSetPrefetchSize(stmt, stmt->prefetch_size)) + CHECK(StatementSetFetchSize(stmt, stmt->fetch_size)) } if ((bnd->direction & OCI_BDM_IN) || - (bnd->alloc && + (bnd->alloc && (OCI_CDT_DATETIME != bnd->type) && - (OCI_CDT_TEXT != bnd->type) && + (OCI_CDT_TEXT != bnd->type) && (OCI_CDT_NUMERIC != bnd->type || SQLT_VNU == bnd->code))) { /* for strings, re-initialize length array with buffer default size */ @@ -574,39 +698,44 @@ boolean OCI_BindCheckAll { if (bnd->is_array) { - const ub4 count = OCI_IS_PLSQL_STMT(stmt->type) ? bnd->nbelem : stmt->nb_iters; + const ub4 count = IS_PLSQL_STMT(stmt->type) ? bnd->nbelem : stmt->nb_iters; - for (j = 0; j < count && OCI_STATUS; j++) + for (j = 0; j < count; j++) { - OCI_STATUS = OCI_BindCheck(bnd, (ub1*)bnd->input, (ub1*)bnd->buffer.data, j); + CHECK(StatementBindCheck(bnd, (ub1*)bnd->input, (ub1*)bnd->buffer.data, j)) } } else { - OCI_STATUS = OCI_BindCheck(bnd, (ub1*)bnd->input, (ub1*)bnd->buffer.data, 0); + CHECK(StatementBindCheck(bnd, (ub1*)bnd->input, (ub1*)bnd->buffer.data, 0)) } } } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindUpdateAll + * StatementBindUpdateAll * --------------------------------------------------------------------------------------------- */ -boolean OCI_BindUpdateAll +boolean StatementBindUpdateAll ( OCI_Statement *stmt ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CHECK(NULL == stmt, FALSE) - OCI_CHECK(NULL == stmt->ubinds, FALSE); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) - for (ub4 i = 0; i < stmt->nb_ubinds && OCI_STATUS; i++) + for (ub4 i = 0; i < stmt->nb_ubinds; i++) { OCI_Bind *bnd = stmt->ubinds[i]; @@ -617,7 +746,7 @@ boolean OCI_BindUpdateAll bnd_stmt->status = OCI_STMT_PREPARED | OCI_STMT_PARSED | OCI_STMT_DESCRIBED | OCI_STMT_EXECUTED; - bnd_stmt->type = OCI_CST_SELECT; + bnd_stmt->type = OCI_CST_SELECT; } if ((bnd->direction & OCI_BDM_OUT) && (bnd->input) && (bnd->buffer.data)) @@ -626,46 +755,56 @@ boolean OCI_BindUpdateAll { if (bnd->is_array) { - const ub4 count = OCI_IS_PLSQL_STMT(stmt->type) ? bnd->nbelem : stmt->nb_iters; + const ub4 count = IS_PLSQL_STMT(stmt->type) ? bnd->nbelem : stmt->nb_iters; - for (ub4 j = 0; j < count && OCI_STATUS; j++) + for (ub4 j = 0; j < count; j++) { - OCI_STATUS = OCI_BindUpdate(bnd, (ub1*)bnd->buffer.data, (ub1*)bnd->input, j); + CHECK(StatementBindUpdate(bnd, (ub1*)bnd->buffer.data, (ub1*)bnd->input, j)) } } else { - OCI_STATUS = OCI_BindUpdate(bnd, (ub1*)bnd->buffer.data, (ub1*)bnd->input, 0); + CHECK(StatementBindUpdate(bnd, (ub1*)bnd->buffer.data, (ub1*)bnd->input, 0)) } } } } - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_FetchIntoUserVariables + * StatementFetchIntoUserVariables * --------------------------------------------------------------------------------------------- */ -boolean OCI_FetchIntoUserVariables +boolean StatementFetchIntoUserVariables ( OCI_Statement *stmt, va_list args ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + OCI_Resultset *rs = NULL; - boolean res = FALSE; + boolean res = FALSE; /* get resultset */ - rs = OCI_GetResultset(stmt); + rs = StatementGetResultset(stmt); /* fetch data */ if (rs) { - res = OCI_FetchNext(rs); + res = ResultsetFetchNext(rs); } if (res) @@ -674,18 +813,18 @@ boolean OCI_FetchIntoUserVariables /* loop on column list for updating user given placeholders */ - for (i = 1, n = OCI_GetColumnCount(rs); (i <= n) && res; i++) + for (i = 1, n = ResultsetGetColumnCount(rs); (i <= n) && res; i++) { - OCI_Column *col = OCI_GetColumn(rs, i); + OCI_Column *col = ResultsetGetColumn(rs, i); const int type = va_arg(args, int); switch (type) { - case OCI_ARG_TEXT: + case OCI_ARG_TEXT: { - const otext *src = OCI_GetString(rs, i); - otext *dst = va_arg(args, otext *); + const otext *src = ResultsetGetString(rs, i); + otext *dst = va_arg(args, otext *); if (dst) { @@ -701,114 +840,113 @@ boolean OCI_FetchIntoUserVariables } case OCI_ARG_SHORT: { - SET_ARG_NUM(short, OCI_GetShort); + SET_ARG_NUM(short, ResultsetGetShort); break; } case OCI_ARG_USHORT: { - SET_ARG_NUM(unsigned short, OCI_GetUnsignedShort); + SET_ARG_NUM(unsigned short, ResultsetGetUnsignedShort); break; } case OCI_ARG_INT: { - SET_ARG_NUM(int, OCI_GetInt); + SET_ARG_NUM(int, ResultsetGetInt); break; } case OCI_ARG_UINT: { - SET_ARG_NUM(unsigned int, OCI_GetUnsignedInt); + SET_ARG_NUM(unsigned int, ResultsetGetUnsignedInt); break; } case OCI_ARG_BIGINT: { - SET_ARG_NUM(big_int, OCI_GetBigInt); + SET_ARG_NUM(big_int, ResultsetGetBigInt); break; } case OCI_ARG_BIGUINT: { - SET_ARG_NUM(big_uint, OCI_GetUnsignedBigInt); + SET_ARG_NUM(big_uint, ResultsetGetUnsignedBigInt); break; } case OCI_ARG_DOUBLE: { - SET_ARG_NUM(double, OCI_GetDouble); + SET_ARG_NUM(double, ResultsetGetDouble); break; } case OCI_ARG_FLOAT: { - SET_ARG_NUM(float, OCI_GetFloat); + SET_ARG_NUM(float, ResultsetGetFloat); break; } case OCI_ARG_NUMBER: { - SET_ARG_HANDLE(OCI_Number, OCI_GetNumber, OCI_NumberAssign); + SET_ARG_HANDLE(OCI_Number, ResultsetGetNumber, NumberAssign); break; } case OCI_ARG_DATETIME: { - SET_ARG_HANDLE(OCI_Date, OCI_GetDate, OCI_DateAssign); + SET_ARG_HANDLE(OCI_Date, ResultsetGetDate, DateAssign); break; } case OCI_ARG_RAW: { - OCI_GetRaw(rs, i, va_arg(args, otext *), col->bufsize); + ResultsetGetRaw(rs, i, va_arg(args, otext *), col->bufsize); break; } case OCI_ARG_LOB: { - SET_ARG_HANDLE(OCI_Lob, OCI_GetLob, OCI_LobAssign); + SET_ARG_HANDLE(OCI_Lob, ResultsetGetLob, LobAssign); break; } case OCI_ARG_FILE: { - SET_ARG_HANDLE(OCI_File, OCI_GetFile, OCI_FileAssign); + SET_ARG_HANDLE(OCI_File, ResultsetGetFile, FileAssign); break; } case OCI_ARG_TIMESTAMP: { - SET_ARG_HANDLE(OCI_Timestamp, OCI_GetTimestamp, OCI_TimestampAssign); + SET_ARG_HANDLE(OCI_Timestamp, ResultsetGetTimestamp, TimestampAssign); break; } case OCI_ARG_INTERVAL: { - SET_ARG_HANDLE(OCI_Interval, OCI_GetInterval, OCI_IntervalAssign); + SET_ARG_HANDLE(OCI_Interval, ResultsetGetInterval, IntervalAssign); break; } case OCI_ARG_OBJECT: { - SET_ARG_HANDLE(OCI_Object, OCI_GetObject, OCI_ObjectAssign); + SET_ARG_HANDLE(OCI_Object, ResultsetGetObject, ObjectAssign); break; } case OCI_ARG_COLLECTION: { - SET_ARG_HANDLE(OCI_Coll, OCI_GetColl, OCI_CollAssign); + SET_ARG_HANDLE(OCI_Coll, ResultsetGetColl, CollectionAssign); break; } case OCI_ARG_REF: { - SET_ARG_HANDLE(OCI_Ref, OCI_GetRef, OCI_RefAssign); + SET_ARG_HANDLE(OCI_Ref, ResultsetGetReference, ReferenceAssign); break; } default: { - OCI_ExceptionMappingArgument(stmt->con, stmt, type); - - res = FALSE; - + THROW(ExceptionMappingArgument, type); break; } } } } - return res; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_StatementInit + * StatementInitialize * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_StatementInit +OCI_Statement * StatementInitialize ( OCI_Connection *con, OCI_Statement *stmt, @@ -817,124 +955,152 @@ OCI_Statement * OCI_StatementInit const otext *sql ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_ALLOCATE_DATA(OCI_IPC_STATEMENT, stmt, 1); - - if (OCI_STATUS) - { - stmt->con = con; - stmt->stmt = handle; + ENTER_FUNC + ( + /* returns */ OCI_Statement*, stmt, + /* context */ OCI_IPC_CONNECTION, con + ) - stmt->exec_mode = OCI_DEFAULT; - stmt->long_size = OCI_SIZE_LONG; - stmt->bind_reuse = FALSE; - stmt->bind_mode = OCI_BIND_BY_NAME; - stmt->long_mode = OCI_LONG_EXPLICIT; - stmt->bind_alloc_mode = OCI_BAM_EXTERNAL; - stmt->fetch_size = OCI_FETCH_SIZE; - stmt->prefetch_size = OCI_PREFETCH_SIZE; + CHECK_PTR(OCI_IPC_CONNECTION, con) - /* reset statement */ + ALLOC_DATA(OCI_IPC_STATEMENT, stmt, 1); - OCI_STATUS = OCI_StatementReset(stmt); + stmt->con = con; + stmt->stmt = handle; - if (is_desc) - { - stmt->hstate = OCI_OBJECT_FETCHED_CLEAN; - stmt->status = OCI_STMT_PREPARED | OCI_STMT_PARSED | - OCI_STMT_DESCRIBED | OCI_STMT_EXECUTED; - stmt->type = OCI_CST_SELECT; + stmt->exec_mode = OCI_DEFAULT; + stmt->long_size = OCI_SIZE_LONG; + stmt->bind_reuse = FALSE; + stmt->bind_mode = OCI_BIND_BY_NAME; + stmt->long_mode = OCI_LONG_EXPLICIT; + stmt->bind_alloc_mode = OCI_BAM_EXTERNAL; + stmt->fetch_size = OCI_FETCH_SIZE; + stmt->prefetch_size = OCI_PREFETCH_SIZE; - if (sql) - { - stmt->sql = ostrdup(sql); - } - else - { - dbtext *dbstr = NULL; - int dbsize = 0; - - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_STATEMENT, stmt->stmt, &dbstr, &dbsize) + /* reset statement */ - if (OCI_STATUS && dbstr) - { - stmt->sql = OCI_StringDuplicateFromOracleString(dbstr, dbcharcount(dbsize)); - OCI_STATUS = (NULL != stmt->sql); - } - } + CHECK(StatementReset(stmt)) - /* Setting fetch attributes here as the statement is already prepared */ + if (is_desc) + { + stmt->hstate = OCI_OBJECT_FETCHED_CLEAN; + stmt->status = OCI_STMT_PREPARED | OCI_STMT_PARSED | + OCI_STMT_DESCRIBED | OCI_STMT_EXECUTED; + stmt->type = OCI_CST_SELECT; - OCI_STATUS = OCI_STATUS && OCI_SetPrefetchSize(stmt, stmt->prefetch_size); - OCI_STATUS = OCI_STATUS && OCI_SetFetchSize(stmt, stmt->fetch_size); + if (NULL != sql) + { + stmt->sql = ostrdup(sql); } else { - /* allocate handle for non fetched cursor */ + dbtext *dbstr = NULL; + int dbsize = 0; + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_STATEMENT, + stmt->stmt, &dbstr, &dbsize, + stmt->con->err + ) - stmt->hstate = OCI_OBJECT_ALLOCATED; + if (NULL != dbstr) + { + stmt->sql = StringDuplicateFromDBString(dbstr, dbcharcount(dbsize)); + CHECK_NULL(stmt->sql) + } } - } - /* check for failure */ + /* Setting fetch attributes here as the statement is already prepared */ - if (!OCI_STATUS && stmt) + CHECK(StatementSetPrefetchSize(stmt, stmt->prefetch_size)) + CHECK(StatementSetFetchSize(stmt, stmt->fetch_size)) + } + else { - OCI_StatementFree(stmt); - stmt = NULL; + /* allocate handle for non fetched cursor */ + + stmt->hstate = OCI_OBJECT_ALLOCATED; } - return stmt; + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + StatementFree(stmt); + stmt = NULL; + } + + SET_RETVAL(stmt) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_StatementClose + * StatementDispose * --------------------------------------------------------------------------------------------- */ -boolean OCI_StatementClose +boolean StatementDispose ( OCI_Statement *stmt ) { - OCI_Error *err = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CHECK(NULL == stmt, FALSE); + OCI_Error* err = NULL; /* clear statement reference from current error object */ - err = OCI_ErrorGet(FALSE, FALSE); + err = ErrorGet(FALSE, FALSE); - if (err && err->stmt == stmt) + if (NULL != err && err->source_ptr == stmt) { - err->stmt = NULL; + err->source_ptr = NULL; } /* reset data */ - return OCI_StatementReset(stmt); + StatementReset(stmt); + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_StatementCheckImplicitResultsets + * StatementCheckImplicitResultsets * --------------------------------------------------------------------------------------------- */ -boolean OCI_StatementCheckImplicitResultsets +boolean StatementCheckImplicitResultsets ( OCI_Statement *stmt ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) #if OCI_VERSION_COMPILE >= OCI_12_1 - if (OCILib.version_runtime >= OCI_12_1) + if (Env.version_runtime >= OCI_12_1) { - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_IMPLICIT_RESULT_COUNT, stmt->stmt, &stmt->nb_stmt, NULL) - - if (OCI_STATUS && stmt->nb_stmt > 0) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_IMPLICIT_RESULT_COUNT, + stmt->stmt, &stmt->nb_stmt, NULL, + stmt->con->err + ) + + if (stmt->nb_stmt > 0) { OCIStmt *result = NULL; ub4 rs_type = OCI_UNKNOWN; @@ -942,27 +1108,23 @@ boolean OCI_StatementCheckImplicitResultsets /* allocate resultset handles array */ - OCI_ALLOCATE_DATA(OCI_IPC_STATEMENT_ARRAY, stmt->stmts, stmt->nb_stmt) - OCI_ALLOCATE_DATA(OCI_IPC_RESULTSET_ARRAY, stmt->rsts, stmt->nb_stmt) + ALLOC_DATA(OCI_IPC_STATEMENT_ARRAY, stmt->stmts, stmt->nb_stmt) + ALLOC_DATA(OCI_IPC_RESULTSET_ARRAY, stmt->rsts, stmt->nb_stmt) - while (OCI_STATUS && OCI_SUCCESS == OCIStmtGetNextResult(stmt->stmt, stmt->con->err, (dvoid **)&result, &rs_type, OCI_DEFAULT)) + while (OCI_SUCCESS == OCIStmtGetNextResult(stmt->stmt, stmt->con->err, (dvoid **)&result, &rs_type, OCI_DEFAULT)) { if (OCI_RESULT_TYPE_SELECT == rs_type) { - stmt->stmts[i] = OCI_StatementInit(stmt->con, NULL, result, TRUE, NULL); - OCI_STATUS = (NULL != stmt->stmts[i]); + stmt->stmts[i] = StatementInitialize(stmt->con, NULL, result, TRUE, NULL); - if (OCI_STATUS) - { - stmt->rsts[i] = OCI_ResultsetCreate(stmt->stmts[i], stmt->stmts[i]->fetch_size); - OCI_STATUS = (NULL != stmt->rsts[i]); - - if (OCI_STATUS) - { - i++; - stmt->nb_rs++; - } - } + CHECK_NULL(stmt->stmts[i]) + + stmt->rsts[i] = ResultsetCreate(stmt->stmts[i], stmt->stmts[i]->fetch_size); + + CHECK_NULL(stmt->rsts[i]) + + i++; + stmt->nb_rs++; } } } @@ -970,224 +1132,234 @@ boolean OCI_StatementCheckImplicitResultsets #endif - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BatchErrorsInit + * StatementBatchErrorsInit * --------------------------------------------------------------------------------------------- */ -boolean OCI_BatchErrorInit +boolean StatementBatchErrorInit ( OCI_Statement *stmt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + OCIError* hndl = NULL; + ub4 err_count = 0; - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_BatchErrorClear(stmt); + CHECK(StatementBatchErrorClear(stmt)) /* all OCI call here are not checked for errors as we already dealing with an array DML error */ - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_NUM_DML_ERRORS, stmt->stmt, &err_count, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_NUM_DML_ERRORS, + stmt->stmt, &err_count, NULL, + stmt->con->err + ) if (err_count > 0) { - OCIError *hndl = NULL; - /* allocate batch error structure */ - OCI_ALLOCATE_DATA(OCI_IPC_BATCH_ERRORS, stmt->batch, 1) + ALLOC_DATA(OCI_IPC_BATCH_ERRORS, stmt->batch, 1) /* allocate array of error objects */ - OCI_ALLOCATE_DATA(OCI_IPC_ERROR, stmt->batch->errs, err_count) + ALLOC_DATA(OCI_IPC_ERROR, stmt->batch->errs, err_count) - if (OCI_STATUS) - { - /* allocate OCI error handle */ + /* allocate OCI error handle */ - OCI_STATUS = OCI_HandleAlloc((dvoid *)stmt->con->env, (dvoid **)(void *)&hndl, OCI_HTYPE_ERROR); - } + CHECK(MemoryAllocHandle((dvoid *)stmt->con->env, (dvoid **)(void *)&hndl, OCI_HTYPE_ERROR)) /* loop on the OCI errors to fill OCILIB error objects */ - if (OCI_STATUS) - { - stmt->batch->count = err_count; + stmt->batch->count = err_count; - for (ub4 i = 0; i < stmt->batch->count; i++) - { - int dbsize = -1; - dbtext *dbstr = NULL; - - OCI_Error *err = &stmt->batch->errs[i]; - - OCIParamGet((dvoid *) stmt->con->err, OCI_HTYPE_ERROR, - stmt->con->err, (dvoid **) (void *) &hndl, i); - - /* get row offset */ - - OCIAttrGet((dvoid *) hndl, (ub4) OCI_HTYPE_ERROR, - (void *) &err->row, (ub4 *) NULL, - (ub4) OCI_ATTR_DML_ROW_OFFSET, stmt->con->err); - - /* fill error attributes */ - - err->type = OCI_ERR_ORACLE; - err->con = stmt->con; - err->stmt = stmt; + for (ub4 i = 0; i < stmt->batch->count; i++) + { + sb4 row = 0; - /* OCILIB indexes start at 1 */ + OCI_Error *err = &stmt->batch->errs[i]; - err->row++; + OCIParamGet((dvoid *) stmt->con->err, OCI_HTYPE_ERROR, + stmt->con->err, (dvoid **) (void *) &hndl, i); - /* get error string */ + if (NULL != hndl) + { + sb4 err_code = 0; + otext buffer[512]; + int err_size = osizeof(buffer); - dbsize = (int) osizeof(err->str) - 1; + dbtext * err_msg = StringGetDBString(buffer, &err_size); - dbstr = OCI_StringGetOracleString(err->str, &dbsize); + OCIAttrGet((dvoid *)hndl, (ub4)OCI_HTYPE_ERROR, + (void *)&row, (ub4 *)NULL, + (ub4)OCI_ATTR_DML_ROW_OFFSET, stmt->con->err); - OCIErrorGet((dvoid *) hndl, - (ub4) 1, - (OraText *) NULL, &err->sqlcode, - (OraText *) dbstr, - (ub4) dbsize, - (ub4) OCI_HTYPE_ERROR); + OCIErrorGet((dvoid *)hndl, (ub4)1, (OraText *)NULL, &err_code, + (OraText *)err_msg, (ub4)err_size, (ub4)OCI_HTYPE_ERROR); - OCI_StringCopyOracleStringToNativeString(dbstr, err->str, dbcharcount(dbsize)); - OCI_StringReleaseOracleString(dbstr); + ErrorSet + ( + err, + OCI_ERR_ORACLE, + (int)err_code, + call_context.source_ptr, + call_context.source_type, + call_context.location, + buffer, + row + 1 + ); + + StringReleaseDBString(err_msg); } } + } - /* release error handle */ + SET_SUCCESS() - if (hndl) + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != hndl) { - OCI_HandleFree(hndl, OCI_HTYPE_ERROR); + MemoryFreeHandle(hndl, OCI_HTYPE_ERROR); } - } - - return OCI_STATUS; + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_PrepareInternal + * StatementPrepareInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_PrepareInternal +boolean StatementPrepareInternal ( OCI_Statement *stmt, const otext *sql ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + dbtext *dbstr = NULL; - int dbsize = -1; + int dbsize = -1; - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) /* reset statement */ - OCI_STATUS = OCI_StatementReset(stmt); + CHECK(StatementReset(stmt)) - if (OCI_STATUS) - { - /* store SQL */ + /* store SQL */ - stmt->sql = ostrdup(sql); + stmt->sql = ostrdup(sql); - dbstr = OCI_StringGetOracleString(stmt->sql, &dbsize); + dbstr = StringGetDBString(stmt->sql, &dbsize); - if (OCILib.version_runtime < OCI_9_2) - { - /* allocate handle */ + if (Env.version_runtime < OCI_9_2) + { + /* allocate handle */ - OCI_STATUS = OCI_HandleAlloc((dvoid *)stmt->con->env, (dvoid **)(void *)&stmt->stmt, OCI_HTYPE_STMT); - } + CHECK(MemoryAllocHandle((dvoid *)stmt->con->env, (dvoid **)(void *)&stmt->stmt, OCI_HTYPE_STMT)) } - if (OCI_STATUS) - { - /* prepare SQL */ + /* prepare SQL */ - #if OCI_VERSION_COMPILE >= OCI_9_2 - - if (OCILib.version_runtime >= OCI_9_2) - { - ub4 mode = OCI_DEFAULT; - - #if OCI_VERSION_COMPILE >= OCI_12_2 +#if OCI_VERSION_COMPILE >= OCI_9_2 - if (OCI_ConnectionIsVersionSupported(stmt->con, OCI_12_2)) - { - mode |= OCI_PREP2_GET_SQL_ID; - } + if (Env.version_runtime >= OCI_9_2) + { + ub4 mode = OCI_DEFAULT; - #endif + #if OCI_VERSION_COMPILE >= OCI_12_2 - OCI_EXEC - ( - OCIStmtPrepare2 - ( - stmt->con->cxt, &stmt->stmt, stmt->con->err, (OraText *) dbstr, - (ub4) dbsize, NULL, 0, (ub4) OCI_NTV_SYNTAX, (ub4) mode - ) - ) + if (ConnectionIsVersionSupported(stmt->con, OCI_12_2)) + { + mode |= OCI_PREP2_GET_SQL_ID; } - else - #endif + #endif - { - OCI_EXEC - ( - OCIStmtPrepare - ( - stmt->stmt,stmt->con->err, (OraText *) dbstr, (ub4) dbsize, - (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT - ) - ) - } + CHECK_OCI + ( + stmt->con->err, + OCIStmtPrepare2, + stmt->con->cxt, &stmt->stmt, stmt->con->err, (OraText *) dbstr, + (ub4) dbsize, NULL, 0, (ub4) OCI_NTV_SYNTAX, (ub4) mode + ) + } + else - /* get statement type */ +#endif - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_STMT_TYPE, stmt->stmt, &stmt->type, NULL) + { + CHECK_OCI + ( + stmt->con->err, + OCIStmtPrepare, + stmt->stmt,stmt->con->err, (OraText *) dbstr, (ub4) dbsize, + (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT + ) } - OCI_StringReleaseOracleString(dbstr); + /* get statement type */ + + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_STMT_TYPE, + stmt->stmt, &stmt->type, NULL, + stmt->con->err + ) /* update statement status */ - if (OCI_STATUS) - { - stmt->status = OCI_STMT_PREPARED; + stmt->status = OCI_STMT_PREPARED; - OCI_STATUS = OCI_STATUS && OCI_SetPrefetchSize(stmt, stmt->prefetch_size); - OCI_STATUS = OCI_STATUS && OCI_SetFetchSize(stmt, stmt->fetch_size); - } + CHECK(StatementSetPrefetchSize(stmt, stmt->prefetch_size)) + CHECK(StatementSetFetchSize(stmt, stmt->fetch_size)) - return OCI_STATUS; + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExecuteInternal + * StatementExecuteInternal * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ExecuteInternal +boolean StatementExecuteInternal ( OCI_Statement *stmt, ub4 mode ) { - sword status = OCI_SUCCESS; - ub4 iters = 0; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + ub4 iters = 0; /* set up iterations and mode values for execution */ @@ -1209,15 +1381,15 @@ boolean OCI_API OCI_ExecuteInternal /* reset batch errors */ - OCI_BatchErrorClear(stmt); + CHECK(StatementBatchErrorClear(stmt)) /* check bind objects for updating their null indicator status */ - OCI_STATUS = OCI_BindCheckAll(stmt); + CHECK(StatementBindCheckAll(stmt)) /* check current resultsets */ - if (OCI_STATUS && stmt->rsts) + if (stmt->rsts) { /* resultsets are freed before any prepare operations. So, if we got ones here, it means the same SQL order @@ -1227,34 +1399,31 @@ boolean OCI_API OCI_ExecuteInternal { /* just reinitialize the current resultset */ - OCI_STATUS = OCI_ResultsetInit(stmt->rsts[0]); + CHECK(ResultsetInitialize(stmt->rsts[0])) } else { /* Must free previous resultsets for 'returning into' SQL orders that can produce multiple resultsets */ - OCI_STATUS = OCI_ReleaseResultsets(stmt); + CHECK(StatementReleaseResultsets(stmt)) } } /* Oracle execute call */ - if (OCI_STATUS) - { - - status = OCIStmtExecute(stmt->con->cxt, stmt->stmt, stmt->con->err, iters, - (ub4)0, (OCISnapshot *)NULL, (OCISnapshot *)NULL, mode); - } + const sword ret = OCIStmtExecute(stmt->con->cxt, stmt->stmt, stmt->con->err, + iters, (ub4)0, (OCISnapshot *)NULL, + (OCISnapshot *)NULL, mode); /* check result */ - OCI_STATUS = ((OCI_SUCCESS == status) || (OCI_SUCCESS_WITH_INFO == status) || - (OCI_NEED_DATA == status) || (OCI_NO_DATA == status)); + boolean success = ((OCI_SUCCESS == ret) || (OCI_SUCCESS_WITH_INFO == ret) || + (OCI_NEED_DATA == ret) || (OCI_NO_DATA == ret)); - if (OCI_SUCCESS_WITH_INFO == status) + if (OCI_SUCCESS_WITH_INFO == ret) { - OCI_ExceptionOCI(stmt->con->err, stmt->con, stmt, TRUE); + ExceptionOCI(&call_context, stmt->con->err, ret); } /* on batch mode, check if any error occurred */ @@ -1263,17 +1432,17 @@ boolean OCI_API OCI_ExecuteInternal { /* build batch error list if the statement is array DML */ - OCI_BatchErrorInit(stmt); + StatementBatchErrorInit(stmt); if (stmt->batch) { - OCI_STATUS = (stmt->batch->count == 0); + success = (stmt->batch->count == 0); } } /* update status on success */ - if (OCI_STATUS) + if (success) { if (mode & OCI_PARSE_ONLY) { @@ -1290,31 +1459,31 @@ boolean OCI_API OCI_ExecuteInternal stmt->status |= OCI_STMT_DESCRIBED; stmt->status |= OCI_STMT_EXECUTED; - #if OCI_VERSION_COMPILE >= OCI_12_2 +#if OCI_VERSION_COMPILE >= OCI_12_2 - if (OCI_ConnectionIsVersionSupported(stmt->con, OCI_12_2)) + if (ConnectionIsVersionSupported(stmt->con, OCI_12_2)) { unsigned int size_id = 0; - OCI_GetStringAttribute(stmt->con, stmt->stmt, OCI_HTYPE_STMT, OCI_ATTR_SQL_ID, &stmt->sql_id, &size_id); + StringGetAttribute(stmt->con, stmt->stmt, OCI_HTYPE_STMT, OCI_ATTR_SQL_ID, &stmt->sql_id, &size_id); } - #endif - +#endif + /* reset binds indicators */ - OCI_BindUpdateAll(stmt); + CHECK(StatementBindUpdateAll(stmt)) /* commit if necessary */ if (stmt->con->autocom) { - OCI_Commit(stmt->con); + CHECK(ConnectionCommit(stmt->con)) } /* check if any implicit results are available */ - OCI_STATUS = OCI_StatementCheckImplicitResultsets(stmt); + CHECK(StatementCheckImplicitResultsets(stmt)) } } @@ -1325,479 +1494,603 @@ boolean OCI_API OCI_ExecuteInternal /* (one of the rare OCI call not enclosed with a OCI_CALL macro ...) */ OCIAttrGet((dvoid *)stmt->stmt, (ub4)OCI_HTYPE_STMT, - (dvoid *)&stmt->err_pos, (ub4 *)NULL, - (ub4)OCI_ATTR_PARSE_ERROR_OFFSET, stmt->con->err); + (dvoid *)&stmt->err_pos, (ub4 *)NULL, + (ub4)OCI_ATTR_PARSE_ERROR_OFFSET, stmt->con->err); /* raise exception */ - OCI_ExceptionOCI(stmt->con->err, stmt->con, stmt, FALSE); + THROW(ExceptionOCI, stmt->con->err, ret) } - return OCI_STATUS; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_StatementCreate + * StatementCreate * --------------------------------------------------------------------------------------------- */ -OCI_Statement * OCI_API OCI_StatementCreate +OCI_Statement * StatementCreate ( OCI_Connection *con ) { - OCI_CALL_ENTER(OCI_Statement *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Statement*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) /* create statement object */ - OCI_RETVAL = OCI_ListAppend(con->stmts, sizeof(*OCI_RETVAL)); - OCI_STATUS = (NULL != OCI_RETVAL); + OCI_Statement *stmt = ListAppend(con->stmts, sizeof(*stmt)); + CHECK_NULL(stmt) - if (OCI_STATUS) - { - OCI_RETVAL = OCI_StatementInit(con, (OCI_Statement *) OCI_RETVAL, NULL, FALSE, NULL); - OCI_STATUS = (NULL != OCI_RETVAL); - } + SET_RETVAL(StatementInitialize(con, (OCI_Statement*)stmt, NULL, FALSE, NULL)) + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * StatementFree + * --------------------------------------------------------------------------------------------- */ + +boolean StatementFree +( + OCI_Statement *stmt +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_OBJECT_FETCHED(stmt) - if (!OCI_STATUS && OCI_RETVAL) + StatementDispose(stmt); + ListRemove(stmt->con->stmts, stmt); + + FREE(stmt) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * StatementGetResultset + * --------------------------------------------------------------------------------------------- */ + +OCI_Resultset * StatementGetResultset +( + OCI_Statement *stmt +) +{ + ENTER_FUNC + ( + /* returns */ OCI_Resultset*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_STMT_STATUS(stmt, OCI_STMT_DESCRIBED) + + OCI_Resultset *rs = NULL; + + /* if the sql statement does not return a result, we just return NULL and not + throwing any exception + statements that can return a resultset are "SELECT..." and "... RETURNING INTO..." + */ + + if ((OCI_CST_SELECT == stmt->type) || (stmt->nb_rbinds > 0) || (stmt->nb_stmt > 0)) { - OCI_StatementFree(OCI_RETVAL); - OCI_RETVAL = NULL; + /* if the resultset exists, let's use it */ + + if (stmt->rsts && stmt->rsts[0]) + { + rs = stmt->rsts[0]; + } + + /* allocate resultset for select statements only */ + + if (NULL == rs && (OCI_CST_SELECT == stmt->type)) + { + /* allocate memory for one resultset handle */ + + ALLOC_DATA(OCI_IPC_RESULTSET_ARRAY, stmt->rsts, 1) + + stmt->nb_rs = 1; + stmt->cur_rs = 0; + + /* create resultset object */ + + rs = stmt->rsts[0] = ResultsetCreate(stmt, stmt->fetch_size); + } + + CHECK_NULL(rs) } - OCI_CALL_EXIT() + SET_RETVAL(rs) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_StatementFree + * StatementGetNextResultset * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_StatementFree +OCI_Resultset * StatementGetNextResultset ( OCI_Statement *stmt ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_OBJECT_FETCHED(stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) - - OCI_StatementClose(stmt); - OCI_ListRemove(stmt->con->stmts, stmt); + ENTER_FUNC + ( + /* returns */ OCI_Resultset*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_FREE(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_STMT_STATUS(stmt, OCI_STMT_DESCRIBED) + CHECK(stmt->cur_rs < stmt->nb_rs-1) - OCI_RETVAL = TRUE; + SET_RETVAL(stmt->rsts[++stmt->cur_rs]) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ReleaseResultsets + * StatementReleaseResultsets * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ReleaseResultsets +boolean StatementReleaseResultsets ( OCI_Statement *stmt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + ub4 i; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) /* Release statements for implicit resultsets */ - if (stmt->stmts) + if (NULL != stmt->stmts) { for (i = 0; i < stmt->nb_stmt; i++) { if (stmt->rsts[i]) { - OCI_StatementClose(stmt->stmts[i]); + StatementDispose(stmt->stmts[i]); } } - OCI_FREE(stmt->rsts) + FREE(stmt->rsts) } /* release resultsets */ - if (stmt->rsts) + if (NULL != stmt->rsts) { for (i = 0; i < stmt->nb_rs; i++) { if (stmt->rsts[i]) { - OCI_ResultsetFree(stmt->rsts[i]); + ResultsetFree(stmt->rsts[i]); } } - OCI_FREE(stmt->rsts) + FREE(stmt->rsts) } - OCI_RETVAL = TRUE; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Prepare + * StatementPrepare * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Prepare +boolean StatementPrepare ( OCI_Statement *stmt, const otext *sql ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) - OCI_RETVAL = OCI_STATUS = OCI_PrepareInternal(stmt, sql); + CHECK(StatementPrepareInternal(stmt, sql)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Execute + * StatementExecute * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Execute +boolean StatementExecute ( OCI_Statement *stmt ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) - OCI_RETVAL = OCI_STATUS = OCI_ExecuteInternal(stmt, OCI_DEFAULT); + CHECK(StatementExecuteInternal(stmt, OCI_DEFAULT)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ExecuteStmt + * StatementExecuteStmt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ExecuteStmt +boolean StatementExecuteStmt ( OCI_Statement *stmt, const otext *sql ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) + + CHECK(StatementPrepareInternal(stmt, sql)) + CHECK(StatementExecuteInternal(stmt, OCI_DEFAULT)) - OCI_RETVAL = OCI_STATUS = OCI_PrepareInternal(stmt, sql) && OCI_ExecuteInternal(stmt, OCI_DEFAULT); + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Parse + * StatementParse * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Parse +boolean StatementParse ( OCI_Statement *stmt, const otext *sql ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) + + CHECK(StatementPrepareInternal(stmt, sql)) + CHECK(StatementExecuteInternal(stmt, OCI_PARSE_ONLY)) - OCI_RETVAL = OCI_STATUS = OCI_PrepareInternal(stmt, sql) && OCI_ExecuteInternal(stmt, OCI_PARSE_ONLY); + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_Describe + * StatementDescribe * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_Describe +boolean StatementDescribe ( OCI_Statement *stmt, const otext *sql ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_STATUS = OCI_PrepareInternal(stmt, sql); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) - if (OCI_STATUS && OCI_CST_SELECT == stmt->type) + CHECK(StatementPrepareInternal(stmt, sql)) + + if (OCI_CST_SELECT == stmt->type) { - OCI_STATUS = OCI_ExecuteInternal(stmt, OCI_DESCRIBE_ONLY); + CHECK(StatementExecuteInternal(stmt, OCI_DESCRIBE_ONLY)) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_PrepareFmt + * StatementPrepareFmt * --------------------------------------------------------------------------------------------- */ -boolean OCI_PrepareFmt +boolean StatementPrepareFmt ( OCI_Statement *stmt, const otext *sql, - ... + va_list args ) { - va_list args; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + otext* sql_fmt = NULL; - /* first, get buffer size */ + va_list first_pass_args; + va_list second_pass_args; - va_start(args, sql); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) - const int size = OCI_ParseSqlFmt(stmt, NULL, sql, &args); + va_copy(first_pass_args, args); + va_copy(second_pass_args, args); - va_end(args); + /* first, get buffer size */ + + const int size = FormatParseSql(stmt, NULL, sql, &first_pass_args); if (size > 0) { - otext *sql_fmt = NULL; - /* allocate buffer */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - - if (OCI_STATUS) - { - /* format buffer */ - - va_start(args, sql); - - if (OCI_ParseSqlFmt(stmt, sql_fmt, sql, &args) > 0) - { - /* parse buffer */ + ALLOC_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - OCI_STATUS = OCI_PrepareInternal(stmt, sql_fmt); - } + /* format buffer */ - va_end(args); + if (FormatParseSql(stmt, sql_fmt, sql, &second_pass_args) > 0) + { + /* parse buffer */ - OCI_FREE(sql_fmt) + CHECK(StatementPrepareInternal(stmt, sql_fmt)) } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + va_end(first_pass_args); + va_end(second_pass_args); - OCI_CALL_EXIT() + FREE(sql_fmt) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ExecuteStmtFmt + * StatementExecuteStmtFmt * --------------------------------------------------------------------------------------------- */ -boolean OCI_ExecuteStmtFmt +boolean StatementExecuteStmtFmt ( OCI_Statement *stmt, const otext *sql, - ... + va_list args ) { - va_list args; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + va_list first_pass_args; + va_list second_pass_args; - /* first, get buffer size */ + otext* sql_fmt = NULL; + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) - va_start(args, sql); + va_copy(first_pass_args, args); + va_copy(second_pass_args, args); - const int size = OCI_ParseSqlFmt(stmt, NULL, sql, &args); + /* first, get buffer size */ - va_end(args); + const int size = FormatParseSql(stmt, NULL, sql, &first_pass_args); if (size > 0) { - otext *sql_fmt = NULL; /* allocate buffer */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - - if (OCI_STATUS) - { - /* format buffer */ - - va_start(args, sql); - - if (OCI_ParseSqlFmt(stmt, sql_fmt, sql, &args) > 0) - { - /* prepare and execute SQL buffer */ + ALLOC_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - OCI_STATUS = OCI_PrepareInternal(stmt, sql_fmt) && OCI_ExecuteInternal(stmt, OCI_DEFAULT); - } + /* format buffer */ - va_end(args); + if (FormatParseSql(stmt, sql_fmt, sql, &second_pass_args) > 0) + { + /* prepare and execute SQL buffer */ - OCI_FREE(sql_fmt) + CHECK(StatementPrepareInternal(stmt, sql_fmt)) + CHECK(StatementExecuteInternal(stmt, OCI_DEFAULT)) } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + va_end(first_pass_args); + va_end(second_pass_args); - OCI_CALL_EXIT() + FREE(sql_fmt) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ParseFmt + * StatementParseFmt * --------------------------------------------------------------------------------------------- */ -boolean OCI_ParseFmt +boolean StatementParseFmt ( OCI_Statement *stmt, const otext *sql, - ... + va_list args ) { - va_list args; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + va_list first_pass_args; + va_list second_pass_args; - /* first, get buffer size */ + otext* sql_fmt = NULL; + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) - va_start(args, sql); + va_copy(first_pass_args, args); + va_copy(second_pass_args, args); - const int size = OCI_ParseSqlFmt(stmt, NULL, sql, &args); + /* first, get buffer size */ - va_end(args); + const int size = FormatParseSql(stmt, NULL, sql, &first_pass_args); if (size > 0) { - otext *sql_fmt = NULL; - /* allocate buffer */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - - if (OCI_STATUS) - { - /* format buffer */ - - va_start(args, sql); - - if (OCI_ParseSqlFmt(stmt, sql_fmt, sql, &args) > 0) - { - /* prepare and execute SQL buffer */ + ALLOC_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - OCI_STATUS = OCI_PrepareInternal(stmt, sql_fmt) && OCI_ExecuteInternal(stmt, OCI_PARSE_ONLY); - } + /* format buffer */ - va_end(args); + if (FormatParseSql(stmt, sql_fmt, sql, &second_pass_args) > 0) + { + /* prepare and execute SQL buffer */ - OCI_FREE(sql_fmt) + CHECK(StatementPrepareInternal(stmt, sql_fmt)) + CHECK(StatementExecuteInternal(stmt, OCI_PARSE_ONLY)) } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + va_end(first_pass_args); + va_end(second_pass_args); - OCI_CALL_EXIT() + FREE(sql_fmt) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_DescribeFmt + * StatementDescribeFmt * --------------------------------------------------------------------------------------------- */ -boolean OCI_DescribeFmt +boolean StatementDescribeFmt ( OCI_Statement *stmt, const otext *sql, - ... + va_list args ) { - va_list args; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, sql) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + va_list first_pass_args; + va_list second_pass_args; - /* first, get buffer size */ + otext* sql_fmt = NULL; - va_start(args, sql); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, sql) - const int size = OCI_ParseSqlFmt(stmt, NULL, sql, &args); + va_copy(first_pass_args, args); + va_copy(second_pass_args, args); + + /* first, get buffer size */ - va_end(args); + const int size = FormatParseSql(stmt, NULL, sql, &first_pass_args); if (size > 0) { - otext *sql_fmt = NULL; - /* allocate buffer */ - OCI_ALLOCATE_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - - if (OCI_STATUS) - { - /* format buffer */ - - va_start(args, sql); + ALLOC_DATA(OCI_IPC_STRING, sql_fmt, size + 1) - if (OCI_ParseSqlFmt(stmt, sql_fmt, sql, &args) > 0) - { - /* prepare and execute SQL buffer */ - - OCI_STATUS = OCI_PrepareInternal(stmt, sql_fmt) && OCI_ExecuteInternal(stmt, OCI_DESCRIBE_ONLY); - } + /* format buffer */ - va_end(args); + if (FormatParseSql(stmt, sql_fmt, sql, &second_pass_args) > 0) + { + /* prepare and execute SQL buffer */ - OCI_FREE(sql_fmt) + CHECK(StatementPrepareInternal(stmt, sql_fmt)) + CHECK(StatementExecuteInternal(stmt, OCI_DESCRIBE_ONLY)) } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + va_end(first_pass_args); + va_end(second_pass_args); + + FREE(sql_fmt) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArraySetSize + * StatementSetBindArraySize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArraySetSize +boolean StatementSetBindArraySize ( OCI_Statement *stmt, unsigned int size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_MIN(stmt->con, stmt, size, 1) - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_MIN(size, 1) + CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) /* if the statements already has binds, we need to check if the new size is not greater than the initial size @@ -1805,7 +2098,7 @@ boolean OCI_API OCI_BindArraySetSize if ((stmt->nb_ubinds > 0) && (stmt->nb_iters_init < size)) { - OCI_RAISE_EXCEPTION(OCI_ExceptionBindArraySize(stmt, stmt->nb_iters_init, stmt->nb_iters, size)) + THROW(ExceptionBindArraySize, stmt->nb_iters_init, stmt->nb_iters, size) } else { @@ -1818,67 +2111,86 @@ boolean OCI_API OCI_BindArraySetSize } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayGetSize + * StatementGetBindArraySize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_BindArrayGetSize +unsigned int StatementGetBindArraySize ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, nb_iters, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + nb_iters + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_AllowRebinding + * StatementAllowRebinding * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_AllowRebinding +boolean StatementAllowRebinding ( OCI_Statement *stmt, boolean value ) { - OCI_SET_PROP(boolean, OCI_IPC_STATEMENT, stmt, bind_reuse, value, stmt->con, stmt, stmt->con->err) + SET_PROP + ( + /* handle */ OCI_IPC_STATEMENT, stmt, + /* member */ bind_reuse, boolean, + /* value */ value + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_IsRebindingAllowed + * StatementIsRebindingAllowed * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_IsRebindingAllowed +boolean StatementIsRebindingAllowed ( OCI_Statement *stmt ) { - OCI_GET_PROP(boolean, FALSE, OCI_IPC_STATEMENT, stmt, bind_reuse, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + boolean, FALSE, + OCI_IPC_STATEMENT, stmt, + bind_reuse + ) } /* --------------------------------------------------------------------------------------------- * * OCI_BindBoolean * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindBoolean +boolean StatementBindBoolean ( OCI_Statement *stmt, const otext *name, boolean *data ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_BOOLEAN, TRUE) - OCI_CALL_CHECK_EXTENDED_PLSQLTYPES_ENABLED(stmt->con) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_BOOLEAN, TRUE) + CHECK_EXTENDED_PLSQLTYPES_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_12_1 - OCI_BIND_DATA(sizeof(boolean), OCI_CDT_BOOLEAN, SQLT_BOL, 0, NULL, 0) + BIND_DATA(sizeof(boolean), OCI_CDT_BOOLEAN, SQLT_BOL, 0, NULL, 0) #else @@ -1887,23 +2199,23 @@ boolean OCI_API OCI_BindBoolean #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindNumber + * StatementBindNumber * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindNumber +boolean StatementBindNumber ( OCI_Statement *stmt, const otext *name, OCI_Number *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_SHORT, sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_NUMBER, NULL, 0 ) @@ -1913,7 +2225,7 @@ boolean OCI_API OCI_BindNumber * OCI_BindArrayOfNumbers * --------------------------------------------------------------------------------------------- */ -OCI_EXPORT boolean OCI_API OCI_BindArrayOfNumbers +boolean StatementBindArrayOfNumbers ( OCI_Statement *stmt, const otext *name, @@ -1921,34 +2233,34 @@ OCI_EXPORT boolean OCI_API OCI_BindArrayOfNumbers unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_NUMBER, sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_NUMBER, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindShort + * StatementBindShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindShort +boolean StatementBindShort ( OCI_Statement *stmt, const otext *name, short *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_SHORT, sizeof(short), OCI_CDT_NUMERIC, SQLT_INT, OCI_NUM_SHORT, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfShorts + * StatementBindArrayOfShorts * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfShorts +boolean StatementBindArrayOfShorts ( OCI_Statement *stmt, const otext *name, @@ -1956,34 +2268,34 @@ boolean OCI_API OCI_BindArrayOfShorts unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_SHORT, sizeof(short), OCI_CDT_NUMERIC, SQLT_INT, OCI_NUM_SHORT, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindUnsignedShort + * StatementBindUnsignedShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindUnsignedShort +boolean StatementBindUnsignedShort ( OCI_Statement *stmt, const otext *name, unsigned short *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_SHORT, sizeof(unsigned short), OCI_CDT_NUMERIC, SQLT_UIN, OCI_NUM_USHORT, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfUnsignedShorts + * StatementBindArrayOfUnsignedShorts * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfUnsignedShorts +boolean StatementBindArrayOfUnsignedShorts ( OCI_Statement *stmt, const otext *name, @@ -1991,34 +2303,34 @@ boolean OCI_API OCI_BindArrayOfUnsignedShorts unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_SHORT, sizeof(unsigned short), OCI_CDT_NUMERIC, SQLT_UIN, OCI_NUM_USHORT, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindInt + * StatementBindInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindInt +boolean StatementBindInt ( OCI_Statement *stmt, const otext *name, int *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_INT, sizeof(int), OCI_CDT_NUMERIC, SQLT_INT, OCI_NUM_INT, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfInts + * StatementBindArrayOfInts * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfInts +boolean StatementBindArrayOfInts ( OCI_Statement *stmt, const otext *name, @@ -2026,34 +2338,34 @@ boolean OCI_API OCI_BindArrayOfInts unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_INT, sizeof(int), OCI_CDT_NUMERIC, SQLT_INT, OCI_NUM_INT, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindUnsignedInt + * StatementBindUnsignedInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindUnsignedInt +boolean StatementBindUnsignedInt ( OCI_Statement *stmt, const otext *name, unsigned int *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_INT, sizeof(unsigned int), OCI_CDT_NUMERIC, SQLT_UIN, OCI_NUM_UINT, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfUnsignedInts + * StatementBindArrayOfUnsignedInts * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfUnsignedInts +boolean StatementBindArrayOfUnsignedInts ( OCI_Statement *stmt, const otext *name, @@ -2061,34 +2373,34 @@ boolean OCI_API OCI_BindArrayOfUnsignedInts unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_INT, sizeof(unsigned int), OCI_CDT_NUMERIC, SQLT_UIN, OCI_NUM_UINT, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindBigInt + * StatementBindBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindBigInt +boolean StatementBindBigInt ( OCI_Statement *stmt, const otext *name, big_int *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_BIGINT, sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGINT, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfBigInts + * StatementBindArrayOfBigInts * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfBigInts +boolean StatementBindArrayOfBigInts ( OCI_Statement *stmt, const otext *name, @@ -2096,34 +2408,34 @@ boolean OCI_API OCI_BindArrayOfBigInts unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_BIGINT, sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGINT, NULL, nbelem - ) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindUnsignedBigInt + * StatementBindUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindUnsignedBigInt +boolean StatementBindUnsignedBigInt ( OCI_Statement *stmt, const otext *name, big_uint *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_BIGINT, sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGUINT, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfUnsignedInts + * StatementBindArrayOfUnsignedInts * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfUnsignedBigInts +boolean StatementBindArrayOfUnsignedBigInts ( OCI_Statement *stmt, const otext *name, @@ -2131,17 +2443,17 @@ boolean OCI_API OCI_BindArrayOfUnsignedBigInts unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_BIGINT, sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGUINT, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindString + * StatementBindString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindString +boolean StatementBindString ( OCI_Statement *stmt, const otext *name, @@ -2149,9 +2461,13 @@ boolean OCI_API OCI_BindString unsigned int len ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_STRING, FALSE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_STRING, FALSE) if ((len == 0) || len == (UINT_MAX)) { @@ -2167,24 +2483,24 @@ boolean OCI_API OCI_BindString An invalid length passed to the function, we do not have a valid length to allocate internal array, thus we need to raise an exception */ - OCI_RAISE_EXCEPTION(OCI_ExceptionMinimumValue(stmt->con, stmt, 1)) + THROW(ExceptionMinimumValue, 1) } } const unsigned int size = (len + 1) * (ub4) sizeof(dbtext); - OCI_BIND_DATA(size, OCI_CDT_TEXT, SQLT_STR, 0, NULL, 0) + BIND_DATA(size, OCI_CDT_TEXT, SQLT_STR, 0, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfStrings + * StatementBindArrayOfStrings * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfStrings +boolean StatementBindArrayOfStrings ( OCI_Statement *stmt, const otext *name, @@ -2193,25 +2509,29 @@ boolean OCI_API OCI_BindArrayOfStrings unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_STRING, FALSE) - OCI_CALL_CHECK_MIN(stmt->con, stmt, len, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_STRING, FALSE) + CHECK_MIN(len, 1) const unsigned int size = (len + 1) * (ub4) sizeof(dbtext); - OCI_BIND_DATA(size, OCI_CDT_TEXT, SQLT_STR, 0, NULL, nbelem) + BIND_DATA(size, OCI_CDT_TEXT, SQLT_STR, 0, NULL, nbelem) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindRaw + * StatementBindRaw * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindRaw +boolean StatementBindRaw ( OCI_Statement *stmt, const otext *name, @@ -2219,9 +2539,13 @@ boolean OCI_API OCI_BindRaw unsigned int len ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_VOID, FALSE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_VOID, FALSE) if (len == 0 && !data) { @@ -2229,21 +2553,21 @@ boolean OCI_API OCI_BindRaw An invalid length passed to the function, we do not have a valid length to allocate internal array, thus we need to raise an exception */ - OCI_RAISE_EXCEPTION(OCI_ExceptionMinimumValue(stmt->con, stmt, 1)) + THROW(ExceptionMinimumValue, 1) } - OCI_BIND_DATA(len, OCI_CDT_RAW, SQLT_BIN, 0, NULL, 0) + BIND_DATA(len, OCI_CDT_RAW, SQLT_BIN, 0, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfRaws + * StatementBindArrayOfRaws * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfRaws +boolean StatementBindArrayOfRaws ( OCI_Statement *stmt, const otext *name, @@ -2252,56 +2576,64 @@ boolean OCI_API OCI_BindArrayOfRaws unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_VOID, FALSE) - OCI_CALL_CHECK_MIN(stmt->con, stmt, len, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_VOID, FALSE) + CHECK_MIN(len, 1) - OCI_BIND_DATA(len, OCI_CDT_RAW, SQLT_BIN, 0, NULL, nbelem) + BIND_DATA(len, OCI_CDT_RAW, SQLT_BIN, 0, NULL, nbelem) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindDouble + * StatementBindDouble * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindDouble +boolean StatementBindDouble ( OCI_Statement *stmt, const otext *name, double *data ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + unsigned int code = SQLT_FLT; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_DOUBLE, FALSE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_BIND(stmt, name, data, OCI_IPC_DOUBLE, FALSE) #if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCI_ConnectionIsVersionSupported(stmt->con, OCI_10_1)) + if (ConnectionIsVersionSupported(stmt->con, OCI_10_1)) { code = SQLT_BDOUBLE; } #endif - OCI_BIND_DATA(sizeof(double), OCI_CDT_NUMERIC, code, OCI_NUM_DOUBLE, NULL, 0) + BIND_DATA(sizeof(double), OCI_CDT_NUMERIC, code, OCI_NUM_DOUBLE, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfDoubles + * StatementBindArrayOfDoubles * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfDoubles +boolean StatementBindArrayOfDoubles ( OCI_Statement *stmt, const otext *name, @@ -2309,66 +2641,74 @@ boolean OCI_API OCI_BindArrayOfDoubles unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + unsigned int code = SQLT_FLT; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_DOUBLE, FALSE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_BIND(stmt, name, data, OCI_IPC_DOUBLE, FALSE) #if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCI_ConnectionIsVersionSupported(stmt->con, OCI_10_1)) + if (ConnectionIsVersionSupported(stmt->con, OCI_10_1)) { code = SQLT_BDOUBLE; } #endif - OCI_BIND_DATA(sizeof(double), OCI_CDT_NUMERIC, code, OCI_NUM_DOUBLE, NULL, nbelem) + BIND_DATA(sizeof(double), OCI_CDT_NUMERIC, code, OCI_NUM_DOUBLE, NULL, nbelem) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindFloat + * StatementBindFloat * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindFloat +boolean StatementBindFloat ( OCI_Statement *stmt, const otext *name, float *data ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + unsigned int code = SQLT_FLT; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_FLOAT, FALSE); - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_BIND(stmt, name, data, OCI_IPC_FLOAT, FALSE); #if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCI_ConnectionIsVersionSupported(stmt->con, OCI_10_1)) + if (ConnectionIsVersionSupported(stmt->con, OCI_10_1)) { code = SQLT_BFLOAT; } #endif - OCI_BIND_DATA(sizeof(float), OCI_CDT_NUMERIC, code, OCI_NUM_FLOAT, NULL, 0) + BIND_DATA(sizeof(float), OCI_CDT_NUMERIC, code, OCI_NUM_FLOAT, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfFloats + * StatementBindArrayOfFloats * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfFloats +boolean StatementBindArrayOfFloats ( OCI_Statement *stmt, const otext *name, @@ -2376,50 +2716,54 @@ boolean OCI_API OCI_BindArrayOfFloats unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + unsigned int code = SQLT_FLT; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_FLOAT, FALSE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_BIND(stmt, name, data, OCI_IPC_FLOAT, FALSE) #if OCI_VERSION_COMPILE >= OCI_10_1 - if (OCI_ConnectionIsVersionSupported(stmt->con, OCI_10_1)) + if (ConnectionIsVersionSupported(stmt->con, OCI_10_1)) { code = SQLT_BFLOAT; } #endif - OCI_BIND_DATA(sizeof(float), OCI_CDT_NUMERIC, code, OCI_NUM_FLOAT, NULL, nbelem) + BIND_DATA(sizeof(float), OCI_CDT_NUMERIC, code, OCI_NUM_FLOAT, NULL, nbelem) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindDate + * StatementBindDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindDate +boolean StatementBindDate ( OCI_Statement *stmt, const otext *name, OCI_Date *data ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_DATE, sizeof(OCIDate), OCI_CDT_DATETIME, SQLT_ODT, 0, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfDates + * StatementBindArrayOfDates * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfDates +boolean StatementBindArrayOfDates ( OCI_Statement *stmt, const otext *name, @@ -2427,46 +2771,50 @@ boolean OCI_API OCI_BindArrayOfDates unsigned int nbelem ) { - OCI_BIND_CALL_NULL_ALLOWED + BIND_CALL_NULL_ALLOWED ( OCI_IPC_DATE, sizeof(OCIDate), OCI_CDT_DATETIME, SQLT_ODT, 0, NULL, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindTimestamp + * StatementBindTimestamp * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindTimestamp +boolean StatementBindTimestamp ( OCI_Statement *stmt, const otext *name, OCI_Timestamp *data ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_TIMESTAMP, TRUE) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(stmt->con) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_TIMESTAMP, TRUE) + CHECK_TIMESTAMP_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_BIND_DATA(sizeof(OCIDateTime *), OCI_CDT_TIMESTAMP, - OCI_ExternalSubTypeToSQLType(OCI_CDT_TIMESTAMP, data->type), - data->type, NULL, 0) + BIND_DATA(sizeof(OCIDateTime *), OCI_CDT_TIMESTAMP, + ExternalSubTypeToSQLType(OCI_CDT_TIMESTAMP, data->type), + data->type, NULL, 0) #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfTimestamps + * StatementBindArrayOfTimestamps * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfTimestamps +boolean StatementBindArrayOfTimestamps ( OCI_Statement *stmt, const otext *name, @@ -2475,18 +2823,22 @@ boolean OCI_API OCI_BindArrayOfTimestamps unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_TIMESTAMP, FALSE) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_TIMESTAMP, FALSE) + CHECK_TIMESTAMP_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, TimestampTypeValues, OTEXT("Timestamp type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_ENUM_VALUE(type, TimestampTypeValues, OTEXT("Timestamp type")) - OCI_BIND_DATA(sizeof(OCIDateTime *), OCI_CDT_TIMESTAMP, - OCI_ExternalSubTypeToSQLType(OCI_CDT_TIMESTAMP, type), - type, NULL, nbelem) + BIND_DATA(sizeof(OCIDateTime *), OCI_CDT_TIMESTAMP, + ExternalSubTypeToSQLType(OCI_CDT_TIMESTAMP, type), + type, NULL, nbelem) #else @@ -2496,32 +2848,36 @@ boolean OCI_API OCI_BindArrayOfTimestamps #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindInterval + * StatementBindInterval * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindInterval +boolean StatementBindInterval ( OCI_Statement *stmt, const otext *name, OCI_Interval *data ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_INTERVAL, TRUE) - OCI_CALL_CHECK_INTERVAL_ENABLED(stmt->con) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_INTERVAL, TRUE) + CHECK_INTERVAL_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_BIND_DATA(sizeof(OCIInterval *), OCI_CDT_INTERVAL, - OCI_ExternalSubTypeToSQLType(OCI_CDT_INTERVAL, data->type), - data->type, NULL, 0) + BIND_DATA(sizeof(OCIInterval *), OCI_CDT_INTERVAL, + ExternalSubTypeToSQLType(OCI_CDT_INTERVAL, data->type), + data->type, NULL, 0) #else @@ -2529,16 +2885,16 @@ boolean OCI_API OCI_BindInterval #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfIntervals + * StatementBindArrayOfIntervals * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfIntervals +boolean StatementBindArrayOfIntervals ( OCI_Statement *stmt, const otext *name, @@ -2547,18 +2903,22 @@ boolean OCI_API OCI_BindArrayOfIntervals unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_INTERVAL, FALSE) - OCI_CALL_CHECK_INTERVAL_ENABLED(stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_INTERVAL, FALSE) + CHECK_INTERVAL_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, IntervalTypeValues, OTEXT("Interval type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_ENUM_VALUE(type, IntervalTypeValues, OTEXT("Interval type")) - OCI_BIND_DATA(sizeof(OCIInterval *), OCI_CDT_INTERVAL, - OCI_ExternalSubTypeToSQLType(OCI_CDT_INTERVAL, type), - type, NULL, nbelem) + BIND_DATA(sizeof(OCIInterval *), OCI_CDT_INTERVAL, + ExternalSubTypeToSQLType(OCI_CDT_INTERVAL, type), + type, NULL, nbelem) #else @@ -2568,33 +2928,33 @@ boolean OCI_API OCI_BindArrayOfIntervals #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindObject + * StatementBindObject * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindObject +boolean StatementBindObject ( OCI_Statement *stmt, const otext *name, OCI_Object *data ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( OCI_IPC_OBJECT, sizeof(void *), OCI_CDT_OBJECT, SQLT_NTY, 0, data->typinf, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfObjects + * StatementBindArrayOfObjects * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfObjects +boolean StatementBindArrayOfObjects ( OCI_Statement *stmt, const otext *name, @@ -2603,43 +2963,47 @@ boolean OCI_API OCI_BindArrayOfObjects unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_OBJECT, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_BIND_DATA(sizeof(void *), OCI_CDT_OBJECT, SQLT_NTY, 0, typinf, nbelem) + CHECK_BIND(stmt, name, data, OCI_IPC_OBJECT, FALSE) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_RETVAL = OCI_STATUS; + BIND_DATA(sizeof(void *), OCI_CDT_OBJECT, SQLT_NTY, 0, typinf, nbelem) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindLob + * StatementBindLob * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindLob +boolean StatementBindLob ( OCI_Statement *stmt, const otext *name, OCI_Lob *data ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( - OCI_IPC_LOB, + OCI_IPC_LOB, sizeof(OCILobLocator*), OCI_CDT_LOB, - OCI_ExternalSubTypeToSQLType(OCI_CDT_LOB, data->type), + ExternalSubTypeToSQLType(OCI_CDT_LOB, data->type), data->type, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfLobs + * StatementBindArrayOfLobs * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfLobs +boolean StatementBindArrayOfLobs ( OCI_Statement *stmt, const otext *name, @@ -2648,45 +3012,50 @@ boolean OCI_API OCI_BindArrayOfLobs unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_LOB, FALSE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, LobTypeValues, OTEXT("Lob type")) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_LOB, FALSE) - OCI_BIND_DATA(sizeof(OCILobLocator*), OCI_CDT_LOB, - OCI_ExternalSubTypeToSQLType(OCI_CDT_LOB, type), - type, NULL, nbelem) + CHECK_ENUM_VALUE(type, LobTypeValues, OTEXT("Lob type")) - OCI_RETVAL = OCI_STATUS; + BIND_DATA(sizeof(OCILobLocator*), OCI_CDT_LOB, + ExternalSubTypeToSQLType(OCI_CDT_LOB, type), + type, NULL, nbelem) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindFile + * StatementBindFile * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindFile +boolean StatementBindFile ( OCI_Statement *stmt, const otext *name, OCI_File *data ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( OCI_IPC_FILE, sizeof(OCILobLocator*), OCI_CDT_FILE, - OCI_ExternalSubTypeToSQLType(OCI_CDT_FILE, data->type), + ExternalSubTypeToSQLType(OCI_CDT_FILE, data->type), data->type, NULL, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfFiles + * StatementBindArrayOfFiles * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfFiles +boolean StatementBindArrayOfFiles ( OCI_Statement *stmt, const otext *name, @@ -2695,42 +3064,46 @@ boolean OCI_API OCI_BindArrayOfFiles unsigned int nbelem ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_LOB, OCI_IPC_FILE) - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, FileTypeValues, OTEXT("File type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_BIND(stmt, name, data, OCI_IPC_LOB, OCI_IPC_FILE) + CHECK_ENUM_VALUE(type, FileTypeValues, OTEXT("File type")) - OCI_BIND_DATA(sizeof(OCILobLocator*), OCI_CDT_FILE, - OCI_ExternalSubTypeToSQLType(OCI_CDT_FILE, type), - type, NULL, nbelem) + BIND_DATA(sizeof(OCILobLocator*), OCI_CDT_FILE, + ExternalSubTypeToSQLType(OCI_CDT_FILE, type), + type, NULL, nbelem) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindRef + * StatementBindReference * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindRef +boolean StatementBindReference ( OCI_Statement *stmt, const otext *name, OCI_Ref *data ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( OCI_IPC_REF, sizeof(OCIRef *), OCI_CDT_REF, SQLT_REF, 0, data->typinf, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfRefs + * StatementBindArrayOfReferences * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfRefs +boolean StatementBindArrayOfReferences ( OCI_Statement *stmt, const otext *name, @@ -2739,34 +3112,34 @@ boolean OCI_API OCI_BindArrayOfRefs unsigned int nbelem ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( OCI_IPC_REF, sizeof(OCIRef *), OCI_CDT_REF, SQLT_REF, 0, typinf, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindColl + * StatementBindCollection * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindColl +boolean StatementBindCollection ( OCI_Statement *stmt, const otext *name, OCI_Coll *data ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( OCI_IPC_COLLECTION, sizeof(OCIColl*), OCI_CDT_COLLECTION, SQLT_NTY, 0, data->typinf, 0 ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindArrayOfColls + * StatementBindArrayOfCollections * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindArrayOfColls +boolean StatementBindArrayOfCollections ( OCI_Statement *stmt, const otext *name, @@ -2775,38 +3148,43 @@ boolean OCI_API OCI_BindArrayOfColls unsigned int nbelem ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( OCI_IPC_COLLECTION, sizeof(OCIColl*), OCI_CDT_COLLECTION, SQLT_NTY, 0, typinf, nbelem ) } /* --------------------------------------------------------------------------------------------- * - * OCI_BindStatement + * StatementBindStatement * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindStatement +boolean StatementBindStatement ( OCI_Statement *stmt, const otext *name, OCI_Statement *data ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_BIND(stmt, name, data, OCI_IPC_STATEMENT, TRUE) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_BIND_DATA(sizeof(OCIStmt*), OCI_CDT_CURSOR, SQLT_RSET, 0, NULL, 0) + CHECK_BIND(stmt, name, data, OCI_IPC_STATEMENT, TRUE) - OCI_RETVAL = OCI_STATUS; - OCI_CALL_EXIT() + BIND_DATA(sizeof(OCIStmt*), OCI_CDT_CURSOR, SQLT_RSET, 0, NULL, 0) + + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_BindLong + * StatementBindLong * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_BindLong +boolean StatementBindLong ( OCI_Statement *stmt, const otext *name, @@ -2814,11 +3192,11 @@ boolean OCI_API OCI_BindLong unsigned int size ) { - OCI_BIND_CALL_NULL_FORBIDDEN + BIND_CALL_NULL_FORBIDDEN ( - OCI_IPC_LONG, + OCI_IPC_LONG, size, OCI_CDT_LONG, - OCI_ExternalSubTypeToSQLType(OCI_CDT_LONG, data->type), + ExternalSubTypeToSQLType(OCI_CDT_LONG, data->type), data->type, NULL, 0 ) } @@ -2827,520 +3205,602 @@ boolean OCI_API OCI_BindLong * OCI_RegisterNumber * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterNumber +boolean StatementRegisterNumber ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_NUMBER, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_NUMBER, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterShort + * StatementRegisterShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterShort +boolean StatementRegisterShort ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_SHORT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_SHORT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterUnsignedShort + * StatementRegisterUnsignedShort * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterUnsignedShort +boolean StatementRegisterUnsignedShort ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_USHORT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_USHORT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterInt + * StatementRegisterInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterInt +boolean StatementRegisterInt ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_INT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_INT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterUnsignedInt + * StatementRegisterUnsignedInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterUnsignedInt +boolean StatementRegisterUnsignedInt ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_UINT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_UINT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterBigInt + * StatementRegisterBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterBigInt +boolean StatementRegisterBigInt ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGINT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGINT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterUnsignedBigInt + * StatementRegisterUnsignedBigInt * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterUnsignedBigInt +boolean StatementRegisterUnsignedBigInt ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGUINT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_BIGUINT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterString + * StatementRegisterString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterString +boolean StatementRegisterString ( OCI_Statement *stmt, const otext *name, unsigned int len ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_MIN(stmt->con, stmt, len, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_REGISTER(stmt, name) + CHECK_MIN(len, 1) const int size = (len + 1) * (ub4) sizeof(dbtext); - OCI_REGISTER_DATA(size, OCI_CDT_TEXT, SQLT_STR, 0, NULL, 0) + REGISTER_DATA(size, OCI_CDT_TEXT, SQLT_STR, 0, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterRaw + * StatementRegisterRaw * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterRaw +boolean StatementRegisterRaw ( OCI_Statement *stmt, const otext *name, unsigned int len ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_MIN(stmt->con, stmt, len, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) - - OCI_REGISTER_DATA(len, OCI_CDT_RAW, SQLT_BIN, 0, NULL, 0) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_REGISTER(stmt, name) + CHECK_MIN(len, 1) - OCI_RETVAL = OCI_STATUS; + REGISTER_DATA(len, OCI_CDT_RAW, SQLT_BIN, 0, NULL, 0) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterDouble + * StatementRegisterDouble * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterDouble +boolean StatementRegisterDouble ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_DOUBLE, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_DOUBLE, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterFloat + * StatementRegisterFloat * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterFloat +boolean StatementRegisterFloat ( OCI_Statement *stmt, const otext *name ) { - OCI_REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_FLOAT, NULL, 0) + REGISTER_CALL(sizeof(OCINumber), OCI_CDT_NUMERIC, SQLT_VNU, OCI_NUM_FLOAT, NULL, 0) } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterDate + * StatementRegisterDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterDate +boolean StatementRegisterDate ( OCI_Statement *stmt, const otext *name ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + unsigned int code = SQLT_ODT; unsigned int size = sizeof(OCIDate); - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_REGISTER(stmt, name) /* versions of OCI (< 10.2) crashes if SQLT_ODT is passed for output data with returning clause. It's an Oracle known bug #3269146 */ - if (OCI_GetVersionConnection(stmt->con) < OCI_10_2) + if (ConnectionGetVersion(stmt->con) < OCI_10_2) { code = SQLT_DAT; size = 7; } - OCI_REGISTER_DATA(size, OCI_CDT_DATETIME, code, 0, NULL, 0) + REGISTER_DATA(size, OCI_CDT_DATETIME, code, 0, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterTimestamp + * StatementRegisterTimestamp * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterTimestamp +boolean StatementRegisterTimestamp ( OCI_Statement *stmt, const otext *name, unsigned int type ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_REGISTER(stmt, name) + CHECK_TIMESTAMP_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, TimestampTypeValues, OTEXT("Timestamp type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_ENUM_VALUE(type, TimestampTypeValues, OTEXT("Timestamp type")) - OCI_REGISTER_DATA(sizeof(OCIDateTime *), OCI_CDT_TIMESTAMP, - OCI_ExternalSubTypeToSQLType(OCI_CDT_TIMESTAMP, type), - type, NULL, 0) + REGISTER_DATA(sizeof(OCIDateTime *), OCI_CDT_TIMESTAMP, + ExternalSubTypeToSQLType(OCI_CDT_TIMESTAMP, type), + type, NULL, 0) #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterInterval + * StatementRegisterInterval * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterInterval +boolean StatementRegisterInterval ( OCI_Statement *stmt, const otext *name, unsigned int type ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_INTERVAL_ENABLED(stmt->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_REGISTER(stmt, name) + CHECK_INTERVAL_ENABLED(stmt->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, IntervalTypeValues, OTEXT("Interval type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_ENUM_VALUE(type, IntervalTypeValues, OTEXT("Interval type")) - OCI_REGISTER_DATA(sizeof(OCIInterval *), OCI_CDT_INTERVAL, - OCI_ExternalSubTypeToSQLType(OCI_CDT_INTERVAL, type), - type, NULL, 0) + REGISTER_DATA(sizeof(OCIInterval *), OCI_CDT_INTERVAL, + ExternalSubTypeToSQLType(OCI_CDT_INTERVAL, type), + type, NULL, 0) #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterObject + * StatementRegisterObject * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterObject +boolean StatementRegisterObject ( OCI_Statement *stmt, const otext *name, OCI_TypeInfo *typinf ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_REGISTER_DATA(sizeof(void *), OCI_CDT_OBJECT, SQLT_NTY, 0, typinf, 0) + CHECK_REGISTER(stmt, name) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_RETVAL = OCI_STATUS; + REGISTER_DATA(sizeof(void *), OCI_CDT_OBJECT, SQLT_NTY, 0, typinf, 0) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterLob + * StatementRegisterLob * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterLob +boolean StatementRegisterLob ( OCI_Statement *stmt, const otext *name, unsigned int type ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, LobTypeValues, OTEXT("Lob type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_REGISTER(stmt, name) + CHECK_ENUM_VALUE(type, LobTypeValues, OTEXT("Lob type")) - OCI_REGISTER_DATA(sizeof(OCILobLocator*), OCI_CDT_LOB, - OCI_ExternalSubTypeToSQLType(OCI_CDT_LOB, type), - type, NULL, 0) + REGISTER_DATA(sizeof(OCILobLocator*), OCI_CDT_LOB, + ExternalSubTypeToSQLType(OCI_CDT_LOB, type), + type, NULL, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterFile + * StatementRegisterFile * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterFile +boolean StatementRegisterFile ( OCI_Statement *stmt, const otext *name, unsigned int type ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, type, FileTypeValues, OTEXT("File type")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_REGISTER_DATA(sizeof(OCILobLocator*), OCI_CDT_FILE, - OCI_ExternalSubTypeToSQLType(OCI_CDT_FILE, type), - type, NULL, 0) + CHECK_REGISTER(stmt, name) + CHECK_ENUM_VALUE(type, FileTypeValues, OTEXT("File type")) - OCI_RETVAL = OCI_STATUS; + REGISTER_DATA(sizeof(OCILobLocator*), OCI_CDT_FILE, + ExternalSubTypeToSQLType(OCI_CDT_FILE, type), + type, NULL, 0) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_RegisterRef + * StatementRegisterReference * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_RegisterRef +boolean StatementRegisterReference ( OCI_Statement *stmt, const otext *name, OCI_TypeInfo *typinf ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_REGISTER(stmt, name) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_REGISTER(stmt, name) + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_REGISTER_DATA(sizeof(OCIRef *), OCI_CDT_REF, SQLT_REF, 0, typinf, 0) + REGISTER_DATA(sizeof(OCIRef *), OCI_CDT_REF, SQLT_REF, 0, typinf, 0) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetStatementType + * StatementGetStatementType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetStatementType +unsigned int StatementGetStatementType ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_STATEMENT, stmt, type, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_STATEMENT, stmt, + type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetFetchMode + * StatementSetFetchMode * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetFetchMode +boolean StatementSetFetchMode ( OCI_Statement *stmt, unsigned int mode ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) unsigned int old_exec_mode = OCI_UNKNOWN; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_SCROLLABLE_CURSOR_ENABLED(stmt->con) - OCI_CALL_CHECK_ENUM_VALUE(stmt->con, stmt, mode, FetchModeValues, OTEXT("Fetch mode")) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_SCROLLABLE_CURSOR_ENABLED(stmt->con) + CHECK_ENUM_VALUE(mode, FetchModeValues, OTEXT("Fetch mode")) - old_exec_mode = stmt->exec_mode; + old_exec_mode = stmt->exec_mode; stmt->exec_mode = mode; if (stmt->con->ver_num == OCI_9_0) { if (old_exec_mode == OCI_SFM_DEFAULT && stmt->exec_mode == OCI_SFM_SCROLLABLE) { - // Disabling prefetch that causes bugs for 9iR1 for scrollable cursors - OCI_SetPrefetchSize(stmt, 0); + /* Disabling prefetch that causes bugs for 9iR1 for scrollable cursors */ + StatementSetPrefetchSize(stmt, 0); } else if (old_exec_mode == OCI_SFM_SCROLLABLE && stmt->exec_mode == OCI_SFM_DEFAULT) { - // Re-enable prefetch previously disabled - OCI_SetPrefetchSize(stmt, OCI_PREFETCH_SIZE); + /* Re-enable prefetch previously disabled */ + StatementSetPrefetchSize(stmt, OCI_PREFETCH_SIZE); } } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetFetchMode + * StatementGetFetchMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetFetchMode +unsigned int StatementGetFetchMode ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_STATEMENT, stmt, exec_mode, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_STATEMENT, stmt, + exec_mode + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetBindMode + * StatementSetBindMode * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetBindMode +boolean StatementSetBindMode ( OCI_Statement *stmt, unsigned int mode ) { - OCI_SET_PROP_ENUM(ub1, OCI_IPC_STATEMENT, stmt, bind_mode, mode, BindModeValues, OTEXT("Bind mode"), stmt->con, stmt, stmt->con->err) + SET_PROP_ENUM + ( + /* handle */ OCI_IPC_STATEMENT, stmt, + /* member */ bind_mode, ub1, + /* value */ mode, BindModeValues, OTEXT("Bind Mode") + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBindMode + * StatementGetBindMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetBindMode +unsigned int StatementGetBindMode ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_STATEMENT, stmt, bind_mode, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_STATEMENT, stmt, + bind_mode + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetBindAllocation + * StatementSetBindAllocation * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetBindAllocation +boolean StatementSetBindAllocation ( OCI_Statement *stmt, unsigned int mode ) { - OCI_SET_PROP_ENUM(ub1, OCI_IPC_STATEMENT, stmt, bind_alloc_mode, mode, BindAllocationValues, OTEXT("Bind Allocation"), stmt->con, stmt, stmt->con->err) + SET_PROP_ENUM + ( + /* handle */ OCI_IPC_STATEMENT, stmt, + /* member */ bind_alloc_mode, ub1, + /* value */ mode, BindAllocationValues, OTEXT("Bind Allocation") + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBindAllocation + * StatementGetBindAllocation * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetBindAllocation +unsigned int StatementGetBindAllocation ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_STATEMENT, stmt, bind_alloc_mode, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_STATEMENT, stmt, + bind_alloc_mode + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetFetchSize + * StatementSetFetchSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetFetchSize +boolean StatementSetFetchSize ( OCI_Statement *stmt, unsigned int size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_MIN(stmt->con, stmt, size, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_MIN(size, 1) stmt->fetch_size = size; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetFetchSize + * StatementGetFetchSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetFetchSize +unsigned int StatementGetFetchSize ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, fetch_size, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + fetch_size + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_PrefetchSize + * StatementPrefetchSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetPrefetchSize +boolean StatementSetPrefetchSize ( OCI_Statement *stmt, unsigned int size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) stmt->prefetch_size = size; @@ -3353,326 +3813,421 @@ boolean OCI_API OCI_SetPrefetchSize if (stmt->stmt) { - OCI_SET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_PREFETCH_ROWS, stmt->stmt, &stmt->prefetch_size, sizeof(stmt->prefetch_size)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_STMT, OCI_ATTR_PREFETCH_ROWS, + stmt->stmt, &stmt->prefetch_size, sizeof(stmt->prefetch_size), + stmt->con->err + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetPrefetchSize + * StatementGetPrefetchSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetPrefetchSize +unsigned int StatementGetPrefetchSize ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, prefetch_size, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + prefetch_size + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetPrefetchMemory + * StatementSetPrefetchMemory * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetPrefetchMemory +boolean StatementSetPrefetchMemory ( OCI_Statement *stmt, unsigned int size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) stmt->prefetch_mem = size; if (stmt->stmt) { - OCI_SET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_PREFETCH_MEMORY, stmt->stmt, &stmt->prefetch_mem, sizeof(stmt->prefetch_mem)) + CHECK_ATTRIB_SET + ( + OCI_HTYPE_STMT, OCI_ATTR_PREFETCH_MEMORY, + stmt->stmt, &stmt->prefetch_mem, sizeof(stmt->prefetch_mem), + stmt->con->err + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetPrefetchMemory + * StatementGetPrefetchMemory * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetPrefetchMemory +unsigned int StatementGetPrefetchMemory ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, prefetch_mem, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + prefetch_mem + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetLongMaxSize + * StatementSetLongMaxSize * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetLongMaxSize +boolean StatementSetLongMaxSize ( OCI_Statement *stmt, unsigned int size ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_MIN(stmt->con, stmt, size, 1) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_MIN(size, 1) stmt->long_size = size; - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLongMaxSize + * StatementGetLongMaxSize * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetLongMaxSize +unsigned int StatementGetLongMaxSize ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, long_size, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + long_size + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SetLongMode + * StatementSetLongMode * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SetLongMode +boolean StatementSetLongMode ( OCI_Statement *stmt, unsigned int mode ) { - OCI_SET_PROP_ENUM(ub1, OCI_IPC_STATEMENT, stmt, long_mode, mode, LongModeValues, OTEXT("Long Mode"), stmt->con, stmt, stmt->con->err) + SET_PROP_ENUM + ( + /* handle */ OCI_IPC_STATEMENT, stmt, + /* member */ long_mode, ub1, + /* value */ mode, LongModeValues, OTEXT("Long Mode") + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetLongMode + * StatementGetLongMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetLongMode +unsigned int StatementGetLongMode ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_STATEMENT, stmt, long_mode, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_STATEMENT, stmt, + long_mode + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_StatementGetConnection + * StatementGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_StatementGetConnection +OCI_Connection * StatementGetConnection ( OCI_Statement *stmt ) { - OCI_GET_PROP(OCI_Connection*, NULL, OCI_IPC_STATEMENT, stmt, con, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + OCI_Connection*, NULL, + OCI_IPC_STATEMENT, stmt, + con + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetSql + * StatementGetSql * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetSql +const otext * StatementGetSql ( OCI_Statement *stmt ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_STATEMENT, stmt, sql, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + const otext*, NULL, + OCI_IPC_STATEMENT, stmt, + sql + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetSqlIdentifier + * StatementGetSqlIdentifier * --------------------------------------------------------------------------------------------- */ -OCI_EXPORT const otext* OCI_API OCI_GetSqlIdentifier +const otext* StatementGetSqlIdentifier ( OCI_Statement *stmt ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_STATEMENT, stmt, sql_id, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + const otext*, NULL, + OCI_IPC_STATEMENT, stmt, + sql_id + ) } - /* --------------------------------------------------------------------------------------------- * - * OCI_GetSqlErrorPos + * StatementGetSqlErrorPos * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetSqlErrorPos +unsigned int StatementGetSqlErrorPos ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, err_pos, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + err_pos + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetAffectedRows + * StatementGetAffectedRows * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetAffectedRows +unsigned int StatementGetAffectedRows ( OCI_Statement *stmt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + ub4 count = 0; - OCI_CALL_ENTER(unsigned int, count) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_ROW_COUNT, stmt->stmt, &count, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_ROW_COUNT, + stmt->stmt, &count, NULL, + stmt->con->err + ) - OCI_RETVAL = count; + SET_RETVAL(count) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBindCount + * StatementGetBindCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetBindCount +unsigned int StatementGetBindCount ( OCI_Statement *stmt ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_STATEMENT, stmt, nb_ubinds, stmt->con, stmt, stmt->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_STATEMENT, stmt, + nb_ubinds + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBind + * StatementGetBind * --------------------------------------------------------------------------------------------- */ -OCI_Bind * OCI_API OCI_GetBind +OCI_Bind * StatementGetBind ( OCI_Statement *stmt, unsigned int index ) { - OCI_CALL_ENTER(OCI_Bind*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_BOUND(stmt->con, index, 1, stmt->nb_ubinds) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ OCI_Bind*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_RETVAL = stmt->ubinds[index - 1]; + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_BOUND(index, 1, stmt->nb_ubinds) - OCI_CALL_EXIT() + SET_RETVAL(stmt->ubinds[index - 1]) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBind2 + * StatementGetBind2 * --------------------------------------------------------------------------------------------- */ -OCI_Bind * OCI_API OCI_GetBind2 +OCI_Bind * StatementGetBind2 ( OCI_Statement *stmt, const otext *name ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ OCI_Bind*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_ENTER(OCI_Bind*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + int index = -1; - index = OCI_BindGetInternalIndex(stmt, name); + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, name) - if (index > 0) - { - OCI_RETVAL = stmt->ubinds[index - 1]; - } - else + index = BindGetIndex(stmt, name); + if (index <= 0) { - OCI_RAISE_EXCEPTION(OCI_ExceptionItemNotFound(stmt->con, stmt, name, OCI_IPC_BIND)) + THROW(ExceptionItemNotFound, name, OCI_IPC_BIND) } - OCI_CALL_EXIT() + SET_RETVAL(stmt->ubinds[index - 1]) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * -* OCI_GetBindIndex +* GetBindIndex * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetBindIndex +unsigned int StatementGetBindIndex ( OCI_Statement *stmt, const otext *name ) { - int index = -1; + ENTER_FUNC + ( + /* returns */ unsigned int, 0, + /* context */ OCI_IPC_STATEMENT, stmt + ) - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + int index = -1; - OCI_STATUS = FALSE; + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_PTR(OCI_IPC_STRING, name) - index = OCI_BindGetInternalIndex(stmt, name); + index = BindGetIndex(stmt, name); + CHECK(index >= 0) - if (index >= 0) - { - OCI_RETVAL = index; - OCI_STATUS = TRUE; - } + SET_RETVAL(index) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetSQLCommand + * StatementGetSqlCommand * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetSQLCommand +unsigned int StatementGetSqlCommand ( OCI_Statement *stmt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) + ub2 code = OCI_UNKNOWN; - OCI_CALL_ENTER(unsigned int, code) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_EXECUTED) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_STMT_STATUS(stmt, OCI_STMT_EXECUTED) - OCI_GET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_SQLFNCODE, stmt->stmt, &code, NULL) + CHECK_ATTRIB_GET + ( + OCI_HTYPE_STMT, OCI_ATTR_SQLFNCODE, + stmt->stmt, &code, NULL, + stmt->con->err + ) - OCI_RETVAL = code; + SET_RETVAL(code) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetSQLVerb + * StatementGetSqlVerb * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_GetSQLVerb +const otext * StatementGetSqlVerb ( OCI_Statement *stmt ) { + ENTER_FUNC + ( + /* returns */ const otext*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) + unsigned int code = OCI_UNKNOWN; - OCI_CALL_ENTER(const otext *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + code = StatementGetSqlCommand(stmt); - code = OCI_GetSQLCommand(stmt); + const otext* verb = NULL; if (OCI_UNKNOWN != code) { @@ -3680,54 +4235,61 @@ const otext * OCI_API OCI_GetSQLVerb { if (code == SQLCmds[i].code) { - OCI_RETVAL = SQLCmds[i].verb; + verb = SQLCmds[i].verb; break; } } } - OCI_CALL_EXIT() + SET_RETVAL(verb) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBatchError + * StatementGetBatchError * --------------------------------------------------------------------------------------------- */ -OCI_Error * OCI_API OCI_GetBatchError +OCI_Error * StatementGetBatchError ( OCI_Statement *stmt ) { - OCI_CALL_ENTER(OCI_Error*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ OCI_Error*, NULL, + /* context */ OCI_IPC_STATEMENT, stmt + ) - if (stmt->batch && (stmt->batch->cur < stmt->batch->count)) - { - OCI_RETVAL = &stmt->batch->errs[stmt->batch->cur++]; - } + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + + CHECK(NULL != stmt->batch && stmt->batch->cur < stmt->batch->count) - OCI_CALL_EXIT() + SET_RETVAL(&stmt->batch->errs[stmt->batch->cur++]) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_GetBatchErrorCount + * StatementGetBatchErrorCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_GetBatchErrorCount +unsigned int StatementGetBatchErrorCount ( OCI_Statement *stmt ) { - OCI_CALL_ENTER(unsigned int, 0) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CONTEXT_SET_FROM_STMT(stmt) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_STATEMENT, stmt + ) - if (stmt->batch) - { - OCI_RETVAL = stmt->batch->count; - } + CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_EXIT() -} + CHECK_NULL(stmt->batch) + SET_RETVAL(stmt->batch->count) + + EXIT_FUNC() +} diff --git a/src/statement.h b/src/statement.h new file mode 100644 index 00000000..1af8f977 --- /dev/null +++ b/src/statement.h @@ -0,0 +1,757 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_STATEMENT_H_INCLUDED +#define OCILIB_STATEMENT_H_INCLUDED + +#include "types.h" + +boolean StatementFetchIntoUserVariables +( + OCI_Statement* stmt, + va_list args +); + +boolean StatementDispose +( + OCI_Statement* stmt +); + +OCI_Statement* StatementInitialize +( + OCI_Connection* con, + OCI_Statement * stmt, + OCIStmt * handle, + boolean is_desc, + const otext * sql +); + +boolean StatementPrepareInternal +( + OCI_Statement* stmt, + const otext * sql +); + +boolean StatementExecuteInternal +( + OCI_Statement* stmt, + ub4 mode +); + +OCI_Statement* StatementCreate +( + OCI_Connection* con +); + +boolean StatementFree +( + OCI_Statement* stmt +); + +OCI_Resultset* StatementGetResultset +( + OCI_Statement* stmt +); + +OCI_Resultset* StatementGetNextResultset +( + OCI_Statement* stmt +); + +boolean StatementReleaseResultsets +( + OCI_Statement* stmt +); + +boolean StatementPrepare +( + OCI_Statement* stmt, + const otext * sql +); + +boolean StatementExecute +( + OCI_Statement* stmt +); + +boolean StatementExecuteStmt +( + OCI_Statement* stmt, + const otext * sql +); + +boolean StatementParse +( + OCI_Statement* stmt, + const otext * sql +); + +boolean StatementDescribe +( + OCI_Statement* stmt, + const otext * sql +); + +boolean StatementPrepareFmt +( + OCI_Statement* stmt, + const otext * sql, + va_list args +); + +boolean StatementExecuteStmtFmt +( + OCI_Statement* stmt, + const otext * sql, + va_list args +); + +boolean StatementParseFmt +( + OCI_Statement* stmt, + const otext * sql, + va_list args +); + +boolean StatementDescribeFmt +( + OCI_Statement* stmt, + const otext * sql, + va_list args +); + +boolean StatementSetBindArraySize +( + OCI_Statement* stmt, + unsigned int size +); + +unsigned int StatementGetBindArraySize +( + OCI_Statement* stmt +); + +boolean StatementAllowRebinding +( + OCI_Statement* stmt, + boolean value +); + +boolean StatementIsRebindingAllowed +( + OCI_Statement* stmt +); + +boolean StatementBindBoolean +( + OCI_Statement* stmt, + const otext * name, + boolean * data +); + +boolean StatementBindNumber +( + OCI_Statement* stmt, + const otext * name, + OCI_Number * data +); + +boolean StatementBindArrayOfNumbers +( + OCI_Statement* stmt, + const otext * name, + OCI_Number ** data, + unsigned int nbelem +); + +boolean StatementBindShort +( + OCI_Statement* stmt, + const otext * name, + short * data +); + +boolean StatementBindArrayOfShorts +( + OCI_Statement* stmt, + const otext * name, + short * data, + unsigned int nbelem +); + +boolean StatementBindUnsignedShort +( + OCI_Statement * stmt, + const otext * name, + unsigned short* data +); + +boolean StatementBindArrayOfUnsignedShorts +( + OCI_Statement * stmt, + const otext * name, + unsigned short* data, + unsigned int nbelem +); + +boolean StatementBindInt +( + OCI_Statement* stmt, + const otext * name, + int * data +); + +boolean StatementBindArrayOfInts +( + OCI_Statement* stmt, + const otext * name, + int * data, + unsigned int nbelem +); + +boolean StatementBindUnsignedInt +( + OCI_Statement* stmt, + const otext * name, + unsigned int * data +); + +boolean StatementBindArrayOfUnsignedInts +( + OCI_Statement* stmt, + const otext * name, + unsigned int * data, + unsigned int nbelem +); + +boolean StatementBindBigInt +( + OCI_Statement* stmt, + const otext * name, + big_int * data +); + +boolean StatementBindArrayOfBigInts +( + OCI_Statement* stmt, + const otext * name, + big_int * data, + unsigned int nbelem +); + +boolean StatementBindUnsignedBigInt +( + OCI_Statement* stmt, + const otext * name, + big_uint * data +); + +boolean StatementBindArrayOfUnsignedBigInts +( + OCI_Statement* stmt, + const otext * name, + big_uint * data, + unsigned int nbelem +); + +boolean StatementBindString +( + OCI_Statement* stmt, + const otext * name, + otext * data, + unsigned int len +); + +boolean StatementBindArrayOfStrings +( + OCI_Statement* stmt, + const otext * name, + otext * data, + unsigned int len, + unsigned int nbelem +); + +boolean StatementBindRaw +( + OCI_Statement* stmt, + const otext * name, + void * data, + unsigned int len +); + +boolean StatementBindArrayOfRaws +( + OCI_Statement* stmt, + const otext * name, + void * data, + unsigned int len, + unsigned int nbelem +); + +boolean StatementBindDouble +( + OCI_Statement* stmt, + const otext * name, + double * data +); + +boolean StatementBindArrayOfDoubles +( + OCI_Statement* stmt, + const otext * name, + double * data, + unsigned int nbelem +); + +boolean StatementBindFloat +( + OCI_Statement* stmt, + const otext * name, + float * data +); + +boolean StatementBindArrayOfFloats +( + OCI_Statement* stmt, + const otext * name, + float * data, + unsigned int nbelem +); + +boolean StatementBindDate +( + OCI_Statement* stmt, + const otext * name, + OCI_Date * data +); + +boolean StatementBindArrayOfDates +( + OCI_Statement* stmt, + const otext * name, + OCI_Date ** data, + unsigned int nbelem +); + +boolean StatementBindTimestamp +( + OCI_Statement* stmt, + const otext * name, + OCI_Timestamp* data +); + +boolean StatementBindArrayOfTimestamps +( + OCI_Statement * stmt, + const otext * name, + OCI_Timestamp** data, + unsigned int type, + unsigned int nbelem +); + +boolean StatementBindInterval +( + OCI_Statement* stmt, + const otext * name, + OCI_Interval * data +); + +boolean StatementBindArrayOfIntervals +( + OCI_Statement* stmt, + const otext * name, + OCI_Interval** data, + unsigned int type, + unsigned int nbelem +); + +boolean StatementBindObject +( + OCI_Statement* stmt, + const otext * name, + OCI_Object * data +); + +boolean StatementBindArrayOfObjects +( + OCI_Statement* stmt, + const otext * name, + OCI_Object ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +boolean StatementBindLob +( + OCI_Statement* stmt, + const otext * name, + OCI_Lob * data +); + +boolean StatementBindArrayOfLobs +( + OCI_Statement* stmt, + const otext * name, + OCI_Lob ** data, + unsigned int type, + unsigned int nbelem +); + +boolean StatementBindFile +( + OCI_Statement* stmt, + const otext * name, + OCI_File * data +); + +boolean StatementBindArrayOfFiles +( + OCI_Statement* stmt, + const otext * name, + OCI_File ** data, + unsigned int type, + unsigned int nbelem +); + +boolean StatementBindReference +( + OCI_Statement* stmt, + const otext * name, + OCI_Ref * data +); + +boolean StatementBindArrayOfReferences +( + OCI_Statement* stmt, + const otext * name, + OCI_Ref ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +boolean StatementBindCollection +( + OCI_Statement* stmt, + const otext * name, + OCI_Coll * data +); + +boolean StatementBindArrayOfCollections +( + OCI_Statement* stmt, + const otext * name, + OCI_Coll ** data, + OCI_TypeInfo * typinf, + unsigned int nbelem +); + +boolean StatementBindStatement +( + OCI_Statement* stmt, + const otext * name, + OCI_Statement* data +); + +boolean StatementBindLong +( + OCI_Statement* stmt, + const otext * name, + OCI_Long * data, + unsigned int size +); + +boolean StatementRegisterNumber +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterShort +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterUnsignedShort +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterInt +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterUnsignedInt +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterBigInt +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterUnsignedBigInt +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterString +( + OCI_Statement* stmt, + const otext * name, + unsigned int len +); + +boolean StatementRegisterRaw +( + OCI_Statement* stmt, + const otext * name, + unsigned int len +); + +boolean StatementRegisterDouble +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterFloat +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterDate +( + OCI_Statement* stmt, + const otext * name +); + +boolean StatementRegisterTimestamp +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +); + +boolean StatementRegisterInterval +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +); + +boolean StatementRegisterObject +( + OCI_Statement* stmt, + const otext * name, + OCI_TypeInfo * typinf +); + +boolean StatementRegisterLob +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +); + +boolean StatementRegisterFile +( + OCI_Statement* stmt, + const otext * name, + unsigned int type +); + +boolean StatementRegisterReference +( + OCI_Statement* stmt, + const otext * name, + OCI_TypeInfo * typinf +); + +unsigned int StatementGetStatementType +( + OCI_Statement* stmt +); + +boolean StatementSetFetchMode +( + OCI_Statement* stmt, + unsigned int mode +); + +unsigned int StatementGetFetchMode +( + OCI_Statement* stmt +); + +boolean StatementSetBindMode +( + OCI_Statement* stmt, + unsigned int mode +); + +unsigned int StatementGetBindMode +( + OCI_Statement* stmt +); + +boolean StatementSetBindAllocation +( + OCI_Statement* stmt, + unsigned int mode +); + +unsigned int StatementGetBindAllocation +( + OCI_Statement* stmt +); + +boolean StatementSetFetchSize +( + OCI_Statement* stmt, + unsigned int size +); + +unsigned int StatementGetFetchSize +( + OCI_Statement* stmt +); + +boolean StatementSetPrefetchSize +( + OCI_Statement* stmt, + unsigned int size +); + +unsigned int StatementGetPrefetchSize +( + OCI_Statement* stmt +); + +boolean StatementSetPrefetchMemory +( + OCI_Statement* stmt, + unsigned int size +); + +unsigned int StatementGetPrefetchMemory +( + OCI_Statement* stmt +); + +boolean StatementSetLongMaxSize +( + OCI_Statement* stmt, + unsigned int size +); + +unsigned int StatementGetLongMaxSize +( + OCI_Statement* stmt +); + +boolean StatementSetLongMode +( + OCI_Statement* stmt, + unsigned int mode +); + +unsigned int StatementGetLongMode +( + OCI_Statement* stmt +); + +OCI_Connection* StatementGetConnection +( + OCI_Statement* stmt +); + +const otext* StatementGetSql +( + OCI_Statement* stmt +); + +const otext* StatementGetSqlIdentifier +( + OCI_Statement* stmt +); + +unsigned int StatementGetSqlErrorPos +( + OCI_Statement* stmt +); + +unsigned int StatementGetAffectedRows +( + OCI_Statement* stmt +); + +unsigned int StatementGetBindCount +( + OCI_Statement* stmt +); + +OCI_Bind* StatementGetBind +( + OCI_Statement* stmt, + unsigned int index +); + +OCI_Bind* StatementGetBind2 +( + OCI_Statement* stmt, + const otext * name +); + +unsigned int StatementGetBindIndex +( + OCI_Statement* stmt, + const otext * name +); + +unsigned int StatementGetSqlCommand +( + OCI_Statement* stmt +); + +const otext* StatementGetSqlVerb +( + OCI_Statement* stmt +); + +OCI_Error* StatementGetBatchError +( + OCI_Statement* stmt +); + +unsigned int StatementGetBatchErrorCount +( + OCI_Statement* stmt +); + +#endif /* OCILIB_STATEMENT_H_INCLUDED */ diff --git a/src/string.c b/src/strings.c similarity index 62% rename from src/string.c rename to src/strings.c index 746d3551..e611b532 100644 --- a/src/string.c +++ b/src/strings.c @@ -1,1250 +1,1322 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ocilib_internal.h" - -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - -#define COMPUTE_LENTGH(type, ptr, size) \ - const type *s = (const type *) (ptr); \ - const type *e = (const type *) (ptr); \ - while (*e++) ; \ - (size) = (int) (e - s - (size_t) 1); \ - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringLength - * --------------------------------------------------------------------------------------------- */ - -size_t OCI_StringLength -( - const void *ptr, - size_t size_elem -) -{ - int size = 0; - - OCI_CHECK(NULL == ptr, 0); - - if (OCILib.nls_utf8) - { - const char *s = (char *) ptr; - while (*s) - { - if ((*s & 0xc0) != 0x80) size++; - s++; - } - } - else if (sizeof(char) == size_elem) - { - COMPUTE_LENTGH(char, ptr, size) - } - else if (sizeof(short) == size_elem) - { - COMPUTE_LENTGH(short, ptr, size) - } - else if (sizeof(int) == size_elem) - { - COMPUTE_LENTGH(int, ptr, size) - } - - return size; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringBinaryToString - * --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_StringBinaryToString -( - const unsigned char *binary, - unsigned int binary_size, - otext *buffer -) -{ - char hex_str[] = "0123456789ABCDEF"; - - const unsigned int len = binary_size * 2; - - if (buffer) - { - for (unsigned int i = 0; i < binary_size; i++) - { - buffer[i * 2 + 0] = hex_str[binary[i] >> 4 ]; - buffer[i * 2 + 1] = hex_str[binary[i] & 0x0F]; - } - - buffer[len] = 0; - } - - return len; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringRequestBuffer - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_StringRequestBuffer -( - otext **buffer, - unsigned int *buffer_size, - unsigned int request_size -) -{ - boolean res = FALSE; - - if (!buffer || !buffer_size) - { - return FALSE; - } - - request_size++; - - request_size *= OCILib.nls_utf8 ? OCI_UTF8_BYTES_PER_CHAR : sizeof(otext); - - if (!*buffer) - { - *buffer = (otext *) OCI_MemAlloc(OCI_IPC_STRING, (size_t) request_size, (size_t) 1, TRUE); - } - else if (*buffer_size < request_size) - { - *buffer = (otext *) OCI_MemRealloc(*buffer, OCI_IPC_STRING, (size_t) request_size, (size_t) 1, TRUE); - } - - if (*buffer) - { - *buffer_size = request_size; - res = TRUE; - } - - return res; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringTranslate - * --------------------------------------------------------------------------------------------- */ - -void OCI_StringTranslate -( - void *src, - void *dst, - int char_count, - size_t size_char_in, - size_t size_char_out -) -{ - const int len = char_count; - - if (!src || !dst) - { - return; - } - - /* raw string packing/expansion without charset conversion */ - - if (size_char_out > size_char_in) - { - /* expand string */ - - if ((size_char_in == sizeof(short)) && (size_char_out == sizeof(int))) - { - /* 2 => 4 bytes */ - - unsigned short *str1 = (unsigned short *) src; - unsigned int *str2 = (unsigned int *) dst; - - if (*str1 == 0) - { - return; - } - - while (char_count--) - { - str2[char_count] = (unsigned int) str1[char_count]; - } - } - - else if ((size_char_in == sizeof(char)) && (size_char_out == sizeof(short))) - { - /* 1 => 2 bytes */ - - unsigned char *str1 = (unsigned char *) src; - unsigned short *str2 = (unsigned short *) dst; - - if (*str1 == 0) - { - return; - } - - while (char_count--) - { - str2[char_count] = (unsigned short) str1[char_count]; - } - } - else if ((size_char_in == sizeof(char)) && (size_char_out == sizeof(int))) - { - /* 1 => 4 bytes */ - - unsigned char *str1 = (unsigned char *) src; - unsigned int *str2 = (unsigned int *) dst; - - if (*str1 == 0) - { - return; - } - - while (char_count--) - { - str2[char_count] = (unsigned int) str1[char_count]; - } - } - } - else if (size_char_out < size_char_in) - { - /* pack string */ - - if ((size_char_in == sizeof(int)) && (size_char_out == sizeof(short))) - { - /* 4 => 2 bytes */ - - unsigned int *str1 = (unsigned int *) src; - unsigned short *str2 = (unsigned short *) dst; - int i = 0; - - if (*str1 == 0) - { - return; - } - - while (i < char_count) - { - str2[i] = (unsigned short) str1[i]; - i++; - } - } - else if ((size_char_in == sizeof(short)) && (size_char_out == sizeof(char))) - { - /* 2 => 1 bytes */ - - unsigned short *str1 = (unsigned short *) src; - unsigned char *str2 = (unsigned char *) dst; - int i = 0; - - if (*str1 == 0) - { - return; - } - - while (i < char_count) - { - str2[i] = (unsigned char) str1[i]; - i++; - } - } - else if ((size_char_in == sizeof(int)) && (size_char_out == sizeof(char))) - { - /* 4 => 1 bytes */ - - unsigned int *str1 = (unsigned int *) src; - unsigned char *str2 = (unsigned char *) dst; - int i = 0; - - if (*str1 == 0) - { - return; - } - - while (i < char_count) - { - str2[i] = (unsigned char) str1[i]; - i++; - } - } - } - else - { - memcpy(dst, src, len * size_char_out); - } - - memset(((char*) dst) + len * size_char_out, 0, size_char_out); -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringGetOracleString - * --------------------------------------------------------------------------------------------- */ - -dbtext * OCI_StringGetOracleString -( - const otext *src, - int *size -) -{ - dbtext *dst = NULL; - int len = 0; - - if (!src) - { - *size = 0; - return dst; - } - - if (*size == -1) - { - COMPUTE_LENTGH(otext, src, len) - } - else - { - len = (int) ((*size) / sizeof(otext)); - } - - if (OCILib.use_wide_char_conv) - { - dst = (dbtext *) OCI_MemAlloc(OCI_IPC_STRING, sizeof(dbtext), len + 1, FALSE); - - if (dst) - { - OCI_StringUTF32ToUTF16( src, dst, len ); - } - } - else - { - dst = (dbtext *) src; - } - - *size = (int) (len * sizeof(dbtext)); - - return dst; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringReleaseOracleString - * --------------------------------------------------------------------------------------------- */ - -void OCI_StringReleaseOracleString -( - dbtext *str -) -{ - if (OCILib.use_wide_char_conv && str) - { - OCI_MemFree(str); - } -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringCopyOracleStringToNativeString - * --------------------------------------------------------------------------------------------- */ - -int OCI_StringCopyOracleStringToNativeString -( - const dbtext *src, - otext *dst, - int len -) -{ - if (OCILib.use_wide_char_conv) - { - OCI_StringUTF16ToUTF32((void *) src, (void *) dst, len); - } - - return len; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringDuplicateFromOracleString - * --------------------------------------------------------------------------------------------- */ - -otext* OCI_StringDuplicateFromOracleString -( - const dbtext *src, - int len -) -{ - otext *dst = (otext *) OCI_MemAlloc(OCI_IPC_STRING, sizeof(otext), len + 1, FALSE); - - if (dst) - { - if (OCILib.use_wide_char_conv) - { - OCI_StringUTF16ToUTF32((void *) src, (void *) dst, len); - } - else - { - OCI_StringRawCopy((void *) src, (void *) dst, len); - } - } - - return dst; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringFromStringPtr - * --------------------------------------------------------------------------------------------- */ - -otext * OCI_StringFromStringPtr -( - OCIEnv *env, - OCIString *str, - otext **buffer, - unsigned int *buffer_size -) -{ - dbtext *tmp = NULL; - - OCI_CHECK(NULL == buffer, NULL); - - tmp = (dbtext *) OCIStringPtr(env, str); - - if (tmp) - { - const size_t length = OCIStringSize(OCILib.env, str) / sizeof(dbtext); - - if (!(*buffer)) - { - *buffer = OCI_MemAlloc(OCI_IPC_STRING, sizeof(otext), length + 1, FALSE); - } - else if ((*buffer_size) < ((length + 1) * sizeof(otext))) - { - *buffer = OCI_MemRealloc((void*) *buffer, OCI_IPC_STRING, sizeof(otext), length + 1, FALSE); - } - - if (*buffer) - { - *buffer_size = (unsigned int) ( (length + 1) * sizeof(otext) ); - - if (OCILib.use_wide_char_conv) - { - OCI_StringUTF16ToUTF32((void *)tmp, (void *)*buffer, (int) length); - } - else - { - OCI_StringRawCopy((void *)tmp, (void *)*buffer, (int) length); - } - } - } - - return *buffer; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringToStringPtr - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_StringToStringPtr -( - OCIEnv *env, - OCIString **str, - OCIError *err, - const otext *value -) -{ - dbtext *dbstr = NULL; - int dbsize = -1; - - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == str, FALSE); - - OCI_CALL_CONTEXT_SET_FROM_ERR(err) - - dbstr = OCI_StringGetOracleString(value, &dbsize); - - OCI_EXEC(OCIStringAssignText(env, err, (oratext *) dbstr, (ub4) dbsize, str)) - - OCI_StringReleaseOracleString(dbstr); - - return OCI_STATUS; -} - - -/* --------------------------------------------------------------------------------------------- * -* OCI_StringFreeStringPtr -* --------------------------------------------------------------------------------------------- */ - -boolean OCI_StringFreeStringPtr -( - OCIEnv *env, - OCIString **str, - OCIError *err -) -{ - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CHECK(NULL == str, FALSE); - OCI_CALL_CONTEXT_SET_FROM_ERR(err) - - OCI_EXEC(OCIStringResize(env, err, (ub4)0, str)) - - return OCI_STATUS; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_GetStringAttribute - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_GetStringAttribute -( - OCI_Connection *con, - void *handle, - unsigned int type, - unsigned int attr, - otext **str, - unsigned int *size - -) -{ - dbtext *dbstr = NULL; - int dbsize = -1; - int len = 0; - - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == str, FALSE) - OCI_CHECK(NULL == size, FALSE) - - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - OCI_GET_ATTRIB(type, attr, handle, &dbstr, &dbsize) - - if (OCI_STATUS && dbstr) - { - boolean is_ansi = FALSE; - - /* Oracle BUG using OCI in Unicode mode (once again...) - Some attributes are returned as ANSI buffer even when OCI is initialized in UTF16 mode - Some we check if the first character slot has any zero bytes set - to detect this defect ! */ - - if ((OCI_CHAR_WIDE == OCILib.charset) && dbsize > 1) - { - char *ptr = (char*) dbstr; - - if (ptr[0] != 0 && ptr[1] != 0) - { - /* ANSI buffer returned instead of an UTF16 one ! */ - is_ansi = TRUE; - len = dbsize; - } - } - - // if the input buffer was not ANSI while using an UTF16 environment, compute string length from returned buffer size - if (len == 0) - { - len = dbcharcount(dbsize); - } - - if (OCI_StringRequestBuffer(str, size, len)) - { - OCI_StringTranslate(dbstr, *str, len, is_ansi ? sizeof(char) : sizeof(dbtext), sizeof(otext)); - } - - OCI_STATUS = (NULL != *str); - } - - return OCI_STATUS; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_SetStringAttribute - * --------------------------------------------------------------------------------------------- */ - -boolean OCI_SetStringAttribute -( - OCI_Connection *con, - void *handle, - unsigned int type, - unsigned int attr, - otext **str, - const otext *value -) -{ - dbtext *dbstr = NULL; - int dbsize = -1; - - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) - - dbstr = OCI_StringGetOracleString(value, &dbsize); - - if (dbsize == -1) - { - dbsize = 0; - } - - OCI_SET_ATTRIB(type, attr, handle, dbstr, dbsize) - - OCI_StringReleaseOracleString(dbstr); - - if (OCI_STATUS && str) - { - OCI_FREE(*str) - - if (value) - { - *str = ostrdup(value); - } - } - - return OCI_STATUS; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringGetFromType - * --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_StringGetFromType -( - OCI_Connection *con, - OCI_Column *col, - void *data, - unsigned int data_size, - otext *buffer, - unsigned int buffer_size, - boolean quote -) -{ - boolean res = TRUE; - boolean check = FALSE; - unsigned int len = 0; - - /* if buffer is not null, then buffer_size must the > 0 */ - - otext *ptr = buffer; - - if (quote && data) - { - len = OCI_StringAddToBuffer(ptr, len, OTEXT("'"), 1, FALSE); - if (ptr) - { - ptr++; - buffer_size--; - } - } - - switch (col->datatype) - { - case OCI_CDT_TEXT: - { - len += OCI_StringAddToBuffer(buffer, len, (otext *) data, dbcharcount(data_size), quote); - break; - } - case OCI_CDT_BOOLEAN: - { - if (ptr) - { - if (data) - { - otext* str_value = (*(boolean*)data) ? OCI_STRING_TRUE : OCI_STRING_FALSE; - const unsigned int str_length = (*(boolean*)data) ? OCI_STRING_TRUE_SIZE : OCI_STRING_FALSE_SIZE; - - len += OCI_StringAddToBuffer(buffer, len, str_value, str_length, quote); - } - else - { - res = FALSE; - } - } - else - { - len = OCI_STRING_FALSE_SIZE; - } - - break; - } - case OCI_CDT_NUMERIC: - { - check = TRUE; - - if (ptr) - { - res = OCI_NumberToString(con, data, col->subtype, ptr, (int) buffer_size, NULL); - } - else - { - len = OCI_SIZE_TMP_CVT; - } - break; - } - case OCI_CDT_DATETIME: - { - check = TRUE; - - if (ptr) - { - OCI_Date *date = (OCI_Date*) data; - const otext *fmt = OCI_GetFormat(con, OCI_FMT_DATE); - - res = date ? OCI_DateToText(date, fmt, (int) buffer_size, ptr) : FALSE; - } - else - { - len = OCI_SIZE_TMP_CVT; - } - break; - } - case OCI_CDT_TIMESTAMP: - { - check = TRUE; - - if (ptr) - { - OCI_Timestamp *tmsp = (OCI_Timestamp *) data; - const otext *fmt = OCI_GetFormat(con, tmsp && tmsp->type == OCI_TIMESTAMP_TZ ? OCI_FMT_TIMESTAMP_TZ : OCI_FMT_TIMESTAMP); - - res = tmsp ? OCI_TimestampToText(tmsp, fmt, (int) buffer_size, ptr, 0) : FALSE; - } - else - { - len = OCI_SIZE_TMP_CVT; - } - break; - } - case OCI_CDT_INTERVAL: - { - check = TRUE; - - if (ptr) - { - OCI_Interval *itv = (OCI_Interval * ) data; - - res = itv ? OCI_IntervalToText(itv, OCI_STRING_DEFAULT_PREC, OCI_STRING_DEFAULT_PREC, buffer_size, ptr) : FALSE; - } - else - { - len = OCI_SIZE_TMP_CVT; - } - break; - } - case OCI_CDT_LONG: - { - OCI_Long *lg = (OCI_Long *) data; - - if (lg) - { - if (OCI_CLONG == col->subtype) - { - len = OCI_StringAddToBuffer(buffer, len, (otext*) OCI_LongGetBuffer(lg), OCI_LongGetSize(lg), quote); - } - else - { - len = OCI_StringBinaryToString((unsigned char *) data, buffer_size, ptr); - } - } - else - { - res = FALSE; - } - - break; - } - case OCI_CDT_RAW: - { - if (data) - { - len = OCI_StringBinaryToString((unsigned char *) data, data_size, ptr); - } - break; - } - case OCI_CDT_LOB: - { - OCI_Lob *lob = (OCI_Lob *) data; - - if (lob) - { - if (ptr) - { - unsigned char lob_buf[OCI_SIZE_LARGE_BUFFER]; - - while (res) - { - const unsigned int bytes_requested = sizeof(lob_buf) - sizeof(otext); - unsigned int bytes_count = bytes_requested; - unsigned int char_count = 0; - - res = OCI_LobRead2(lob, lob_buf, &char_count, &bytes_count); - - if (bytes_count > 0) - { - if (OCI_CLOB == lob->type) - { - len += OCI_StringAddToBuffer(buffer, len, (otext*)lob_buf, ocharcount(bytes_count), quote); - } - else - { - len += OCI_StringBinaryToString(lob_buf, bytes_count, ptr + len); - } - } - - if (bytes_count < bytes_requested) - { - // lob eof reached - break; - } - } - - OCI_LobSeek(lob, 0, OCI_SEEK_SET); - } - else - { - len = (unsigned int)OCI_LobGetLength(lob); - - if (OCI_BLOB == lob->type) - { - /* here we have binary blob, it will be output in hexadecimal */ - len *= 2; - } - } - } - else - { - res = FALSE; - } - - break; - - } - case OCI_CDT_FILE: - { - OCI_File *file = (OCI_File *) data; - - if (file) - { - const otext * dir = OCI_FileGetDirectory(file); - const otext * name = OCI_FileGetName(file); - - len += OCI_StringAddToBuffer(buffer, len, dir, (unsigned int) ostrlen(dir), TRUE); - len += OCI_StringAddToBuffer(buffer, len, OTEXT("/"), 1, TRUE); - len += OCI_StringAddToBuffer(buffer, len, name, (unsigned int) ostrlen(name), TRUE); - } - else - { - res = FALSE; - } - - break; - - } - case OCI_CDT_REF: - { - check = TRUE; - - if (ptr) - { - OCI_Ref *ref = (OCI_Ref *) data; - res = ref ? OCI_RefToText(ref, buffer_size, ptr) : FALSE; - } - else - { - len = OCI_SIZE_TMP_CVT; - } - break; - } - case OCI_CDT_OBJECT: - { - OCI_Object *obj = (OCI_Object *) data; - unsigned int real_size = buffer_size; - quote = FALSE; - res = obj ? OCI_ObjectToText(obj, &real_size, ptr) : FALSE; - len = real_size; - break; - } - case OCI_CDT_COLLECTION: - { - OCI_Coll *coll = (OCI_Coll *) data; - unsigned int real_size = buffer_size; - quote = FALSE; - res = coll ? OCI_CollToText(coll, &real_size, ptr) : FALSE; - len = real_size; - break; - } - case OCI_CDT_CURSOR: - { - OCI_Statement *stmt = (OCI_Statement *)data; - quote = TRUE; - if (stmt) - { - len = OCI_StringAddToBuffer(buffer, len, stmt->sql, (unsigned int) ostrlen(stmt->sql), quote); - } - else - { - res = FALSE; - } - break; - } - default: - { - res = FALSE; - quote = FALSE; - } - } - - if (res) - { - if (buffer && check && buffer_size > len) - { - /* the resulting string shall be computed as it was not known in advance */ - len = (unsigned int) ostrlen(buffer); - } - - if (quote && data) - { - len += OCI_StringAddToBuffer(buffer, len, OTEXT("'"), 1, FALSE); - } - } - else - { - len = 0; - } - - /* make sure it is null terminated */ - if (buffer) - { - /* if computed length > buffer_size, something went wrong, consider this as failure */ - if (len > buffer_size) - { - len = 0; - } - - buffer[len] = 0; - } - - return len; -} - -/* --------------------------------------------------------------------------------------------- * - * OCI_StringAddToBuffer - * --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_StringAddToBuffer -( - otext *buffer, - unsigned int offset, - const otext *str, - unsigned int length, - boolean check_quote -) -{ - const unsigned int len_in = length; - unsigned int len_out = 0; - - if (!str) - { - return 0; - } - - if (check_quote) - { - if (buffer) - { - const otext *src = str; - otext *dst = buffer + offset; - unsigned int src_len = len_in; - - while (src && *src && src_len) - { - *dst = *src; - - if (*src == OTEXT('\'')) - { - *(++dst) = OTEXT('\''); - len_out++; - } - - dst++; - src++; - src_len--; - } - - len_out += len_in; - - *dst = 0; - } - else - { - const otext *s = str; - len_out = len_in; - - while (s && *s) - { - if (*s++ == OTEXT('\'')) - { - len_out++; - } - } - } - } - else - { - len_out = len_in; - - if (buffer) - { - ostrcpy(buffer + offset, str); - } - } - - return len_out; -} - -/* --------------------------------------------------------------------------------------------- * -* OCI_StringGetTypeName -* --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_StringGetTypeName -( - const otext *source, - otext *dest, - unsigned int length -) -{ - boolean quote = FALSE; - unsigned int offset = 0; - - if (!OCI_STRING_VALID(source) || !dest) - { - return 0; - } - - /* For types created WITH case sensitivity, OCI may not return quoted names... */ - - if (source[0] != OTEXT('"')) - { - const otext *str = NULL; - - for (str = source; *str; str++) - { - if ((*str) != otoupper(*str)) - { - quote = TRUE; - break; - } - } - } - - /* Fill destination string */ - - if (quote) - { - ostrncpy(dest + offset, OTEXT("\""), length - offset); - offset++; - } - - ostrncpy(dest + offset, source, length - offset); - offset += (unsigned int)ostrlen(source); - - if (quote) - { - ostrncpy(dest + offset, OTEXT("\""), length - offset); - offset++; - } - - return offset; -} - -/* --------------------------------------------------------------------------------------------- * -* OCI_StringGetFullTypeName -* --------------------------------------------------------------------------------------------- */ - -unsigned int OCI_StringGetFullTypeName -( - const otext *schema, - const otext *package, - const otext *type, - const otext *link, - otext *name, - unsigned int length - ) -{ - unsigned int offset = 0; - - if (OCI_STRING_VALID(schema)) - { - offset += OCI_StringGetTypeName(schema, name + offset, length - offset); - - if (offset) - { - ostrncpy(name + offset, OTEXT("."), length - offset); - offset++; - } - } - - if (OCI_STRING_VALID(package)) - { - offset += OCI_StringGetTypeName(package, name + offset, length - offset); - - if (offset) - { - ostrncpy(name + offset, OTEXT("."), length - offset); - offset++; - } - } - - if (OCI_STRING_VALID(type)) - { - offset += OCI_StringGetTypeName(type, name + offset, length - offset); - } - - if (OCI_STRING_VALID(link)) - { - ostrncpy(name + offset, OTEXT("@"), length - offset); - offset++; - offset += OCI_StringGetTypeName(link, name + offset, length - offset); - } - - return offset; -} - -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - -/* --------------------------------------------------------------------------------------------- * - * ocistrdup - * --------------------------------------------------------------------------------------------- */ - -char * ocistrdup -( - const char * src -) -{ - OCI_CHECK(NULL == src, NULL) - - char *dst = (char *) OCI_MemAlloc(OCI_IPC_STRING, 1, strlen(src) + 1, 0); - - if (dst) - { - strcpy(dst, src); - } - - return dst; -} - -/* --------------------------------------------------------------------------------------------- * - * ocistrcasecmp - * --------------------------------------------------------------------------------------------- */ - -int ocistrcasecmp -( - const char *str1, - const char *str2 -) -{ - if (!str1 && !str2) - { - return 0; - } - - if (!str1) - { - return 1; - } - - if (!str2) - { - return -1; - } - - while (((*str1) != 0) && ((*str2) != 0) && (tolower((int)(*str1)) == tolower((int)(*str2)))) - { - str1++; - str2++; - } - - return (tolower((int) (*str1)) - tolower((int) (*str2))); -} - -/* --------------------------------------------------------------------------------------------- * - * ocisprintf - * --------------------------------------------------------------------------------------------- */ - -int ocisprintf -( - char *str, - int size, - const char *format, - ... -) -{ - va_list args; - - va_start(args, format); - - const int n = (int) vsnprintf(str, (size_t) size, format, args); - - va_end(args); - - return n; -} - -/* --------------------------------------------------------------------------------------------- * - * ociwcsdup - * --------------------------------------------------------------------------------------------- */ - -wchar_t * ociwcsdup -( - const wchar_t * src -) -{ - OCI_CHECK(NULL == src, NULL) - - wchar_t *dst = (wchar_t *) OCI_MemAlloc(OCI_IPC_STRING, sizeof(wchar_t), wcslen(src) + 1, 0); - - if (dst) - { - wcscpy(dst, src); - } - - return dst; -} - -/* --------------------------------------------------------------------------------------------- * - * ociwcscasecmp - * --------------------------------------------------------------------------------------------- */ - -int ociwcscasecmp -( - const wchar_t *str1, - const wchar_t *str2 -) -{ - if (!str1 && !str2) - { - return 0; - } - - if (!str1) - { - return 1; - } - - if (!str2) - { - return -1; - } - - while (((*str1) != 0) && ((*str2) != 0) && (towlower((wint_t)*str1) == towlower((wint_t)*str2))) - { - str1++; - str2++; - } - - return (towlower((wint_t) *str1) - towlower((wint_t) *str2)); -} - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "strings.h" + +#include "collection.h" +#include "date.h" +#include "environment.h" +#include "file.h" +#include "interval.h" +#include "lob.h" +#include "long.h" +#include "macros.h" +#include "memory.h" +#include "number.h" +#include "object.h" +#include "reference.h" +#include "timestamp.h" + +#define COMPUTE_LENTGH(type, ptr, size) \ + const type *s = (const type *) (ptr); \ + const type *e = (const type *) (ptr); \ + while (*e++); \ + (size) = (int) (e - s - (size_t) 1); \ + + +/* --------------------------------------------------------------------------------------------- * + * StringLength + * --------------------------------------------------------------------------------------------- */ + +size_t StringLength +( + const void *ptr, + size_t size_elem +) +{ + int size = 0; + + CHECK_FALSE(NULL == ptr, 0); + + if (Env.nls_utf8) + { + const char *s = (char *) ptr; + while (*s) + { + if ((*s & 0xc0) != 0x80) size++; + s++; + } + } + else if (sizeof(char) == size_elem) + { + COMPUTE_LENTGH(char, ptr, size) + } + else if (sizeof(short) == size_elem) + { + COMPUTE_LENTGH(short, ptr, size) + } + else if (sizeof(int) == size_elem) + { + COMPUTE_LENTGH(int, ptr, size) + } + + return size; +} + +/* --------------------------------------------------------------------------------------------- * + * StringBinaryToString + * --------------------------------------------------------------------------------------------- */ + +unsigned int StringBinaryToString +( + const unsigned char *binary, + unsigned int binary_size, + otext *buffer +) +{ + char hex_str[] = "0123456789ABCDEF"; + + const unsigned int len = binary_size * 2; + + if (buffer) + { + for (unsigned int i = 0; i < binary_size; i++) + { + buffer[i * 2 + 0] = hex_str[binary[i] >> 4 ]; + buffer[i * 2 + 1] = hex_str[binary[i] & 0x0F]; + } + + buffer[len] = 0; + } + + return len; +} + +/* --------------------------------------------------------------------------------------------- * + * StringRequestBuffer + * --------------------------------------------------------------------------------------------- */ + +boolean StringRequestBuffer +( + otext **buffer, + unsigned int *buffer_size, + unsigned int request_size +) +{ + boolean res = FALSE; + + if (!buffer || !buffer_size) + { + return FALSE; + } + + request_size++; + + request_size *= Env.nls_utf8 ? OCI_UTF8_BYTES_PER_CHAR : sizeof(otext); + + if (!*buffer) + { + *buffer = (otext *) MemoryAlloc(OCI_IPC_STRING, (size_t) request_size, + (size_t) 1, TRUE); + } + else if (*buffer_size < request_size) + { + *buffer = (otext *) MemoryRealloc(*buffer, OCI_IPC_STRING, (size_t) request_size, + (size_t) 1, TRUE); + } + + if (*buffer) + { + *buffer_size = request_size; + + res = TRUE; + } + + return res; +} + +/* --------------------------------------------------------------------------------------------- * + * StringTranslate + * --------------------------------------------------------------------------------------------- */ + +void StringTranslate +( + void *src, + void *dst, + int char_count, + size_t size_char_in, + size_t size_char_out +) +{ + const int len = char_count; + + if (!src || !dst) + { + return; + } + + /* raw string packing/expansion without charset conversion */ + + if (size_char_out > size_char_in) + { + /* expand string */ + + if ((size_char_in == sizeof(short)) && (size_char_out == sizeof(int))) + { + /* 2 => 4 bytes */ + + unsigned short *str1 = (unsigned short *) src; + unsigned int *str2 = (unsigned int *) dst; + + if (*str1 == 0) + { + return; + } + + while (char_count--) + { + str2[char_count] = (unsigned int) str1[char_count]; + } + } + + else if ((size_char_in == sizeof(char)) && (size_char_out == sizeof(short))) + { + /* 1 => 2 bytes */ + + unsigned char *str1 = (unsigned char *) src; + unsigned short *str2 = (unsigned short *) dst; + + if (*str1 == 0) + { + return; + } + + while (char_count--) + { + str2[char_count] = (unsigned short) str1[char_count]; + } + } + else if ((size_char_in == sizeof(char)) && (size_char_out == sizeof(int))) + { + /* 1 => 4 bytes */ + + unsigned char *str1 = (unsigned char *) src; + unsigned int *str2 = (unsigned int *) dst; + + if (*str1 == 0) + { + return; + } + + while (char_count--) + { + str2[char_count] = (unsigned int) str1[char_count]; + } + } + } + else if (size_char_out < size_char_in) + { + /* pack string */ + + if ((size_char_in == sizeof(int)) && (size_char_out == sizeof(short))) + { + /* 4 => 2 bytes */ + + unsigned int *str1 = (unsigned int *) src; + unsigned short *str2 = (unsigned short *) dst; + + int i = 0; + + if (*str1 == 0) + { + return; + } + + while (i < char_count) + { + str2[i] = (unsigned short) str1[i]; + i++; + } + } + else if ((size_char_in == sizeof(short)) && (size_char_out == sizeof(char))) + { + /* 2 => 1 bytes */ + + unsigned short *str1 = (unsigned short *) src; + unsigned char *str2 = (unsigned char *) dst; + + int i= 0; + + if (*str1 == 0) + { + return; + } + + while (i < char_count) + { + str2[i] = (unsigned char) str1[i]; + i++; + } + } + else if ((size_char_in == sizeof(int)) && (size_char_out == sizeof(char))) + { + /* 4 => 1 bytes */ + + unsigned int *str1 = (unsigned int *) src; + unsigned char *str2 = (unsigned char *) dst; + + int i = 0; + + if (*str1 == 0) + { + return; + } + + while (i < char_count) + { + str2[i] = (unsigned char) str1[i]; + i++; + } + } + } + else + { + memcpy(dst, src, len * size_char_out); + } + + memset(((char*) dst) + len * size_char_out, 0, size_char_out); +} + +/* --------------------------------------------------------------------------------------------- * + * StringGetDBString + * --------------------------------------------------------------------------------------------- */ + +dbtext * StringGetDBString +( + const otext *src, + int *size +) +{ + dbtext *dst = NULL; + int len = 0; + + if (!src) + { + *size = 0; + return dst; + } + + if (*size == -1) + { + COMPUTE_LENTGH(otext, src, len) + } + else + { + len = (int) ((*size) / sizeof(otext)); + } + + if (Env.use_wide_char_conv) + { + dst = (dbtext *) MemoryAlloc(OCI_IPC_STRING, sizeof(dbtext), len + 1, FALSE); + + if (NULL != dst) + { + StringUTF32ToUTF16( src, dst, len ); + } + } + else + { + dst = (dbtext *) src; + } + + *size = (int) (len * sizeof(dbtext)); + + return dst; +} + +/* --------------------------------------------------------------------------------------------- * + * StringReleaseDBString + * --------------------------------------------------------------------------------------------- */ + +void StringReleaseDBString +( + dbtext *str +) +{ + if (Env.use_wide_char_conv && NULL != str) + { + MemoryFree(str); + } +} + +/* --------------------------------------------------------------------------------------------- * + * StringCopyDBStringToNativeString + * --------------------------------------------------------------------------------------------- */ + +int StringCopyDBStringToNativeString +( + const dbtext *src, + otext *dst, + int len +) +{ + if (Env.use_wide_char_conv) + { + StringUTF16ToUTF32((void *) src, (void *) dst, len); + } + + return len; +} + +/* --------------------------------------------------------------------------------------------- * + * StringDuplicateFromDBString + * --------------------------------------------------------------------------------------------- */ + +otext* StringDuplicateFromDBString +( + const dbtext *src, + int len +) +{ + otext *dst = (otext *) MemoryAlloc(OCI_IPC_STRING, sizeof(otext), len + 1, FALSE); + + if (NULL != dst) + { + if (Env.use_wide_char_conv) + { + StringUTF16ToUTF32((void *) src, (void *) dst, len); + } + else + { + StringRawCopy((void *) src, (void *) dst, len); + } + } + + return dst; +} + +/* --------------------------------------------------------------------------------------------- * + * StringFromStringPtr + * --------------------------------------------------------------------------------------------- */ + +otext * StringFromStringPtr +( + OCIEnv *env, + OCIString *str, + otext **buffer, + unsigned int *buffer_size +) +{ + dbtext *tmp = NULL; + + CHECK_FALSE(NULL == buffer, NULL); + + tmp = (dbtext *) OCIStringPtr(env, str); + + if (tmp) + { + const size_t length = OCIStringSize(Env.env, str) / sizeof(dbtext); + + if (NULL == *buffer) + { + *buffer = MemoryAlloc(OCI_IPC_STRING, sizeof(otext), + length + 1, FALSE); + } + else if ((*buffer_size) < ((length + 1) * sizeof(otext))) + { + *buffer = MemoryRealloc((void*) *buffer, OCI_IPC_STRING, sizeof(otext), + length + 1, FALSE); + } + + if (NULL != *buffer) + { + *buffer_size = (unsigned int) ( (length + 1) * sizeof(otext)); + + if (Env.use_wide_char_conv) + { + StringUTF16ToUTF32((void *)tmp, (void *)*buffer, (int) length); + } + else + { + StringRawCopy((void *)tmp, (void *)*buffer, (int) length); + } + } + } + + return *buffer; +} + +/* --------------------------------------------------------------------------------------------- * + * StringToStringPtr + * --------------------------------------------------------------------------------------------- */ + +boolean StringToStringPtr +( + OCIEnv *env, + OCIString **str, + OCIError *err, + const otext *value +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + dbtext *dbstr = NULL; + int dbsize = -1; + + CHECK_PTR(OCI_IPC_STRING, value) + + dbstr = StringGetDBString(value, &dbsize); + + CHECK_OCI + ( + err, + OCIStringAssignText, + env, err, (oratext*)dbstr, (ub4)dbsize, str + ) + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) +} + +/* --------------------------------------------------------------------------------------------- * +* StringFreeStringPtr +* --------------------------------------------------------------------------------------------- */ + +boolean StringFreeStringPtr +( + OCIEnv *env, + OCIString **str, + OCIError *err +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + + CHECK_PTR(OCI_IPC_STRING, str) + + CHECK_OCI + ( + err, + OCIStringResize, + env, err, (ub4)0, str + ) + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * StringGetAttribute + * --------------------------------------------------------------------------------------------- */ + +boolean StringGetAttribute +( + OCI_Connection *con, + void *handle, + unsigned int type, + unsigned int attr, + otext **str, + unsigned int *size +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, str) + CHECK_PTR(OCI_IPC_INT, size) + + dbtext *dbstr = NULL; + int dbsize = -1; + int len = 0; + + CHECK_ATTRIB_GET + ( + type, attr, handle, &dbstr, &dbsize, con->err + ) + + if (NULL != dbstr) + { + boolean is_ansi = FALSE; + + /* Oracle BUG using OCI in Unicode mode (once again...) + Some attributes are returned as ANSI buffer even when OCI is initialized in UTF16 mode + Some we check if the first character slot has any zero bytes set + to detect this defect ! */ + + if ((OCI_CHAR_WIDE == Env.charset) && dbsize > 1) + { + char *ptr = (char*) dbstr; + + if (ptr[0] != 0 && ptr[1] != 0) + { + /* ANSI buffer returned instead of an UTF16 one ! */ + is_ansi = TRUE; + len = dbsize; + } + } + + /* if the input buffer was not ANSI while using an UTF16 environment, compute string length + * from returned buffer size */ + if (len == 0) + { + len = dbcharcount(dbsize); + } + + if (StringRequestBuffer(str, size, len)) + { + StringTranslate(dbstr, *str, len, is_ansi ? sizeof(char) : sizeof(dbtext), + sizeof(otext)); + } + + CHECK_NULL(*str) + } + + SET_SUCCESS() + + EXIT_FUNC() +} + +/* --------------------------------------------------------------------------------------------- * + * StringSetAttribute + * --------------------------------------------------------------------------------------------- */ + +boolean StringSetAttribute +( + OCI_Connection *con, + void *handle, + unsigned int type, + unsigned int attr, + otext **str, + const otext *value +) +{ + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_CONNECTION, con + ) + + dbtext *dbstr = NULL; + int dbsize = -1; + + CHECK_PTR(OCI_IPC_CONNECTION, con) + + dbstr = StringGetDBString(value, &dbsize); + + if (dbsize == -1) + { + dbsize = 0; + } + + CHECK_ATTRIB_SET + ( + type, attr, handle, dbstr, dbsize, con->err + ) + + if (NULL != str) + { + FREE(*str) + + if (NULL != value) + { + *str = ostrdup(value); + } + } + + SET_SUCCESS() + + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr); + ) +} + +/* --------------------------------------------------------------------------------------------- * + * StringGetFromType + * --------------------------------------------------------------------------------------------- */ + +unsigned int StringGetFromType +( + OCI_Connection *con, + OCI_Column *col, + void *data, + unsigned int data_size, + otext *buffer, + unsigned int buffer_size, + boolean quote +) +{ + boolean res = TRUE; + boolean check = FALSE; + unsigned int len = 0; + + /* if buffer is not null, then buffer_size must the > 0 */ + + otext *ptr = buffer; + + if (quote && NULL != data) + { + len = StringAddToBuffer(ptr, len, OTEXT("'"), 1, FALSE); + if (ptr) + { + ptr++; + buffer_size--; + } + } + + switch (col->datatype) + { + case OCI_CDT_TEXT: + { + len += StringAddToBuffer(buffer, len, (otext *) data, dbcharcount(data_size), quote); + break; + } + case OCI_CDT_BOOLEAN: + { + if (NULL != ptr) + { + if (data) + { + otext * str_value = *(boolean*)data ? OCI_STRING_TRUE : OCI_STRING_FALSE; + + const unsigned int str_length = (*(boolean*)data) ? OCI_STRING_TRUE_SIZE : OCI_STRING_FALSE_SIZE; + + len += StringAddToBuffer(buffer, len, str_value, str_length, quote); + } + else + { + res = FALSE; + } + } + else + { + len = OCI_STRING_FALSE_SIZE; + } + + break; + } + case OCI_CDT_NUMERIC: + { + check = TRUE; + + if (NULL != ptr) + { + res = NumberToStringInternal(con, data, col->subtype, ptr, (int) buffer_size, NULL); + } + else + { + len = OCI_SIZE_TMP_CVT; + } + break; + } + case OCI_CDT_DATETIME: + { + check = TRUE; + + if (ptr) + { + OCI_Date *date = (OCI_Date*) data; + const otext *fmt = EnvironmentGetFormat(con, OCI_FMT_DATE); + + res = date ? DateToString(date, fmt, (int) buffer_size, ptr) : FALSE; + } + else + { + len = OCI_SIZE_TMP_CVT; + } + break; + } + case OCI_CDT_TIMESTAMP: + { + check = TRUE; + + if (ptr) + { + OCI_Timestamp *tmsp = (OCI_Timestamp *) data; + const int fmt_type = tmsp && tmsp->type == OCI_TIMESTAMP_TZ ? OCI_FMT_TIMESTAMP_TZ : OCI_FMT_TIMESTAMP; + + const otext *fmt = EnvironmentGetFormat(con, fmt_type); + + res = tmsp ? TimestampToString(tmsp, fmt, (int) buffer_size, ptr, 0) : FALSE; + } + else + { + len = OCI_SIZE_TMP_CVT; + } + break; + } + case OCI_CDT_INTERVAL: + { + check = TRUE; + + if (NULL != ptr) + { + OCI_Interval *itv = (OCI_Interval * ) data; + + res = itv ? IntervalToString(itv, OCI_STRING_DEFAULT_PREC, + OCI_STRING_DEFAULT_PREC, (int) buffer_size, ptr) : FALSE; + } + else + { + len = OCI_SIZE_TMP_CVT; + } + break; + } + case OCI_CDT_LONG: + { + OCI_Long *lg = (OCI_Long *) data; + + if (NULL != lg) + { + if (OCI_CLONG == col->subtype) + { + len = StringAddToBuffer(buffer, len, (otext*) LongGetBuffer(lg), + LongGetSize(lg), quote); + } + else + { + len = StringBinaryToString((unsigned char *) data, buffer_size, ptr); + } + } + else + { + res = FALSE; + } + + break; + } + case OCI_CDT_RAW: + { + if (NULL != data) + { + len = StringBinaryToString((unsigned char *) data, data_size, ptr); + } + break; + } + case OCI_CDT_LOB: + { + OCI_Lob *lob = (OCI_Lob *) data; + + if (NULL != lob) + { + if (NULL != ptr) + { + unsigned char lob_buf[OCI_SIZE_LARGE_BUFFER]; + + while (res) + { + const unsigned int bytes_requested = sizeof(lob_buf) - sizeof(otext); + + unsigned int bytes_count = bytes_requested; + unsigned int char_count = 0; + + res = LobRead2(lob, lob_buf, &char_count, &bytes_count); + + if (bytes_count > 0) + { + if (OCI_CLOB == lob->type) + { + len += StringAddToBuffer(buffer, len, (otext*)lob_buf, + ocharcount(bytes_count), quote); + } + else + { + len += StringBinaryToString(lob_buf, bytes_count, ptr + len); + } + } + + if (bytes_count < bytes_requested) + { + /* lob eof reached */ + break; + } + } + + LobSeek(lob, 0, OCI_SEEK_SET); + } + else + { + len = (unsigned int)LobGetLength(lob); + + if (OCI_BLOB == lob->type) + { + /* here we have binary blob, it will be output in hexadecimal */ + len *= 2; + } + } + } + else + { + res = FALSE; + } + + break; + + } + case OCI_CDT_FILE: + { + OCI_File *file = (OCI_File *) data; + + if (NULL != file) + { + const otext * dir = FileGetDirectory(file); + const otext * name = FileGetName(file); + + len += StringAddToBuffer(buffer, len, dir, (unsigned int) ostrlen(dir), TRUE); + len += StringAddToBuffer(buffer, len, OTEXT("/"), 1, TRUE); + len += StringAddToBuffer(buffer, len, name, (unsigned int) ostrlen(name), TRUE); + } + else + { + res = FALSE; + } + + break; + + } + case OCI_CDT_REF: + { + check = TRUE; + + if (NULL != ptr) + { + OCI_Ref *ref = (OCI_Ref *) data; + res = ref ? ReferenceToString(ref, buffer_size, ptr) : FALSE; + } + else + { + len = OCI_SIZE_TMP_CVT; + } + break; + } + case OCI_CDT_OBJECT: + { + OCI_Object *obj = (OCI_Object *) data; + + unsigned int real_size = buffer_size; + + quote = FALSE; + res = obj ? ObjectToString(obj, &real_size, ptr) : FALSE; + len = real_size; + break; + } + case OCI_CDT_COLLECTION: + { + OCI_Coll *coll = (OCI_Coll *) data; + + unsigned int real_size = buffer_size; + + quote = FALSE; + res = coll ? CollectionToString(coll, &real_size, ptr) : FALSE; + len = real_size; + break; + } + case OCI_CDT_CURSOR: + { + OCI_Statement *stmt = (OCI_Statement *)data; + + quote = TRUE; + + if (NULL != stmt) + { + len = StringAddToBuffer(buffer, len, stmt->sql, + (unsigned int) ostrlen(stmt->sql), quote); + } + else + { + res = FALSE; + } + break; + } + default: + { + res = FALSE; + quote = FALSE; + } + } + + if (res) + { + if (NULL != buffer && check && buffer_size > len) + { + /* the resulting string shall be computed as it was not known in advance */ + len = (unsigned int) ostrlen(buffer); + } + + if (quote && NULL != data) + { + len += StringAddToBuffer(buffer, len, OTEXT("'"), 1, FALSE); + } + } + else + { + len = 0; + } + + /* make sure it is null terminated */ + if (NULL != buffer) + { + /* if computed length > buffer_size, something went wrong, consider this as failure */ + if (len > buffer_size) + { + len = 0; + } + + buffer[len] = 0; + } + + return len; +} + +/* --------------------------------------------------------------------------------------------- * + * StringAddToBuffer + * --------------------------------------------------------------------------------------------- */ + +unsigned int StringAddToBuffer +( + otext *buffer, + unsigned int offset, + const otext *str, + unsigned int length, + boolean check_quote +) +{ + const unsigned int len_in = length; + + unsigned int len_out = 0; + + if (NULL == str) + { + return 0; + } + + if (check_quote) + { + if (NULL != buffer) + { + const otext *src = str; + + otext *dst = buffer + offset; + + unsigned int src_len = len_in; + + while (NULL != src && *src && src_len) + { + *dst = *src; + + if (*src == OTEXT('\'')) + { + *(++dst) = OTEXT('\''); + len_out++; + } + + dst++; + src++; + src_len--; + } + + len_out += len_in; + + *dst = 0; + } + else + { + const otext *s = str; + len_out = len_in; + + while (NULL != s && *s) + { + if (*s++ == OTEXT('\'')) + { + len_out++; + } + } + } + } + else + { + len_out = len_in; + + if (NULL != buffer) + { + ostrcpy(buffer + offset, str); + } + } + + return len_out; +} + +/* --------------------------------------------------------------------------------------------- * +* StringGetTypeName +* --------------------------------------------------------------------------------------------- */ + +unsigned int StringGetTypeName +( + const otext *source, + otext *dest, + unsigned int length +) +{ + boolean quote = FALSE; + unsigned int offset = 0; + + if (!IS_STRING_VALID(source) || NULL == dest) + { + return 0; + } + + /* For types created WITH case sensitivity, OCI may not return quoted names... */ + + if (source[0] != OTEXT('"')) + { + const otext *str = NULL; + + for (str = source; *str; str++) + { + if ((*str) != otoupper(*str)) + { + quote = TRUE; + break; + } + } + } + + /* Fill destination string */ + + if (quote) + { + ostrncpy(dest + offset, OTEXT("\""), length - offset); + offset++; + } + + ostrncpy(dest + offset, source, length - offset); + offset += (unsigned int)ostrlen(source); + + if (quote) + { + ostrncpy(dest + offset, OTEXT("\""), length - offset); + offset++; + } + + return offset; +} + +/* --------------------------------------------------------------------------------------------- * +* StringGetFullTypeName +* --------------------------------------------------------------------------------------------- */ + +unsigned int StringGetFullTypeName +( + const otext *schema, + const otext *package, + const otext *type, + const otext *link, + otext *name, + unsigned int length +) +{ + unsigned int offset = 0; + + if (IS_STRING_VALID(schema)) + { + offset += StringGetTypeName(schema, name + offset, length - offset); + + if (offset) + { + ostrncpy(name + offset, OTEXT("."), length - offset); + offset++; + } + } + + if (IS_STRING_VALID(package)) + { + offset += StringGetTypeName(package, name + offset, length - offset); + + if (offset) + { + ostrncpy(name + offset, OTEXT("."), length - offset); + offset++; + } + } + + if (IS_STRING_VALID(type)) + { + offset += StringGetTypeName(type, name + offset, length - offset); + } + + if (IS_STRING_VALID(link)) + { + ostrncpy(name + offset, OTEXT("@"), length - offset); + offset++; + offset += StringGetTypeName(link, name + offset, length - offset); + } + + return offset; +} + +/* --------------------------------------------------------------------------------------------- * + * ocistrdup + * --------------------------------------------------------------------------------------------- */ + +char * ocistrdup +( + const char * src +) +{ + CHECK_FALSE(NULL == src, NULL) + + char *dst = (char *) MemoryAlloc(OCI_IPC_STRING, 1, strlen(src) + 1, 0); + + if (NULL != dst) + { + strcpy(dst, src); + } + + return dst; +} + +/* --------------------------------------------------------------------------------------------- * + * ocistrcasecmp + * --------------------------------------------------------------------------------------------- */ + +int ocistrcasecmp +( + const char *str1, + const char *str2 +) +{ + if (NULL == str1 && NULL == str2) + { + return 0; + } + + if (NULL == str1) + { + return 1; + } + + if (NULL == str2) + { + return -1; + } + + while (((*str1) != 0) && ((*str2) != 0) && (tolower((int)(*str1)) == tolower((int)(*str2)))) + { + str1++; + str2++; + } + + return (tolower((int) (*str1)) - tolower((int) (*str2))); +} + +/* --------------------------------------------------------------------------------------------- * + * ocisprintf + * --------------------------------------------------------------------------------------------- */ + +int ocisprintf +( + char *str, + int size, + const char *format, + ... +) +{ + va_list args; + + va_start(args, format); + + const int n = (int) vsnprintf(str, (size_t) size, format, args); + + va_end(args); + + return n; +} + +/* --------------------------------------------------------------------------------------------- * + * ociwcsdup + * --------------------------------------------------------------------------------------------- */ + +wchar_t * ociwcsdup +( + const wchar_t * src +) +{ + CHECK_FALSE(NULL == src, NULL) + + wchar_t *dst = (wchar_t *) MemoryAlloc(OCI_IPC_STRING, sizeof(wchar_t), + wcslen(src) + 1, 0); + + if (NULL != dst) + { + wcscpy(dst, src); + } + + return dst; +} + +/* --------------------------------------------------------------------------------------------- * + * ociwcscasecmp + * --------------------------------------------------------------------------------------------- */ + +int ociwcscasecmp +( + const wchar_t *str1, + const wchar_t *str2 +) +{ + if (NULL == str1 && NULL == str2) + { + return 0; + } + + if (NULL == str1) + { + return 1; + } + + if (NULL == str2) + { + return -1; + } + + while (((*str1) != 0) && ((*str2) != 0) && (towlower((wint_t)*str1) == towlower((wint_t)*str2))) + { + str1++; + str2++; + } + + return (towlower((wint_t) *str1) - towlower((wint_t) *str2)); +} diff --git a/src/strings.h b/src/strings.h new file mode 100644 index 00000000..98542657 --- /dev/null +++ b/src/strings.h @@ -0,0 +1,177 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_STRING_H_INCLUDED +#define OCILIB_STRING_H_INCLUDED + +#include "types.h" + +size_t StringLength +( + void const* ptr, + size_t size_elem +); + +unsigned int StringBinaryToString +( + const unsigned char* binary, + unsigned int binary_size, + otext * buffer +); + +boolean StringRequestBuffer +( + otext ** buffer, + unsigned int* buffer_size, + unsigned int request_size +); + +void StringTranslate +( + void * src, + void * dst, + int char_count, + size_t size_char_in, + size_t size_char_out +); + +#define StringAnsiToNative(s, d, l) \ + StringTranslate( (void *) (s), (void *) (d), l, sizeof(char), sizeof(otext) ) + +#define StringNativeToAnsi(s, d, l) \ + StringTranslate( (void *) (s), (void *) (d), l, sizeof(otext), sizeof(char) ) + +#define StringUTF16ToUTF32(s, d, l) \ + StringTranslate( (void *) (s), (void *) (d), l, sizeof(short), sizeof(int) ) + +#define StringUTF32ToUTF16(s, d, l) \ + StringTranslate( (void *) (s), (void *) (d), l, sizeof(int), sizeof(short) ) + +#define StringOracleToNative(s, d, l) \ + StringTranslate( (void *) (s), (void *) (d), l, sizeof(dbtext), sizeof(otext) ) + +#define StringRawCopy(s, d, l) \ + StringTranslate( (void *) (s), (void *) (d), l, sizeof(otext), sizeof(otext) ) + +dbtext* StringGetDBString +( + const otext* src, + int * size +); + +void StringReleaseDBString +( + dbtext* str +); + +int StringCopyDBStringToNativeString +( + const dbtext* src, + otext * dst, + int len +); + +otext* StringDuplicateFromDBString +( + const dbtext* src, + int len +); + +otext* StringFromStringPtr +( + OCIEnv * env, + OCIString * str, + otext ** buffer, + unsigned int* buffer_size +); + +boolean StringToStringPtr +( + OCIEnv * env, + OCIString ** str, + OCIError * err, + const otext* value +); + +boolean StringFreeStringPtr +( + OCIEnv * env, + OCIString** str, + OCIError * err +); + +unsigned int StringGetFromType +( + OCI_Connection* con, + OCI_Column * col, + void * data, + unsigned int data_size, + otext * buffer, + unsigned int buffer_size, + boolean quote +); + +unsigned int StringAddToBuffer +( + otext * buffer, + unsigned int offset, + const otext* str, + unsigned int length, + boolean check_quote +); + +unsigned int StringGetTypeName +( + const otext* source, + otext * dest, + unsigned int length +); + +unsigned int StringGetFullTypeName +( + const otext* schema, + const otext* package, + const otext* type, + const otext* link, + otext * name, + unsigned int length +); + +boolean StringGetAttribute +( + OCI_Connection* con, + void * handle, + unsigned int type, + unsigned int attr, + otext ** str, + unsigned int * size +); + +boolean StringSetAttribute +( + OCI_Connection* con, + void * handle, + unsigned int type, + unsigned int attr, + otext ** str, + const otext * value +); + +#endif /* OCILIB_STRING_H_INCLUDED */ diff --git a/src/subscription.c b/src/subscription.c index 50921580..30a2920e 100644 --- a/src/subscription.c +++ b/src/subscription.c @@ -18,52 +18,61 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "subscription.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "callback.h" +#include "connection.h" +#include "list.h" +#include "macros.h" +#include "memory.h" +#include "statement.h" +#include "strings.h" /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionClose + * SubscriptionDispose * --------------------------------------------------------------------------------------------- */ -boolean OCI_SubscriptionClose +boolean SubscriptionDispose ( OCI_Subscription *sub ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NOTIFY, sub + ) + boolean alloc = FALSE; - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == sub, FALSE); - - OCI_CALL_CONTEXT_SET(sub->con, NULL, sub->err) + CHECK_PTR(OCI_IPC_NOTIFY, sub) #if OCI_VERSION_COMPILE >= OCI_10_2 /* unregister the subscription if connection still alive */ - if (sub->subhp) + if (NULL != sub->subhp) { - if (!sub->con) + if (NULL == sub->con) { - sub->con = OCI_ConnectionCreate(sub->saved_db, sub->saved_user, - sub->saved_pwd, OCI_SESSION_DEFAULT); + sub->con = ConnectionCreate(sub->saved_db, sub->saved_user, + sub->saved_pwd, OCI_SESSION_DEFAULT); + + CHECK_NULL(sub->con) alloc = TRUE; } - if (sub->con) + if (NULL != sub->con) { - // OCISubscriptionUnRegister() seems to partially fail when OCI is initialized in UTF16 mode as it returns ORA-24915 - // Thus, if using OCI in Unicode mode, discard error ORA-24915 + /* OCISubscriptionUnRegister() seems to partially fail when OCI is initialized in UTF16 + * mode as it returns ORA-24915 */ - const sword res = OCISubscriptionUnRegister(sub->con->cxt, sub->subhp, sub->err, (ub4) OCI_DEFAULT); + /* Thus, if using OCI in Unicode mode, discard error ORA-24915 */ -#if defined(OCI_CHARSET_WIDE) + #if defined(OCI_CHARSET_WIDE) + const sword res = OCISubscriptionUnRegister(sub->con->cxt, sub->subhp, sub->err, (ub4)OCI_DEFAULT); if (OCI_FAILURE(res)) { sb4 code = 0; @@ -72,60 +81,64 @@ boolean OCI_SubscriptionClose if (OCI_ERR_SUB_BUG_OCI_UTF16 != code) { - OCI_ExceptionOCI(sub->err, sub->con, NULL, FALSE); - OCI_STATUS = FALSE; + THROW(ExceptionOCI, sub->err, res) } } -#else + #else - OCI_EXEC(res); -#endif + CHECK_OCI + ( + sub->err, + OCISubscriptionUnRegister, + sub->con->cxt, sub->subhp, + sub->err, (ub4)OCI_DEFAULT + ) + + #endif - if (alloc) + if (alloc && NULL != sub->con) { - OCI_ConnectionFree(sub->con); + ConnectionFree(sub->con); } } } /* free OCI handle */ - OCI_HandleFree((dvoid *) sub->subhp, OCI_HTYPE_SUBSCRIPTION); + MemoryFreeHandle((dvoid*)sub->subhp, OCI_HTYPE_SUBSCRIPTION); /* close error handle */ - if (sub->err) + if (NULL != sub->err) { - OCI_HandleFree(sub->err, OCI_HTYPE_ERROR); + MemoryFreeHandle(sub->err, OCI_HTYPE_ERROR); } #endif /* free event data */ - OCI_FREE(sub->event.dbname) - OCI_FREE(sub->event.objname) - OCI_FREE(sub->event.rowid) + FREE(sub->event.dbname) + FREE(sub->event.objname) + FREE(sub->event.rowid) /* free strings */ - OCI_FREE(sub->saved_db) - OCI_FREE(sub->saved_user) - OCI_FREE(sub->saved_pwd) - OCI_FREE(sub->name) + FREE(sub->saved_db) + FREE(sub->saved_user) + FREE(sub->saved_pwd) + FREE(sub->name) - return OCI_STATUS; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionRegister + * SubscriptionRegister * --------------------------------------------------------------------------------------------- */ -OCI_Subscription * OCI_API OCI_SubscriptionRegister +OCI_Subscription * SubscriptionRegister ( OCI_Connection *con, const otext *name, @@ -135,126 +148,163 @@ OCI_Subscription * OCI_API OCI_SubscriptionRegister unsigned int timeout ) { - OCI_Subscription *sub = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Subscription*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) - OCI_CALL_ENTER(OCI_Subscription*, NULL) - OCI_CALL_CHECK_DATABASE_NOTIFY_ENABLED() - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_PROC, handler) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ub4 attr = 0; + int dbsize = -1; + dbtext *dbstr = NULL; -#if OCI_VERSION_COMPILE >= OCI_10_2 - - /* create subscription object */ + OCI_Subscription* sub = NULL; - sub = OCI_ListAppend(OCILib.subs, sizeof(*sub)); - OCI_STATUS = (NULL != sub); + CHECK_DATABASE_NOTIFY_ENABLED() + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_PROC, handler) + CHECK_PTR(OCI_IPC_STRING, name) - if (sub) - { - /* allocate error handle */ +#if OCI_VERSION_COMPILE >= OCI_10_2 - OCI_STATUS = OCI_HandleAlloc(con->env, (dvoid **)(void *)&sub->err, OCI_HTYPE_ERROR); + /* create subscription object */ - /* allocate subscription handle */ + sub = ListAppend(Env.subs, sizeof(*sub)); + CHECK_NULL(sub) - OCI_STATUS = OCI_STATUS && OCI_HandleAlloc(con->env, (dvoid **)(void *)&sub->subhp, OCI_HTYPE_SUBSCRIPTION); + /* allocate error handle */ - if (OCI_STATUS) - { - ub4 attr = 0; - int dbsize = -1; - dbtext *dbstr = NULL; + CHECK(MemoryAllocHandle(con->env, (dvoid **)(void *)&sub->err, OCI_HTYPE_ERROR)) - sub->con = con; - sub->env = con->env; - sub->timeout = (ub4)timeout; - sub->handler = handler; - sub->type = type; - sub->name = ostrdup(name); - sub->event.sub = sub; + /* allocate subscription handle */ - /* set port number */ + CHECK(MemoryAllocHandle(con->env, (dvoid **)(void *)&sub->subhp, OCI_HTYPE_SUBSCRIPTION)) - if (port > 0) - { - OCI_SET_ATTRIB(OCI_HTYPE_ENV, OCI_ATTR_SUBSCR_PORTNO, sub->env, &port, sizeof(port)) - } + sub->con = con; + sub->env = con->env; + sub->timeout = (ub4)timeout; + sub->handler = handler; + sub->type = type; + sub->name = ostrdup(name); + sub->event.sub = sub; - /* set timeout */ + /* set port number */ - if (sub->timeout > 0) - { - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_TIMEOUT, sub->subhp, &sub->timeout, sizeof(sub->timeout)) - } + if (port > 0) + { + CHECK_ATTRIB_SET + ( + OCI_HTYPE_ENV, OCI_ATTR_SUBSCR_PORTNO, + sub->env, &port, sizeof(port), + sub->con->err + ) + } - /* name */ + /* set timeout */ - dbstr = OCI_StringGetOracleString(sub->name, &dbsize); + if (sub->timeout > 0) + { + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_TIMEOUT, + sub->subhp, &sub->timeout, + sizeof(sub->timeout), + sub->con->err + ) + } - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAME, sub->subhp, dbstr, dbsize) + /* name */ - OCI_StringReleaseOracleString(dbstr); + dbstr = StringGetDBString(sub->name, &dbsize); - /* namespace for CDN */ + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAME, + sub->subhp, dbstr, dbsize, + sub->con->err + ) - attr = OCI_SUBSCR_NAMESPACE_DBCHANGE; - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAMESPACE, sub->subhp, &attr, sizeof(attr)) + /* namespace for CDN */ - /* protocol for CDN */ + attr = OCI_SUBSCR_NAMESPACE_DBCHANGE; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_NAMESPACE, + sub->subhp, &attr, sizeof(attr), + sub->con->err + ) - attr = OCI_SUBSCR_PROTO_OCI; - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_RECPTPROTO, sub->subhp, &attr, sizeof(attr)) + /* protocol for CDN */ - /* On MSVC, casting a function pointer to a data pointer generates a warning. - As there is no other to way to do regarding the OCI API, let's disable this - warning just the time to set the callback attribute to the subscription handle */ + attr = OCI_SUBSCR_PROTO_OCI; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_RECPTPROTO, + sub->subhp, &attr, sizeof(attr), + sub->con->err + ) - #ifdef _MSC_VER - #pragma warning(disable: 4054) - #endif + /* On MSVC, casting a function pointer to a data pointer generates a warning. + As there is no other to way to do regarding the OCI API, let's disable this + warning just the time to set the callback attribute to the subscription handle */ - /* internal callback handler */ + #ifdef _MSC_VER + #pragma warning(disable: 4054) + #endif - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CALLBACK, sub->subhp, OCI_ProcNotifyChanges, 0) + /* internal callback handler */ - #ifdef _MSC_VER - #pragma warning(default: 4054) - #endif + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CALLBACK, + sub->subhp, CallbackNotifyChanges, 0, + sub->con->err + ) - /* RowIds handling */ + #ifdef _MSC_VER + #pragma warning(default: 4054) + #endif - if (sub->type & OCI_CNT_ROWS) - { - attr = TRUE; - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_CHNF_ROWIDS, sub->subhp, &attr, sizeof(attr)) - } + /* RowIds handling */ - /* set subscription context pointer to our subscription structure */ + if (sub->type & OCI_CNT_ROWS) + { + attr = TRUE; + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_CHNF_ROWIDS, + sub->subhp, &attr, sizeof(attr), + sub->con->err + ) + } - OCI_SET_ATTRIB(OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CTX, sub->subhp, sub, 0) + /* set subscription context pointer to our subscription structure */ - /* all attributes set, let's register the subscription ! */ + CHECK_ATTRIB_SET + ( + OCI_HTYPE_SUBSCRIPTION, OCI_ATTR_SUBSCR_CTX, + sub->subhp, sub, 0, + sub->con->err + ) - OCI_EXEC(OCISubscriptionRegister(sub->con->cxt, &sub->subhp, (ub2) 1, sub->err,(ub4) OCI_DEFAULT)) + /* all attributes set, let's register the subscription ! */ - /* get real port number */ + CHECK_OCI + ( + sub->con->err, + OCISubscriptionRegister, + sub->con->cxt, &sub->subhp, + (ub2)1, sub->err, (ub4)OCI_DEFAULT + ) - OCI_GET_ATTRIB(OCI_HTYPE_ENV, OCI_ATTR_SUBSCR_PORTNO, sub->env, &sub->port, sizeof(sub->port)) - } - } + /* get real port number */ - if (OCI_STATUS) - { - OCI_RETVAL = sub; - } - else if (sub) - { - OCI_SubscriptionClose(sub); - OCI_ListRemove(OCILib.subs, sub); - OCI_FREE(sub) - } + CHECK_ATTRIB_GET + ( + OCI_HTYPE_ENV, OCI_ATTR_SUBSCR_PORTNO, + sub->env, &sub->port, sizeof(sub->port), + sub->con->err + ) #else @@ -267,47 +317,65 @@ OCI_Subscription * OCI_API OCI_SubscriptionRegister #endif - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + StringReleaseDBString(dbstr); + + SubscriptionDispose(sub); + ListRemove(Env.subs, sub); + FREE(sub) + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionUnregister + * SubscriptionUnregister * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SubscriptionUnregister +boolean SubscriptionUnregister ( OCI_Subscription *sub ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NOTIFY, sub) - OCI_CALL_CONTEXT_SET(sub->con, NULL, sub->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NOTIFY, sub + ) - OCI_RETVAL = OCI_STATUS = OCI_SubscriptionClose(sub); + CHECK_PTR(OCI_IPC_NOTIFY, sub) - OCI_ListRemove(OCILib.subs, sub); + SubscriptionDispose(sub); + ListRemove(Env.subs, sub); - OCI_FREE(sub); + FREE(sub); - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionAddStatement + * SubscriptionAddStatement * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_SubscriptionAddStatement +boolean SubscriptionAddStatement ( OCI_Subscription *sub, OCI_Statement *stmt ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_NOTIFY, sub) - OCI_CALL_CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_CALL_CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) - - OCI_CALL_CONTEXT_SET(sub->con, stmt, sub->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_NOTIFY, sub + ) + + CHECK_PTR(OCI_IPC_NOTIFY, sub) + CHECK_PTR(OCI_IPC_STATEMENT, stmt) + CHECK_STMT_STATUS(stmt, OCI_STMT_PREPARED) #if OCI_VERSION_COMPILE >= OCI_10_2 @@ -315,63 +383,88 @@ boolean OCI_API OCI_SubscriptionAddStatement if (sub->type & OCI_CNT_OBJECTS) { - OCI_SET_ATTRIB(OCI_HTYPE_STMT, OCI_ATTR_CHNF_REGHANDLE, stmt->stmt, sub->subhp, 0) - - OCI_STATUS = OCI_STATUS && OCI_Execute(stmt) && (NULL != OCI_GetResultset(stmt)); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_STMT, OCI_ATTR_CHNF_REGHANDLE, + stmt->stmt, sub->subhp, 0, + stmt->con->err + ) + + CHECK(StatementExecute(stmt)) + CHECK_NULL(StatementGetResultset(stmt)) } #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionGetName + * SubscriptionGetName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_SubscriptionGetName +const otext * SubscriptionGetName ( OCI_Subscription *sub ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_NOTIFY, sub, name, sub->con, NULL, sub->err) + GET_PROP + ( + const otext*, NULL, + OCI_IPC_NOTIFY, sub, + name + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionGetPort + * SubscriptionGetPort * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_SubscriptionGetPort +unsigned int SubscriptionGetPort ( OCI_Subscription *sub ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_NOTIFY, sub, port, sub->con, NULL, sub->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_NOTIFY, sub, + port + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionGetTimeout + * SubscriptionGetTimeout * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_SubscriptionGetTimeout +unsigned int SubscriptionGetTimeout ( OCI_Subscription *sub ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_NOTIFY, sub, timeout, sub->con, NULL, sub->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_NOTIFY, sub, + timeout + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_SubscriptionGetConnection + * SubscriptionGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_SubscriptionGetConnection +OCI_Connection * SubscriptionGetConnection ( OCI_Subscription *sub ) { - OCI_GET_PROP(OCI_Connection*, NULL, OCI_IPC_NOTIFY, sub, con, sub->con, NULL, sub->err) + GET_PROP + ( + OCI_Connection*, NULL, + OCI_IPC_NOTIFY, sub, + con + ) } - diff --git a/src/subscription.h b/src/subscription.h new file mode 100644 index 00000000..98e79e80 --- /dev/null +++ b/src/subscription.h @@ -0,0 +1,72 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_SUBSCRIPTION_H_INCLUDED +#define OCILIB_SUBSCRIPTION_H_INCLUDED + +#include "types.h" + +boolean SubscriptionDispose +( + OCI_Subscription *sub +); + +OCI_Subscription * SubscriptionRegister +( + OCI_Connection *con, + const otext *name, + unsigned int type, + POCI_NOTIFY handler, + unsigned int port, + unsigned int timeout +); + +boolean SubscriptionUnregister +( + OCI_Subscription *sub +); + +boolean SubscriptionAddStatement +( + OCI_Subscription *sub, + OCI_Statement *stmt +); + +const otext * SubscriptionGetName +( + OCI_Subscription *sub +); + +unsigned int SubscriptionGetPort +( + OCI_Subscription *sub +); + +unsigned int SubscriptionGetTimeout +( + OCI_Subscription *sub +); + +OCI_Connection * SubscriptionGetConnection +( + OCI_Subscription *sub +); + +#endif /* OCILIB_SUBSCRIPTION_H_INCLUDED */ diff --git a/src/thread.c b/src/thread.c index 7b386145..2fa05610 100644 --- a/src/thread.c +++ b/src/thread.c @@ -18,166 +18,218 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "thread.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "macros.h" +#include "memory.h" /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadProc + * ThreadProc * --------------------------------------------------------------------------------------------- */ -void OCI_ThreadProc +void ThreadProc ( dvoid *arg ) { OCI_Thread *thread = (OCI_Thread *) arg; - if (thread) + if (NULL != thread) { thread->proc(thread, thread->arg); } } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadCreate + * ThreadCreate * --------------------------------------------------------------------------------------------- */ -OCI_Thread * OCI_API OCI_ThreadCreate +OCI_Thread * ThreadCreate ( void ) { - OCI_Thread *thread = NULL; + ENTER_FUNC + ( + /* returns */ OCI_Thread*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + + OCI_Thread* thread = NULL; - OCI_CALL_ENTER(OCI_Thread*, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_THREAD_ENABLED() + CHECK_INITIALIZED() + CHECK_THREAD_ENABLED() /* allocate thread structure */ - OCI_ALLOCATE_DATA(OCI_IPC_THREAD, thread, 1) + ALLOC_DATA(OCI_IPC_THREAD, thread, 1) - if (OCI_STATUS) - { - /* allocate error handle */ + /* allocate error handle */ - OCI_STATUS = OCI_HandleAlloc(OCILib.env, (dvoid **)(void *)&thread->err, OCI_HTYPE_ERROR); + CHECK(MemoryAllocHandle(Env.env, (dvoid **)(void *)&thread->err, OCI_HTYPE_ERROR)) - /* allocate thread handle */ + /* allocate thread handle */ - OCI_EXEC(OCIThreadHndInit(OCILib.env, thread->err, &thread->handle)) + CHECK_OCI + ( + thread->err, + OCIThreadHndInit, + Env.env, thread->err, + &thread->handle + ) - /* allocate thread ID */ + /* allocate thread ID */ - OCI_EXEC(OCIThreadIdInit(OCILib.env, thread->err, &thread->id)) - } + CHECK_OCI + ( + thread->err, + OCIThreadIdInit, + Env.env, thread->err, + &thread->id + ) - if (OCI_STATUS) - { - OCI_RETVAL = thread; - } - else if (thread) - { - OCI_ThreadFree(thread); - } + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + ThreadFree(thread); + thread = NULL; + } - OCI_CALL_EXIT() + SET_RETVAL(thread) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadFree + * ThreadFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ThreadFree +boolean ThreadFree ( OCI_Thread *thread ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_THREAD_ENABLED() - OCI_CALL_CHECK_PTR(OCI_IPC_THREAD, thread) - OCI_CALL_CONTEXT_SET_FROM_ERR(thread->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_THREAD, thread + ) + + CHECK_THREAD_ENABLED() + CHECK_PTR(OCI_IPC_THREAD, thread) /* close thread handle */ - if (thread->handle) + if (NULL != thread->handle) { - OCI_EXEC(OCIThreadClose(OCILib.env, thread->err, thread->handle)) - OCI_EXEC(OCIThreadHndDestroy(OCILib.env, thread->err, &thread->handle)) + CHECK_OCI + ( + thread->err, + OCIThreadClose, + Env.env, thread->err, + thread->handle + ) + + CHECK_OCI + ( + thread->err, + OCIThreadHndDestroy, + Env.env, thread->err, + &thread->handle + ) } /* close thread id */ - if (thread->id) + if (NULL != thread->id) { - OCI_EXEC(OCIThreadIdDestroy(OCILib.env, thread->err, &thread->id)) + CHECK_OCI + ( + thread->err, + OCIThreadIdDestroy, + Env.env, thread->err, + &thread->id + ) } /* close error handle */ - if (thread->err) + if (NULL != thread->err) { - OCI_HandleFree(thread->err, OCI_HTYPE_ERROR); + MemoryFreeHandle(thread->err, OCI_HTYPE_ERROR); } /* free thread structure */ - OCI_FREE(thread) + FREE(thread) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadRun + * ThreadRun * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ThreadRun +boolean ThreadRun ( OCI_Thread *thread, POCI_THREAD proc, void *arg ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_THREAD, thread) - OCI_CALL_CHECK_PTR(OCI_IPC_PROC, proc) - OCI_CALL_CONTEXT_SET_FROM_ERR(thread->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_THREAD, thread + ) + + CHECK_PTR(OCI_IPC_THREAD, thread) + CHECK_PTR(OCI_IPC_PROC, proc) thread->proc = proc; thread->arg = arg; - OCI_EXEC(OCIThreadCreate(OCILib.env, thread->err, OCI_ThreadProc, thread, thread->id, thread->handle)) + CHECK_OCI + ( + thread->err, + OCIThreadCreate, + Env.env, thread->err, ThreadProc, + thread, thread->id, thread->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadJoin + * ThreadJoin * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ThreadJoin +boolean ThreadJoin ( OCI_Thread *thread ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_THREAD, thread) - OCI_CALL_CONTEXT_SET_FROM_ERR(thread->err) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_THREAD, thread + ) + + CHECK_PTR(OCI_IPC_THREAD, thread) - OCI_EXEC(OCIThreadJoin(OCILib.env, thread->err, thread->handle)) + CHECK_OCI + ( + thread->err, + OCIThreadJoin, + Env.env, thread->err, + thread->handle + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/thread.h b/src/thread.h new file mode 100644 index 00000000..c90364d3 --- /dev/null +++ b/src/thread.h @@ -0,0 +1,48 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_THREAD_H_INCLUDED +#define OCILIB_THREAD_H_INCLUDED + +#include "types.h" + +OCI_Thread * ThreadCreate +( + void +); + +boolean ThreadFree +( + OCI_Thread *thread +); + +boolean ThreadRun +( + OCI_Thread *thread, + POCI_THREAD proc, + void *arg +); + +boolean ThreadJoin +( + OCI_Thread* thread +); + +#endif /* OCILIB_THREAD_H_INCLUDED */ diff --git a/src/threadkey.c b/src/threadkey.c index 92c1237f..fc3bff7d 100644 --- a/src/threadkey.c +++ b/src/threadkey.c @@ -18,215 +18,271 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "threadkey.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "hash.h" +#include "macros.h" /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeyCreateInternal + * ThreadKeyCreateInternal * --------------------------------------------------------------------------------------------- */ -OCI_ThreadKey * OCI_ThreadKeyCreateInternal +OCI_ThreadKey * ThreadKeyCreateInternal ( POCI_THREADKEYDEST destfunc ) { - OCI_ThreadKey *key = NULL; + ENTER_FUNC + ( + /* returns */ OCI_ThreadKey*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_CALL_DECLARE_CONTEXT(TRUE) - /* allocate key structure */ - OCI_ALLOCATE_DATA(OCI_IPC_THREADKEY, key, 1) + OCI_ThreadKey *key = NULL; - if (OCI_STATUS) - { - /* allocate error handle */ + ALLOC_DATA(OCI_IPC_THREADKEY, key, 1) - OCI_STATUS = OCI_HandleAlloc(OCILib.env, (dvoid **)(void *)&key->err, OCI_HTYPE_ERROR); + /* allocate error handle */ - /* key initialization */ + CHECK(MemoryAllocHandle(Env.env, (dvoid **)(void *)&key->err, OCI_HTYPE_ERROR)) - OCI_EXEC(OCIThreadKeyInit(OCILib.env, key->err, &key->handle, destfunc)) + /* key initialization */ - /* check errors */ + CHECK_OCI + ( + key->err, + OCIThreadKeyInit, + Env.env, key->err, &key->handle, destfunc + ) - if (!OCI_STATUS) + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) { - OCI_ThreadKeyFree(key); + ThreadKeyFree(key); key = NULL; } - } - return key; + SET_RETVAL(key) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeyFree + * ThreadKeyFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_ThreadKeyFree +boolean ThreadKeyFree ( OCI_ThreadKey *key ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_THREADKEY, key + ) - OCI_CHECK(NULL == key, FALSE); + CHECK_PTR(OCI_IPC_THREADKEY, key) /* close key handle */ - if (key->handle) + if (NULL != key->handle) { - OCI_EXEC(OCIThreadKeyDestroy(OCILib.env, key->err, &key->handle)) + CHECK_OCI + ( + key->err, + OCIThreadKeyDestroy, + Env.env, key->err, + &key->handle + ) } /* close error handle */ - if (key->err) + if (NULL != key->err) { - OCI_HandleFree(key->err, OCI_HTYPE_ERROR); + MemoryFreeHandle(key->err, OCI_HTYPE_ERROR); } /* free key structure */ - OCI_FREE(key) + FREE(key) - return OCI_STATUS; + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeySet + * ThreadKeySet * --------------------------------------------------------------------------------------------- */ -boolean OCI_ThreadKeySet +boolean ThreadKeySet ( OCI_ThreadKey *key, void *value ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_THREADKEY, key + ) + + CHECK_PTR(OCI_IPC_THREADKEY, key) - OCI_CHECK(NULL == key, FALSE); + CHECK_OCI + ( + key->err, + OCIThreadKeySet, + Env.env, key->err, + key->handle, value + ) - OCI_EXEC(OCIThreadKeySet(OCILib.env, key->err, key->handle, value)) + SET_SUCCESS() - return OCI_STATUS; + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeyGet + * ThreadKeyGet * --------------------------------------------------------------------------------------------- */ -boolean OCI_ThreadKeyGet +boolean ThreadKeyGet ( OCI_ThreadKey* key, void **value ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - - OCI_CHECK(NULL == key, FALSE); - - OCI_EXEC(OCIThreadKeyGet(OCILib.env, key->err, key->handle, value)) - - return OCI_STATUS; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_THREADKEY, key + ) + + CHECK_PTR(OCI_IPC_THREADKEY, key) + CHECK_PTR(OCI_IPC_VOID, value) + + CHECK_OCI + ( + key->err, + OCIThreadKeyGet, + Env.env, key->err, + key->handle, value + ) + + SET_SUCCESS() + + EXIT_FUNC() } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeyCreate + * ThreadKeyCreate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ThreadKeyCreate +boolean ThreadKeyCreate ( const otext *name, POCI_THREADKEYDEST destfunc ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + OCI_ThreadKey *key = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CHECK_INITIALIZED() + CHECK_PTR(OCI_IPC_STRING, name) + CHECK_INITIALIZED() - if (!OCILib.key_map) + if (NULL == Env.key_map) { - /* create the map at the first call to OCI_ThreadKeyCreate to save + /* create the map at the first call to ThreadKeyCreate to save time and memory when it's not needed */ - OCILib.key_map = OCI_HashCreate(OCI_HASH_DEFAULT_SIZE, OCI_HASH_POINTER); - OCI_STATUS = (NULL != OCILib.key_map); + Env.key_map = HashCreate(OCI_HASH_DEFAULT_SIZE, OCI_HASH_POINTER); + CHECK_NULL(Env.key_map) } /* create key */ - if (OCI_STATUS) - { - key = OCI_ThreadKeyCreateInternal(destfunc); - OCI_STATUS = (NULL != key); - - /* add key to internal key hash table */ - - OCI_STATUS = OCI_STATUS && OCI_HashAddPointer(OCILib.key_map, name, key); - } + key = ThreadKeyCreateInternal(destfunc); + CHECK_NULL(key) - /* check errors */ + /* add key to internal key hash table */ - if (!OCI_STATUS && key) - { - OCI_ThreadKeyFree(key); - } + CHECK(HashAddPointer(Env.key_map, name, key)) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE && NULL != key) + { + ThreadKeyFree(key); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeySetValue + * ThreadKeySetValue * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_ThreadKeySetValue +boolean ThreadKeySetValue ( const otext *name, void *value ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) + OCI_ThreadKey *key = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) + CHECK_PTR(OCI_IPC_STRING, name) - key = (OCI_ThreadKey *) OCI_HashGetPointer(OCILib.key_map, name); + key = (OCI_ThreadKey*) HashGetPointer(Env.key_map, name); + CHECK_NULL(key) - OCI_RETVAL = OCI_STATUS = OCI_ThreadKeySet(key, value); + CHECK(ThreadKeySet(key, value)) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_ThreadKeyGetValue + * ThreadKeyGetValue * --------------------------------------------------------------------------------------------- */ -void * OCI_API OCI_ThreadKeyGetValue +void * ThreadKeyGetValue ( const otext *name ) { + ENTER_FUNC + ( + /* returns */ void*, NULL, + /* context */ OCI_IPC_VOID, &Env + ) + OCI_ThreadKey* key = NULL; + CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_ENTER(void*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) + key = (OCI_ThreadKey*)HashGetPointer(Env.key_map, name); + CHECK_NULL(key) - key = (OCI_ThreadKey *)OCI_HashGetPointer(OCILib.key_map, name); + void *data = NULL; + CHECK(ThreadKeyGet(key, &data)) - OCI_STATUS = OCI_ThreadKeyGet(key, &OCI_RETVAL); + SET_RETVAL(data) - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/threadkey.h b/src/threadkey.h new file mode 100644 index 00000000..e1fe43ed --- /dev/null +++ b/src/threadkey.h @@ -0,0 +1,65 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_THREADKEY_H_INCLUDED +#define OCILIB_THREADKEY_H_INCLUDED + +#include "types.h" + +OCI_ThreadKey* ThreadKeyCreateInternal +( + POCI_THREADKEYDEST destfunc +); + +boolean ThreadKeyCreate +( + const otext * name, + POCI_THREADKEYDEST destfunc +); + +boolean ThreadKeyFree +( + OCI_ThreadKey* key +); + +boolean ThreadKeySet +( + OCI_ThreadKey* key, + void * value +); + +boolean ThreadKeyGet +( + OCI_ThreadKey* key, + void ** value +); + +boolean ThreadKeySetValue +( + const otext *name, + void *value +); + +void * ThreadKeyGetValue +( + const otext *name +); + +#endif /* OCILIB_THREADKEY_H_INCLUDED */ diff --git a/src/timestamp.c b/src/timestamp.c index 0f2842b7..6d3b4cc9 100644 --- a/src/timestamp.c +++ b/src/timestamp.c @@ -18,25 +18,30 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "timestamp.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "array.h" +#include "environment.h" +#include "helpers.h" +#include "macros.h" +#include "strings.h" #if OCI_VERSION_COMPILE >= OCI_9_0 -static unsigned int TimestampTypeValues[] = { OCI_TIMESTAMP, OCI_TIMESTAMP_TZ, OCI_TIMESTAMP_LTZ }; -#endif -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +static unsigned int TimestampTypeValues[] = +{ + OCI_TIMESTAMP, + OCI_TIMESTAMP_TZ, + OCI_TIMESTAMP_LTZ +}; + +#endif /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampInit + * TimestampInitialize * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_TimestampInit +OCI_Timestamp * TimestampInitialize ( OCI_Connection *con, OCI_Timestamp *tmsp, @@ -44,91 +49,103 @@ OCI_Timestamp * OCI_TimestampInit ub4 type ) { - OCI_CALL_DECLARE_CONTEXT(TRUE) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Timestamp*, tmsp, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_ALLOCATE_DATA(OCI_IPC_TIMESTAMP, tmsp, 1); + ALLOC_DATA(OCI_IPC_TIMESTAMP, tmsp, 1); - if (OCI_STATUS) - { - tmsp->con = con; - tmsp->handle = buffer; - tmsp->type = type; + tmsp->con = con; + tmsp->handle = buffer; + tmsp->type = type; - /* get the right error handle */ + /* get the right error handle */ - if (con) - { - tmsp->err = con->err; - tmsp->env = con->env; - } - else - { - tmsp->err = OCILib.err; - tmsp->env = OCILib.env; - } + if (con) + { + tmsp->err = con->err; + tmsp->env = con->env; + } + else + { + tmsp->err = Env.err; + tmsp->env = Env.env; + } - /* allocate buffer if needed */ + /* allocate buffer if needed */ - if (!tmsp->handle || (OCI_OBJECT_ALLOCATED_ARRAY == tmsp->hstate)) - { - if (OCI_OBJECT_ALLOCATED_ARRAY != tmsp->hstate) - { - OCI_STATUS = OCI_DescriptorAlloc((dvoid *)tmsp->env, (dvoid **)(void *)&tmsp->handle, (ub4)OCI_ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, type)); - tmsp->hstate = OCI_OBJECT_ALLOCATED; - } - } - else + if (NULL == tmsp->handle || (OCI_OBJECT_ALLOCATED_ARRAY == tmsp->hstate)) + { + if (OCI_OBJECT_ALLOCATED_ARRAY != tmsp->hstate) { - tmsp->hstate = OCI_OBJECT_FETCHED_CLEAN; + CHECK + ( + MemoryAllocDescriptor + ( + (dvoid *)tmsp->env, + (dvoid **)(void *)&tmsp->handle, + (ub4)ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, type) + ) + ) + + tmsp->hstate = OCI_OBJECT_ALLOCATED; } } - - /* check for failure */ - - if (!OCI_STATUS && tmsp) + else { - OCI_TimestampFree(tmsp); - tmsp = NULL; + tmsp->hstate = OCI_OBJECT_FETCHED_CLEAN; } + #else OCI_NOT_USED(con) OCI_NOT_USED(type) OCI_NOT_USED(buffer) + CHECK(FALSE) + #endif - return tmsp; -} + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + TimestampFree(tmsp); + tmsp = NULL; + } -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + SET_RETVAL(tmsp) + ) +} /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampCreate + * TimestampCreate * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp * OCI_API OCI_TimestampCreate +OCI_Timestamp * TimestampCreate ( OCI_Connection *con, unsigned int type ) { - OCI_CALL_ENTER(OCI_Timestamp*, NULL) - OCI_CALL_CHECK_INITIALIZED() - OCI_CALL_CHECK_TIMESTAMP_ENABLED(con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Timestamp*, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + + CHECK_INITIALIZED() + CHECK_TIMESTAMP_ENABLED(con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, TimestampTypeValues, OTEXT("Timestamp type")) + CHECK_ENUM_VALUE(type, TimestampTypeValues, OTEXT("Timestamp type")) - OCI_RETVAL = OCI_TimestampInit(con, NULL, NULL, type); - OCI_STATUS = (NULL != OCI_RETVAL); + SET_RETVAL(TimestampInitialize(con, NULL, NULL, type)) #else @@ -136,75 +153,84 @@ OCI_Timestamp * OCI_API OCI_TimestampCreate #endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampFree + * TimestampFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampFree +boolean TimestampFree ( OCI_Timestamp *tmsp ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_OBJECT_FETCHED(tmsp) + CHECK_OBJECT_FETCHED(tmsp) if (OCI_OBJECT_ALLOCATED == tmsp->hstate) { - OCI_DescriptorFree((dvoid *)tmsp->handle, OCI_ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, tmsp->type)); + MemoryFreeDescriptor + ( + (dvoid*)tmsp->handle, + ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, tmsp->type) + ); } if (OCI_OBJECT_ALLOCATED_ARRAY != tmsp->hstate) { - OCI_FREE(tmsp) + FREE(tmsp) } #endif - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampArrayCreate + * TimestampCreateArray * --------------------------------------------------------------------------------------------- */ -OCI_Timestamp ** OCI_API OCI_TimestampArrayCreate +OCI_Timestamp ** TimestampCreateArray ( OCI_Connection *con, unsigned int type, unsigned int nbelem ) { + ENTER_FUNC + ( + /* returns */ OCI_Timestamp**, NULL, + /* context */ (con ? OCI_IPC_CONNECTION : OCI_IPC_VOID), (con ? (void*)con : (void*)&Env) + ) + OCI_Array *arr = NULL; - OCI_CALL_ENTER(OCI_Timestamp **, NULL) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_TIMESTAMP_ENABLED(con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, TimestampTypeValues, OTEXT("Timestamp type")) + CHECK_ENUM_VALUE(type, TimestampTypeValues, OTEXT("Timestamp type")) - arr = OCI_ArrayCreate(con, nbelem, OCI_CDT_TIMESTAMP, type, - sizeof(OCIDateTime *), sizeof(OCI_Timestamp), - OCI_ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, type), NULL); + arr = ArrayCreate(con, nbelem, OCI_CDT_TIMESTAMP, type, + sizeof(OCIDateTime*), sizeof(OCI_Timestamp), + ExternalSubTypeToHandleType(OCI_CDT_TIMESTAMP, type), NULL); - OCI_STATUS = (NULL != arr); + CHECK_NULL(arr) - if (OCI_STATUS) - { - OCI_RETVAL = (OCI_Timestamp **) arr->tab_obj; - } + SET_RETVAL((OCI_Timestamp**)arr->tab_obj) #else @@ -214,57 +240,71 @@ OCI_Timestamp ** OCI_API OCI_TimestampArrayCreate #endif - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampArrayFree + * TimestampFreeArray * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampArrayFree +boolean TimestampFreeArray ( OCI_Timestamp **tmsps ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_ARRAY, tmsps) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_VOID, &Env + ) - OCI_RETVAL = OCI_STATUS = OCI_ArrayFreeFromHandles((void **) tmsps); + CHECK_PTR(OCI_IPC_ARRAY, tmsps) - OCI_CALL_EXIT() + SET_RETVAL(ArrayFreeFromHandles((void **) tmsps)) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampGetType + * TimestampGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_TimestampGetType +unsigned int TimestampGetType ( OCI_Timestamp *tmsp ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_TIMESTAMP, tmsp, type, tmsp->con, NULL, tmsp->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_TIMESTAMP, tmsp, + type + ) } /* --------------------------------------------------------------------------------------------- * * OCI_DateZoneToZone * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampAssign +boolean TimestampAssign ( OCI_Timestamp *tmsp, OCI_Timestamp *tmsp_src ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + OCI_Timestamp *tmp_tmsp = NULL; OCI_Timestamp *tmp_tmsp_src = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp_src) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CHECK_COMPAT(tmsp->con, tmsp->type == tmsp_src->type) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp_src) + CHECK_TIMESTAMP_ENABLED(tmsp->con) + CHECK_COMPAT(tmsp->type == tmsp_src->type) #if OCI_VERSION_COMPILE >= OCI_9_0 @@ -272,11 +312,14 @@ boolean OCI_API OCI_TimestampAssign if (OCI_TIMESTAMP_LTZ == tmsp_src->type) { - tmp_tmsp_src = OCI_TimestampCreate(tmsp_src->con, OCI_TIMESTAMP_TZ); - tmp_tmsp = OCI_TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + tmp_tmsp_src = TimestampCreate(tmsp_src->con, OCI_TIMESTAMP_TZ); + CHECK_NULL(tmp_tmsp_src) - OCI_STATUS = OCI_STATUS && OCI_TimestampConvert(tmp_tmsp_src, tmsp_src); - OCI_STATUS = OCI_STATUS && OCI_TimestampConvert(tmp_tmsp, tmsp); + tmp_tmsp = TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + CHECK_NULL(tmp_tmsp) + + CHECK(TimestampConvert(tmp_tmsp_src, tmsp_src)) + CHECK(TimestampConvert(tmp_tmsp, tmsp)) } else { @@ -284,94 +327,122 @@ boolean OCI_API OCI_TimestampAssign tmp_tmsp = tmsp; } - OCI_EXEC(OCIDateTimeAssign((dvoid *)tmp_tmsp->env, tmp_tmsp->err, tmp_tmsp_src->handle, tmp_tmsp->handle)) + CHECK_OCI + ( + tmp_tmsp->err, + OCIDateTimeAssign, + (dvoid *)tmp_tmsp->env, tmp_tmsp->err, + tmp_tmsp_src->handle, tmp_tmsp->handle + ) /* converting back */ if (OCI_TIMESTAMP_LTZ == tmsp_src->type) { - OCI_STATUS = OCI_STATUS && OCI_TimestampConvert(tmsp_src, tmp_tmsp_src); - OCI_STATUS = OCI_STATUS && OCI_TimestampConvert(tmsp, tmp_tmsp); - } - - if (tmsp != tmp_tmsp) - { - OCI_TimestampFree(tmp_tmsp); + CHECK(TimestampConvert(tmsp_src, tmp_tmsp_src)) + CHECK(TimestampConvert(tmsp, tmp_tmsp)) } - if (tmsp_src != tmp_tmsp_src) - { - OCI_TimestampFree(tmp_tmsp_src); - } + SET_SUCCESS() #endif - OCI_RETVAL = OCI_STATUS; + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != tmp_tmsp && tmsp != tmp_tmsp) + { + TimestampFree(tmp_tmsp); + } - OCI_CALL_EXIT() + if (NULL != tmp_tmsp_src && tmsp_src != tmp_tmsp_src) + { + TimestampFree(tmp_tmsp_src); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampCheck + * TimestampCheck * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_TimestampCheck +int TimestampCheck ( OCI_Timestamp *tmsp ) { + ENTER_FUNC + ( + /* returns */ int, 0, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + ub4 value = 0; - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeCheck((dvoid *)tmsp->env, tmsp->err, tmsp->handle, &value)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeCheck, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, &value + ) #endif - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampCompare + * TimestampCompare * --------------------------------------------------------------------------------------------- */ -int OCI_API OCI_TimestampCompare +int TimestampCompare ( OCI_Timestamp *tmsp, OCI_Timestamp *tmsp2 ) { + ENTER_FUNC + ( + /* returns */ int, OCI_ERROR, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + sword value = OCI_ERROR; - OCI_CALL_ENTER(int, value) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp2) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp2) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeCompare((dvoid *)tmsp->env, tmsp->err, tmsp->handle, tmsp2->handle, &value)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeCompare, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, tmsp2->handle, + &value + ) #endif - OCI_RETVAL = value; + SET_RETVAL(value) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampConstruct + * TimestampConstruct * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampConstruct +boolean TimestampConstruct ( OCI_Timestamp *tmsp, int year, @@ -384,23 +455,31 @@ boolean OCI_API OCI_TimestampConstruct const otext *time_zone ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC + CHECK_OCI ( - OCIDateTimeConstruct((dvoid *) tmsp->env, tmsp->err, - tmsp->handle, - (sb2) year, (ub1) month, (ub1) day, - (ub1) hour, (ub1) min,(ub1) sec, - (ub4) fsec, (OraText *) time_zone, - (size_t) (time_zone ? otextsize(time_zone) : 0)) + tmsp->err, + OCIDateTimeConstruct, + (dvoid *) tmsp->env, tmsp->err, + tmsp->handle, + (sb2) year, (ub1) month, (ub1) day, + (ub1) hour, (ub1) min,(ub1) sec, + (ub4) fsec, (OraText *) time_zone, + (size_t) (time_zone ? otextsize(time_zone) : 0) ) + SET_SUCCESS() + #else OCI_NOT_USED(year) @@ -414,81 +493,95 @@ boolean OCI_API OCI_TimestampConstruct #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampConvert + * TimestampConvert * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampConvert +boolean TimestampConvert ( OCI_Timestamp *tmsp, OCI_Timestamp *tmsp_src ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp_src) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp_src) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeConvert((dvoid *)tmsp->env, tmsp->err, tmsp_src->handle, tmsp->handle)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeConvert, + (dvoid *)tmsp->env, tmsp->err, + tmsp_src->handle, tmsp->handle + ) + + SET_SUCCESS() #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampFromText + * TimestampFromString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampFromText +boolean TimestampFromString ( OCI_Timestamp *tmsp, const otext *str, const otext *fmt ) { - dbtext *dbstr1 = NULL; - dbtext *dbstr2 = NULL; - int dbsize1 = -1; - int dbsize2 = -1; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + dbtext *dbstr1 = NULL; + dbtext *dbstr2 = NULL; + int dbsize1 = -1; + int dbsize2 = -1; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_STRING, str) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (!OCI_STRING_VALID(fmt)) + if (!IS_STRING_VALID(fmt)) { - fmt = OCI_GetFormat(tmsp->con, tmsp->type == OCI_TIMESTAMP_TZ ? OCI_FMT_TIMESTAMP_TZ : OCI_FMT_TIMESTAMP); + fmt = EnvironmentGetFormat(tmsp->con, tmsp->type == OCI_TIMESTAMP_TZ ? OCI_FMT_TIMESTAMP_TZ : OCI_FMT_TIMESTAMP); + CHECK_NULL(fmt) } - dbstr1 = OCI_StringGetOracleString(str, &dbsize1); - dbstr2 = OCI_StringGetOracleString(fmt, &dbsize2); + dbstr1 = StringGetDBString(str, &dbsize1); + dbstr2 = StringGetDBString(fmt, &dbsize2); - OCI_EXEC + CHECK_OCI ( - OCIDateTimeFromText((dvoid *) tmsp->env, tmsp->err, - (OraText *) dbstr1, (size_t) dbsize1, - (OraText *) dbstr2, (ub1) dbsize2, - (OraText *) NULL, (size_t) 0, - tmsp->handle) + tmsp->err, + OCIDateTimeFromText, + (dvoid *) tmsp->env, tmsp->err, + (OraText *) dbstr1, (size_t) dbsize1, + (OraText *) dbstr2, (ub1) dbsize2, + (OraText *) NULL, (size_t) 0, + tmsp->handle ) - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); + SET_SUCCESS() #else @@ -499,16 +592,18 @@ boolean OCI_API OCI_TimestampFromText #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampToText + * TimestampToString * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampToText +boolean TimestampToString ( OCI_Timestamp *tmsp, const otext *fmt, @@ -517,50 +612,55 @@ boolean OCI_API OCI_TimestampToText int precision ) { - dbtext *dbstr1 = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + dbtext *dbstr1 = NULL; dbtext *dbstr2 = NULL; int dbsize1 = size * (int) sizeof(otext); int dbsize2 = -1; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_STRING, str) /* initialize output buffer in case of OCI failure */ str[0] = 0; - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - if (!OCI_STRING_VALID(fmt)) + if (!IS_STRING_VALID(fmt)) { - fmt = OCI_GetFormat(tmsp->con, tmsp->type == OCI_TIMESTAMP_TZ ? OCI_FMT_TIMESTAMP_TZ : OCI_FMT_TIMESTAMP); + fmt = EnvironmentGetFormat(tmsp->con, tmsp->type == OCI_TIMESTAMP_TZ ? OCI_FMT_TIMESTAMP_TZ : OCI_FMT_TIMESTAMP); } - dbstr1 = OCI_StringGetOracleString(str, &dbsize1); - dbstr2 = OCI_StringGetOracleString(fmt, &dbsize2); + dbstr1 = StringGetDBString(str, &dbsize1); + dbstr2 = StringGetDBString(fmt, &dbsize2); - OCI_EXEC + CHECK_OCI ( - OCIDateTimeToText((dvoid *) tmsp->env, tmsp->err, - tmsp->handle, (OraText *) dbstr2, - (ub1) dbsize2, (ub1) precision, - (OraText *) NULL, (size_t) 0, - (ub4*) &dbsize1, (OraText *) dbstr1) + tmsp->err, + OCIDateTimeToText, + (dvoid *) tmsp->env, tmsp->err, + tmsp->handle, (OraText *) dbstr2, + (ub1) dbsize2, (ub1) precision, + (OraText *) NULL, (size_t) 0, + (ub4*) &dbsize1, (OraText *) dbstr1 ) - OCI_StringCopyOracleStringToNativeString(dbstr1, str, dbcharcount(dbsize1)); - - OCI_StringReleaseOracleString(dbstr1); - OCI_StringReleaseOracleString(dbstr2); + StringCopyDBStringToNativeString(dbstr1, str, dbcharcount(dbsize1)); /* set null string terminator */ str[dbcharcount(dbsize1)] = 0; + SET_SUCCESS() + #else OCI_NOT_USED(dbstr1) @@ -571,16 +671,18 @@ boolean OCI_API OCI_TimestampToText #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + StringReleaseDBString(dbstr2); + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampGetDate + * TimestampGetDate * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampGetDate +boolean TimestampGetDate ( OCI_Timestamp *tmsp, int *year, @@ -588,26 +690,38 @@ boolean OCI_API OCI_TimestampGetDate int *day ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + sb2 yr = 0; ub1 mt = 0; ub1 dy = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, year) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, month) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, day) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_INT, year) + CHECK_PTR(OCI_IPC_INT, month) + CHECK_PTR(OCI_IPC_INT, day) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeGetDate((dvoid *)tmsp->env, tmsp->err, tmsp->handle, &yr, &mt, &dy)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeGetDate, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, &yr, &mt, &dy + ) *year = (int) yr; *month = (int) mt; *day = (int) dy; + SET_SUCCESS() + #else OCI_NOT_USED(year) @@ -619,16 +733,14 @@ boolean OCI_API OCI_TimestampGetDate #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampGetTime + * TimestampGetTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampGetTime +boolean TimestampGetTime ( OCI_Timestamp *tmsp, int *hour, @@ -637,19 +749,23 @@ boolean OCI_API OCI_TimestampGetTime int *fsec ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + ub1 hr = 0; ub1 mn = 0; ub1 sc = 0; ub4 fs = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, hour) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, min) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, sec) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, fsec) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_INT, hour) + CHECK_PTR(OCI_IPC_INT, min) + CHECK_PTR(OCI_IPC_INT, sec) + CHECK_PTR(OCI_IPC_INT, fsec) + CHECK_TIMESTAMP_ENABLED(tmsp->con) *hour = 0; *min = 0; @@ -658,13 +774,21 @@ boolean OCI_API OCI_TimestampGetTime #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeGetTime((dvoid *)tmsp->env, tmsp->err, tmsp->handle, &hr, &mn, &sc, &fs)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeGetTime, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, &hr, &mn, &sc, &fs + ) *hour = (int) hr; *min = (int) mn; *sec = (int) sc; *fsec = (int) fs; + SET_SUCCESS() + #else OCI_NOT_USED(hour) @@ -678,16 +802,14 @@ boolean OCI_API OCI_TimestampGetTime #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampGetDateTime + * TimestampGetDateTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampGetDateTime +boolean TimestampGetDateTime ( OCI_Timestamp *tmsp, int *year, @@ -699,43 +821,55 @@ boolean OCI_API OCI_TimestampGetDateTime int *fsec ) { - return (OCI_TimestampGetDate(tmsp, year, month, day) && - OCI_TimestampGetTime(tmsp, hour, min, sec, fsec)); + return (TimestampGetDate(tmsp, year, month, day) && + TimestampGetTime(tmsp, hour, min, sec, fsec)); } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampGetTimeZoneName + * TimestampGetTimeZoneName * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampGetTimeZoneName +boolean TimestampGetTimeZoneName ( OCI_Timestamp *tmsp, int size, otext *str ) { - dbtext *dbstr = NULL; - int dbsize = size * (int) sizeof(otext); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + dbtext *dbstr = NULL; + int dbsize = size * (int) sizeof(otext); - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, str) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_STRING, str) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - dbstr = OCI_StringGetOracleString(str, &dbsize); + dbstr = StringGetDBString(str, &dbsize); - OCI_EXEC(OCIDateTimeGetTimeZoneName((dvoid *)tmsp->env, tmsp->err, tmsp->handle, (ub1*) dbstr, (ub4*) &dbsize)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeGetTimeZoneName, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, (ub1*) dbstr, + (ub4*) &dbsize + ) - OCI_StringCopyOracleStringToNativeString(dbstr, str, dbcharcount(dbsize)); - OCI_StringReleaseOracleString(dbstr); + StringCopyDBStringToNativeString(dbstr, str, dbcharcount(dbsize)); /* set null string terminator */ str[dbcharcount(dbsize)] = 0; + SET_SUCCESS() + #else OCI_NOT_USED(str) @@ -745,38 +879,51 @@ boolean OCI_API OCI_TimestampGetTimeZoneName #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampGetTimeZoneOffset + * TimestampGetTimeZoneOffset * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampGetTimeZoneOffset +boolean TimestampGetTimeZoneOffset ( OCI_Timestamp *tmsp, int *hour, int *min ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + sb1 sb_hour = 0, sb_min = 0; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, hour) - OCI_CALL_CHECK_PTR(OCI_IPC_INT, min) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_INT, hour) + CHECK_PTR(OCI_IPC_INT, min) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeGetTimeZoneOffset((dvoid *)tmsp->env, tmsp->err, tmsp->handle, &sb_hour, &sb_min)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeGetTimeZoneOffset, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, &sb_hour, &sb_min + ) *hour = sb_hour; *min = sb_min; + SET_SUCCESS() + #else OCI_NOT_USED(hour) @@ -784,28 +931,30 @@ boolean OCI_API OCI_TimestampGetTimeZoneOffset #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampIntervalAdd + * TimestampIntervalAdd * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampIntervalAdd +boolean TimestampIntervalAdd ( OCI_Timestamp *tmsp, OCI_Interval *itv ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + OCI_Timestamp *tmp = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 @@ -813,28 +962,33 @@ boolean OCI_API OCI_TimestampIntervalAdd if (OCI_TIMESTAMP_TZ != tmsp->type) { - tmp = OCI_TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + tmp = TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + CHECK_NULL(tmp); - OCI_STATUS = OCI_TimestampConvert(tmp, tmsp); + CHECK(TimestampConvert(tmp, tmsp)) } else { tmp = tmsp; } - OCI_EXEC(OCIDateTimeIntervalAdd((dvoid *)tmp->env, tmp->err, tmp->handle, itv->handle, tmp->handle)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeIntervalAdd, + (dvoid *)tmp->env, tmp->err, + tmp->handle, itv->handle, + tmp->handle + ) /* converting back */ - if (OCI_STATUS && (OCI_TIMESTAMP_TZ != tmsp->type)) + if (OCI_TIMESTAMP_TZ != tmsp->type) { - OCI_STATUS = OCI_TimestampConvert(tmsp, tmp); + CHECK(TimestampConvert(tmsp, tmp)) } - if (tmsp != tmp) - { - OCI_TimestampFree(tmp); - } + SET_SUCCESS() #else @@ -842,28 +996,36 @@ boolean OCI_API OCI_TimestampIntervalAdd #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != tmsp && tmsp != tmp) + { + TimestampFree(tmp); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampIntervalSub + * TimestampIntervalSub * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampIntervalSub +boolean TimestampIntervalSub ( OCI_Timestamp *tmsp, OCI_Interval *itv ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + OCI_Timestamp *tmp = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 @@ -871,28 +1033,33 @@ boolean OCI_API OCI_TimestampIntervalSub if (OCI_TIMESTAMP_TZ != tmsp->type) { - tmp = OCI_TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + tmp = TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + CHECK_NULL(tmp) - OCI_STATUS = OCI_TimestampConvert(tmp, tmsp); + CHECK(TimestampConvert(tmp, tmsp)) } else { tmp = tmsp; } - OCI_EXEC(OCIDateTimeIntervalSub((dvoid *)tmp->env, tmp->err, tmp->handle, itv->handle, tmp->handle)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeIntervalSub, + (dvoid *)tmp->env, tmp->err, + tmp->handle, itv->handle, + tmp->handle + ) /* converting back */ - if (OCI_STATUS && (OCI_TIMESTAMP_TZ != tmsp->type)) + if (OCI_TIMESTAMP_TZ != tmsp->type) { - OCI_STATUS = OCI_TimestampConvert(tmsp, tmp); + CHECK(TimestampConvert(tmsp, tmp)) } - if (tmsp != tmp) - { - OCI_TimestampFree(tmp); - } + SET_SUCCESS() #else @@ -900,57 +1067,75 @@ boolean OCI_API OCI_TimestampIntervalSub #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != tmsp && tmsp != tmp) + { + TimestampFree(tmp); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampSubtract + * TimestampSubtract * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampSubtract +boolean TimestampSubtract ( OCI_Timestamp *tmsp, OCI_Timestamp *tmsp2, OCI_Interval *itv ) { - OCI_CALL_ENTER(boolean, FALSE) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp2) - OCI_CALL_CHECK_PTR(OCI_IPC_INTERVAL, itv) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp2) + CHECK_PTR(OCI_IPC_INTERVAL, itv) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 - OCI_EXEC(OCIDateTimeSubtract((dvoid *)tmsp->env, tmsp->err, tmsp->handle, tmsp2->handle, itv->handle)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeSubtract, + (dvoid *)tmsp->env, tmsp->err, + tmsp->handle, tmsp2->handle, + itv->handle + ) + + SET_SUCCESS() #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampSysTimestamp + * TimestampSysTimestamp * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampSysTimestamp +boolean TimestampSysTimestamp ( OCI_Timestamp *tmsp ) { - OCI_Timestamp *tmp = NULL; + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + OCI_Timestamp *tmp = NULL; OCIDateTime *handle = NULL; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_TIMESTAMP_ENABLED(tmsp->con) #if OCI_VERSION_COMPILE >= OCI_9_0 @@ -964,7 +1149,8 @@ boolean OCI_API OCI_TimestampSysTimestamp if (OCI_TIMESTAMP == tmsp->type) { - tmp = OCI_TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + tmp = TimestampCreate(tmsp->con, OCI_TIMESTAMP_TZ); + CHECK_NULL(tmp) handle = tmp->handle; } @@ -973,17 +1159,19 @@ boolean OCI_API OCI_TimestampSysTimestamp handle = tmsp->handle; } - OCI_EXEC(OCIDateTimeSysTimeStamp((dvoid *) tmsp->env, tmsp->err, handle)) + CHECK_OCI + ( + tmsp->err, + OCIDateTimeSysTimeStamp, + (dvoid *) tmsp->env, tmsp->err, handle + ) - if (OCI_STATUS && (OCI_TIMESTAMP == tmsp->type)) + if (OCI_TIMESTAMP == tmsp->type) { - OCI_STATUS = OCI_TimestampConvert(tmsp, tmp); + CHECK(TimestampConvert(tmsp, tmp)) } - if (tmp && tmsp != tmp) - { - OCI_TimestampFree(tmp); - } + SET_SUCCESS() #else @@ -992,94 +1180,102 @@ boolean OCI_API OCI_TimestampSysTimestamp #endif - OCI_RETVAL = OCI_STATUS; - - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (NULL != tmsp && tmsp != tmp) + { + TimestampFree(tmp); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampToCTime + * TimestampToCTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampToCTime +boolean TimestampToCTime ( OCI_Timestamp *tmsp, struct tm *ptm, time_t *pt ) { + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + time_t time = (time_t) -1; - int msec = 0; + int msec = 0; struct tm t; - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_TIMESTAMP_ENABLED(tmsp->con) memset(&t, 0, sizeof(t)); - OCI_STATUS = OCI_TimestampGetDateTime(tmsp, &t.tm_year, &t.tm_mon, &t.tm_mday, - &t.tm_hour, &t.tm_min, &t.tm_sec, &msec); - - if (OCI_STATUS) - { - t.tm_year -= 1900; - t.tm_mon -= 1; - t.tm_wday = 0; - t.tm_yday = 0; - t.tm_isdst = -1; + CHECK(TimestampGetDateTime(tmsp, &t.tm_year, &t.tm_mon, &t.tm_mday, + &t.tm_hour, &t.tm_min, &t.tm_sec, &msec)) - time = mktime(&t); + t.tm_year -= 1900; + t.tm_mon -= 1; + t.tm_wday = 0; + t.tm_yday = 0; + t.tm_isdst = -1; - if (ptm) - { - memcpy(ptm, &t, sizeof(t)); - } + time = mktime(&t); - if (pt) - { - *pt = time; - } + if (NULL != ptm) + { + memcpy(ptm, &t, sizeof(t)); } - if (OCI_STATUS) + if (NULL != pt) { - OCI_RETVAL = (time != (time_t)-1); + *pt = time; } - OCI_CALL_EXIT() + SET_RETVAL(time != (time_t)-1) + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TimestampFromCTime + * TimestampFromCTime * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TimestampFromCTime +boolean TimestampFromCTime ( OCI_Timestamp *tmsp, struct tm *ptm, time_t t ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) - OCI_CALL_CHECK_TIMESTAMP_ENABLED(tmsp->con) - OCI_CALL_CONTEXT_SET_FROM_OBJ(tmsp) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TIMESTAMP, tmsp + ) + + CHECK_PTR(OCI_IPC_TIMESTAMP, tmsp) + CHECK_TIMESTAMP_ENABLED(tmsp->con) - if (!ptm && t != (time_t)0) + if (NULL == ptm && (t == (time_t)0)) { - ptm = localtime(&t); + THROW(ExceptionNullPointer, OCI_IPC_TM) } - if (!ptm) + if (NULL == ptm) { - OCI_RAISE_EXCEPTION(OCI_ExceptionNullPointer(OCI_IPC_TM)) + ptm = localtime(&t); } - OCI_RETVAL = OCI_STATUS = OCI_TimestampConstruct(tmsp, ptm->tm_year + 1900, ptm->tm_mon + 1, - ptm->tm_mday, ptm->tm_hour, ptm->tm_min, - ptm->tm_sec, (int) 0, (const otext *) NULL); + CHECK(TimestampConstruct(tmsp, ptm->tm_year + 1900, ptm->tm_mon + 1, + ptm->tm_mday, ptm->tm_hour, ptm->tm_min, + ptm->tm_sec, (int) 0, (const otext *) NULL)) + + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } diff --git a/src/timestamp.h b/src/timestamp.h new file mode 100644 index 00000000..b6bfe595 --- /dev/null +++ b/src/timestamp.h @@ -0,0 +1,195 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_TIMESTAMP_H_INCLUDED +#define OCILIB_TIMESTAMP_INCLUDED + +#include "types.h" + +OCI_Timestamp * TimestampInitialize +( + OCI_Connection *con, + OCI_Timestamp *tmsp, + OCIDateTime *buffer, + ub4 type +); + +OCI_Timestamp * TimestampCreate +( + OCI_Connection *con, + unsigned int type +); + +boolean TimestampFree +( + OCI_Timestamp *tmsp +); + +OCI_Timestamp ** TimestampCreateArray +( + OCI_Connection* con, + unsigned int type, + unsigned int nbelem +); + +boolean TimestampFreeArray +( + OCI_Timestamp **tmsps +); + +unsigned int TimestampGetType +( + OCI_Timestamp *tmsp +); + +boolean TimestampAssign +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp_src +); + +int TimestampCheck +( + OCI_Timestamp *tmsp +); + +int TimestampCompare +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp2 +); + +boolean TimestampConstruct +( + OCI_Timestamp *tmsp, + int year, + int month, + int day, + int hour, + int min, + int sec, + int fsec, + const otext *time_zone +); + +boolean TimestampConvert +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp_src +); + +boolean TimestampFromString +( + OCI_Timestamp *tmsp, + const otext *str, + const otext *fmt +); + +boolean TimestampToString +( + OCI_Timestamp *tmsp, + const otext *fmt, + int size, + otext *str, + int precision +); + +boolean TimestampGetDate +( + OCI_Timestamp *tmsp, + int *year, + int *month, + int *day +); + +boolean TimestampGetTime +( + OCI_Timestamp *tmsp, + int *hour, + int *min, + int *sec, + int *fsec +); + +boolean TimestampGetDateTime +( + OCI_Timestamp *tmsp, + int *year, + int *month, + int *day, + int *hour, + int *min, + int *sec, + int *fsec +); + +boolean TimestampGetTimeZoneName +( + OCI_Timestamp *tmsp, + int size, + otext *str +); + +boolean TimestampGetTimeZoneOffset +( + OCI_Timestamp *tmsp, + int *hour, + int *min +); + +boolean TimestampIntervalAdd +( + OCI_Timestamp *tmsp, + OCI_Interval *itv +); + +boolean TimestampIntervalSub +( + OCI_Timestamp* tmsp, + OCI_Interval *itv +); + +boolean TimestampSubtract +( + OCI_Timestamp *tmsp, + OCI_Timestamp *tmsp2, + OCI_Interval *itv +); + +boolean TimestampSysTimestamp +( + OCI_Timestamp *tmsp +); + +boolean TimestampToCTime +( + OCI_Timestamp *tmsp, + struct tm *ptm, + time_t *pt +); + +boolean TimestampFromCTime +( + OCI_Timestamp *tmsp, + struct tm *ptm, + time_t t +); + +#endif /* OCILIB_TIMESTAMP_H_INCLUDED */ diff --git a/src/transaction.c b/src/transaction.c index 94afaa39..dc4e0303 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -18,28 +18,36 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "transaction.h" -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ +#include "connection.h" +#include "list.h" +#include "macros.h" /* --------------------------------------------------------------------------------------------- * -* OCI_TransactionClose +* TransactionDispose * --------------------------------------------------------------------------------------------- */ -boolean OCI_TransactionClose +boolean TransactionDispose ( -OCI_Transaction * trans + OCI_Transaction * trans ) { - const boolean res = OCI_TransactionStop(trans); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) + + CHECK_PTR(OCI_IPC_TRANSACTION, trans) + + CHECK(TransactionStop(trans)) /* close transaction handle */ if (trans->htr) { - OCI_HandleFree((dvoid *)trans->htr, OCI_HTYPE_TRANS); + MemoryFreeHandle((dvoid*)trans->htr, OCI_HTYPE_TRANS); } if (trans->con->trs == trans) @@ -47,18 +55,16 @@ OCI_Transaction * trans trans->con->trs = NULL; } - return res; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC() +} /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionCreate + * TransactionCreate * --------------------------------------------------------------------------------------------- */ -OCI_Transaction * OCI_API OCI_TransactionCreate +OCI_Transaction * TransactionCreate ( OCI_Connection *con, unsigned int timeout, @@ -66,207 +72,282 @@ OCI_Transaction * OCI_API OCI_TransactionCreate OCI_XID *pxid ) { - OCI_Transaction *trans = NULL; - - OCI_CALL_ENTER(OCI_Transaction *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + ENTER_FUNC + ( + /* returns */ OCI_Transaction*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) - /* create transaction object */ + OCI_Transaction* trans = NULL; - trans = OCI_ListAppend(con->trsns, sizeof(*trans)); - OCI_STATUS = (NULL != trans); - - if (OCI_STATUS) - { - trans->con = con; - trans->mode = mode; - trans->timeout = timeout; - trans->local = (NULL == pxid); + CHECK_PTR(OCI_IPC_CONNECTION, con) - /* allocate transaction handle */ + /* create transaction object */ - OCI_STATUS = OCI_HandleAlloc((dvoid *)trans->con->env, (dvoid **)&trans->htr, OCI_HTYPE_TRANS); + trans = ListAppend(con->trsns, sizeof(*trans)); + CHECK_NULL(trans) - /* set XID attribute for global transaction */ + trans->con = con; + trans->mode = mode; + trans->timeout = timeout; + trans->local = (NULL == pxid); - if (OCI_STATUS && pxid) - { - memcpy(&trans->xid, pxid, sizeof(trans->xid)); + /* allocate transaction handle */ - OCI_SET_ATTRIB(OCI_HTYPE_TRANS, OCI_ATTR_XID, trans->htr, &trans->xid, sizeof(trans->xid)) - } - } + CHECK(MemoryAllocHandle((dvoid *)trans->con->env, (dvoid **)&trans->htr, OCI_HTYPE_TRANS)) - /* handle errors */ + /* set XID attribute for global transaction */ - if (OCI_STATUS) - { - OCI_RETVAL = trans; - } - else if (trans) + if (pxid) { - OCI_TransactionFree(trans); + memcpy(&trans->xid, pxid, sizeof(trans->xid)); + + CHECK_ATTRIB_SET + ( + OCI_HTYPE_TRANS, OCI_ATTR_XID, + trans->htr, &trans->xid, sizeof(trans->xid), + trans->con->err + ) } - OCI_CALL_EXIT() + CLEANUP_AND_EXIT_FUNC + ( + if (FAILURE) + { + TransactionFree(trans); + trans = NULL; + } + + SET_RETVAL(trans) + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionFree + * TransactionFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TransactionFree +boolean TransactionFree ( OCI_Transaction * trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(trans->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) + + CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_STATUS = OCI_TransactionClose(trans); + TransactionDispose(trans); /* remove transaction from internal list */ - OCI_ListRemove(trans->con->trsns, trans); + ListRemove(trans->con->trsns, trans); - OCI_FREE(trans) + FREE(trans) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionStart + * TransactionStart * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TransactionStart +boolean TransactionStart ( OCI_Transaction * trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(trans->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) - OCI_EXEC(OCITransStart(trans->con->cxt, trans->con->err, (uword) trans->timeout, (ub4) trans->mode)) + CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + trans->con->err, + OCITransStart, + trans->con->cxt, trans->con->err, + (uword) trans->timeout, (ub4) trans->mode + ) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionStop + * TransactionStop * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TransactionStop +boolean TransactionStop ( OCI_Transaction * trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(trans->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) + + CHECK_PTR(OCI_IPC_TRANSACTION, trans) /* commit or rollback upon auto commit mode */ - OCI_STATUS = trans->con->autocom ? OCI_Commit(trans->con) : OCI_Rollback(trans->con); + if (trans->con->autocom) + { + ConnectionCommit(trans->con); + } + else + { + ConnectionRollback(trans->con); + } /* detach global transaction */ - if (OCI_STATUS && !trans->local) + if (!trans->local) { - OCI_EXEC(OCITransDetach(trans->con->cxt, trans->con->err, (ub4) OCI_DEFAULT)) + CHECK_OCI + ( + trans->con->err, + OCITransDetach, + trans->con->cxt, trans->con->err, + (ub4) OCI_DEFAULT + ) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionResume + * TransactionResume * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TransactionResume +boolean TransactionResume ( OCI_Transaction * trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(trans->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) - OCI_EXEC(OCITransStart(trans->con->cxt, trans->con->err, (uword) trans->timeout, (ub4) OCI_TRANS_RESUME)) + CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_RETVAL = OCI_STATUS; + CHECK_OCI + ( + trans->con->err, + OCITransStart, + trans->con->cxt, trans->con->err, + (uword) trans->timeout, (ub4) OCI_TRANS_RESUME + ) - OCI_CALL_EXIT() + SET_SUCCESS() + + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionPrepare + * TransactionPrepare * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TransactionPrepare +boolean TransactionPrepare ( OCI_Transaction * trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(trans->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) + + CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_EXEC(OCITransPrepare(trans->con->cxt, trans->con->err, (ub4) OCI_DEFAULT)) + CHECK_OCI + ( + trans->con->err, + OCITransPrepare, + trans->con->cxt, trans->con->err, + (ub4) OCI_DEFAULT + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionForget + * TransactionForget * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TransactionForget +boolean TransactionForget ( OCI_Transaction * trans ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_CALL_CONTEXT_SET_FROM_CONN(trans->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TRANSACTION, trans + ) + + CHECK_PTR(OCI_IPC_TRANSACTION, trans) - OCI_EXEC(OCITransForget(trans->con->cxt, trans->con->err, (ub4) OCI_DEFAULT)) + CHECK_OCI + ( + trans->con->err, + OCITransForget, + trans->con->cxt, trans->con->err, + (ub4) OCI_DEFAULT + ) - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionGetMode + * TransactionGetMode * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_TransactionGetMode +unsigned int TransactionGetMode ( OCI_Transaction * trans ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_TRANSACTION, trans, mode, trans->con, NULL, trans->con->err); + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_TRANSACTION, trans, + mode + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TransactionGetTimeout + * TransactionGetTimeout * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_TransactionGetTimeout +unsigned int TransactionGetTimeout ( OCI_Transaction * trans ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_TRANSACTION, trans, timeout, trans->con, NULL, trans->con->err); + GET_PROP + ( + unsigned int, 0, + OCI_IPC_TRANSACTION, trans, + timeout + ) } diff --git a/src/transaction.h b/src/transaction.h new file mode 100644 index 00000000..74a73c23 --- /dev/null +++ b/src/transaction.h @@ -0,0 +1,79 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_TRANSACTION_H_INCLUDED +#define OCILIB_TRANSACTION_H_INCLUDED + +#include "types.h" + +boolean TransactionDispose +( + OCI_Transaction * trans +); + +OCI_Transaction * TransactionCreate +( + OCI_Connection *con, + unsigned int timeout, + unsigned int mode, + OCI_XID *pxid +); + +boolean TransactionFree +( + OCI_Transaction * trans +); + +boolean TransactionStart +( + OCI_Transaction * trans +); + +boolean TransactionStop +( + OCI_Transaction * trans +); + +boolean TransactionResume +( + OCI_Transaction * trans +); + +boolean TransactionPrepare +( + OCI_Transaction * trans +); + +boolean TransactionForget +( + OCI_Transaction * trans +); + +unsigned int TransactionGetMode +( + OCI_Transaction * trans +); + +unsigned int TransactionGetTimeout +( + OCI_Transaction * trans +); + +#endif /* OCILIB_TRANSACTION_H_INCLUDED */ diff --git a/src/typeinfo.c b/src/typeinfo.c index fb84ae10..25e2d951 100644 --- a/src/typeinfo.c +++ b/src/typeinfo.c @@ -18,101 +18,133 @@ * limitations under the License. */ -#include "ocilib_internal.h" +#include "typeinfo.h" -/* ********************************************************************************************* * - * PRIVATE VARIABLES - * ********************************************************************************************* */ +#include "column.h" +#include "list.h" +#include "macros.h" +#include "memory.h" +#include "strings.h" -static unsigned int TypeInfoTypeValues[] = { OCI_TIF_TABLE, OCI_TIF_VIEW, OCI_TIF_TYPE }; +static unsigned int TypeInfoTypeValues[] = +{ + OCI_TIF_TABLE, + OCI_TIF_VIEW, + OCI_TIF_TYPE +}; typedef struct TypeInfoFindParams { unsigned int type; - otext * schema; - otext * name; + otext * schema; + otext * name; } TypeInfoFindParams; -/* ********************************************************************************************* * - * PRIVATE FUNCTIONS - * ********************************************************************************************* */ - /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoFind + * TypeInfoFind * --------------------------------------------------------------------------------------------- */ -boolean OCI_TypeInfoFind(OCI_TypeInfo *typinf, TypeInfoFindParams *find_params) +static boolean TypeInfoFind(OCI_TypeInfo *typinf, TypeInfoFindParams *find_params) { - return - typinf && + return + typinf && find_params && typinf->type == find_params->type && - ostrcasecmp(typinf->name, find_params->name) == 0 && + ostrcasecmp(typinf->name, find_params->name) == 0 && ostrcasecmp(typinf->schema, find_params->schema) == 0; } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoClose + * TypeInfoDispose * --------------------------------------------------------------------------------------------- */ -boolean OCI_TypeInfoClose +boolean TypeInfoDispose ( OCI_TypeInfo *typinf ) { - OCI_CHECK(NULL == typinf, FALSE); + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) + + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) for (ub2 i = 0; i < typinf->nb_cols; i++) { - OCI_FREE(typinf->cols[i].name) + FREE(typinf->cols[i].name) } - OCI_FREE(typinf->cols) - OCI_FREE(typinf->name) - OCI_FREE(typinf->schema) - OCI_FREE(typinf->offsets) + FREE(typinf->cols) + FREE(typinf->name) + FREE(typinf->schema) + FREE(typinf->offsets) - return TRUE; -} + SET_SUCCESS() -/* ********************************************************************************************* * - * PUBLIC FUNCTIONS - * ********************************************************************************************* */ + EXIT_FUNC(); +} /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoGet + * TypeInfoGet * --------------------------------------------------------------------------------------------- */ -OCI_TypeInfo * OCI_API OCI_TypeInfoGet +OCI_TypeInfo * TypeInfoGet ( OCI_Connection *con, const otext *name, unsigned int type ) { + ENTER_FUNC + ( + /* returns */ OCI_TypeInfo*, NULL, + /* context */ OCI_IPC_CONNECTION, con + ) + TypeInfoFindParams find_params; - OCI_TypeInfo *typinf = NULL; - OCI_TypeInfo *syn_typinf = NULL; - OCIDescribe *dschp = NULL; - OCIParam *param_root = NULL; - OCIParam *param_type = NULL; - OCIParam *param_cols = NULL; - OCIParam *param_list = NULL; - otext *str = NULL; - int ptype = 0; - ub1 desc_type = 0; - ub4 attr_type = 0; - ub4 num_type = 0; + OCI_TypeInfo *typinf = NULL; + OCI_TypeInfo *syn_typinf = NULL; + OCIDescribe *dschp = NULL; + OCIParam *param_root = NULL; + OCIParam *param_type = NULL; + OCIParam *param_cols = NULL; + OCIParam *param_list = NULL; + otext *str = NULL; + int ptype = 0; + ub1 desc_type = 0; + ub4 attr_type = 0; + ub4 num_type = 0; + + otext* syn_schema_name = NULL; + otext* syn_object_name = NULL; + otext* syn_link_name = NULL; + + unsigned int size_schema = 0; + unsigned int size_object = 0; + unsigned int size_link = 0; + + otext* sp_schema_name = NULL; + otext* sp_object_name = NULL; + + unsigned int sp_size_schema = 0; + unsigned int sp_size_object = 0; + + otext buffer[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); + + size_t max_chars = sizeof(buffer) / sizeof(otext) - 1; + dbtext* dbstr1 = NULL; + int dbsize1 = -1; + sb4 pbsp = 1; otext obj_schema[OCI_SIZE_OBJ_NAME + 1]; otext obj_name[OCI_SIZE_OBJ_NAME + 1]; - OCI_CALL_ENTER(OCI_TypeInfo*, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_CONNECTION, con) - OCI_CALL_CHECK_PTR(OCI_IPC_STRING, name) - OCI_CALL_CHECK_ENUM_VALUE(con, NULL, type, TypeInfoTypeValues, OTEXT("Type")) - OCI_CALL_CONTEXT_SET_FROM_CONN(con) + CHECK_PTR(OCI_IPC_CONNECTION, con) + CHECK_PTR(OCI_IPC_STRING, name) + CHECK_ENUM_VALUE(type, TypeInfoTypeValues, OTEXT("Type")) obj_schema[0] = 0; obj_name[0] = 0; @@ -123,8 +155,8 @@ OCI_TypeInfo * OCI_API OCI_TypeInfoGet { if (*str == OTEXT('.')) { - ostrncat(obj_schema, name, str-name); - ostrncat(obj_name, ++str, (size_t) OCI_SIZE_OBJ_NAME); + ostrncat(obj_schema, name, str-name); + ostrncat(obj_name, ++str, (size_t) OCI_SIZE_OBJ_NAME); break; } } @@ -154,322 +186,340 @@ OCI_TypeInfo * OCI_API OCI_TypeInfoGet { *str = (otext)otoupper(*str); } - } + } /* first try to find it in list */ - find_params.type = type; - find_params.name = obj_name; + find_params.type = type; + find_params.name = obj_name; find_params.schema = obj_schema; - typinf = OCI_ListFind(con->tinfs, (POCI_LIST_FIND) OCI_TypeInfoFind, &find_params); - + typinf = ListFind(con->tinfs, (POCI_LIST_FIND)TypeInfoFind, &find_params); + /* Not found, so create type object */ - if (!typinf) + if (NULL == typinf) { - typinf = OCI_ListAppend(con->tinfs, sizeof(OCI_TypeInfo)); - OCI_STATUS = (NULL != typinf); + typinf = ListAppend(con->tinfs, sizeof(OCI_TypeInfo)); + CHECK_NULL(typinf) /* allocate describe handle */ - if (OCI_STATUS) - { - typinf->con = con; - typinf->name = ostrdup(obj_name); - typinf->schema = ostrdup(obj_schema); - typinf->struct_size = 0; - typinf->align = 0; + typinf->con = con; + typinf->name = ostrdup(obj_name); + typinf->schema = ostrdup(obj_schema); + typinf->struct_size = 0; + typinf->align = 0; - OCI_STATUS = OCI_HandleAlloc(typinf->con->env, (dvoid **)(void *)&dschp, OCI_HTYPE_DESCRIBE); - } + CHECK(MemoryAllocHandle(typinf->con->env, (dvoid **)(void *)&dschp, OCI_HTYPE_DESCRIBE)) /* perform describe */ - if (OCI_STATUS) - { - otext buffer[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); + str = buffer; + + /* compute full object name */ - size_t max_chars = sizeof(buffer) / sizeof(otext) - 1; - dbtext *dbstr1 = NULL; - int dbsize1 = -1; - sb4 pbsp = 1; + if (IS_STRING_VALID(typinf->schema)) + { + str = ostrncat(buffer, typinf->schema, max_chars); + max_chars -= ostrlen(typinf->schema); - str = buffer; + str = ostrncat(str, OTEXT("."), max_chars); + max_chars -= (size_t)1; + } - /* compute full object name */ + ostrncat(str, typinf->name, max_chars); - if (OCI_STRING_VALID(typinf->schema)) - { - str = ostrncat(buffer, typinf->schema, max_chars); - max_chars -= ostrlen(typinf->schema); + dbstr1 = StringGetDBString(str, &dbsize1); - str = ostrncat(str, OTEXT("."), max_chars); - max_chars -= (size_t)1; - } + /* set public scope to include synonyms */ - ostrncat(str, typinf->name, max_chars); + CHECK_ATTRIB_SET + ( + OCI_HTYPE_DESCRIBE, OCI_ATTR_DESC_PUBLIC, + dschp, &pbsp, sizeof(pbsp), + con->err + ) - dbstr1 = OCI_StringGetOracleString(str, &dbsize1); + /* describe call */ - /* set public scope to include synonyms */ - - OCI_SET_ATTRIB(OCI_HTYPE_DESCRIBE, OCI_ATTR_DESC_PUBLIC, dschp, &pbsp, sizeof(pbsp)) - - /* describe call */ + CHECK_OCI + ( + con->err, + OCIDescribeAny, + con->cxt, con->err, (dvoid *) dbstr1, + (ub4) dbsize1, OCI_OTYPE_NAME, + OCI_DEFAULT, OCI_PTYPE_UNK, dschp + ) - OCI_EXEC - ( - OCIDescribeAny(con->cxt, con->err, (dvoid *) dbstr1, - (ub4) dbsize1, OCI_OTYPE_NAME, - OCI_DEFAULT, OCI_PTYPE_UNK, dschp) - ) + /* get parameter handle */ - OCI_StringReleaseOracleString(dbstr1); + CHECK_ATTRIB_GET + ( + OCI_HTYPE_DESCRIBE, OCI_ATTR_PARAM, + dschp, ¶m_root, NULL, + con->err + ) - /* get parameter handle */ - - OCI_GET_ATTRIB(OCI_HTYPE_DESCRIBE, OCI_ATTR_PARAM, dschp, ¶m_root, NULL) - - /* get describe type */ + /* get describe type */ - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_PTYPE, param_root, &desc_type, NULL) - } + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_PTYPE, + param_root, &desc_type, NULL, + con->err + ) - /* on successful describe call, retrieve all information about the object + /* on successful describe call, retrieve all information about the object if it is not a synonym */ - if (OCI_STATUS) + switch (desc_type) { - switch (desc_type) + case OCI_PTYPE_TYPE: + case OCI_PTYPE_LIST: { - case OCI_PTYPE_TYPE: - case OCI_PTYPE_LIST: - { - ub1 pdt = 0; // Is Predefined Type - ub1 ist = 0; // Is Sub Type - OCIRef *ref = NULL; - - OCI_STATUS = (OCI_TIF_TYPE == type); + ub1 pdt = 0; /* Is Predefined Type */ + ub1 ist = 0; /* Is Sub Type */ + OCIRef* ref = NULL; - if (OCI_STATUS) - { - typinf->type = OCI_TIF_TYPE; - - if (OCI_PTYPE_LIST == desc_type) - { - OCI_EXEC(OCIParamGet((dvoid *)param_root, OCI_DTYPE_PARAM, con->err, (void**)¶m_type, (ub4)0)) - } - else - { - param_type = param_root; - } - - /* get the object type descriptor */ - - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_REF_TDO, param_type, &ref, NULL) - - OCI_EXEC(OCITypeByRef(typinf->con->env, con->err, ref, OCI_DURATION_SESSION, OCI_TYPEGET_ALL, &typinf->tdo)) - - /* check if the type is not final, e.g. can be inherited */ + CHECK(OCI_TIF_TYPE == type) - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_IS_FINAL_TYPE, param_type, &typinf->is_final, NULL) + typinf->type = OCI_TIF_TYPE; - /* check if it's system predefined type if order to avoid the next call that is not allowed on system types */ + if (OCI_PTYPE_LIST == desc_type) + { + CHECK_OCI + ( + con->err, + OCIParamGet, + (dvoid*)param_root, OCI_DTYPE_PARAM, + con->err, (void**)¶m_type, (ub4) 0 + ) + } + else + { + param_type = param_root; + } - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_IS_PREDEFINED_TYPE, param_type, &pdt, NULL) + /* get the object type descriptor */ + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_REF_TDO, + param_type, &ref, NULL, + con->err + ) + + CHECK_OCI + ( + con->err, + OCITypeByRef, + typinf->con->env, con->err, ref, + OCI_DURATION_SESSION, OCI_TYPEGET_ALL, + &typinf->tdo + ) + + /* check if the type is not final, e.g. can be inherited */ + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_IS_FINAL_TYPE, + param_type, &typinf->is_final, NULL, + con->err + ) + + /* check if it's system predefined type if order to avoid the next call that + * is not allowed on system types */ + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_IS_PREDEFINED_TYPE, + param_type, &pdt, NULL, con->err + ) + + if (!pdt) + { + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_TYPECODE, + param_type, &typinf->typecode, NULL, + con->err + ) + } - if (!pdt) - { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_TYPECODE, param_type, &typinf->typecode, NULL) - } + /* check if the type is a subtype derived from a super type */ - /* check if the type is a subtype derived from a super type */ + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_IS_SUBTYPE, + param_type, &ist, NULL, + con->err + ) - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_IS_SUBTYPE, param_type, &ist, NULL) + if (ist) + { + otext sp_fullname[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); - if (ist) - { - otext *sp_schema_name = NULL; - otext *sp_object_name = NULL; + /* get super type schema and name */ - unsigned int size_schema = 0; - unsigned int size_object = 0; + CHECK(StringGetAttribute(con, param_root, OCI_DTYPE_PARAM, + OCI_ATTR_SUPERTYPE_SCHEMA_NAME, + &sp_schema_name, &sp_size_schema)) - otext sp_fullname[(OCI_SIZE_OBJ_NAME * 2) + 2] = OTEXT(""); + CHECK(StringGetAttribute(con, param_root, OCI_DTYPE_PARAM, + OCI_ATTR_SUPERTYPE_NAME, + &sp_object_name, &sp_size_object)) - /* get super type schema and name */ + /* compute super type full name */ - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(con, param_root, OCI_DTYPE_PARAM, - OCI_ATTR_SUPERTYPE_SCHEMA_NAME, - &sp_schema_name, &size_schema); - - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(con, param_root, OCI_DTYPE_PARAM, - OCI_ATTR_SUPERTYPE_NAME, - &sp_object_name, &size_object); + StringGetFullTypeName(sp_schema_name, NULL, sp_object_name, NULL, sp_fullname, + (sizeof(sp_fullname) / sizeof(otext)) - 1); - /* compute super type full name */ + /* retrieve the type info of the real object */ - OCI_StringGetFullTypeName(sp_schema_name, NULL, sp_object_name, NULL, sp_fullname, (sizeof(sp_fullname) / sizeof(otext)) - 1); + typinf->parent_type = TypeInfoGet(con, sp_fullname, type); - /* retrieve the type info of the real object */ + CHECK_NULL(typinf->parent_type) + } - typinf->parent_type = OCI_TypeInfoGet(con, sp_fullname, type); - - /* free temporary strings */ + switch (typinf->typecode) + { + case SQLT_NTY: +#if OCI_VERSION_COMPILE >= OCI_12_1 + case SQLT_REC: +#endif + { + param_list = param_type; + ptype = OCI_DESC_TYPE; + attr_type = OCI_ATTR_LIST_TYPE_ATTRS; + num_type = OCI_ATTR_NUM_TYPE_ATTRS; + break; + } + case SQLT_NCO: + { + typinf->nb_cols = 1; + + ptype = OCI_DESC_COLLECTION; + param_cols = param_type; + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, OCI_ATTR_COLLECTION_TYPECODE, + param_type, &typinf->colcode, NULL, + con->err + ) + break; + } + default: + { + THROW(ExceptionDatatypeNotSupported, typinf->typecode) + break; + } + } - OCI_MemFree (sp_schema_name); - OCI_MemFree (sp_object_name); + break; + } + case OCI_PTYPE_TABLE: + case OCI_PTYPE_VIEW: +#if OCI_VERSION_COMPILE >= OCI_10_1 + case OCI_PTYPE_TABLE_ALIAS: +#endif + { + CHECK(((OCI_TIF_TABLE == type) && (OCI_PTYPE_VIEW != desc_type)) || + ((OCI_TIF_VIEW == type) && (OCI_PTYPE_VIEW == desc_type))) - OCI_STATUS = (NULL != typinf->parent_type); - } + typinf->type = (OCI_PTYPE_VIEW == desc_type ? OCI_TIF_VIEW : OCI_TIF_TABLE); + attr_type = OCI_ATTR_LIST_COLUMNS; + num_type = OCI_ATTR_NUM_COLS; + ptype = OCI_DESC_TABLE; + param_list = param_root; - switch (typinf->typecode) - { - case SQLT_NTY: - #if OCI_VERSION_COMPILE >= OCI_12_1 - case SQLT_REC: - #endif - { - param_list = param_type; - ptype = OCI_DESC_TYPE; - attr_type = OCI_ATTR_LIST_TYPE_ATTRS; - num_type = OCI_ATTR_NUM_TYPE_ATTRS; - break; - } - case SQLT_NCO: - { - typinf->nb_cols = 1; + break; + } + case OCI_PTYPE_SYN: + { + otext syn_fullname[(OCI_SIZE_OBJ_NAME * 3) + 3] = OTEXT(""); - ptype = OCI_DESC_COLLECTION; - param_cols = param_type; + /* get link schema, object and database link names */ - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, OCI_ATTR_COLLECTION_TYPECODE, param_type, &typinf->colcode, NULL) - break; - } - default: - { - OCI_STATUS = FALSE; - OCI_ExceptionDatatypeNotSupported(con, NULL, typinf->typecode); - break; - } - } - } - - break; - } - case OCI_PTYPE_TABLE: - case OCI_PTYPE_VIEW: - #if OCI_VERSION_COMPILE >= OCI_10_1 - case OCI_PTYPE_TABLE_ALIAS: - #endif - { - OCI_STATUS = (((OCI_TIF_TABLE == type) && (OCI_PTYPE_VIEW != desc_type)) || - ((OCI_TIF_VIEW == type) && (OCI_PTYPE_VIEW == desc_type))); - - if (OCI_STATUS) - { - typinf->type = (OCI_PTYPE_VIEW == desc_type ? OCI_TIF_VIEW : OCI_TIF_TABLE); - attr_type = OCI_ATTR_LIST_COLUMNS; - num_type = OCI_ATTR_NUM_COLS; - ptype = OCI_DESC_TABLE; - param_list = param_root; - } - - break; - } - case OCI_PTYPE_SYN: - { - otext *syn_schema_name = NULL; - otext *syn_object_name = NULL; - otext *syn_link_name = NULL; + CHECK(StringGetAttribute(con, param_root, + OCI_DTYPE_PARAM, + OCI_ATTR_SCHEMA_NAME, + &syn_schema_name, + &size_schema)) - unsigned int size_schema = 0; - unsigned int size_object = 0; - unsigned int size_link = 0; + CHECK(StringGetAttribute(con, param_root, + OCI_DTYPE_PARAM, + OCI_ATTR_NAME, + &syn_object_name, + &size_object)) - otext syn_fullname[(OCI_SIZE_OBJ_NAME * 3) + 3] = OTEXT(""); + CHECK(StringGetAttribute(con, param_root, + OCI_DTYPE_PARAM, + OCI_ATTR_LINK, + &syn_link_name, + &size_link)) - /* get link schema, object and database link names */ + /* compute link full name */ - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(con, param_root, OCI_DTYPE_PARAM, - OCI_ATTR_SCHEMA_NAME, &syn_schema_name, &size_schema); - - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(con, param_root, OCI_DTYPE_PARAM, - OCI_ATTR_NAME, &syn_object_name, &size_object); - - OCI_STATUS = OCI_STATUS && OCI_GetStringAttribute(con, param_root, OCI_DTYPE_PARAM, - OCI_ATTR_LINK, &syn_link_name, &size_link); + StringGetFullTypeName(syn_schema_name, NULL, syn_object_name, syn_link_name, syn_fullname, + (sizeof(syn_fullname) / sizeof(otext)) - 1); - /* compute link full name */ + /* retrieve the type info of the real object */ - OCI_StringGetFullTypeName(syn_schema_name, NULL, syn_object_name, syn_link_name, syn_fullname, (sizeof(syn_fullname) / sizeof(otext)) - 1); + syn_typinf = TypeInfoGet(con, syn_fullname, type); - /* retrieve the type info of the real object */ + /* do we have a valid object ? */ - syn_typinf = OCI_TypeInfoGet (con, syn_fullname, type); - - /* free temporary strings */ + CHECK_NULL(syn_typinf) - OCI_MemFree (syn_link_name); - OCI_MemFree (syn_object_name); - OCI_MemFree (syn_schema_name); - - /* do we have a valid object ? */ + break; + } + } - OCI_STATUS = (NULL != syn_typinf); + /* did we handle a supported object other than a synonym */ - break; - } + if (OCI_UNKNOWN != ptype) + { + /* retrieve the columns parameter if not already retrieved */ + if (param_list) + { + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, attr_type, + param_list, ¶m_cols, NULL, + con->err + ) + + CHECK_ATTRIB_GET + ( + OCI_DTYPE_PARAM, num_type, + param_list, &typinf->nb_cols, NULL, + con->err + ) } - /* did we handle a supported object other than a synonym */ + /* allocates memory for cached offsets */ - if (OCI_STATUS && (OCI_UNKNOWN != ptype)) + if (typinf->nb_cols > 0) { - /* retrieve the columns parameter if not already retrieved */ - if (param_list) - { - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, attr_type, param_list, ¶m_cols, NULL) - OCI_GET_ATTRIB(OCI_DTYPE_PARAM, num_type, param_list, &typinf->nb_cols, NULL) - } + ALLOC_DATA(OCI_IPC_ARRAY, typinf->offsets, typinf->nb_cols) - /* allocates memory for cached offsets */ + memset(typinf->offsets, -1, sizeof(*typinf->offsets) * typinf->nb_cols); + } - if (typinf->nb_cols > 0) - { - OCI_ALLOCATE_DATA(OCI_IPC_ARRAY, typinf->offsets, typinf->nb_cols) + /* allocates memory for children */ - if (OCI_STATUS) - { - memset(typinf->offsets, -1, sizeof(*typinf->offsets) * typinf->nb_cols); - } - } + if (typinf->nb_cols > 0) + { + ALLOC_DATA(OCI_IPC_COLUMN, typinf->cols, typinf->nb_cols) - /* allocates memory for children */ + /* describe children */ - if (typinf->nb_cols > 0) + for (ub2 i = 0; i < typinf->nb_cols; i++) { - OCI_ALLOCATE_DATA(OCI_IPC_COLUMN, typinf->cols, typinf->nb_cols) - - /* describe children */ - if (OCI_STATUS) - { - for (ub2 i = 0; i < typinf->nb_cols; i++) - { - OCI_STATUS = OCI_STATUS && OCI_ColumnDescribe(&typinf->cols[i], con, NULL, param_cols, i + 1, ptype); - OCI_STATUS = OCI_STATUS && OCI_ColumnMap(&typinf->cols[i], NULL); - - if (!OCI_STATUS) - { - break; - } - } - } - else - { - OCI_STATUS = FALSE; - } + CHECK(ColumnRetrieveInfo(&typinf->cols[i], con, NULL, param_cols, i + 1, ptype)) + CHECK(ColumnMapInfo(&typinf->cols[i], NULL)) } } } @@ -477,157 +527,196 @@ OCI_TypeInfo * OCI_API OCI_TypeInfoGet /* free describe handle */ - OCI_HandleFree(dschp, OCI_HTYPE_DESCRIBE); + MemoryFreeHandle(dschp, OCI_HTYPE_DESCRIBE); /* increment type info reference counter on success */ - if (typinf && OCI_STATUS) - { - typinf->refcount++; - - /* type checking sanity checks */ + typinf->refcount++; - if ((type != OCI_UNKNOWN) && ((syn_typinf && syn_typinf->type != type) || (!syn_typinf && typinf->type != type))) - { - OCI_ExceptionTypeInfoWrongType(con, name); + /* type checking sanity checks */ - OCI_STATUS = FALSE; - } - } - - /* handle errors */ - - if (!OCI_STATUS || syn_typinf) + if ((type != OCI_UNKNOWN) && ((syn_typinf && syn_typinf->type != type) || (!syn_typinf && typinf->type != type))) { - OCI_TypeInfoFree(typinf); + THROW(ExceptionTypeInfoWrongType, name) } + SET_RETVAL(syn_typinf ? syn_typinf : typinf) - if (OCI_STATUS) - { - OCI_RETVAL = syn_typinf ? syn_typinf : typinf; - } + CLEANUP_AND_EXIT_FUNC + ( + StringReleaseDBString(dbstr1); + + /* free temporary strings */ + + MemoryFree(syn_link_name); + MemoryFree(syn_object_name); + MemoryFree(syn_schema_name); + MemoryFree(sp_schema_name); + MemoryFree(sp_object_name); + + MemoryFreeHandle(dschp, OCI_HTYPE_DESCRIBE); - OCI_CALL_EXIT() + if (FAILURE || syn_typinf) + { + TypeInfoFree(typinf); + } + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoFree + * TypeInfoFree * --------------------------------------------------------------------------------------------- */ -boolean OCI_API OCI_TypeInfoFree +boolean TypeInfoFree ( OCI_TypeInfo *typinf ) { - OCI_CALL_ENTER(boolean, FALSE) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) + ENTER_FUNC + ( + /* returns */ boolean, FALSE, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) + + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) typinf->refcount--; if (typinf->refcount == 0) { - OCI_ListRemove(typinf->con->tinfs, typinf); + ListRemove(typinf->con->tinfs, typinf); + TypeInfoDispose(typinf); - OCI_TypeInfoClose(typinf); - - OCI_FREE(typinf) + FREE(typinf) } - OCI_RETVAL = OCI_STATUS; + SET_SUCCESS() - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoGetType + * TypeInfoGetType * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_TypeInfoGetType +unsigned int TypeInfoGetType ( OCI_TypeInfo *typinf ) { - OCI_GET_PROP(unsigned int, OCI_UNKNOWN, OCI_IPC_TYPE_INFO, typinf, type, typinf->con, NULL, typinf->con->err) + GET_PROP + ( + unsigned int, OCI_UNKNOWN, + OCI_IPC_TYPE_INFO, typinf, + type + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoGetConnection + * TypeInfoGetConnection * --------------------------------------------------------------------------------------------- */ -OCI_Connection * OCI_API OCI_TypeInfoGetConnection +OCI_Connection * TypeInfoGetConnection ( OCI_TypeInfo *typinf ) { - OCI_GET_PROP(OCI_Connection*, NULL, OCI_IPC_TYPE_INFO, typinf, con, typinf->con, NULL, typinf->con->err) + GET_PROP + ( + OCI_Connection*, NULL, + OCI_IPC_TYPE_INFO, typinf, + con + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoGetColumnCount + * TypeInfoGetColumnCount * --------------------------------------------------------------------------------------------- */ -unsigned int OCI_API OCI_TypeInfoGetColumnCount +unsigned int TypeInfoGetColumnCount ( OCI_TypeInfo *typinf ) { - OCI_GET_PROP(unsigned int, 0, OCI_IPC_TYPE_INFO, typinf, nb_cols, typinf->con, NULL, typinf->con->err) + GET_PROP + ( + unsigned int, 0, + OCI_IPC_TYPE_INFO, typinf, + nb_cols + ) } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoGetColumn + * TypeInfoGetColumn * --------------------------------------------------------------------------------------------- */ -OCI_Column * OCI_API OCI_TypeInfoGetColumn +OCI_Column * TypeInfoGetColumn ( OCI_TypeInfo *typinf, unsigned int index ) { - OCI_CALL_ENTER(OCI_Column *, NULL) - OCI_CALL_CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) - OCI_CALL_CHECK_BOUND(typinf->con, index, 1, typinf->nb_cols) - OCI_CALL_CONTEXT_SET_FROM_CONN(typinf->con) + ENTER_FUNC + ( + /* returns */ OCI_Column*, NULL, + /* context */ OCI_IPC_TYPE_INFO, typinf + ) + + CHECK_PTR(OCI_IPC_TYPE_INFO, typinf) + CHECK_BOUND(index, 1, typinf->nb_cols) - OCI_RETVAL = &(typinf->cols[index - 1]); + SET_RETVAL(&(typinf->cols[index - 1])) - OCI_CALL_EXIT() + EXIT_FUNC() } /* --------------------------------------------------------------------------------------------- * - * OCI_TypeInfoGetName + * TypeInfoGetName * --------------------------------------------------------------------------------------------- */ -const otext * OCI_API OCI_TypeInfoGetName +const otext * TypeInfoGetName ( OCI_TypeInfo *typinf ) { - OCI_GET_PROP(const otext*, NULL, OCI_IPC_TYPE_INFO, typinf, name, typinf->con, NULL, typinf->con->err) + GET_PROP + ( + const otext*, NULL, + OCI_IPC_TYPE_INFO, typinf, + name + ) } /* --------------------------------------------------------------------------------------------- * * OCI_TypeInfoIsFinalType * --------------------------------------------------------------------------------------------- */ -OCI_EXPORT boolean OCI_API OCI_TypeInfoIsFinalType +boolean TypeInfoIsFinalType ( OCI_TypeInfo *typinf ) { - OCI_GET_PROP(boolean, TRUE, OCI_IPC_TYPE_INFO, typinf, is_final, typinf->con, NULL, typinf->con->err) + GET_PROP + ( + boolean, TRUE, + OCI_IPC_TYPE_INFO, typinf, + is_final + ) } /* --------------------------------------------------------------------------------------------- * * OCI_TypeInfoGetSuperType * --------------------------------------------------------------------------------------------- */ -OCI_TypeInfo* OCI_API OCI_TypeInfoGetSuperType +OCI_TypeInfo* TypeInfoGetSuperType ( OCI_TypeInfo *typinf ) { - OCI_GET_PROP(OCI_TypeInfo*, NULL, OCI_IPC_TYPE_INFO, typinf, parent_type, typinf->con, NULL, typinf->con->err) + GET_PROP + ( + OCI_TypeInfo*, NULL, + OCI_IPC_TYPE_INFO, typinf, + parent_type + ) } diff --git a/src/typeinfo.h b/src/typeinfo.h new file mode 100644 index 00000000..458e1e24 --- /dev/null +++ b/src/typeinfo.h @@ -0,0 +1,79 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_TYPEINFO_H_INCLUDED +#define OCILIB_TYPEINFO_H_INCLUDED + +#include "types.h" + +boolean TypeInfoDispose +( + OCI_TypeInfo* typinf +); + +OCI_TypeInfo * TypeInfoGet +( + OCI_Connection *con, + const otext *name, + unsigned int type +); + +boolean TypeInfoFree +( + OCI_TypeInfo *typinf +); + +unsigned int TypeInfoGetType +( + OCI_TypeInfo *typinf +); + +OCI_Connection * TypeInfoGetConnection +( + OCI_TypeInfo *typinf +); + +unsigned int TypeInfoGetColumnCount +( + OCI_TypeInfo *typinf +); + +OCI_Column * TypeInfoGetColumn +( + OCI_TypeInfo *typinf, + unsigned int index +); + +const otext * TypeInfoGetName +( + OCI_TypeInfo *typinf +); + +boolean TypeInfoIsFinalType +( + OCI_TypeInfo* typinf +); + +OCI_TypeInfo* TypeInfoGetSuperType +( + OCI_TypeInfo* typinf +); + +#endif /* OCILIB_TYPEINFO_H_INCLUDED */ diff --git a/src/ocilib_types.h b/src/types.h similarity index 74% rename from src/ocilib_types.h rename to src/types.h index e8a84a20..f83f98ab 100644 --- a/src/ocilib_types.h +++ b/src/types.h @@ -1,978 +1,976 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OCILIB_OCILIB_TYPES_H_INCLUDED -#define OCILIB_OCILIB_TYPES_H_INCLUDED - -#include "ocilib_defs.h" - -/* ********************************************************************************************* * - * PRIVATE TYPES - * ********************************************************************************************* */ - -/* -* OCI_MemoryBlock : Internal block of Memory. -* -*/ - -struct OCI_MemoryBlock -{ - int type; /* type of allocated data */ - unsigned int size; /* allocated memory size*/ -}; - -typedef struct OCI_MemoryBlock OCI_MemoryBlock; - -/* - * OCI_Item : Internal list entry. - * - * The library needs to manage internal list of objects in order to be able to - * free them if the application does not. - * - * @note - * Internal lists are using mutexes for resource locking in multithreaded - * environments - * - */ - -struct OCI_Item -{ - void *data; /* pointer to external data */ - struct OCI_Item *next; /* next element in list */ -}; - -typedef struct OCI_Item OCI_Item; - -/* - * OCI_List : Internal list object. - * - * The OCI_List object is used to maintain a collection of handles allocated - * by user programs. - * - * Those handles are freed when the collection owner is destroyed. - * So, we make sure that if OCI_Cleanup() is called, all allocated handles will - * be destroyed even if the program does not free them. - * - */ - -struct OCI_List -{ - OCI_Item *head; /* pointer to first item */ - OCI_Mutex *mutex; /* mutex handle */ - ub4 count; /* number of elements in list */ - int type; /* type of list item */ -}; - -typedef struct OCI_List OCI_List; - -/* - * Server output object used to retrieve server dbms.output buffers - * - */ - -struct OCI_ServerOutput -{ - ub1 *arrbuf; /* array buffer */ - unsigned int arrsize; /* array size */ - unsigned int cursize; /* number of filled items in the array */ - unsigned int curpos; /* current position in the array */ - unsigned int lnsize; /* line size */ - OCI_Statement *stmt; /* pointer to statement object (dbms_output calls) */ -}; - -typedef struct OCI_ServerOutput OCI_ServerOutput; - -/* - * Connection trace information - * - */ - -struct OCI_TraceInfo -{ - otext identifier[OCI_SIZE_TRACE_ID+1]; - otext module[OCI_SIZE_TRACE_MODULE+1]; - otext action[OCI_SIZE_TRACE_ACTION+1]; - otext info[OCI_SIZE_TRACE_INFO+1]; - otext operation[OCI_SIZE_TRACE_OPERATION + 1]; - -}; - -typedef struct OCI_TraceInfo OCI_TraceInfo; - -/* ********************************************************************************************* * - * PUBLIC TYPES - * ********************************************************************************************* */ - -struct OCI_Error -{ - unsigned int depth; - boolean raise; /* Must be raised to user */ - boolean active; /* to avoid recursive exceptions */ - OCI_Connection *con; /* pointer to connection object */ - OCI_Statement *stmt; /* pointer to statement object */ - sb4 sqlcode; /* Oracle OCI error code */ - int libcode; /* OCILIB internal error code */ - unsigned int type; /* OCILIB error type */ - ub4 row; /* Error row offset (array DML) */ - otext str[OCI_ERR_MSG_SIZE+1]; /* error message */ -}; - -/* - * Mutex object - * - * Mutexes have their own error handle to avoid conflict using OCIErrorGet() - * from different threads - * - */ - -struct OCI_Mutex -{ - OCIThreadMutex *handle; /* OCI Mutex handle */ - OCIError *err; /* OCI Error handle */ -}; - -/* - * Thread object - * - * Threads have their own error handle to avoid conflict using OCIErrorGet() - * - */ - -struct OCI_Thread -{ - OCIThreadHandle *handle; /* OCI Thread handle */ - OCIThreadId *id; /* OCI Thread ID */ - OCIError *err; /* OCI Error handle */ - void *arg; /* thread routine argument */ - POCI_THREAD proc; /* thread routine */ -}; - -/* - * Thread key object - * - * Thread keys have their own error handle to avoid conflict using OCIErrorGet() - * from different s threads - * - */ - -struct OCI_ThreadKey -{ - OCIThreadKey *handle; /* OCI Thread key handle */ - OCIError *err; /* OCI Error handle */ -}; - -typedef struct OCI_ThreadKey OCI_ThreadKey; - -/* - * OCI_Library : Internal OCILIB library encapsulation. - * - * It's a static, local and unique object that collects all the global variables - * needed by the library - * - */ - -struct OCI_Library -{ - OCI_List *cons; /* list of connection objects */ - OCI_List *pools; /* list of pools objects */ - OCI_List *subs; /* list of subscription objects */ - OCI_List *arrs; /* list of arrays objects */ - OCIError *err; /* OCI error handle */ - OCIEnv *env; /* OCI environment handle */ - POCI_ERROR error_handler; /* user defined error handler */ - unsigned int version_compile; /* OCI version used at compile time */ - unsigned int version_runtime; /* OCI version used at runtime */ - boolean use_lob_ub8; /* use 64 bits integers for lobs ? */ - boolean use_xa; /* is xa enabled */ - boolean use_scrollable_cursors; /* use Oracle 9i fetch API */ - ub4 env_mode; /* default environment mode */ - boolean loaded; /* OCILIB correctly loaded ? */ - boolean nls_utf8; /* is UFT8 enabled for data strings ? */ - unsigned int charset; /* charset type */ - boolean use_wide_char_conv; /* are we on a unix like platform with unicode */ - boolean warnings_on; /* warnings enabled ? */ - OCI_Error lib_err; /* Global error */ - OCI_HashTable *key_map; /* hash table for mapping name/key */ - OCI_ThreadKey *key_errs; /* Thread key to store thread errors */ - unsigned int nb_hndlp; /* number of OCI handles allocated */ - unsigned int nb_descp; /* number of OCI descriptors allocated */ - unsigned int nb_objinst; /* number of OCI objects allocated */ - OCI_HashTable *sql_funcs; /* hash table handle for sql function names */ - POCI_HA_HANDLER ha_handler; /* HA event callback*/ - otext *formats[OCI_FMT_COUNT]; /* string conversion default formats */ - big_uint mem_bytes_oci; /* allocated bytes by OCI client */ - big_uint mem_bytes_lib; /* allocated bytes by OCILIB */ - OCI_Mutex *mem_mutex; /* mutex for memory counters */ - void *usrdata; /* user data */ - boolean env_vars[OCI_VARS_COUNT];/* specific environment variables */ -#ifdef OCI_IMPORT_RUNTIME - LIB_HANDLE lib_handle; /* handle of runtime shared library */ -#endif -}; - -typedef struct OCI_Library OCI_Library; - -/* - * Pool object - * - */ - -struct OCI_Pool -{ - void *handle; /* OCI pool handle */ - void *authp; /* OCI authentication handle */ - OCIError *err; /* OCI context handle */ - otext *name; /* pool name */ - otext *db; /* database */ - otext *user; /* user */ - otext *pwd; /* password */ - ub4 mode; /* session mode */ - ub4 min; /* minimum of objects */ - ub4 max; /* maximum of objects */ - ub4 incr; /* increment step of objects */ - ub4 htype; /* handle type of pool : connection / session */ - ub4 cache_size; /* statement cache size */ -}; - -/* - * Connection object - * - */ - -struct OCI_Connection -{ - otext *db; /* database */ - otext *user; /* user */ - otext *pwd; /* password */ - OCI_List *stmts; /* list of statements */ - OCI_List *trsns; /* list of transactions */ - OCI_List *tinfs; /* list of type info objects */ - OCI_Transaction *trs; /* pointer to current transaction object */ - OCI_Pool *pool; /* pointer to parent pool object */ - OCI_ServerOutput *svopt; /* Pointer to server output object */ - OCIServer *svr; /* OCI server handle */ - OCIError *err; /* OCI context handle */ - OCIEnv *env; /* OCI environment handle */ - OCISession *ses; /* OCI session handle */ - OCISvcCtx *cxt; /* OCI context handle */ - boolean autocom; /* auto commit mode */ - unsigned int nb_files; /* number of OCI_File opened by the connection */ - boolean alloc_handles;/* do new need to allocate OCI handles ? */ - unsigned int mode; /* session mode */ - int cstate; /* connection state */ - void *usrdata; /* user data */ - otext *ver_str; /* string server version*/ - unsigned int ver_num; /* numeric server version */ - OCI_TraceInfo *trace; /* trace information */ - otext *sess_tag; /* session tag */ - POCI_TAF_HANDLER taf_handler; /* failover call back */ - otext *db_name; /* session tag */ - otext *inst_name; /* instance name */ - otext *service_name; /* server service name */ - otext *server_name; /* server name (hostname) */ - otext *domain_name; /* server domain name */ - OCI_Timestamp *inst_startup; /* instance startup timestamp */ - otext *formats[OCI_FMT_COUNT]; /* string conversion default formats */ -}; - -/* - * Transaction object - * - */ - -struct OCI_Transaction -{ - OCI_Connection *con; /* pointer to connection object */ - OCITrans *htr; /* OCI transaction handle */ - unsigned int timeout; /* timeout */ - unsigned int mode; /* transaction mode */ - boolean local; /* is local transaction ? */ - OCI_XID xid; /* global transaction identifier */ -}; - -/* - * Column object - * - */ - -struct OCI_Column -{ - /* OCILIB infos */ - OCI_TypeInfo *typinf; /* user type descriptor */ - ub4 bufsize; /* element size */ - ub2 subtype; /* Ocilib sub type */ - ub2 struct_subtype; /* Ocilib numeric sub type for OCI_GetStruct() :( */ - /* Oracle infos */ - ub2 sqlcode; /* Oracle SQL code */ - ub2 typecode; /* Oracle type code */ - ub2 libcode; /* Internal translated Oracle SQL code */ - ub2 size; /* SQL Size */ - sb2 prec; /* SQL precision 1 (number prec, leading prec) */ - sb2 prec2; /* SQL precision 2 (fractional prec) */ - sb1 scale; /* SQL scale */ - ub1 datatype; /* internal datatype */ - ub1 nullable; /* is nullable */ - ub1 charused; /* is column size expressed in characters */ - otext *name; /* column name */ - ub2 charsize; /* SQL Size in character */ - ub1 csfrm; /* charset form */ - ub1 handletype; /* oracle handle type */ - ub4 props; /* column properties */ - ub4 collation_id; /* collation id */ -}; - -/* - * OCI_Buffer : Internal input/output place holder - * - */ - -struct OCI_Buffer -{ - void *handle; /* OCI handle (bind or define) */ - void **data; /* data / array of data */ - void *lens; /* array of lengths */ - ub4 count; /* number of elements in the buffer */ - int sizelen; /* size of an element in the lens array */ - otext *tmpbuf; /* temporary buffer */ - unsigned int tmpsize; /* temporary buffer size */ - OCIInd* inds; /* indicators */ - void** obj_inds; /* object indicators */ - -}; - -typedef struct OCI_Buffer OCI_Buffer; - -/* - * OCI_Bind object - * - */ - -struct OCI_Bind -{ - OCI_Statement *stmt; /* pointer to statement object */ - void **input; /* input values */ - otext *name; /* name of the bind */ - sb4 size; /* data size */ - ub2 *plrcds; /* PL/SQL tables return codes */ - ub4 nbelem; /* PL/SQL tables number of elements */ - OCI_TypeInfo *typinf; /* for object, collection and ref */ - ub1 type; /* internal datatype */ - ub1 subtype; /* internal subtype */ - ub2 code; /* SQL datatype code */ - boolean is_array; /* is it an array bind ? */ - OCI_Buffer buffer; /* place holder */ - ub2 dynpos; /* index of the bind for dynamic binds */ - ub1 alloc; /* is buffer allocated or mapped to input */ - ub1 csfrm; /* charset form */ - ub1 direction; /* in, out or in/out bind */ - ub1 alloc_mode; /* allocation mode : internal or external */ -} -; - -/* - * OCI_Define : Internal Resultset column data implementation - * - */ - -struct OCI_Define -{ - OCI_Resultset *rs; /* pointer to resultset object */ - void *obj; /* current OCILIB object instance */ - OCI_Column col; /* column object */ - OCI_Buffer buf; /* placeholder */ -}; - -typedef struct OCI_Define OCI_Define; - -/* - * Resultset object - * - */ - -struct OCI_Resultset -{ - OCI_Statement *stmt; /* pointer to statement object */ - OCI_HashTable *map; /* hash table handle for mapping name/index */ - OCI_Define *defs; /* array of define objects */ - ub4 nb_defs; /* number of elements */ - ub4 row_cur; /* actual position in the array of rows */ - ub4 row_abs; /* absolute position in the resultset */ - ub4 row_count; /* number of rows fetched so far */ - ub4 row_fetched; /* rows fetched by last call (scrollable) */ - boolean eof; /* end of resultset reached ? */ - boolean bof; /* beginning of resultset reached ? */ - ub4 fetch_size; /* internal array size */ - sword fetch_status; /* internal fetch status */ -}; - -/* - * OCI_Define : Internal Resultset column data implementation - * - */ - -struct OCI_BatchErrors -{ - OCI_Error *errs; /* sub array of OCILIB errors(array DML) */ - ub4 cur; /* current sub error index (array DML) */ - ub4 count; /* number of errors (array DML) */ -}; - -typedef struct OCI_BatchErrors OCI_BatchErrors; - -/* - * Statement object - * - */ - -struct OCI_Statement -{ - OCIStmt *stmt; /* OCI statement handle */ - ub4 hstate; /* object variable state */ - OCI_Resultset **rsts; /* pointer to resultset list */ - OCI_Statement **stmts; /* pointer to implicit statement resultset list */ - OCI_Connection *con; /* pointer to connection object */ - otext *sql; /* SQL statement */ - otext *sql_id; /* server statement sql id */ - OCI_Bind **ubinds; /* array of user bind objects */ - OCI_Bind **rbinds; /* array of register bind objects */ - OCI_HashTable *map; /* hash table handle for mapping bind name/index */ - ub2 nb_ubinds; /* number of used user binds */ - ub2 nb_rbinds; /* number of used register binds */ - ub2 allocated_ubinds; /* number of allocated user binds */ - ub2 allocated_rbinds; /* number of allocated register binds */ - boolean bind_reuse; /* rebind data allowed ? */ - unsigned int bind_mode; /* type of binding */ - unsigned int bind_alloc_mode; /* type of bind allocation */ - ub4 exec_mode; /* type of execution */ - ub4 fetch_size; /* fetch array size */ - ub4 prefetch_size; /* pre-fetch size */ - ub4 prefetch_mem; /* pre-fetch memory */ - ub4 long_size; /* default size for LONG columns */ - ub1 long_mode; /* LONG datatype handling mode */ - ub1 status; /* statement status */ - ub2 type; /* type of SQL statement */ - ub4 nb_iters; /* current number of iterations for execution */ - ub4 nb_iters_init; /* initial number of iterations for execution */ - ub4 nb_stmt; /* number of implicit statements */ - ub4 nb_rs; /* number of resultsets */ - ub2 cur_rs; /* index of the current resultset */ - ub2 dynidx; /* bind index counter for dynamic exec */ - boolean bind_array; /* has array binds ? */ - OCI_BatchErrors *batch; /* error handling for array DML */ - ub2 err_pos; /* error position in sql statement */ -}; - -/* - * Internal Large object - * - */ - -struct OCI_Lob -{ - OCILobLocator *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - ub4 type; /* type of lob */ - big_uint offset; /* current offset for R/W */ -}; - -/* - * External Large object - * - */ - -struct OCI_File -{ - OCILobLocator *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - otext *dir; /* directory name */ - otext *name; /* file name */ - ub4 type; /* type of file */ - big_uint offset; /* current offset for read */ -}; - -/* - * Long object - * - */ - -struct OCI_Long -{ - OCI_Statement *stmt; /* pointer to statement object */ - ub4 hstate; /* object variable state */ - OCI_Define *def; /* pointer to resultset define object */ - ub4 size; /* size of the buffer read / written */ - unsigned int type; /* type of long */ - ub4 offset; /* current offset for R/W */ - ub4 piecesize; /* size of current fetched piece */ - ub4 maxsize; /* size to R/W */ - ub1 *buffer; /* fetched buffer */ -}; - -/* -* Number object -* -*/ - -struct OCI_Number -{ - OCINumber *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCIError *err; /* OCI error handle */ - OCIEnv *env; /* OCI environment handle */ -}; - -/* - * Date object - * - */ - -struct OCI_Date -{ - OCIDate *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCIError *err; /* OCI context handle */ - OCIEnv *env; /* OCI environment handle */ - ub4 allocated; /* is handle allocated ? */ -}; - -/* - * Timestamp object - * - */ - -struct OCI_Timestamp -{ -#if OCI_VERSION_COMPILE >= OCI_9_0 - OCIDateTime *handle; /* OCI handle */ -#else - void *handle; /* fake handle for alignment */ -#endif - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCIError *err; /* OCI context handle */ - OCIEnv *env; /* OCI environment handle */ - ub4 type; /* sub type */ -}; - -/* - * Interval object - * - */ - -struct OCI_Interval -{ -#if OCI_VERSION_COMPILE >= OCI_9_0 - OCIInterval *handle; /* OCI handle */ -#else - void *handle; /* fake handle for alignment */ -#endif - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCIError *err; /* OCI context handle */ - OCIEnv *env; /* OCI environment handle */ - ub4 type; /* sub type */ -}; - -/* - * Oracle Named type object - * - */ - -struct OCI_Object -{ - void *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCI_TypeInfo *typinf; /* pointer to type info object */ - void **objs; /* array of OCILIB sub objects */ - OCIObjectLifetime type; /* object type */ - sb2 *tab_ind; /* indicators for root instance */ - ub2 idx_ind; /* instance indicator offset / indicator table */ - otext **tmpbufs; /* temporary buffer per column */ - unsigned int *tmpsizes; /* temporary buffer size per column */ -}; - -/* - * Oracle Collection Item object - * - */ - -struct OCI_Elem -{ - void *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - void *obj; /* OCILIB sub object */ - otext *tmpbuf; /* temporary buffer */ - unsigned int tmpsize; /* temporary buffer size */ - boolean init; /* underlying object has been initialized ? */ - OCI_TypeInfo *typinf; /* object type information */ - OCIInd *pind; /* indicator pointer */ - OCIInd ind; /* internal temporary data state indicator */ - uword alloc; /* is handle locally allocated */ -}; - -/* - * Oracle Collection object - * - */ - -struct OCI_Coll -{ - OCIColl *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCI_TypeInfo *typinf; /* pointer to type info object */ - OCI_Elem *elem; /* item object */ -}; - -/* - * Oracle Iterator object - * - */ - -struct OCI_Iter -{ - OCIIter *handle; /* OCI handle */ - OCI_Coll *coll; /* pointer to connection object */ - OCI_Elem *elem; /* item object */ - boolean eoc; /* end of collection */ - boolean boc; /* beginning of collection */ - boolean dirty; /* indicate if elem is dirty, e.g. not fetched yet */ -}; - -/* - * Oracle REF object - * - */ - -struct OCI_Ref -{ - OCIRef *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* pointer to connection object */ - OCI_TypeInfo *typinf; /* pointer to type info object */ - OCI_Object *obj; /* Pinned object */ - boolean pinned; /* is the reference pinned */ -}; - -/* - * Type info object - * - */ - -struct OCI_TypeInfo -{ - OCI_Connection *con; /* pointer to connection object */ - otext *name; /* name of the type info object */ - otext *schema; /* owner of the type info object */ - unsigned int type; /* type of type info handle */ - OCIType *tdo; /* datatype object type */ - ub2 typecode; /* Oracle type code */ - ub2 colcode; /* Oracle collection code */ - OCI_Column *cols; /* array of column datatype info */ - ub2 nb_cols; /* number of columns */ - ub2 refcount; /* reference counter */ - int *offsets; /* cached offsets */ - size_t struct_size; /* cached structure size */ - size_t align; /* cached structure alignment */ - OCI_TypeInfo *parent_type; /* parent super type for derived type */ - ub1 is_final; /* is is a virtual type that can be inherited ? */ -}; - -/* - * OCI_DirPathColumn : Internal Direct Path column object - * - */ - -struct OCI_DirPathColumn -{ - ub4 format_size; /* size of the column format */ - otext *format; /* date or numeric format */ - ub2 type; /* column type */ - ub2 sqlcode; /* sql type */ - ub4 *lens; /* array of lengths */ - ub2 bufsize; /* buffer size */ - ub2 index; /* ref index in the type info columns list */ - ub1 *data; /* array of data */ - ub1 *flags; /* array of row flags */ - ub2 maxsize; /* input max size */ -}; - -typedef struct OCI_DirPathColumn OCI_DirPathColumn; - -/* - * Oracle Direct Path column object - * - */ - -struct OCI_DirPath -{ - OCI_Connection *con; /* pointer to connection object */ - OCI_TypeInfo *typinf; /* type info about table to load */ - OCIDirPathCtx *ctx; /* OCI DP context handle */ - OCIDirPathColArray *arr; /* OCI DP column array handle */ - OCIDirPathStream *strm; /* OCI DP stream handle */ - OCI_DirPathColumn *cols; /* array of column info */ - ub4 nb_processed; /* number of row processed at last call */ - ub4 nb_loaded; /* number of row loaded so far */ - ub4 nb_converted; /* number of row converted so far */ - ub4 nb_entries; /* number of rows currently set */ - ub4 status; /* internal status */ - ub4 nb_cur; /* current number of row to load per stream */ - ub2 nb_cols; /* number of columns to load */ - ub2 nb_rows; /* maximum number of row to load per stream */ - ub2 cvt_mode; /* conversion mode */ - ub2 idx_err_col; /* index of current erred row */ - ub4 idx_err_row; /* index of current erred column */ - ub4 nb_err; /* number of conversion errors since the last load */ - unsigned int res_conv; /* status of the last conversion */ - unsigned int res_load; /* status of the last load */ - ub4 *err_rows; /* array of err rows index */ - ub2 *err_cols; /* array of err col index */ -}; - -/* - * Oracle Event object - * - */ - -struct OCI_Event -{ - OCI_Subscription *sub; /* OCILIB subscription handle */ - unsigned int type; /* event type */ - ub4 op; /* event object operation */ - otext *objname; /* altered object name */ - unsigned int objname_size; /* altered object name size */ - otext *rowid; /* altered row id */ - unsigned int rowid_size; /* altered row id size */ - otext *dbname; /* database name */ - unsigned int dbname_size; /* database name size */ -}; - -/* - * Oracle Notification object - * - */ - -struct OCI_Subscription -{ - OCI_Connection *con; /* OCILIB connection handle */ - OCISubscription *subhp; /* OCI subscription handle */ - OCIEnv *env; /* OCI environment handle */ - OCIError *err; /* OCI error handle */ - otext *name; /* notification name */ - unsigned int type; /* notification type */ - POCI_NOTIFY handler; /* user callback */ - ub4 timeout; /* notification timeout */ - ub4 port; /* port to use */ - otext *saved_db; /* database for reconnection if needed */ - otext *saved_user; /* user for reconnection if needed */ - otext *saved_pwd; /* password for reconnection if needed */ - OCI_Event event; /* event object for user callback */ -}; - -/* - * Oracle A/Q Agent - * - */ - -struct OCI_Agent -{ - OCIAQAgent *handle; /* OCI agent handle */ - ub4 hstate; /* object variable state */ - OCI_Connection *con; /* OCILIB connection handle */ - otext *address; /* agent address */ - otext *name; /* agent name */ -}; - -/* - * Oracle A/Q message - * - */ - -struct OCI_Msg -{ - OCI_TypeInfo *typinf; /* pointer to type info object */ - OCIAQMsgProperties *proph; /* OCI message properties handle */ - void *payload; /* message payload (object handle or raw handle) */ - OCIRaw *id; /* message identifier */ - OCI_Date *date; /* enqueue date */ - otext *correlation; /* correlation string */ - otext *except_queue; /* exception queue name */ - OCI_Agent *sender; /* sender */ - OCI_Object *obj; /* OCILIB object handle for object payloads */ - OCIInd ind; /* message payload indicator pointer */ -}; - -/* - * Oracle A/Q enqueue - * - */ - -struct OCI_Enqueue -{ - OCI_TypeInfo *typinf; /* pointer to type info object */ - OCIAQEnqOptions *opth; /* OCI enqueue options handle */ - otext *name; /* queue name */ -}; - -/* - * Oracle A/Q Dequeue - * - */ - -struct OCI_Dequeue -{ - OCI_TypeInfo *typinf; /* pointer to type info object */ - OCIAQDeqOptions *opth; /* OCI dequeue options handle */ - otext *name; /* queue name */ - otext *pattern; /* queue name */ - otext *consumer; /* consumer name */ - OCI_Msg *msg; /* message retrieved from queue */ - OCIAQAgent **agent_list; /* array of agents objects */ - ub4 agent_count; /* number of agents objects */ - OCI_Agent *agent; /* pointer to agent object for listen call */ - POCI_NOTIFY_AQ callback; /* user callback */ - OCISubscription *subhp; /* AQ subscription for async dequeueing */ -}; - -/* - * OCILIB array - * - */ - -struct OCI_Array -{ - OCIError *err; /* OCI context handle */ - OCIEnv *env; /* OCI environment handle */ - OCI_Connection *con; /* Connection object for type dependent on connections */ - unsigned int elem_type; /* array element type */ - unsigned int elem_subtype; /* array element subtype */ - unsigned int elem_size; /* array element handle size */ - unsigned int nb_elem; /* array size of number of elements */ - unsigned int struct_size; /* array element size */ - unsigned int handle_type; /* array element OCI handle type */ - void ** tab_obj; /* array of pointers to OCILIB objects */ - void * mem_handle; /* array OCI handles */ - void * mem_struct; /* array of OCILIB objects structures */ - -}; - -typedef struct OCI_Array OCI_Array; - -/* - * Hash table object - * - */ - -struct OCI_HashTable -{ - OCI_HashEntry **items; /* array of slots */ - unsigned int size; /* size of the slots array */ - unsigned int count; /* number of used slots */ - unsigned int type; /* type of data */ -}; - -/* - * OCI_Datatype : fake dummy structure for casting object with - * handles for more compact code - * - */ - -struct OCI_Datatype -{ - void *handle; /* OCI handle */ - ub4 hstate; /* object variable state */ -}; - -typedef struct OCI_Datatype OCI_Datatype; - -/* - * OCI_SQLCmdInfo : Oracle SQL commands code and verbs - * - */ - -struct OCI_SQLCmdInfo -{ - unsigned int code; /* SQL command code */ - const otext *verb; /* SQL command verb */ -}; - -typedef struct OCI_SQLCmdInfo OCI_SQLCmdInfo; - -/* OCI context */ - -struct OCI_Context -{ - OCI_Connection *lib_con; - OCI_Statement *lib_stmt; - OCIError *oci_err; - OCI_Error *call_err; - boolean call_status; -}; - -typedef struct OCI_Context OCI_Context; - -/* static and unique OCI_Library object */ - -extern OCI_Library OCILib; -extern const OCI_SQLCmdInfo SQLCmds[]; - -/* Start of Experimental section containing some Oracle opaque structure definitions - - These partial structures are "guessed" from memory analysis in order to - find workarounds to bugs that Oracle does not / refuses to fix. - - These structures are not used in OCILIB unless specific environment variables are set -*/ - - -/* The following structures contain definitions for a structure matching an Oracle Parameter - retrieved from a statement handle when describing columns from resultsets. - They were added in order to implement a workaround for the unfixed Oracle Bug 9838993 -*/ - -struct OCIParamStructColumnInfo -{ - unsigned char unknown_fields[6 * sizeof(int) + 2 * sizeof(void*)]; - unsigned char attributes[sizeof(void *)]; - char *name; -}; - -typedef struct OCIParamStructColumnInfo OCIParamStructColumnInfo; - -struct OCIParamStruct -{ - unsigned char unknown_fields[3 * sizeof(void*)]; - - OCIParamStructColumnInfo *column_info; -}; - -typedef struct OCIParamStruct OCIParamStruct; - -/* End of Experimental section */ - -#endif /* OCILIB_OCILIB_TYPES_H_INCLUDED */ - +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OCILIB_TYPES_H_INCLUDED +#define OCILIB_TYPES_H_INCLUDED + +#include "ocilib_types.h" + +#include "defs.h" + +/* ********************************************************************************************* * + * PRIVATE TYPES + * ********************************************************************************************* */ + +/* +* OCI_MemoryBlock : Internal block of Memory. +* +*/ + +struct OCI_MemoryBlock +{ + int type; /* type of allocated data */ + unsigned int size; /* allocated memory size*/ +}; + +typedef struct OCI_MemoryBlock OCI_MemoryBlock; + +/* + * OCI_Item : Internal list entry. + * + * The library needs to manage internal list of objects in order to be able to + * free them if the application does not. + * + * @note + * Internal lists are using mutexes for resource locking in multithreaded + * environments + * + */ + +struct OCI_Item +{ + void *data; /* pointer to external data */ + struct OCI_Item *next; /* next element in list */ +}; + +typedef struct OCI_Item OCI_Item; + +/* + * OCI_List : Internal list object. + * + * The OCI_List object is used to maintain a collection of handles allocated + * by user programs. + * + * Those handles are freed when the collection owner is destroyed. + * So, we make sure that if OCI_Cleanup() is called, all allocated handles will + * be destroyed even if the program does not free them. + * + */ + +struct OCI_List +{ + OCI_Item *head; /* pointer to first item */ + OCI_Mutex *mutex; /* mutex handle */ + ub4 count; /* number of elements in list */ + int type; /* type of list item */ +}; + +typedef struct OCI_List OCI_List; + +/* + * Server output object used to retrieve server dbms.output buffers + * + */ + +struct OCI_ServerOutput +{ + ub1 *arrbuf; /* array buffer */ + unsigned int arrsize; /* array size */ + unsigned int cursize; /* number of filled items in the array */ + unsigned int curpos; /* current position in the array */ + unsigned int lnsize; /* line size */ + OCI_Statement *stmt; /* pointer to statement object (dbms_output calls) */ +}; + +typedef struct OCI_ServerOutput OCI_ServerOutput; + +/* + * Connection trace information + * + */ + +struct OCI_TraceInfo +{ + otext identifier[OCI_SIZE_TRACE_ID+1]; + otext module[OCI_SIZE_TRACE_MODULE+1]; + otext action[OCI_SIZE_TRACE_ACTION+1]; + otext info[OCI_SIZE_TRACE_INFO+1]; + otext operation[OCI_SIZE_TRACE_OPERATION + 1]; + +}; + +typedef struct OCI_TraceInfo OCI_TraceInfo; + +/* ********************************************************************************************* * + * PUBLIC TYPES + * ********************************************************************************************* */ + +struct OCI_Error +{ + boolean active; /* to avoid recursive exceptions */ + void *source_ptr; /* pointer to source ptr */ + unsigned int source_type; /* source type */ + int code; /* Oracle OCI or OCILIB internal error code */ + unsigned int type; /* OCILIB error type */ + ub4 row; /* Error row offset (array DML) */ + otext *location; /* location (method) */ + otext *message; /* error message */ + unsigned int location_len; /* length of error message */ + unsigned int message_len; /* length of error location */ +}; + +/* + * Mutex object + * + * Mutexes have their own error handle to avoid conflict using OCIErrorGet() + * from different threads + * + */ + +struct OCI_Mutex +{ + OCIThreadMutex *handle; /* OCI Mutex handle */ + OCIError *err; /* OCI Error handle */ +}; + +/* + * Thread object + * + * Threads have their own error handle to avoid conflict using OCIErrorGet() + * + */ + +struct OCI_Thread +{ + OCIThreadHandle *handle; /* OCI Thread handle */ + OCIThreadId *id; /* OCI Thread ID */ + OCIError *err; /* OCI Error handle */ + void *arg; /* thread routine argument */ + POCI_THREAD proc; /* thread routine */ +}; + +/* + * Thread key object + * + * Thread keys have their own error handle to avoid conflict using OCIErrorGet() + * from different s threads + * + */ + +struct OCI_ThreadKey +{ + OCIThreadKey *handle; /* OCI Thread key handle */ + OCIError *err; /* OCI Error handle */ +}; + +typedef struct OCI_ThreadKey OCI_ThreadKey; + +/* + * OCI_Environment : Internal OCILIB library encapsulation. + * + * It's a static, local and unique object that collects all the global variables + * needed by the library + * + */ + +struct OCI_Environment +{ + OCI_List *cons; /* list of connection objects */ + OCI_List *pools; /* list of pools objects */ + OCI_List *subs; /* list of subscription objects */ + OCI_List *arrs; /* list of arrays objects */ + OCIError *err; /* OCI error handle */ + OCIEnv *env; /* OCI environment handle */ + POCI_ERROR error_handler; /* user defined error handler */ + unsigned int version_compile; /* OCI version used at compile time */ + unsigned int version_runtime; /* OCI version used at runtime */ + boolean use_lob_ub8; /* use 64 bits integers for lobs ? */ + boolean use_xa; /* is xa enabled */ + boolean use_scrollable_cursors; /* use Oracle 9i fetch API */ + ub4 env_mode; /* default environment mode */ + boolean loaded; /* OCILIB correctly loaded ? */ + boolean nls_utf8; /* is UFT8 enabled for data strings ? */ + unsigned int charset; /* charset type */ + boolean use_wide_char_conv; /* are we on a unix like platform with unicode */ + boolean warnings_on; /* warnings enabled ? */ + OCI_Error *lib_err; /* Global error */ + OCI_HashTable *key_map; /* hash table for mapping name/key */ + OCI_ThreadKey *key_errs; /* Thread key to store thread errors */ + unsigned int nb_hndlp; /* number of OCI handles allocated */ + unsigned int nb_descp; /* number of OCI descriptors allocated */ + unsigned int nb_objinst; /* number of OCI objects allocated */ + OCI_HashTable *sql_funcs; /* hash table handle for sql function names */ + POCI_HA_HANDLER ha_handler; /* HA event callback*/ + otext *formats[OCI_FMT_COUNT]; /* string conversion default formats */ + big_uint mem_bytes_oci; /* allocated bytes by OCI client */ + big_uint mem_bytes_lib; /* allocated bytes by OCILIB */ + OCI_Mutex *mem_mutex; /* mutex for memory counters */ + void *usrdata; /* user data */ + boolean env_vars[OCI_VARS_COUNT]; /* specific environment variables */ +#ifdef OCI_IMPORT_RUNTIME + LIB_HANDLE lib_handle; /* handle of runtime shared library */ +#endif +}; + +typedef struct OCI_Environment OCI_Environment; + +/* + * Pool object + * + */ + +struct OCI_Pool +{ + void *handle; /* OCI pool handle */ + void *authp; /* OCI authentication handle */ + OCIError *err; /* OCI context handle */ + otext *name; /* pool name */ + otext *db; /* database */ + otext *user; /* user */ + otext *pwd; /* password */ + ub4 mode; /* session mode */ + ub4 min; /* minimum of objects */ + ub4 max; /* maximum of objects */ + ub4 incr; /* increment step of objects */ + ub4 htype; /* handle type of pool : connection / session */ + ub4 cache_size; /* statement cache size */ +}; + +/* + * Connection object + * + */ + +struct OCI_Connection +{ + otext *db; /* database */ + otext *user; /* user */ + otext *pwd; /* password */ + OCI_List *stmts; /* list of statements */ + OCI_List *trsns; /* list of transactions */ + OCI_List *tinfs; /* list of type info objects */ + OCI_Transaction *trs; /* pointer to current transaction object */ + OCI_Pool *pool; /* pointer to parent pool object */ + OCI_ServerOutput *svopt; /* Pointer to server output object */ + OCIServer *svr; /* OCI server handle */ + OCIError *err; /* OCI context handle */ + OCIEnv *env; /* OCI environment handle */ + OCISession *ses; /* OCI session handle */ + OCISvcCtx *cxt; /* OCI context handle */ + boolean autocom; /* auto commit mode */ + unsigned int nb_files; /* number of OCI_File opened by the connection */ + boolean alloc_handles;/* do new need to allocate OCI handles ? */ + unsigned int mode; /* session mode */ + int cstate; /* connection state */ + void *usrdata; /* user data */ + otext *ver_str; /* string server version*/ + unsigned int ver_num; /* numeric server version */ + OCI_TraceInfo *trace; /* trace information */ + otext *sess_tag; /* session tag */ + POCI_TAF_HANDLER taf_handler; /* failover call back */ + otext *db_name; /* session tag */ + otext *inst_name; /* instance name */ + otext *service_name; /* server service name */ + otext *server_name; /* server name (hostname) */ + otext *domain_name; /* server domain name */ + OCI_Timestamp *inst_startup; /* instance startup timestamp */ + otext *formats[OCI_FMT_COUNT]; /* string conversion default formats */ +}; + +/* + * Transaction object + * + */ + +struct OCI_Transaction +{ + OCI_Connection *con; /* pointer to connection object */ + OCITrans *htr; /* OCI transaction handle */ + unsigned int timeout; /* timeout */ + unsigned int mode; /* transaction mode */ + boolean local; /* is local transaction ? */ + OCI_XID xid; /* global transaction identifier */ +}; + +/* + * Column object + * + */ + +struct OCI_Column +{ + /* OCILIB infos */ + OCI_TypeInfo *typinf; /* user type descriptor */ + ub4 bufsize; /* element size */ + ub2 subtype; /* Ocilib sub type */ + ub2 struct_subtype; /* Ocilib numeric sub type for OCI_GetStruct() :( */ + /* Oracle infos */ + ub2 sqlcode; /* Oracle SQL code */ + ub2 typecode; /* Oracle type code */ + ub2 libcode; /* Internal translated Oracle SQL code */ + ub2 size; /* SQL Size */ + sb2 prec; /* SQL precision 1 (number prec, leading prec) */ + sb2 prec2; /* SQL precision 2 (fractional prec) */ + sb1 scale; /* SQL scale */ + ub1 datatype; /* internal datatype */ + ub1 nullable; /* is nullable */ + ub1 charused; /* is column size expressed in characters */ + otext *name; /* column name */ + ub2 charsize; /* SQL Size in character */ + ub1 csfrm; /* charset form */ + ub1 handletype; /* oracle handle type */ + ub4 props; /* column properties */ + ub4 collation_id; /* collation id */ +}; + +/* + * OCI_Buffer : Internal input/output place holder + * + */ + +struct OCI_Buffer +{ + void *handle; /* OCI handle (bind or define) */ + void **data; /* data / array of data */ + void *lens; /* array of lengths */ + ub4 count; /* number of elements in the buffer */ + int sizelen; /* size of an element in the lens array */ + otext *tmpbuf; /* temporary buffer */ + unsigned int tmpsize; /* temporary buffer size */ + OCIInd * inds; /* indicators */ + void ** obj_inds; /* object indicators */ + +}; + +typedef struct OCI_Buffer OCI_Buffer; + +/* + * OCI_Bind object + * + */ + +struct OCI_Bind +{ + OCI_Statement *stmt; /* pointer to statement object */ + void **input; /* input values */ + otext *name; /* name of the bind */ + sb4 size; /* data size */ + ub2 *plrcds; /* PL/SQL tables return codes */ + ub4 nbelem; /* PL/SQL tables number of elements */ + OCI_TypeInfo *typinf; /* for object, collection and ref */ + ub1 type; /* internal datatype */ + ub1 subtype; /* internal subtype */ + ub2 code; /* SQL datatype code */ + boolean is_array; /* is it an array bind ? */ + OCI_Buffer buffer; /* place holder */ + ub2 dynpos; /* index of the bind for dynamic binds */ + ub1 alloc; /* is buffer allocated or mapped to input */ + ub1 csfrm; /* charset form */ + ub1 direction; /* in, out or in/out bind */ + ub1 alloc_mode; /* allocation mode : internal or external */ +} +; + +/* + * OCI_Define : Internal Resultset column data implementation + * + */ + +struct OCI_Define +{ + OCI_Resultset *rs; /* pointer to resultset object */ + void *obj; /* current OCILIB object instance */ + OCI_Column col; /* column object */ + OCI_Buffer buf; /* placeholder */ +}; + +typedef struct OCI_Define OCI_Define; + +/* + * Resultset object + * + */ + +struct OCI_Resultset +{ + OCI_Statement *stmt; /* pointer to statement object */ + OCI_HashTable *map; /* hash table handle for mapping name/index */ + OCI_Define *defs; /* array of define objects */ + ub4 nb_defs; /* number of elements */ + ub4 row_cur; /* actual position in the array of rows */ + ub4 row_abs; /* absolute position in the resultset */ + ub4 row_count; /* number of rows fetched so far */ + ub4 row_fetched; /* rows fetched by last call (scrollable) */ + boolean eof; /* end of resultset reached ? */ + boolean bof; /* beginning of resultset reached ? */ + ub4 fetch_size; /* internal array size */ + sword fetch_status; /* internal fetch status */ +}; + +/* + * OCI_Define : Internal Resultset column data implementation + * + */ + +struct OCI_BatchErrors +{ + OCI_Error *errs; /* sub array of OCILIB errors(array DML) */ + ub4 cur; /* current sub error index (array DML) */ + ub4 count; /* number of errors (array DML) */ +}; + +typedef struct OCI_BatchErrors OCI_BatchErrors; + +/* + * Statement object + * + */ + +struct OCI_Statement +{ + OCIStmt *stmt; /* OCI statement handle */ + ub4 hstate; /* object variable state */ + OCI_Resultset **rsts; /* pointer to resultset list */ + OCI_Statement **stmts; /* pointer to implicit statement resultset list */ + OCI_Connection *con; /* pointer to connection object */ + otext *sql; /* SQL statement */ + otext *sql_id; /* server statement sql id */ + OCI_Bind **ubinds; /* array of user bind objects */ + OCI_Bind **rbinds; /* array of register bind objects */ + OCI_HashTable *map; /* hash table handle for mapping bind name/index */ + ub2 nb_ubinds; /* number of used user binds */ + ub2 nb_rbinds; /* number of used register binds */ + ub2 allocated_ubinds; /* number of allocated user binds */ + ub2 allocated_rbinds; /* number of allocated register binds */ + boolean bind_reuse; /* rebind data allowed ? */ + unsigned int bind_mode; /* type of binding */ + unsigned int bind_alloc_mode; /* type of bind allocation */ + ub4 exec_mode; /* type of execution */ + ub4 fetch_size; /* fetch array size */ + ub4 prefetch_size; /* pre-fetch size */ + ub4 prefetch_mem; /* pre-fetch memory */ + ub4 long_size; /* default size for LONG columns */ + ub1 long_mode; /* LONG datatype handling mode */ + ub1 status; /* statement status */ + ub2 type; /* type of SQL statement */ + ub4 nb_iters; /* current number of iterations for execution */ + ub4 nb_iters_init; /* initial number of iterations for execution */ + ub4 nb_stmt; /* number of implicit statements */ + ub4 nb_rs; /* number of resultsets */ + ub2 cur_rs; /* index of the current resultset */ + ub2 dynidx; /* bind index counter for dynamic exec */ + boolean bind_array; /* has array binds ? */ + OCI_BatchErrors *batch; /* error handling for array DML */ + ub2 err_pos; /* error position in sql statement */ +}; + +/* + * Internal Large object + * + */ + +struct OCI_Lob +{ + OCILobLocator *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + ub4 type; /* type of lob */ + big_uint offset; /* current offset for R/W */ +}; + +/* + * External Large object + * + */ + +struct OCI_File +{ + OCILobLocator *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + otext *dir; /* directory name */ + otext *name; /* file name */ + ub4 type; /* type of file */ + big_uint offset; /* current offset for read */ +}; + +/* + * Long object + * + */ + +struct OCI_Long +{ + OCI_Statement *stmt; /* pointer to statement object */ + ub4 hstate; /* object variable state */ + OCI_Define *def; /* pointer to resultset define object */ + ub4 size; /* size of the buffer read / written */ + unsigned int type; /* type of long */ + ub4 offset; /* current offset for R/W */ + ub4 piecesize; /* size of current fetched piece */ + ub4 maxsize; /* size to R/W */ + ub1 *buffer; /* fetched buffer */ +}; + +/* +* Number object +* +*/ + +struct OCI_Number +{ + OCINumber *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCIError *err; /* OCI error handle */ + OCIEnv *env; /* OCI environment handle */ +}; + +/* + * Date object + * + */ + +struct OCI_Date +{ + OCIDate *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCIError *err; /* OCI context handle */ + OCIEnv *env; /* OCI environment handle */ + ub4 allocated; /* is handle allocated ? */ +}; + +/* + * Timestamp object + * + */ + +struct OCI_Timestamp +{ +#if OCI_VERSION_COMPILE >= OCI_9_0 + OCIDateTime *handle; /* OCI handle */ +#else + void *handle; /* fake handle for alignment */ +#endif + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCIError *err; /* OCI context handle */ + OCIEnv *env; /* OCI environment handle */ + ub4 type; /* sub type */ +}; + +/* + * Interval object + * + */ + +struct OCI_Interval +{ +#if OCI_VERSION_COMPILE >= OCI_9_0 + OCIInterval *handle; /* OCI handle */ +#else + void *handle; /* fake handle for alignment */ +#endif + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCIError *err; /* OCI context handle */ + OCIEnv *env; /* OCI environment handle */ + ub4 type; /* sub type */ +}; + +/* + * Oracle Named type object + * + */ + +struct OCI_Object +{ + void *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCI_TypeInfo *typinf; /* pointer to type info object */ + void **objs; /* array of OCILIB sub objects */ + OCIObjectLifetime type; /* object type */ + sb2 *tab_ind; /* indicators for root instance */ + ub2 idx_ind; /* instance indicator offset / indicator table */ + otext **tmpbufs; /* temporary buffer per column */ + unsigned int *tmpsizes; /* temporary buffer size per column */ +}; + +/* + * Oracle Collection Item object + * + */ + +struct OCI_Elem +{ + void *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + void *obj; /* OCILIB sub object */ + otext *tmpbuf; /* temporary buffer */ + unsigned int tmpsize; /* temporary buffer size */ + boolean init; /* underlying object has been initialized ? */ + OCI_TypeInfo *typinf; /* object type information */ + OCIInd *pind; /* indicator pointer */ + OCIInd ind; /* internal temporary data state indicator */ + uword alloc; /* is handle locally allocated */ +}; + +/* + * Oracle Collection object + * + */ + +struct OCI_Coll +{ + OCIColl *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCI_TypeInfo *typinf; /* pointer to type info object */ + OCI_Elem *elem; /* item object */ +}; + +/* + * Oracle Iterator object + * + */ + +struct OCI_Iter +{ + OCIIter *handle; /* OCI handle */ + OCI_Coll *coll; /* pointer to connection object */ + OCI_Elem *elem; /* item object */ + boolean eoc; /* end of collection */ + boolean boc; /* beginning of collection */ + boolean dirty; /* indicate if elem is dirty, e.g. not fetched yet */ +}; + +/* + * Oracle REF object + * + */ + +struct OCI_Ref +{ + OCIRef *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* pointer to connection object */ + OCI_TypeInfo *typinf; /* pointer to type info object */ + OCI_Object *obj; /* Pinned object */ + boolean pinned; /* is the reference pinned */ +}; + +/* + * Type info object + * + */ + +struct OCI_TypeInfo +{ + OCI_Connection *con; /* pointer to connection object */ + otext *name; /* name of the type info object */ + otext *schema; /* owner of the type info object */ + unsigned int type; /* type of type info handle */ + OCIType *tdo; /* datatype object type */ + ub2 typecode; /* Oracle type code */ + ub2 colcode; /* Oracle collection code */ + OCI_Column *cols; /* array of column datatype info */ + ub2 nb_cols; /* number of columns */ + ub2 refcount; /* reference counter */ + int *offsets; /* cached offsets */ + size_t struct_size; /* cached structure size */ + size_t align; /* cached structure alignment */ + OCI_TypeInfo *parent_type; /* parent super type for derived type */ + ub1 is_final; /* is is a virtual type that can be inherited ? */ +}; + +/* + * OCI_DirPathColumn : Internal Direct Path column object + * + */ + +struct OCI_DirPathColumn +{ + ub4 format_size; /* size of the column format */ + otext *format; /* date or numeric format */ + ub2 type; /* column type */ + ub2 sqlcode; /* sql type */ + ub4 *lens; /* array of lengths */ + ub2 bufsize; /* buffer size */ + ub2 index; /* ref index in the type info columns list */ + ub1 *data; /* array of data */ + ub1 *flags; /* array of row flags */ + ub2 maxsize; /* input max size */ +}; + +typedef struct OCI_DirPathColumn OCI_DirPathColumn; + +/* + * Oracle Direct Path column object + * + */ + +struct OCI_DirPath +{ + OCI_Connection *con; /* pointer to connection object */ + OCI_TypeInfo *typinf; /* type info about table to load */ + OCIDirPathCtx *ctx; /* OCI DP context handle */ + OCIDirPathColArray *arr; /* OCI DP column array handle */ + OCIDirPathStream *strm; /* OCI DP stream handle */ + OCI_DirPathColumn *cols; /* array of column info */ + ub4 nb_processed; /* number of row processed at last call */ + ub4 nb_loaded; /* number of row loaded so far */ + ub4 nb_converted; /* number of row converted so far */ + ub4 nb_entries; /* number of rows currently set */ + ub4 status; /* internal status */ + ub4 nb_cur; /* current number of row to load per stream */ + ub2 nb_cols; /* number of columns to load */ + ub2 nb_rows; /* maximum number of row to load per stream */ + ub2 cvt_mode; /* conversion mode */ + ub2 idx_err_col; /* index of current erred row */ + ub4 idx_err_row; /* index of current erred column */ + ub4 nb_err; /* number of conversion errors since the last load */ + unsigned int res_conv; /* status of the last conversion */ + unsigned int res_load; /* status of the last load */ + ub4 *err_rows; /* array of err rows index */ + ub2 *err_cols; /* array of err col index */ +}; + +/* + * Oracle Event object + * + */ + +struct OCI_Event +{ + OCI_Subscription *sub; /* OCILIB subscription handle */ + unsigned int type; /* event type */ + ub4 op; /* event object operation */ + otext *objname; /* altered object name */ + unsigned int objname_size; /* altered object name size */ + otext *rowid; /* altered row id */ + unsigned int rowid_size; /* altered row id size */ + otext *dbname; /* database name */ + unsigned int dbname_size; /* database name size */ +}; + +/* + * Oracle Notification object + * + */ + +struct OCI_Subscription +{ + OCI_Connection *con; /* OCILIB connection handle */ + OCISubscription *subhp; /* OCI subscription handle */ + OCIEnv *env; /* OCI environment handle */ + OCIError *err; /* OCI error handle */ + otext *name; /* notification name */ + unsigned int type; /* notification type */ + POCI_NOTIFY handler; /* user callback */ + ub4 timeout; /* notification timeout */ + ub4 port; /* port to use */ + otext *saved_db; /* database for reconnection if needed */ + otext *saved_user; /* user for reconnection if needed */ + otext *saved_pwd; /* password for reconnection if needed */ + OCI_Event event; /* event object for user callback */ +}; + +/* + * Oracle A/Q Agent + * + */ + +struct OCI_Agent +{ + OCIAQAgent *handle; /* OCI agent handle */ + ub4 hstate; /* object variable state */ + OCI_Connection *con; /* OCILIB connection handle */ + otext *address; /* agent address */ + otext *name; /* agent name */ +}; + +/* + * Oracle A/Q message + * + */ + +struct OCI_Msg +{ + OCI_TypeInfo *typinf; /* pointer to type info object */ + OCIAQMsgProperties *proph; /* OCI message properties handle */ + void *payload; /* message payload (object handle or raw handle) */ + OCIRaw *id; /* message identifier */ + OCI_Date *date; /* enqueue date */ + otext *correlation; /* correlation string */ + otext *except_queue; /* exception queue name */ + OCI_Agent *sender; /* sender */ + OCI_Object *obj; /* OCILIB object handle for object payloads */ + OCIInd ind; /* message payload indicator pointer */ +}; + +/* + * Oracle A/Q enqueue + * + */ + +struct OCI_Enqueue +{ + OCI_TypeInfo *typinf; /* pointer to type info object */ + OCIAQEnqOptions *opth; /* OCI enqueue options handle */ + otext *name; /* queue name */ +}; + +/* + * Oracle A/Q Dequeue + * + */ + +struct OCI_Dequeue +{ + OCI_TypeInfo *typinf; /* pointer to type info object */ + OCIAQDeqOptions *opth; /* OCI dequeue options handle */ + otext *name; /* queue name */ + otext *pattern; /* queue name */ + otext *consumer; /* consumer name */ + OCI_Msg *msg; /* message retrieved from queue */ + OCIAQAgent **agent_list; /* array of agents objects */ + ub4 agent_count; /* number of agents objects */ + OCI_Agent *agent; /* pointer to agent object for listen call */ + POCI_NOTIFY_AQ callback; /* user callback */ + OCISubscription *subhp; /* AQ subscription for async dequeueing */ +}; + +/* + * OCILIB array + * + */ + +struct OCI_Array +{ + OCIError *err; /* OCI context handle */ + OCIEnv *env; /* OCI environment handle */ + OCI_Connection *con; /* Connection object for type dependent on connections */ + unsigned int elem_type; /* array element type */ + unsigned int elem_subtype; /* array element subtype */ + unsigned int elem_size; /* array element handle size */ + unsigned int nb_elem; /* array size of number of elements */ + unsigned int struct_size; /* array element size */ + unsigned int handle_type; /* array element OCI handle type */ + void ** tab_obj; /* array of pointers to OCILIB objects */ + void * mem_handle; /* array OCI handles */ + void * mem_struct; /* array of OCILIB objects structures */ + +}; + +typedef struct OCI_Array OCI_Array; + +/* + * Hash table object + * + */ + +struct OCI_HashTable +{ + OCI_HashEntry **items; /* array of slots */ + unsigned int size; /* size of the slots array */ + unsigned int count; /* number of used slots */ + unsigned int type; /* type of data */ +}; + +/* + * OCI_Datatype : fake dummy structure for casting object with + * handles for more compact code + * + */ + +struct OCI_Datatype +{ + void *handle; /* OCI handle */ + ub4 hstate; /* object variable state */ +}; + +typedef struct OCI_Datatype OCI_Datatype; + +/* + * OCI_SQLCmdInfo : Oracle SQL commands code and verbs + * + */ + +struct OCI_SQLCmdInfo +{ + unsigned int code; /* SQL command code */ + const otext *verb; /* SQL command verb */ +}; + +typedef struct OCI_SQLCmdInfo OCI_SQLCmdInfo; + +/* OCI context */ + +struct OCI_Context +{ + unsigned int source_type; + void * source_ptr; + const char * location; +}; + +typedef struct OCI_Context OCI_Context; + +/* static and unique OCI_Environment object */ + +extern OCI_Environment Env; +extern const OCI_SQLCmdInfo SQLCmds[]; + +/* Start of Experimental section containing some Oracle opaque structure definitions + + These partial structures are "guessed" from memory analysis in order to + find workarounds to bugs that Oracle does not / refuses to fix. + + These structures are not used in OCILIB unless specific environment variables are set +*/ + +/* The following structures contain definitions for a structure matching an Oracle Parameter + retrieved from a statement handle when describing columns from resultsets. + They were added in order to implement a workaround for the unfixed Oracle Bug 9838993 +*/ + +struct OCIParamStructColumnInfo +{ + unsigned char unknown_fields[6 * sizeof(int) + 2 * sizeof(void*)]; + unsigned char attributes[sizeof(void *)]; + char *name; +}; + +typedef struct OCIParamStructColumnInfo OCIParamStructColumnInfo; + +struct OCIParamStruct +{ + unsigned char unknown_fields[3 * sizeof(void*)]; + + OCIParamStructColumnInfo *column_info; +}; + +typedef struct OCIParamStruct OCIParamStruct; + +/* End of Experimental section */ + +#endif /* OCILIB_TYPES_H_INCLUDED */ From a0c91126871e1c7304cd8bf6821b457417faad4a Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 4 May 2020 22:25:24 +0200 Subject: [PATCH 02/62] Fixed refactoring regressions --- src/array.c | 2 -- src/date.c | 4 ++-- src/lob.c | 6 +++--- src/pool.c | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/array.c b/src/array.c index 74e9c183..71102c1c 100644 --- a/src/array.c +++ b/src/array.c @@ -236,8 +236,6 @@ OCI_Array * ArrayCreate OCI_Array* arr = NULL; - CHECK_PTR(OCI_IPC_CONNECTION, con) - /* create array object */ arr = ListAppend(Env.arrs, sizeof(*arr)); diff --git a/src/date.c b/src/date.c index b9693e62..c7627dcc 100644 --- a/src/date.c +++ b/src/date.c @@ -645,7 +645,7 @@ boolean DateSetDate OCIDateSetDate(date->handle, (sb2) year, (ub1) month, (ub1) day); - SET_RETVAL(DateCheck(date)) + SET_RETVAL(DateCheck(date) == 0) EXIT_FUNC() } @@ -672,7 +672,7 @@ boolean DateSetTime OCIDateSetTime(date->handle, (ub1) hour, (ub1) min, (ub1) sec); - SET_RETVAL(DateCheck(date)) + SET_RETVAL(DateCheck(date) == 0) EXIT_FUNC() } diff --git a/src/lob.c b/src/lob.c index f446e64f..3cd0f81e 100644 --- a/src/lob.c +++ b/src/lob.c @@ -314,7 +314,7 @@ boolean LobSeek { lob->offset += offset; - success = FALSE; + success = TRUE; } break; } @@ -324,7 +324,7 @@ boolean LobSeek { lob->offset = offset + 1; - success = FALSE; + success = TRUE; } break; } @@ -334,7 +334,7 @@ boolean LobSeek { lob->offset = size - offset + 1; - success = FALSE; + success = TRUE; } break; } diff --git a/src/pool.c b/src/pool.c index 1b91d363..1e3e9032 100644 --- a/src/pool.c +++ b/src/pool.c @@ -331,7 +331,7 @@ OCI_Pool * PoolCreate /* retrieve statement cache size */ - CHECK(PoolGetStatementCacheSize(pool)) + PoolGetStatementCacheSize(pool); /* for connection pools that do not handle the statement cache attribute, let's set the value with documented default cache size */ From 8dcf7b3bc28f091b478bf431841d4a1a3c8f9085 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 4 May 2020 22:26:02 +0200 Subject: [PATCH 03/62] Adding some unit tests --- tests/Array.cpp | 92 ++++++++++++++++++++++++++++++ tests/connection.cpp | 40 ++++++++++++- tests/interval.cpp | 1 - tests/main.cpp | 16 ++++++ tests/ocilib_tests.h | 2 + tests/ocilib_tests.vcxproj | 3 + tests/ocilib_tests.vcxproj.filters | 6 ++ 7 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 tests/Array.cpp create mode 100644 tests/main.cpp diff --git a/tests/Array.cpp b/tests/Array.cpp new file mode 100644 index 00000000..96cceb59 --- /dev/null +++ b/tests/Array.cpp @@ -0,0 +1,92 @@ +#include "ocilib_tests.h" + +// requires DDL from /demo/product.sql + +TEST(TestArray, InsertArray) +{ + ExecDML(OTEXT("create table TestArrayInsertArray(code int, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestArrayInsertArray(code int, name varchar2(50))")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + int tab_int[ARRAY_SIZE]; + char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; + + ASSERT_TRUE(OCI_Prepare(stmt, "insert into TestArrayInsertArray values(:i, :s)")); + ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); + ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); + + for (int i = 0; i < ARRAY_SIZE; i++) + { + tab_int[i] = i + 1; + osprintf(tab_str[i], STRING_SIZE, OTEXT("Name %d"), i + 1); + } + + ASSERT_TRUE(OCI_Execute(stmt)); + + ASSERT_EQ(ARRAY_SIZE, OCI_GetAffectedRows(stmt)); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop table TestArrayInsertArray")); +} + +TEST(TestArray, InsertArrayError) +{ + ExecDML(OTEXT("create table TestArrayInsertArrayError(code int NOT NULL, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestArrayInsertArrayError(code int, name varchar2(50))")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + int tab_int[ARRAY_SIZE]; + char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; + + ASSERT_TRUE(OCI_Prepare(stmt, "insert into TestArrayInsertArrayError values(:i, :s)")); + ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); + ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); + + for (int i = 0; i < ARRAY_SIZE; i++) + { + tab_int[i] = i + 1; + osprintf(tab_str[i], STRING_SIZE, OTEXT("Name %d"), i + 1); + } + + const auto bnd = OCI_GetBind(stmt, 1); + ASSERT_NE(nullptr, bnd); + + ASSERT_TRUE(OCI_BindSetNullAtPos(bnd, 3)); + + ASSERT_FALSE(OCI_Execute(stmt)); + + const auto err = OCI_GetBatchError(stmt); + ASSERT_NE(nullptr, err); + + // Row 3 must be in error + ASSERT_EQ(3, OCI_ErrorGetRow(err)); + // Only 1 error + ASSERT_EQ(nullptr, OCI_GetBatchError(stmt)); + // Only 1 error, ARRAY_SIZE - 1 must have been inserted + ASSERT_EQ(ARRAY_SIZE -1, OCI_GetAffectedRows(stmt)); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop table TestArrayInsertArrayError")); +} diff --git a/tests/connection.cpp b/tests/connection.cpp index 4c02ee16..7177dd39 100644 --- a/tests/connection.cpp +++ b/tests/connection.cpp @@ -38,7 +38,6 @@ TEST(TestConnection, InvalidUser) ASSERT_TRUE(OCI_Cleanup()); } - TEST(TestConnection, InvalidPassword) { Guard guard(context.Lock); @@ -47,7 +46,6 @@ TEST(TestConnection, InvalidPassword) ASSERT_TRUE(OCI_Initialize(AddError, HOME, OCI_ENV_DEFAULT)); const auto conn = OCI_ConnectionCreate(DBS, USR, PWD_WRONG, OCI_SESSION_DEFAULT); - ASSERT_EQ(nullptr, conn); ASSERT_EQ(1, context.Errs.size()); @@ -56,4 +54,42 @@ TEST(TestConnection, InvalidPassword) ASSERT_FALSE(OCI_ConnectionFree(conn)); ASSERT_TRUE(OCI_Cleanup()); +} + +TEST(TestConnection, Abort) +{ + Guard guard(context.Lock); + context.Errs.clear(); + + ASSERT_TRUE(OCI_Initialize(AddError, HOME, OCI_ENV_DEFAULT | OCI_ENV_THREADED)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto thrd = OCI_ThreadCreate(); + ASSERT_NE(nullptr, thrd); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + auto callback = [](OCI_Thread* thread, void* data) + { + ASSERT_FALSE(OCI_ExecuteStmt(static_cast(data), "begin dbms_lock.sleep(10); end;")); + }; + + OCI_ThreadRun(thrd, callback, stmt); + + Sleep(500); + ASSERT_TRUE(OCI_Break(conn)); + + ASSERT_TRUE(OCI_ThreadJoin(thrd)); + ASSERT_TRUE(OCI_ThreadFree(thrd)); + + ASSERT_EQ(1, context.Errs.size()); + ASSERT_EQ(0, context.Errs[0].LibCode); + ASSERT_EQ(1013, context.Errs[0].OCICode); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); } \ No newline at end of file diff --git a/tests/interval.cpp b/tests/interval.cpp index 0e374c71..57989ea0 100644 --- a/tests/interval.cpp +++ b/tests/interval.cpp @@ -1,6 +1,5 @@ #include "ocilib_tests.h" - static Context context; static inline void AddError(OCI_Error *err) diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 00000000..ffbf4003 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,16 @@ +#include "ocilib_tests.h" + + +void ExecDML(ostring dml) +{ + OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT); + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + OCI_Immediate(conn, dml.data()); + OCI_Cleanup(); +} + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file diff --git a/tests/ocilib_tests.h b/tests/ocilib_tests.h index 74c970dc..9ae84bef 100644 --- a/tests/ocilib_tests.h +++ b/tests/ocilib_tests.h @@ -26,6 +26,7 @@ #define HOME OTEXT("") #define PWD_WRONG OTEXT("pwd_wrong") #define ARRAY_SIZE 10 +#define STRING_SIZE 20 #define NLS_LANGUAGE_SUNDAY_NAME OTEXT("Dimanche") #include "mutex" @@ -62,3 +63,4 @@ struct Context #define Sleep(x) usleep(x * 1000); #endif +void ExecDML(ostring dml); diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 2e3ef87a..54e94eca 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -33,6 +33,7 @@ + NotUsing NotUsing @@ -41,6 +42,7 @@ + @@ -113,6 +115,7 @@ MultiThreaded Level3 ProgramDatabase + 4996 true diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 8e8f6f69..cdf43cdb 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -25,6 +25,12 @@ Source files + + Source files + + + Source files + From 65058920661592328fc248dac7b3594e9b05b7a3 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 07:27:20 +0200 Subject: [PATCH 04/62] Added C sources to the C++ Test suite project instead of referencing prebuilt DLLs --- .gitignore | 6 +- tests/{connection.cpp => TestConnection.cpp} | 0 tests/{date.cpp => TestDate.cpp} | 0 tests/{lob.cpp => TestLob.cpp} | 0 tests/{number.cpp => TestNumber.cpp} | 0 tests/{ref.cpp => TestReference.cpp} | 0 ...ortedIssues.cpp => TestReportedIssues.cpp} | 0 tests/{timestamp.cpp => TestTimestamp.cpp} | 0 tests/{interval.cpp => Testinterval.cpp} | 0 tests/ocilib_tests.h | 9 - tests/ocilib_tests.vcxproj | 86 ++++++-- tests/ocilib_tests.vcxproj.filters | 184 +++++++++++++++--- 12 files changed, 239 insertions(+), 46 deletions(-) rename tests/{connection.cpp => TestConnection.cpp} (100%) rename tests/{date.cpp => TestDate.cpp} (100%) rename tests/{lob.cpp => TestLob.cpp} (100%) rename tests/{number.cpp => TestNumber.cpp} (100%) rename tests/{ref.cpp => TestReference.cpp} (100%) rename tests/{ReportedIssues.cpp => TestReportedIssues.cpp} (100%) rename tests/{timestamp.cpp => TestTimestamp.cpp} (100%) rename tests/{interval.cpp => Testinterval.cpp} (100%) diff --git a/.gitignore b/.gitignore index b063541b..e10baf80 100644 --- a/.gitignore +++ b/.gitignore @@ -172,4 +172,8 @@ $RECYCLE.BIN/ # Mac desktop service store files .DS_Store *.opendb -/tests/packages/*.* \ No newline at end of file +/tests/packages/*.* +/tests/.vs/ocilib_tests/v16/TestStore/0/testlog.manifest +/tests/.vs/ocilib_tests/v16/TestStore/0/002.testlog +/proj/dll/.vs/ocilib_dll_vs2019/v16/TestStore/0/testlog.manifest +/proj/dll/.vs/ocilib_dll_vs2019/v16/TestStore/0/000.testlog diff --git a/tests/connection.cpp b/tests/TestConnection.cpp similarity index 100% rename from tests/connection.cpp rename to tests/TestConnection.cpp diff --git a/tests/date.cpp b/tests/TestDate.cpp similarity index 100% rename from tests/date.cpp rename to tests/TestDate.cpp diff --git a/tests/lob.cpp b/tests/TestLob.cpp similarity index 100% rename from tests/lob.cpp rename to tests/TestLob.cpp diff --git a/tests/number.cpp b/tests/TestNumber.cpp similarity index 100% rename from tests/number.cpp rename to tests/TestNumber.cpp diff --git a/tests/ref.cpp b/tests/TestReference.cpp similarity index 100% rename from tests/ref.cpp rename to tests/TestReference.cpp diff --git a/tests/ReportedIssues.cpp b/tests/TestReportedIssues.cpp similarity index 100% rename from tests/ReportedIssues.cpp rename to tests/TestReportedIssues.cpp diff --git a/tests/timestamp.cpp b/tests/TestTimestamp.cpp similarity index 100% rename from tests/timestamp.cpp rename to tests/TestTimestamp.cpp diff --git a/tests/interval.cpp b/tests/Testinterval.cpp similarity index 100% rename from tests/interval.cpp rename to tests/Testinterval.cpp diff --git a/tests/ocilib_tests.h b/tests/ocilib_tests.h index 9ae84bef..6a4f4494 100644 --- a/tests/ocilib_tests.h +++ b/tests/ocilib_tests.h @@ -49,15 +49,6 @@ struct Context }; -#ifdef _MSC_VER - -#if defined(OCI_CHARSET_WIDE) -#pragma comment(lib, "../lib64/ocilibw.lib") -#elif defined(OCI_CHARSET_ANSI) -#pragma comment(lib, "../lib64/ociliba.lib") -#endif -#endif - #ifndef _WINDOWS #include #define Sleep(x) usleep(x * 1000); diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 54e94eca..c3076aa8 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -32,21 +32,78 @@ + + ..\src;..\include;$(IncludePath) + + + ..\src;..\include;$(IncludePath) + + + ..\src;..\include;$(IncludePath) + + + ..\src;..\include;$(IncludePath) + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NotUsing NotUsing NotUsing - - - + + + - - - - + + + + @@ -64,11 +121,12 @@ Use pch.h Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug Level3 + 4996 true @@ -80,11 +138,12 @@ NotUsing pch.h Disabled - X64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + X64;_DEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug Level3 + 4996 true @@ -95,10 +154,11 @@ Use pch.h - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE; OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) MultiThreaded Level3 ProgramDatabase + 4996 true @@ -111,7 +171,7 @@ NotUsing pch.h - X64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + X64;NDEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) MultiThreaded Level3 ProgramDatabase diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index cdf43cdb..81e8bd74 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -1,47 +1,185 @@  - - Source files + + Tests suite - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources - - Source files + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Sources + + + Tests suite + + + Tests suite + + + Tests suite + + + Tests suite + + + Tests suite + + + Tests suite + + + Tests suite + + + Tests suite + + + Sources - - {a27a0a28-f04a-4730-a09e-72366b3cc3de} - {dd240098-c9aa-4f76-9b0d-50e653c6086b} + + {a27a0a28-f04a-4730-a09e-72366b3cc3de} + + + {fc9505f2-5f34-43eb-8c4c-29c05561e5c0} + From 7081ae24f2556edfa5e937d6e2681580969e8792 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 08:56:54 +0200 Subject: [PATCH 05/62] Added Collection test suite --- .gitignore | 8 +- tests/{Array.cpp => TestArray.cpp} | 2 - tests/TestCollection.cpp | 194 +++++++++++++++++++++++++++++ tests/main.cpp | 1 + tests/ocilib_tests.vcxproj | 2 + tests/ocilib_tests.vcxproj.filters | 6 + 6 files changed, 207 insertions(+), 6 deletions(-) rename tests/{Array.cpp => TestArray.cpp} (98%) create mode 100644 tests/TestCollection.cpp diff --git a/.gitignore b/.gitignore index e10baf80..bdc15ed2 100644 --- a/.gitignore +++ b/.gitignore @@ -172,8 +172,8 @@ $RECYCLE.BIN/ # Mac desktop service store files .DS_Store *.opendb + +# Unit test files /tests/packages/*.* -/tests/.vs/ocilib_tests/v16/TestStore/0/testlog.manifest -/tests/.vs/ocilib_tests/v16/TestStore/0/002.testlog -/proj/dll/.vs/ocilib_dll_vs2019/v16/TestStore/0/testlog.manifest -/proj/dll/.vs/ocilib_dll_vs2019/v16/TestStore/0/000.testlog +testlog.manifest +*.testlog diff --git a/tests/Array.cpp b/tests/TestArray.cpp similarity index 98% rename from tests/Array.cpp rename to tests/TestArray.cpp index 96cceb59..d0976c46 100644 --- a/tests/Array.cpp +++ b/tests/TestArray.cpp @@ -1,7 +1,5 @@ #include "ocilib_tests.h" -// requires DDL from /demo/product.sql - TEST(TestArray, InsertArray) { ExecDML(OTEXT("create table TestArrayInsertArray(code int, name varchar2(50))")); diff --git a/tests/TestCollection.cpp b/tests/TestCollection.cpp new file mode 100644 index 00000000..624bb258 --- /dev/null +++ b/tests/TestCollection.cpp @@ -0,0 +1,194 @@ +#include "ocilib_tests.h" + + +void SelectCollection(ostring sql) +{ + const int expectedRows = 2; + const int expectedItems = 2; + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, sql.data())); + + const auto rset = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rset); + + int nbRows = 0; + int itemIndex = 0; + + while (OCI_FetchNext(rset)) + { + nbRows++; + + ostring category = "category " + std::to_string(nbRows); + ASSERT_EQ(category, ostring(OCI_GetString(rset, 1))); + + const auto coll = OCI_GetColl(rset, 2); + ASSERT_NE(nullptr, coll); + + ASSERT_EQ(expectedItems, OCI_CollGetCount(coll)); + ASSERT_EQ(expectedItems, OCI_CollGetSize(coll)); + + const auto iter = OCI_IterCreate(coll); + ASSERT_NE(nullptr, iter); + + auto elem = OCI_IterGetNext(iter); + ASSERT_NE(nullptr, elem); + + while (elem) + { + itemIndex++; + + const auto obj = OCI_ElemGetObject(elem); + ASSERT_NE(nullptr, obj); + + ostring itemName = "name " + std::to_string(itemIndex); + + ASSERT_EQ(itemIndex, OCI_ObjectGetInt(obj, "code")); + ASSERT_EQ(itemName, OCI_ObjectGetString(obj, "name")); + elem = OCI_IterGetNext(iter); + } + } + + ASSERT_EQ(expectedRows, nbRows); + ASSERT_EQ(expectedRows * expectedItems, itemIndex); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); +} + +void BindOutCollection(ostring type, ostring sql) +{ + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + const auto coll = OCI_CollCreate(OCI_TypeInfoGet(conn, type.data(), OCI_TIF_TYPE)); + ASSERT_NE(nullptr, coll); + + ASSERT_TRUE(OCI_Prepare(stmt, sql.data())); + ASSERT_TRUE(OCI_BindColl(stmt, OTEXT(":coll"), coll)); + ASSERT_TRUE(OCI_Execute(stmt)); + + const int expectedItems = 3; + + int itemIndex = 0; + + ASSERT_EQ(expectedItems, OCI_CollGetCount(coll)); + ASSERT_EQ(expectedItems, OCI_CollGetSize(coll)); + + const auto iter = OCI_IterCreate(coll); + ASSERT_NE(nullptr, iter); + + auto elem = OCI_IterGetNext(iter); + ASSERT_NE(nullptr, elem); + + while (elem) + { + itemIndex++; + + const auto obj = OCI_ElemGetObject(elem); + ASSERT_NE(nullptr, obj); + + ostring itemName = "name " + std::to_string(itemIndex); + + ASSERT_EQ(itemIndex, OCI_ObjectGetInt(obj, "code")); + ASSERT_EQ(itemName, OCI_ObjectGetString(obj, "name")); + elem = OCI_IterGetNext(iter); + } + + ASSERT_EQ(expectedItems, itemIndex); + + ASSERT_TRUE(OCI_CollFree(coll)); + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); +} + +TEST(TestCollection, SelectVarray) +{ + ExecDML(OTEXT("create type SelectVarray_Type as object(code int, name varchar2(50))")); + ExecDML(OTEXT("create type SelectVarray_Coll as varray(2) of SelectVarray_Type")); + ExecDML(OTEXT("create table SelectVarray_Table(category varchar2(50), products SelectVarray_Coll)")); + ExecDML(OTEXT("truncate table SelectVarray_Table")); + ExecDML(OTEXT("insert into SelectVarray_Table values('category 1', SelectVarray_Coll(SelectVarray_Type(1, 'name 1'), SelectVarray_Type(2, 'name 2')))")); + ExecDML(OTEXT("insert into SelectVarray_Table values('category 2', SelectVarray_Coll(SelectVarray_Type(3, 'name 3'), SelectVarray_Type(4, 'name 4')))")); + + SelectCollection(OTEXT("SELECT * from SelectVarray_Table")); + + ExecDML(OTEXT("drop table SelectVarray_Table")); + ExecDML(OTEXT("drop type SelectVarray_Coll")); + ExecDML(OTEXT("drop type SelectVarray_Type")); +} + +TEST(TestCollection, SelectNestedTable) +{ + ExecDML(OTEXT("create type SelectNestedTable_Type as object(code int, name varchar2(50))")); + ExecDML(OTEXT("create type SelectNestedTable_Coll as table of SelectNestedTable_Type")); + ExecDML(OTEXT("create table SelectNestedTable_Table(category varchar2(50), products SelectNestedTable_Coll) nested table products store as SelectNestedTable_Storage")); + ExecDML(OTEXT("truncate table SelectNestedTable_Table")); + ExecDML(OTEXT("insert into SelectNestedTable_Table values('category 1', SelectNestedTable_Coll(SelectNestedTable_Type(1, 'name 1'), SelectNestedTable_Type(2, 'name 2')))")); + ExecDML(OTEXT("insert into SelectNestedTable_Table values('category 2', SelectNestedTable_Coll(SelectNestedTable_Type(3, 'name 3'), SelectNestedTable_Type(4, 'name 4')))")); + + SelectCollection(OTEXT("SELECT * from SelectNestedTable_Table")); + + ExecDML(OTEXT("drop table SelectNestedTable_Table")); + ExecDML(OTEXT("drop type SelectNestedTable_Coll")); + ExecDML(OTEXT("drop type SelectNestedTable_Type")); +} + +TEST(TestCollection, BindOutVarray) +{ + ExecDML(OTEXT("create type BindOutVarray_Type as object(code int, name varchar2(50))")); + ExecDML(OTEXT("create type BindOutVarray_Coll as varray(3) of BindOutVarray_Type")); + + BindOutCollection + ( + OTEXT("BindOutVarray_Coll"), + OTEXT("begin ") + OTEXT(" :coll := BindOutVarray_Coll ") + OTEXT(" ( ") + OTEXT(" BindOutVarray_Type(1, 'name 1'), ") + OTEXT(" BindOutVarray_Type(2, 'name 2'), ") + OTEXT(" BindOutVarray_Type(3, 'name 3') ") + OTEXT(" ); ") + OTEXT("end; ") + ); + + ExecDML(OTEXT("drop type BindOutVarray_Coll")); + ExecDML(OTEXT("drop type BindOutVarray_Type")); +} +TEST(TestCollection, BindOutNestedTable) +{ + ExecDML(OTEXT("create type BindOutNestedTable_Type as object(code int, name varchar2(50))")); + ExecDML(OTEXT("create type BindOutNestedTable_Coll as table of BindOutNestedTable_Type")); + + + BindOutCollection + ( + OTEXT("BindOutNestedTable_Coll"), + OTEXT("begin ") + OTEXT(" :coll := BindOutNestedTable_Coll ") + OTEXT(" ( ") + OTEXT(" BindOutNestedTable_Type(1, 'name 1'), ") + OTEXT(" BindOutNestedTable_Type(2, 'name 2'), ") + OTEXT(" BindOutNestedTable_Type(3, 'name 3') ") + OTEXT(" ); ") + OTEXT("end; ") + ); + + ExecDML(OTEXT("drop type BindOutNestedTable_Coll")); + ExecDML(OTEXT("drop type BindOutNestedTable_Type")); +} + diff --git a/tests/main.cpp b/tests/main.cpp index ffbf4003..8ca89b87 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -6,6 +6,7 @@ void ExecDML(ostring dml) OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT); const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); OCI_Immediate(conn, dml.data()); + OCI_Commit(conn); OCI_Cleanup(); } diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index c3076aa8..5b4189e0 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -91,6 +91,8 @@ + + NotUsing NotUsing diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 81e8bd74..6279ed6a 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -166,6 +166,12 @@ Sources + + Tests suite + + + Tests suite + From 44dd7b71ca98c363eb47cf76efcdfdd47170f61f Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 09:11:26 +0200 Subject: [PATCH 06/62] Added Tests for Cursor fetching --- tests/TestArray.cpp | 4 +-- tests/TestCursor.cpp | 48 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 1 + tests/ocilib_tests.vcxproj.filters | 3 ++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/TestCursor.cpp diff --git a/tests/TestArray.cpp b/tests/TestArray.cpp index d0976c46..51b35f03 100644 --- a/tests/TestArray.cpp +++ b/tests/TestArray.cpp @@ -16,7 +16,7 @@ TEST(TestArray, InsertArray) int tab_int[ARRAY_SIZE]; char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; - ASSERT_TRUE(OCI_Prepare(stmt, "insert into TestArrayInsertArray values(:i, :s)")); + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestArrayInsertArray values(:i, :s)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); @@ -54,7 +54,7 @@ TEST(TestArray, InsertArrayError) int tab_int[ARRAY_SIZE]; char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; - ASSERT_TRUE(OCI_Prepare(stmt, "insert into TestArrayInsertArrayError values(:i, :s)")); + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestArrayInsertArrayError values(:i, :s)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); diff --git a/tests/TestCursor.cpp b/tests/TestCursor.cpp new file mode 100644 index 00000000..83963953 --- /dev/null +++ b/tests/TestCursor.cpp @@ -0,0 +1,48 @@ +#include "ocilib_tests.h" + + +TEST(TestCursor, Fetch) +{ + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, OTEXT("select rownum, cursor(select TO_DATE('19780430', 'yyyymmdd') from dual) from (select 1 from dual connect by level <= 10)"))); + + const auto rset = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rset); + + int index = 0; + + while (OCI_FetchNext(rset)) + { + index++; + ASSERT_EQ(index, OCI_GetInt(rset, 1)); + + const auto stmt2 = OCI_GetStatement(rset, 2); + ASSERT_NE(nullptr, stmt2); + const auto rset2 = OCI_GetResultset(stmt2); + ASSERT_NE(nullptr, stmt2); + + while (OCI_FetchNext(rset2)) + { + const auto date = OCI_GetDate(rset2, 1); + ASSERT_NE(nullptr, date); + + otext buffer[OCI_SIZE_BUFFER] = OTEXT(""); + ASSERT_TRUE(OCI_DateToText(date, OTEXT("yyyymmdd"), OCI_SIZE_BUFFER, buffer)); + + ASSERT_EQ(ostring(OTEXT("19780430")), ostring(buffer)); + } + } + + ASSERT_EQ(10, OCI_GetRowCount(rset)); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); +} \ No newline at end of file diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 5b4189e0..d0fc6c7e 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -91,6 +91,7 @@ + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 6279ed6a..95d99ba9 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -172,6 +172,9 @@ Tests suite + + Tests suite + From ccd5782cab095332fe7e5f5717238bbf64eb1990 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 13:01:50 +0200 Subject: [PATCH 07/62] Added test suite for describe and implicit resultsets --- tests/TestDescribe.cpp | 135 +++++++++++++++++++++++++++++ tests/TestImplicitResultset.cpp | 51 +++++++++++ tests/ocilib_tests.vcxproj | 2 + tests/ocilib_tests.vcxproj.filters | 6 ++ 4 files changed, 194 insertions(+) create mode 100644 tests/TestDescribe.cpp create mode 100644 tests/TestImplicitResultset.cpp diff --git a/tests/TestDescribe.cpp b/tests/TestDescribe.cpp new file mode 100644 index 00000000..26555984 --- /dev/null +++ b/tests/TestDescribe.cpp @@ -0,0 +1,135 @@ +#include "ocilib_tests.h" + +void CheckColumnType +( + int index, + OCI_TypeInfo *typinf, + const ostring &name, + const ostring &typeName, + unsigned int type +) +{ + const auto col = OCI_TypeInfoGetColumn(typinf, index); + ASSERT_NE(nullptr, col); + + ASSERT_EQ(name, ostring(OCI_GetColumnName(col))); + ASSERT_EQ(typeName, ostring(OCI_GetColumnSQLType(col))); + ASSERT_EQ(type, OCI_GetColumnType(col)); +} + +TEST(TestDescribe, Type) +{ + ExecDML + ( + OTEXT("create type TestDescribeSubType as OBJECT (id int, name varchar2(50))") + ); + + ExecDML + ( + OTEXT("create type TestDescribeType as object ") + OTEXT("( ") + OTEXT(" val_int number, ") + OTEXT(" val_flt float, ") + OTEXT(" val_str varchar2(30), ") + OTEXT(" val_date date, ") + OTEXT(" val_tsmp timestamp, ") + OTEXT(" val_itv interval year to month, ") + OTEXT(" val_lob clob, ") + OTEXT(" val_file bfile, ") + OTEXT(" val_raw raw(10), ") + OTEXT(" val_obj TestDescribeSubType") + OTEXT(")") + ); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto typinf = OCI_TypeInfoGet(conn, OTEXT("TestDescribeType"), OCI_TIF_TYPE); + ASSERT_NE(nullptr, typinf); + + const int typepPropCount = 10; + + ASSERT_EQ(typepPropCount, OCI_TypeInfoGetColumnCount(typinf)); + + CheckColumnType(1, typinf, OTEXT("VAL_INT"), OTEXT("NUMBER"), OCI_CDT_NUMERIC); + CheckColumnType(2, typinf, OTEXT("VAL_FLT"), OTEXT("FLOAT"), OCI_CDT_NUMERIC); + CheckColumnType(3, typinf, OTEXT("VAL_STR"), OTEXT("VARCHAR2"), OCI_CDT_TEXT); + CheckColumnType(4, typinf, OTEXT("VAL_DATE"), OTEXT("DATE"), OCI_CDT_DATETIME); + CheckColumnType(5, typinf, OTEXT("VAL_TSMP"), OTEXT("TIMESTAMP"), OCI_CDT_TIMESTAMP); + CheckColumnType(6, typinf, OTEXT("VAL_ITV"), OTEXT("INTERVAL YEAR TO MONTH"), OCI_CDT_INTERVAL); + CheckColumnType(7, typinf, OTEXT("VAL_LOB"), OTEXT("CLOB"), OCI_CDT_LOB); + CheckColumnType(8, typinf, OTEXT("VAL_FILE"), OTEXT("BINARY FILE LOB"), OCI_CDT_FILE); + CheckColumnType(9, typinf, OTEXT("VAL_RAW"), OTEXT("RAW"), OCI_CDT_RAW); + CheckColumnType(10, typinf, OTEXT("VAL_OBJ"), OTEXT("TESTDESCRIBESUBTYPE"), OCI_CDT_OBJECT); + + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop type TestDescribeType")); + ExecDML(OTEXT("drop type TestDescribeSubType")); +} + + +TEST(TestDescribe, Table) +{ + ExecDML + ( + OTEXT("create type TestDescribeTableSubType as OBJECT (id int, name varchar2(50))") + ); + + ExecDML + ( + OTEXT("create table TestDescribeTable ") + OTEXT("( ") + OTEXT(" val_int number NOT NULL, ") + OTEXT(" val_flt float, ") + OTEXT(" val_str varchar2(30), ") + OTEXT(" val_date date, ") + OTEXT(" val_tsmp timestamp, ") + OTEXT(" val_itv interval year to month, ") + OTEXT(" val_lob clob, ") + OTEXT(" val_file bfile, ") + OTEXT(" val_raw raw(10), ") + OTEXT(" val_obj TestDescribeTableSubType") + OTEXT(")") + ); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto typinf = OCI_TypeInfoGet(conn, OTEXT("TestDescribeTable"), OCI_TIF_TABLE); + ASSERT_NE(nullptr, typinf); + + const int typepPropCount = 10; + + ASSERT_EQ(typepPropCount, OCI_TypeInfoGetColumnCount(typinf)); + + CheckColumnType(1, typinf, OTEXT("VAL_INT"), OTEXT("NUMBER"), OCI_CDT_NUMERIC); + CheckColumnType(2, typinf, OTEXT("VAL_FLT"), OTEXT("FLOAT"), OCI_CDT_NUMERIC); + CheckColumnType(3, typinf, OTEXT("VAL_STR"), OTEXT("VARCHAR2"), OCI_CDT_TEXT); + CheckColumnType(4, typinf, OTEXT("VAL_DATE"), OTEXT("DATE"), OCI_CDT_DATETIME); + CheckColumnType(5, typinf, OTEXT("VAL_TSMP"), OTEXT("TIMESTAMP"), OCI_CDT_TIMESTAMP); + CheckColumnType(6, typinf, OTEXT("VAL_ITV"), OTEXT("INTERVAL YEAR TO MONTH"), OCI_CDT_INTERVAL); + CheckColumnType(7, typinf, OTEXT("VAL_LOB"), OTEXT("CLOB"), OCI_CDT_LOB); + CheckColumnType(8, typinf, OTEXT("VAL_FILE"), OTEXT("BINARY FILE LOB"), OCI_CDT_FILE); + CheckColumnType(9, typinf, OTEXT("VAL_RAW"), OTEXT("RAW"), OCI_CDT_RAW); + CheckColumnType(10, typinf, OTEXT("VAL_OBJ"), OTEXT("TESTDESCRIBETABLESUBTYPE"), OCI_CDT_OBJECT); + + const auto col1 = OCI_TypeInfoGetColumn(typinf, 1); + ASSERT_NE(nullptr, col1); + ASSERT_EQ(FALSE, OCI_ColumnGetNullable(col1)); + + const auto col2 = OCI_TypeInfoGetColumn(typinf, 2); + ASSERT_NE(nullptr, col2); + ASSERT_EQ(TRUE, OCI_ColumnGetNullable(col2)); + + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop type TestDescribeTableSubType")); + ExecDML(OTEXT("drop type TestDescribeTable")); +} \ No newline at end of file diff --git a/tests/TestImplicitResultset.cpp b/tests/TestImplicitResultset.cpp new file mode 100644 index 00000000..448fd14f --- /dev/null +++ b/tests/TestImplicitResultset.cpp @@ -0,0 +1,51 @@ +#include "ocilib_tests.h" + + +TEST(TestImplicitResultset, Fetch) +{ + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, + OTEXT("declare") + OTEXT(" c1 sys_refcursor;") + OTEXT(" c2 sys_refcursor;") + OTEXT(" begin") + OTEXT(" open c1 for select rownum from dual connect by level <= 3;") + OTEXT(" dbms_sql.return_result (c1); ") + OTEXT(" open c2 for select rownum from dual connect by level <= 5;") + OTEXT(" dbms_sql.return_result (c2); ") + OTEXT("end;"))); + + auto rset = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rset); + + std::vector counts; + + while (rset) + { + int count = 0; + + while (OCI_FetchNext(rset)) + { + count++; + } + + counts.push_back(count); + + rset = OCI_GetNextResultset(stmt); + } + + ASSERT_EQ(2, counts.size()); + ASSERT_EQ(3, counts[0]); + ASSERT_EQ(5, counts[1]); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); +} \ No newline at end of file diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index d0fc6c7e..02372766 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -100,6 +100,8 @@ NotUsing + + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 95d99ba9..2450ad5a 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -175,6 +175,12 @@ Tests suite + + Tests suite + + + Tests suite + From 653fd59ec868dc84906bbfc1ee134c40457ac036 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 14:25:37 +0200 Subject: [PATCH 08/62] Fixed regression in MessageFree() and DequeueGetMessage() --- src/dequeue.c | 2 +- src/message.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dequeue.c b/src/dequeue.c index 6f4a97d3..8568bdb1 100644 --- a/src/dequeue.c +++ b/src/dequeue.c @@ -251,7 +251,7 @@ OCI_Msg * DequeueGetMessage /* dequeue message */ - StringGetDBString(dequeue->name, &dbsize); + dbstr = StringGetDBString(dequeue->name, &dbsize); if (OCI_UNKNOWN == dequeue->typinf->typecode) { diff --git a/src/message.c b/src/message.c index ab9175de..48b24d54 100644 --- a/src/message.c +++ b/src/message.c @@ -154,6 +154,8 @@ boolean MessageFree FREE(msg) + SET_SUCCESS() + EXIT_FUNC() } From ff5b6a39fe1ca7c6138eb89f977946feac64a5fa Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 14:26:03 +0200 Subject: [PATCH 09/62] added basic test suite for message queueing --- tests/TestQueue.cpp | 70 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 1 + tests/ocilib_tests.vcxproj.filters | 3 ++ 3 files changed, 74 insertions(+) create mode 100644 tests/TestQueue.cpp diff --git a/tests/TestQueue.cpp b/tests/TestQueue.cpp new file mode 100644 index 00000000..4976cc09 --- /dev/null +++ b/tests/TestQueue.cpp @@ -0,0 +1,70 @@ +#include "ocilib_tests.h" + + +TEST(TestQueue, SingleMessage) +{ + ExecDML(OTEXT("create type TestQueueSingleMessageType as object(title varchar2(50), content varchar2(100))")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + // no check - for cleanup + OCI_QueueStop(conn, OTEXT("TestQueueSingleMessage"), TRUE, TRUE, FALSE); + OCI_QueueDrop(conn, OTEXT("TestQueueSingleMessage")); + OCI_QueueTableDrop(conn, OTEXT("TestQueueSingleMessageTable"), TRUE); + // end no check + + ASSERT_TRUE(OCI_QueueTableCreate(conn, OTEXT("TestQueueSingleMessageTable"), OTEXT("TestQueueSingleMessageType"), NULL, NULL, FALSE, OCI_AGM_NONE, NULL, 0, 0, NULL)); + ASSERT_TRUE(OCI_QueueCreate(conn, OTEXT("TestQueueSingleMessage"), OTEXT("TestQueueSingleMessageTable"), OCI_AQT_NORMAL, 0, 0, 0, FALSE, NULL)); + ASSERT_TRUE(OCI_QueueStart(conn, OTEXT("TestQueueSingleMessage"), TRUE, TRUE)); + + const auto inf = OCI_TypeInfoGet(conn, OTEXT("TestQueueSingleMessageType"), OCI_TIF_TYPE); + ASSERT_NE(nullptr, inf); + + const auto enq = OCI_EnqueueCreate(inf, OTEXT("TestQueueSingleMessage")); + ASSERT_NE(nullptr, enq); + + const auto deq = OCI_DequeueCreate(inf, OTEXT("TestQueueSingleMessage")); + ASSERT_NE(nullptr, deq); + + const auto msg_in = OCI_MsgCreate(inf); + ASSERT_NE(nullptr, deq); + + const auto obj_in = OCI_ObjectCreate(conn, inf); + ASSERT_NE(nullptr, deq); + + ASSERT_TRUE(OCI_ObjectSetString(obj_in, OTEXT("title"), OTEXT("NEXT MEETING"))); + ASSERT_TRUE(OCI_ObjectSetString(obj_in, OTEXT("content"), OTEXT("12:00 PM IN STARBUCKS"))); + + ASSERT_TRUE(OCI_MsgSetObject(msg_in, obj_in)); + + ASSERT_TRUE(OCI_EnqueuePut(enq, msg_in)); + + ASSERT_TRUE(OCI_MsgFree(msg_in)); + ASSERT_TRUE(OCI_ObjectFree(obj_in)); + + ASSERT_TRUE(OCI_Commit(conn)); + + const auto msg_out = OCI_DequeueGet(deq); + ASSERT_NE(nullptr, msg_out); + + const auto obj_out = OCI_MsgGetObject(msg_out); + ASSERT_NE(nullptr, obj_out); + + ASSERT_EQ(ostring(OTEXT("NEXT MEETING")), ostring(OCI_ObjectGetString(obj_out, OTEXT("title")))); + ASSERT_EQ(ostring(OTEXT("12:00 PM IN STARBUCKS")), ostring(OCI_ObjectGetString(obj_out, OTEXT("content")))); + + ASSERT_TRUE(OCI_EnqueueFree(enq)); + ASSERT_TRUE(OCI_DequeueFree(deq)); + + ASSERT_TRUE(OCI_QueueStop(conn, OTEXT("TestQueueSingleMessage"), TRUE, TRUE, FALSE)); + ASSERT_TRUE(OCI_QueueDrop(conn, OTEXT("TestQueueSingleMessage"))); + ASSERT_TRUE(OCI_QueueTableDrop(conn, OTEXT("TestQueueSingleMessageTable"), TRUE)); + + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop type TestQueueSingleMessageType")); +} \ No newline at end of file diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 02372766..4989f81e 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -106,6 +106,7 @@ + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 2450ad5a..c4a3a815 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -181,6 +181,9 @@ Tests suite + + Tests suite + From e5a49c84a3eb0a172023ed7d1df4169773437cff Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 5 May 2020 20:25:10 +0200 Subject: [PATCH 10/62] added object inheritance basic test suite --- tests/TestObjectInheritance.cpp | 54 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 1 + tests/ocilib_tests.vcxproj.filters | 3 ++ 3 files changed, 58 insertions(+) create mode 100644 tests/TestObjectInheritance.cpp diff --git a/tests/TestObjectInheritance.cpp b/tests/TestObjectInheritance.cpp new file mode 100644 index 00000000..71242958 --- /dev/null +++ b/tests/TestObjectInheritance.cpp @@ -0,0 +1,54 @@ +#include "ocilib_tests.h" + + +TEST(TestObjectInheritance, OCI_TypeInfoGetSuperType) +{ + ExecDML(OTEXT("create type TestObjectInheritanceVehicule as object (code number, name varchar2(30)) not final")); + ExecDML(OTEXT("create type TestObjectInheritanceCar under TestObjectInheritanceVehicule (price number) not final")); + ExecDML(OTEXT("create type TestObjectInheritanceRacingCar under TestObjectInheritanceCar (speed number)")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + char buffer[512]; + unsigned int size = sizeof(buffer) - 1; + + const auto racingCar = OCI_ObjectCreate(conn, OCI_TypeInfoGet(conn, OTEXT("TestObjectInheritanceRacingCar"), OCI_TIF_TYPE)); + ASSERT_NE(nullptr, racingCar); + + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("begin :obj := TestObjectInheritanceRacingCar(1,'Formula1', 123456789, 300); end;"))); + ASSERT_TRUE(OCI_BindObject(stmt, OTEXT("obj"), racingCar)); + ASSERT_TRUE(OCI_Execute(stmt)); + ASSERT_TRUE(OCI_ObjectToText(racingCar, &size, buffer)); + + ASSERT_EQ(ostring(OTEXT("TESTOBJECTINHERITANCERACINGCAR(1, 'Formula1', 123456789, 300)")), ostring(buffer)); + + const auto typinfRacingCar = OCI_ObjectGetTypeInfo(racingCar); + ASSERT_NE(nullptr, typinfRacingCar); + const auto typinfCar = OCI_TypeInfoGetSuperType(typinfRacingCar); + ASSERT_NE(nullptr, typinfCar); + const auto typinfVehicule = OCI_TypeInfoGetSuperType(typinfCar); + ASSERT_NE(nullptr, typinfVehicule); + + ASSERT_EQ(ostring(OTEXT("TESTOBJECTINHERITANCERACINGCAR")), ostring(OCI_TypeInfoGetName(typinfRacingCar))); + ASSERT_EQ(ostring(OTEXT("TESTOBJECTINHERITANCECAR")), ostring(OCI_TypeInfoGetName(typinfCar))); + ASSERT_EQ(ostring(OTEXT("TESTOBJECTINHERITANCEVEHICULE")), ostring(OCI_TypeInfoGetName(typinfVehicule))); + + ASSERT_EQ(TRUE, OCI_TypeInfoIsFinalType(typinfRacingCar)); + ASSERT_EQ(FALSE, OCI_TypeInfoIsFinalType(typinfCar)); + ASSERT_EQ(FALSE, OCI_TypeInfoIsFinalType(typinfVehicule)); + + ASSERT_TRUE(OCI_ObjectFree(racingCar)); + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop type TestObjectInheritanceRacingCar")); + ExecDML(OTEXT("drop type TestObjectInheritanceCar")); + ExecDML(OTEXT("drop type TestObjectInheritanceVehicule")); +} \ No newline at end of file diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 4989f81e..d1d7f024 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -106,6 +106,7 @@ + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index c4a3a815..395b4790 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -184,6 +184,9 @@ Tests suite + + Tests suite + From 099cb7b8635144ebdde4d959220c06f54576d011 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Fri, 8 May 2020 18:19:16 +0200 Subject: [PATCH 11/62] Fix refactoring regression : Public OCI_Error functions were resetting last error while trying to retrieve it! --- src/ocilib.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ocilib.c b/src/ocilib.c index e77bd6f7..6fa66e74 100644 --- a/src/ocilib.c +++ b/src/ocilib.c @@ -2143,7 +2143,7 @@ const otext* OCI_API OCI_ErrorGetString OCI_Error* err ) { - CALL_IMPL(ErrorGetString, err) + return ErrorGetString(err); } unsigned int OCI_API OCI_ErrorGetType @@ -2151,7 +2151,7 @@ unsigned int OCI_API OCI_ErrorGetType OCI_Error* err ) { - CALL_IMPL(ErrorGetType, err) + return ErrorGetType(err); } int OCI_API OCI_ErrorGetOCICode @@ -2159,7 +2159,7 @@ int OCI_API OCI_ErrorGetOCICode OCI_Error* err ) { - CALL_IMPL(ErrorGetOCICode, err) + return ErrorGetOCICode(err); } int OCI_API OCI_ErrorGetInternalCode @@ -2167,7 +2167,7 @@ int OCI_API OCI_ErrorGetInternalCode OCI_Error* err ) { - CALL_IMPL(ErrorGetInternalCode, err) + return ErrorGetInternalCode(err); } OCI_Connection* OCI_API OCI_ErrorGetConnection @@ -2175,7 +2175,7 @@ OCI_Connection* OCI_API OCI_ErrorGetConnection OCI_Error* err ) { - CALL_IMPL(ErrorGetConnection, err) + return ErrorGetConnection(err); } OCI_Statement* OCI_API OCI_ErrorGetStatement @@ -2183,7 +2183,7 @@ OCI_Statement* OCI_API OCI_ErrorGetStatement OCI_Error* err ) { - CALL_IMPL(ErrorGetStatement, err) + return ErrorGetStatement(err); } unsigned int OCI_API OCI_ErrorGetRow @@ -2191,7 +2191,7 @@ unsigned int OCI_API OCI_ErrorGetRow OCI_Error* err ) { - CALL_IMPL(ErrorGetRow, err) + return ErrorGetRow(err); } const otext* OCI_API OCI_ErrorGetLocation @@ -2199,7 +2199,7 @@ const otext* OCI_API OCI_ErrorGetLocation OCI_Error* err ) { - CALL_IMPL(ErrorGetLocation, err) + return ErrorGetLocation(err); } /* --------------------------------------------------------------------------------------------- * From d37129f36424fc2a6a64ee3f4308ce2b47aecbbb Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sat, 9 May 2020 15:29:40 +0200 Subject: [PATCH 12/62] FIxed #230, added possiblity to traks libray allocations, refactored C++ compiler capabilites management --- include/ocilib_core.hpp | 79 ++++++++++++++----- include/ocilib_impl.hpp | 169 +++++++++++++++++++++++++++++++--------- 2 files changed, 192 insertions(+), 56 deletions(-) diff --git a/include/ocilib_core.hpp b/include/ocilib_core.hpp index d3e12049..22c93afa 100644 --- a/include/ocilib_core.hpp +++ b/include/ocilib_core.hpp @@ -42,44 +42,87 @@ #include -namespace ocilib -{ /* Try to guess C++ Compiler capabilities ... */ -#define CPP_98 199711L -#define CPP_11 201103L -#define CPP_14 201402L +#define OCILIBPP_CPP_98 199711L +#define OCILIBPP_CPP_11 201103L +#define OCILIBPP_CPP_14 201402L + +#if __cplusplus < OCILIBPP_CPP_11 -#if __cplusplus < CPP_11 + // GCC #if defined(__GNUC__) #if defined(__GXX_EXPERIMENTAL_CXX0X__) - #define HAS_CXX + #define OCILIBPP_HAS_CXX #endif + // MSVC #elif defined(_MSC_VER) - #if _MSC_VER >= 1600 - #define HAS_CXX - #endif + #if _MSVC_LANG >= OCILIBPP_CPP_11 + #define OCILIBPP_HAS_CXX + #endif #endif + #else - #define HAS_CXX + + #define OCILIBPP_HAS_CXX + #endif -#ifdef HAS_CXX +#ifdef OCILIBPP_HAS_CXX - template - using EnableIf = std::enable_if; + #define OCILIBPP_HAS_ENABLEIF + #define OCILIBPP_HAS_VARIADIC - template - using IsSame = std::is_same; + #ifdef OCILIBCPP_DEBUG_MEMORY + + #include + #define OCILIBPP_DEBUG_MEMORY_ENABLED + + #endif #else - - #define nullptr 0 + #define OCILIBPP_DEFINE_CXX_KEYWORDS + +#endif + +#ifdef OCILIBPP_TEST_CPP98 + + #ifdef OCILIBPP_DEFINE_CXX_KEYWORDS + #undef OCILIBPP_DEFINE_CXX_KEYWORDS + #endif + + #ifdef OCILIBPP_HAS_ENABLEIF + #undef OCILIBPP_HAS_ENABLEIF + #endif + + #ifdef OCILIBPP_HAS_VARIADIC + #undef OCILIBPP_HAS_VARIADIC + #endif + +#endif + +#ifdef OCILIBPP_DEFINE_CXX_KEYWORDS + + #define nullptr 0 #define override #define noexcept +#endif + +namespace ocilib +{ +#ifdef OCILIBPP_HAS_ENABLEIF + + template + using EnableIf = std::enable_if; + + template + using IsSame = std::is_same; + +#else + template struct EnableIf {}; diff --git a/include/ocilib_impl.hpp b/include/ocilib_impl.hpp index fd4b5566..5a51fca7 100644 --- a/include/ocilib_impl.hpp +++ b/include/ocilib_impl.hpp @@ -48,7 +48,6 @@ // ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment // - #pragma once #include @@ -60,6 +59,87 @@ namespace ocilib * IMPLEMENTATION * ********************************************************************************************* */ +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + +struct MemoryAllocation +{ + void* Address; + const char* Name; + size_t Size; + size_t Count; +}; + +class MemoryDebugInfo +{ +private: + std::vector Allocations; +public: + + template + void OnAllocate(T* address, size_t count) + { + Allocations.push_back({ address, typeid(T).name(), sizeof(T), count }); + } + + template + void OnDeallocate(T* address) + { + auto it = std::find_if(std::begin(Allocations), std::end(Allocations), [address](const auto& alloc) + { + return alloc.Address == address; + }); + if (it != std::end(Allocations)) + { + Allocations.erase(it); + } + } + + void PrintAllocations() + { + if (Allocations.empty()) return; + + std::cout << "Unfreed memory found" << std::endl; + + for (auto& alloc : Allocations) + { + std::cout << "=> Address " << alloc.Address + << " - Size " << alloc.Count + << " - Count " << alloc.Size + << " - Type " << alloc.Name + << std::endl; + } + } +}; + +inline MemoryDebugInfo& GetMemoryDebugInfo() +{ + static MemoryDebugInfo memoryDebugInfo; + + return memoryDebugInfo; +} + +#endif + +template +static T* OnAllocate(T* address, size_t count = 1) +{ +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + GetMemoryDebugInfo().OnAllocate(address, count); +#endif + + return address; +} + +template +static T* OnDeallocate(T* address) +{ +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + GetMemoryDebugInfo().OnDeallocate(address); +#endif + + return address; +} + /** * Catch silently any exception thrown in the given expression * Used for compliance with the standard (copy constructor, assignment operator, destructor) @@ -449,14 +529,14 @@ ManagedBuffer::ManagedBuffer(T *buffer, size_t size) : _buffer(buffer), _size } template -ManagedBuffer::ManagedBuffer(size_t size) : _buffer(new T[size]), _size(size) +ManagedBuffer::ManagedBuffer(size_t size) : _buffer(OnAllocate(new T[size], size)), _size(size) { memset(_buffer, 0, sizeof(T) * _size); } template ManagedBuffer::~ManagedBuffer() noexcept { - delete [] _buffer; + delete OnDeallocate(_buffer); } template @@ -549,7 +629,7 @@ void HandleHolder::Acquire(T handle, HandleFreeFunc handleFreefunc, SmartHand if (!_smartHandle) { - _smartHandle = new SmartHandle(this, handle, handleFreefunc, freeNotifyFunc, parent); + _smartHandle = OnAllocate(new SmartHandle(this, handle, handleFreefunc, freeNotifyFunc, parent)); } else { @@ -871,7 +951,7 @@ void HandleHolder::SmartHandle::DeleteHandle(Handle *handle) handle->DetachFromParent(); handle->DetachFromHolders(); - delete handle; + delete OnDeallocate(handle); } } @@ -897,7 +977,7 @@ void HandleHolder::SmartHandle::Release(HandleHolder *holder) if (_holders.GetSize() == 0) { - delete this; + delete OnDeallocate(this); } holder->_smartHandle = nullptr; @@ -1066,6 +1146,13 @@ inline void Environment::Cleanup() Environment* handle = static_cast(OCI_GetUserData(nullptr)); OCI_SetUserData(nullptr, handle); + +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + + ocilib::GetMemoryDebugInfo().PrintAllocations(); + +#endif + } inline Environment::EnvironmentFlags Environment::GetMode() @@ -4670,12 +4757,12 @@ inline BindArray::BindArray(const Statement &statement, const ostring& name, uns template void BindArray::SetVector(std::vector & vector, bool isPlSqlTable, unsigned int elemSize) { - _object = new BindArrayObject(_statement, GetName(), vector, isPlSqlTable, GetMode(), elemSize); + _object = OnAllocate(new BindArrayObject(_statement, GetName(), vector, isPlSqlTable, GetMode(), elemSize)); } inline BindArray::~BindArray() noexcept { - delete _object; + delete OnDeallocate(_object); } template @@ -4727,7 +4814,7 @@ BindArray::BindArrayObject::~BindArrayObject() noexcept template void BindArray::BindArrayObject::AllocData() { - _data = new NativeType[_elemCount]; + _data = OnAllocate(new NativeType[_elemCount], _elemCount); memset(_data, 0, sizeof(NativeType) * _elemCount); } @@ -4735,23 +4822,27 @@ void BindArray::BindArrayObject::AllocData() template<> inline void BindArray::BindArrayObject::AllocData() { - _data = new otext[_elemSize * _elemCount]; + const size_t count = _elemSize * _elemCount; + + _data = OnAllocate(new otext[count], count); - memset(_data, 0, _elemSize * _elemCount * sizeof(otext)); + memset(_data, 0, count * sizeof(otext)); } template<> inline void BindArray::BindArrayObject ::AllocData() { - _data = new unsigned char[_elemSize * _elemCount]; + const size_t count = _elemSize * _elemCount; + + _data = OnAllocate(new unsigned char[count], count); - memset(_data, 0, _elemSize * _elemCount * sizeof(unsigned char)); + memset(_data, 0, count * sizeof(unsigned char)); } template void BindArray::BindArrayObject::FreeData() const { - delete [] _data ; + delete [] OnDeallocate(_data); } template @@ -4931,16 +5022,16 @@ template BindObjectAdaptor::BindObjectAdaptor(const Statement &statement, const ostring& name, unsigned int mode, ObjectType &object, unsigned int size) : BindObject(statement, name, mode), _object(object), - _data(new NativeType[size + 1]), + _data(OnAllocate(new NativeType[size+1], size+1)), _size(size) { - memset(_data, 0, _size * sizeof(NativeType)); + memset(_data, 0, (_size+1) * sizeof(NativeType)); } template BindObjectAdaptor::~BindObjectAdaptor() noexcept { - delete [] _data; + delete OnDeallocate(_data); } template @@ -4975,7 +5066,7 @@ template BindTypeAdaptor::BindTypeAdaptor(const Statement &statement, const ostring& name, unsigned int mode, ObjectType &object) : BindObject(statement, name, mode), _object(object), -_data(new NativeType) +_data(OnAllocate(new NativeType)) { } @@ -4983,7 +5074,7 @@ _data(new NativeType) template BindTypeAdaptor::~BindTypeAdaptor() noexcept { - delete _data; + delete OnDeallocate(_data); } template @@ -5030,7 +5121,7 @@ inline void BindsHolder::Clear() for(it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) { - delete (*it); + delete OnDeallocate(*it); } _bindObjects.clear(); @@ -5044,9 +5135,11 @@ inline void BindsHolder::AddBindObject(BindObject *bindObject) for(it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) { - if ((*it)->GetName() == bindObject->GetName()) + BindObject *previousBindObject = *it; + if (previousBindObject->GetName() == bindObject->GetName()) { _bindObjects.erase(it); + delete OnDeallocate(previousBindObject); break; } } @@ -5341,7 +5434,7 @@ void Statement::Bind2(M &method, const ostring& name, T& value, BindInfo::BindDi template void Statement::BindVector1(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) { - BindArray * bnd = new BindArray(*this, name, mode); + BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); bnd->SetVector(values, type == BindInfo::AsPlSqlTable, sizeof(typename BindResolver::OutputType)); const boolean res = method(*this, name.c_str(), bnd->GetData(), bnd->GetSizeForBindCall()); @@ -5354,7 +5447,7 @@ void Statement::BindVector1(M &method, const ostring& name, std::vector &valu } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -5363,7 +5456,7 @@ void Statement::BindVector1(M &method, const ostring& name, std::vector &valu template void Statement::BindVector2(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, U subType, BindInfo::VectorType type) { - BindArray * bnd = new BindArray(*this, name, mode); + BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); bnd->SetVector(values, type == BindInfo::AsPlSqlTable, sizeof(typename BindResolver::OutputType)); const boolean res = method(*this, name.c_str(), bnd->GetData(), subType, bnd->GetSizeForBindCall()); @@ -5376,7 +5469,7 @@ void Statement::BindVector2(M &method, const ostring& name, std::vector &valu } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -5385,7 +5478,7 @@ void Statement::BindVector2(M &method, const ostring& name, std::vector &valu template<> inline void Statement::Bind(const ostring& name, bool &value, BindInfo::BindDirection mode) { - BindTypeAdaptor * bnd = new BindTypeAdaptor(*this, name, mode, value); + BindTypeAdaptor * bnd = OnAllocate(new BindTypeAdaptor(*this, name, mode, value)); const boolean res = OCI_BindBoolean(*this, name.c_str(), static_cast(*bnd)); @@ -5397,7 +5490,7 @@ inline void Statement::Bind(const ostring& name, bool &value, BindInfo::Bi } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -5553,7 +5646,7 @@ inline void Statement::Bind(const ostring& name, ostring value.reserve(maxSize); - BindObjectAdaptor * bnd = new BindObjectAdaptor(*this, name, mode, value, maxSize + 1); + BindObjectAdaptor * bnd = OnAllocate(new BindObjectAdaptor(*this, name, mode, value, maxSize + 1)); const boolean res = OCI_BindString(*this, name.c_str(), static_cast(*bnd), maxSize); @@ -5565,7 +5658,7 @@ inline void Statement::Bind(const ostring& name, ostring } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -5587,7 +5680,7 @@ inline void Statement::Bind(const ostring& name, Raw &value, value.reserve(maxSize); - BindObjectAdaptor * bnd = new BindObjectAdaptor(*this, name, mode, value, maxSize); + BindObjectAdaptor * bnd = OnAllocate(new BindObjectAdaptor(*this, name, mode, value, maxSize)); const boolean res = OCI_BindRaw(*this, name.c_str(), static_cast(*bnd), maxSize); @@ -5599,7 +5692,7 @@ inline void Statement::Bind(const ostring& name, Raw &value, } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -5747,7 +5840,7 @@ void Statement::Bind(const ostring& name, std::vector > &values, T template<> inline void Statement::Bind(const ostring& name, std::vector &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) { - BindArray * bnd = new BindArray(*this, name, mode); + BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); bnd->SetVector(values, type == BindInfo::AsPlSqlTable, maxSize+1); const boolean res = OCI_BindArrayOfStrings(*this, name.c_str(), bnd->GetData(), maxSize, bnd->GetSizeForBindCall()); @@ -5760,7 +5853,7 @@ inline void Statement::Bind(const ostring& name, std::vec } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -5775,7 +5868,7 @@ inline void Statement::Bind(const ostring& name, std::vector inline void Statement::Bind(const ostring& name, std::vector &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) { - BindArray * bnd = new BindArray(*this, name, mode); + BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); bnd->SetVector(values, type == BindInfo::AsPlSqlTable, maxSize); const boolean res = OCI_BindArrayOfRaws(*this, name.c_str(), bnd->GetData(), maxSize, bnd->GetSizeForBindCall()); @@ -5788,7 +5881,7 @@ inline void Statement::Bind(const ostring& name, std::vector< } else { - delete bnd; + delete OnDeallocate(bnd); } Check(res); @@ -6090,7 +6183,7 @@ inline void Statement::ReleaseResultsets() const { handle->DetachFromHolders(); - delete handle; + delete OnDeallocate(handle); handle = nullptr; } @@ -6113,7 +6206,7 @@ inline void Statement::OnFreeSmartHandle(SmartHandle *smartHandle) smartHandle->SetExtraInfos(nullptr); - delete bindsHolder; + delete OnDeallocate(bindsHolder); } } @@ -6128,7 +6221,7 @@ inline BindsHolder * Statement::GetBindsHolder(bool create) const if (bindsHolder == nullptr && create) { - bindsHolder = new BindsHolder(*this); + bindsHolder = OnAllocate(new BindsHolder(*this)); _smartHandle->SetExtraInfos(bindsHolder); } From 0f7d0c22fad00c38cbc313afc47afa390ffb3122 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sat, 9 May 2020 16:14:44 +0200 Subject: [PATCH 13/62] Added location i error message --- src/error.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/error.c b/src/error.c index 43ff1862..37178140 100644 --- a/src/error.c +++ b/src/error.c @@ -112,23 +112,36 @@ void ErrorSet err->source_type = source_type; err->row = row; - size_t len = ostrlen(message); - if (err->message_len < len) + const otext* format = OTEXT("Error occured at %s: %s"); + + const size_t format_len = ostrlen(format); + const size_t message_len = message ? ostrlen(message) : 0; + const size_t location_len = location ? strlen(location) : 0; + const size_t total_len = format_len + message_len + location_len; + + /* allocate storage for location */ + if (err->location_len < location_len) { - err->message = realloc(err->message, len + 1); + err->location = realloc(err->location, location_len + 1); } - ostrcpy(err->message, message); - err->message_len = (unsigned int) len; + /* convert location if needed */ + + StringAnsiToNative(location, err->location, (unsigned int) location_len); + err->location_len = max(err->location_len, (unsigned int) location_len); - len = strlen(location); - if (err->location_len < len) + /* allocate storage for message */ + + if (err->message_len < total_len) { - err->location = realloc(err->location, len + 1); + err->message = realloc(err->message, total_len + 1); } - StringAnsiToNative(location, err->location, (unsigned int) len); - err->location_len = (unsigned int) len; + /* format message */ + + osprintf(err->message, (int)total_len, format, err->location, message); + + err->message_len = max(err->message_len, (unsigned int) location_len); } /* --------------------------------------------------------------------------------------------- * From 86dbc2ccde87ab5d5961293600e799c7b4bbda36 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sat, 9 May 2020 16:30:20 +0200 Subject: [PATCH 14/62] Bumped version to 4.7.0 --- ChangeLog | 8 ++++++++ VERSION | 2 +- doxygen/Doxyfile.dox | 2 +- doxygen/Introduction.txt | 2 +- nuget/ocilib.nuspec | 4 ++-- proj/dll/main.rc | 16 ++++++++-------- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b2a40e6a..d7edd8e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-05-16 Version 4.7.0 Vincent Rogier vince.rogier@ocilib.net + + * Enhancements (C API) + + * Fixes (C API) + + * Fixes (C++ API) + 2020-04-18 Version 4.6.4 Vincent Rogier vince.rogier@ocilib.net * Fixes (C API) diff --git a/VERSION b/VERSION index ef36c9a7..f6cdf409 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.6.4 +4.7.0 diff --git a/doxygen/Doxyfile.dox b/doxygen/Doxyfile.dox index a3d30b0b..3f5725aa 100644 --- a/doxygen/Doxyfile.dox +++ b/doxygen/Doxyfile.dox @@ -38,7 +38,7 @@ PROJECT_NAME = "OCILIB (C and C++ Driver for Oracle)" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 4.6.4 +PROJECT_NUMBER = 4.7.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doxygen/Introduction.txt b/doxygen/Introduction.txt index d844d222..1a7f4ca2 100644 --- a/doxygen/Introduction.txt +++ b/doxygen/Introduction.txt @@ -19,7 +19,7 @@ @section Version Version information -Current version : 4.6.4 +Current version : 4.7.0 @section Features Main features diff --git a/nuget/ocilib.nuspec b/nuget/ocilib.nuspec index 6bb20d6e..ae043ecb 100644 --- a/nuget/ocilib.nuspec +++ b/nuget/ocilib.nuspec @@ -2,7 +2,7 @@ ocilib - 4.6.4 + 4.7.0 Ocilib Driver for Oracle databases OCILIB is an open source and cross platform Oracle Driver delivering efficient access to Oracle databases. @@ -18,7 +18,7 @@ It requires Oracle Client libraries (Regular or instant client). Vincent Rogier Vincentt Rogier - https://github.com/vrogier/ocilib/releases/tag/v4.6.4 + https://github.com/vrogier/ocilib/releases/tag/v4.7.0 https://github.com/vrogier/ocilib http://ocilib.net/images/logo-160x120.png images\logo-160x120.png diff --git a/proj/dll/main.rc b/proj/dll/main.rc index ac0b29db..1200102e 100644 --- a/proj/dll/main.rc +++ b/proj/dll/main.rc @@ -2,8 +2,8 @@ #include "resource.h" VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,6,4,0 - PRODUCTVERSION 4,6,4,0 + FILEVERSION 4,7,0,0 + PRODUCTVERSION 4,7,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -20,11 +20,11 @@ BEGIN BEGIN VALUE "CompanyName", "Vincent Rogier" VALUE "FileDescription", "Open source C driver for Oracle databases" - VALUE "FileVersion", "4.6.4.0" + VALUE "FileVersion", "4.7.0.0" VALUE "InternalName", "OCILIB" VALUE "LegalCopyright", "Copyright © 2007-2020" VALUE "ProductName", "OCILIB (C driver for Oracle)" - VALUE "ProductVersion", "4.6.4.0" + VALUE "ProductVersion", "4.7.0.0" END END BLOCK "VarFileInfo" @@ -34,8 +34,8 @@ BEGIN END IDR_VERSION VERSIONINFO - FILEVERSION 4,6,4,0 - PRODUCTVERSION 4,6,4,0 + FILEVERSION 4,7,0,0 + PRODUCTVERSION 4,7,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -52,12 +52,12 @@ BEGIN BEGIN VALUE "CompanyName", "Vincent Rogier" VALUE "FileDescription", "Open source C driver for Oracle databases" - VALUE "FileVersion", "4.6.4.0" + VALUE "FileVersion", "4.7.0.0" VALUE "InternalName", "OCILIB.dll" VALUE "LegalCopyright", "Copyright © 2007-2020" VALUE "OriginalFilename", "OCILIB.dll" VALUE "ProductName", "OCILIB (C driver for Oracle)" - VALUE "ProductVersion", "4.6.4.0" + VALUE "ProductVersion", "4.7.0.0" END END BLOCK "VarFileInfo" From 1965ecd0ffe8a76fe1384e224e1aa11a80d4c26d Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sat, 9 May 2020 16:38:15 +0200 Subject: [PATCH 15/62] fixed wrong test --- src/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.c b/src/error.c index 37178140..65362500 100644 --- a/src/error.c +++ b/src/error.c @@ -141,7 +141,7 @@ void ErrorSet osprintf(err->message, (int)total_len, format, err->location, message); - err->message_len = max(err->message_len, (unsigned int) location_len); + err->message_len = max(err->message_len, (unsigned int)total_len); } /* --------------------------------------------------------------------------------------------- * From 18875a15f33d98b3e42d5c3925a6a1b5eff4d386 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sat, 9 May 2020 17:24:35 +0200 Subject: [PATCH 16/62] relocated public C and C++ headers --- include/ocilib.h | 8 +++---- include/ocilib.hpp | 4 ++-- include/{ocilib_api.h => ocilibc/api.h} | 2 +- include/{ocilib_compat.h => ocilibc/compat.h} | 2 +- include/{ocilib_config.h => ocilibc/config.h} | 0 include/{ocilib_types.h => ocilibc/types.h} | 2 +- .../{ocilib_core.hpp => ocilibcpp/core.hpp} | 0 .../{ocilib_impl.hpp => ocilibcpp/impl.hpp} | 0 proj/dll/ocilib_dll_vs2019.vcxproj | 8 +++---- proj/dll/ocilib_dll_vs2019.vcxproj.filters | 24 +++++++++---------- src/Makefile.am | 18 +++++++------- src/Makefile.in | 18 +++++++------- src/defs.h | 2 +- src/types.h | 2 +- 14 files changed, 45 insertions(+), 45 deletions(-) rename include/{ocilib_api.h => ocilibc/api.h} (99%) rename include/{ocilib_compat.h => ocilibc/compat.h} (99%) rename include/{ocilib_config.h => ocilibc/config.h} (100%) rename include/{ocilib_types.h => ocilibc/types.h} (99%) rename include/{ocilib_core.hpp => ocilibcpp/core.hpp} (100%) rename include/{ocilib_impl.hpp => ocilibcpp/impl.hpp} (100%) diff --git a/include/ocilib.h b/include/ocilib.h index cc8c6a82..fd4541d9 100644 --- a/include/ocilib.h +++ b/include/ocilib.h @@ -38,10 +38,10 @@ extern "C" { #endif /* __cplusplus */ -#include "ocilib_config.h" -#include "ocilib_types.h" -#include "ocilib_api.h" -#include "ocilib_compat.h" +#include "ocilibc/config.h" +#include "ocilibc/types.h" +#include "ocilibc/api.h" +#include "ocilibc/compat.h" #ifdef __cplusplus } diff --git a/include/ocilib.hpp b/include/ocilib.hpp index 80c7b0e7..b1a173dd 100644 --- a/include/ocilib.hpp +++ b/include/ocilib.hpp @@ -228,7 +228,7 @@ typedef void * CallbackPointer; /* Including core classes */ -#include "ocilib_core.hpp" +#include "ocilibcpp/core.hpp" /* Defining public classes */ @@ -9212,7 +9212,7 @@ class DirectPath : public HandleHolder } -#include "ocilib_impl.hpp" +#include "ocilibcpp/impl.hpp" #endif diff --git a/include/ocilib_api.h b/include/ocilibc/api.h similarity index 99% rename from include/ocilib_api.h rename to include/ocilibc/api.h index f35f50ab..b79059cf 100644 --- a/include/ocilib_api.h +++ b/include/ocilibc/api.h @@ -34,7 +34,7 @@ #ifndef OCILIB_API_H_INCLUDED #define OCILIB_API_H_INCLUDED -#include "ocilib_types.h" +#include "ocilibc/types.h" /** * @defgroup OcilibCApiInitialization Initializing the library diff --git a/include/ocilib_compat.h b/include/ocilibc/compat.h similarity index 99% rename from include/ocilib_compat.h rename to include/ocilibc/compat.h index 26b857a5..2f4c166c 100644 --- a/include/ocilib_compat.h +++ b/include/ocilibc/compat.h @@ -34,7 +34,7 @@ #ifndef OCILIB_COMPAT_H_INCLUDED #define OCILIB_COMPAT_H_INCLUDED -#include "ocilib_api.h" +#include "ocilibc/api.h" /** * @defgroup OcilibCApi C API diff --git a/include/ocilib_config.h b/include/ocilibc/config.h similarity index 100% rename from include/ocilib_config.h rename to include/ocilibc/config.h diff --git a/include/ocilib_types.h b/include/ocilibc/types.h similarity index 99% rename from include/ocilib_types.h rename to include/ocilibc/types.h index 7a499198..1ab55ad1 100644 --- a/include/ocilib_types.h +++ b/include/ocilibc/types.h @@ -34,7 +34,7 @@ #ifndef OCILIB_OCILIB_TYPES_H_INCLUDED #define OCILIB_OCILIB_TYPES_H_INCLUDED -#include "ocilib_config.h" +#include "ocilibc/config.h" /** * @defgroup OcilibCApi C API diff --git a/include/ocilib_core.hpp b/include/ocilibcpp/core.hpp similarity index 100% rename from include/ocilib_core.hpp rename to include/ocilibcpp/core.hpp diff --git a/include/ocilib_impl.hpp b/include/ocilibcpp/impl.hpp similarity index 100% rename from include/ocilib_impl.hpp rename to include/ocilibcpp/impl.hpp diff --git a/proj/dll/ocilib_dll_vs2019.vcxproj b/proj/dll/ocilib_dll_vs2019.vcxproj index 3adf3072..dbfd58bb 100644 --- a/proj/dll/ocilib_dll_vs2019.vcxproj +++ b/proj/dll/ocilib_dll_vs2019.vcxproj @@ -360,10 +360,10 @@ - - - - + + + + diff --git a/proj/dll/ocilib_dll_vs2019.vcxproj.filters b/proj/dll/ocilib_dll_vs2019.vcxproj.filters index 47de7d3c..8ac98932 100644 --- a/proj/dll/ocilib_dll_vs2019.vcxproj.filters +++ b/proj/dll/ocilib_dll_vs2019.vcxproj.filters @@ -298,18 +298,6 @@ Headers %28OCI%29 - - Headers %28Public%29 - - - Headers %28Public%29 - - - Headers %28Public%29 - - - Headers %28Public%29 - Headers %28Public%29 @@ -340,5 +328,17 @@ Headers %28Private%29 + + Headers %28Public%29 + + + Headers %28Public%29 + + + Headers %28Public%29 + + + Headers %28Public%29 + \ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index fec19ca1..da66c97b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,15 +64,15 @@ libocilib_la_SOURCES= \ libocilib_la_CFLAGS= -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS= @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -include_HEADERS= \ - $(top_srcdir)/include/ocilib.h \ - $(top_srcdir)/include/ocilib_api.h \ - $(top_srcdir)/include/ocilib_compat.h \ - $(top_srcdir)/include/ocilib_config.h \ - $(top_srcdir)/include/ocilib_types.h \ - $(top_srcdir)/include/ocilib.hpp \ - $(top_srcdir)/include/ocilib_core.hpp \ - $(top_srcdir)/include/ocilib_impl.hpp +include_HEADERS= \ + $(top_srcdir)/include/ocilib.h \ + $(top_srcdir)/include/ocilibc/api.h \ + $(top_srcdir)/include/ocilibc/compat.h \ + $(top_srcdir)/include/ocilibc/config.h \ + $(top_srcdir)/include/ocilibc/types.h \ + $(top_srcdir)/include/ocilib.hpp \ + $(top_srcdir)/include/ocilibcpp/core.hpp \ + $(top_srcdir)/include/ocilibcpp/impl.hpp noinst_HEADERS= \ agent.h \ diff --git a/src/Makefile.in b/src/Makefile.in index a70932ce..f6c8453f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -418,15 +418,15 @@ libocilib_la_SOURCES= \ libocilib_la_CFLAGS = -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS = @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -include_HEADERS= \ - $(top_srcdir)/include/ocilib.h \ - $(top_srcdir)/include/ocilib_api.h \ - $(top_srcdir)/include/ocilib_compat.h \ - $(top_srcdir)/include/ocilib_config.h \ - $(top_srcdir)/include/ocilib_types.h \ - $(top_srcdir)/include/ocilib.hpp \ - $(top_srcdir)/include/ocilib_core.hpp \ - $(top_srcdir)/include/ocilib_impl.hpp +include_HEADERS= \ + $(top_srcdir)/include/ocilib.h \ + $(top_srcdir)/include/ocilibc/api.h \ + $(top_srcdir)/include/ocilibc/compat.h \ + $(top_srcdir)/include/ocilibc/config.h \ + $(top_srcdir)/include/ocilibc/types.h \ + $(top_srcdir)/include/ocilib.hpp \ + $(top_srcdir)/include/ocilibcpp/core.hpp \ + $(top_srcdir)/include/ocilibcpp/impl.hpp noinst_HEADERS= \ agent.h \ array.h \ diff --git a/src/defs.h b/src/defs.h index d0a59bbf..cd5ee267 100644 --- a/src/defs.h +++ b/src/defs.h @@ -21,7 +21,7 @@ #ifndef OCILIB_DEFS_H_INCLUDED #define OCILIB_DEFS_H_INCLUDED -#include "ocilib_config.h" +#include "ocilibc/config.h" #include "import.h" diff --git a/src/types.h b/src/types.h index f83f98ab..bde49ed8 100644 --- a/src/types.h +++ b/src/types.h @@ -21,7 +21,7 @@ #ifndef OCILIB_TYPES_H_INCLUDED #define OCILIB_TYPES_H_INCLUDED -#include "ocilib_types.h" +#include "ocilibc/types.h" #include "defs.h" From 1d0afa0d70f45a57c19284193619cba8c12def2b Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 15:59:34 +0200 Subject: [PATCH 17/62] Reorganized C++ headers --- include/ocilib.hpp | 9211 +---------------- include/ocilibcpp/config.hpp | 224 + include/ocilibcpp/core.hpp | 818 +- include/ocilibcpp/detail/Agent.hpp | 58 + include/ocilibcpp/detail/BindInfo.hpp | 85 + include/ocilibcpp/detail/Collection.hpp | 492 + .../ocilibcpp/detail/CollectionElement.hpp | 80 + .../ocilibcpp/detail/CollectionIterator.hpp | 168 + include/ocilibcpp/detail/Column.hpp | 119 + include/ocilibcpp/detail/Connection.hpp | 291 + include/ocilibcpp/detail/Date.hpp | 374 + include/ocilibcpp/detail/Dequeue.hpp | 153 + include/ocilibcpp/detail/DirectPath.hpp | 149 + include/ocilibcpp/detail/Enqueue.hpp | 76 + include/ocilibcpp/detail/Environment.hpp | 313 + include/ocilibcpp/detail/Event.hpp | 63 + include/ocilibcpp/detail/Exception.hpp | 129 + include/ocilibcpp/detail/File.hpp | 137 + include/ocilibcpp/detail/Interval.hpp | 300 + include/ocilibcpp/detail/Lob.hpp | 259 + include/ocilibcpp/detail/Long.hpp | 74 + include/ocilibcpp/detail/Message.hpp | 194 + include/ocilibcpp/detail/Mutex.hpp | 48 + include/ocilibcpp/detail/Number.hpp | 294 + include/ocilibcpp/detail/Object.hpp | 375 + include/ocilibcpp/detail/Pool.hpp | 113 + include/ocilibcpp/detail/Queue.hpp | 54 + include/ocilibcpp/detail/QueueTable.hpp | 56 + include/ocilibcpp/detail/Reference.hpp | 88 + include/ocilibcpp/detail/Resultset.hpp | 469 + include/ocilibcpp/detail/Statement.hpp | 1026 ++ include/ocilibcpp/detail/Subscription.hpp | 86 + include/ocilibcpp/detail/Thread.hpp | 53 + include/ocilibcpp/detail/ThreadKey.hpp | 43 + include/ocilibcpp/detail/Timestamp.hpp | 427 + include/ocilibcpp/detail/Transaction.hpp | 75 + include/ocilibcpp/detail/TypeInfo.hpp | 73 + .../ocilibcpp/detail/core/ConcurrentList.hpp | 122 + .../ocilibcpp/detail/core/ConcurrentMap.hpp | 92 + include/ocilibcpp/detail/core/Enum.hpp | 82 + include/ocilibcpp/detail/core/Flags.hpp | 168 + .../ocilibcpp/detail/core/HandleHolder.hpp | 144 + include/ocilibcpp/detail/core/Lockable.hpp | 61 + include/ocilibcpp/detail/core/Locker.hpp | 69 + .../ocilibcpp/detail/core/ManagedBuffer.hpp | 57 + .../ocilibcpp/detail/core/MemoryDebugInfo.hpp | 90 + include/ocilibcpp/detail/core/SmartHandle.hpp | 171 + include/ocilibcpp/detail/core/Utils.hpp | 111 + .../ocilibcpp/detail/support/BindArray.hpp | 265 + .../ocilibcpp/detail/support/BindObject.hpp | 54 + .../detail/support/BindObjectAdaptor.hpp | 84 + .../ocilibcpp/detail/support/BindResolver.hpp | 83 + .../detail/support/BindTypeAdaptor.hpp | 86 + .../ocilibcpp/detail/support/BindsHolder.hpp | 92 + .../detail/support/NumericTypeResolver.hpp | 45 + include/ocilibcpp/impl.hpp | 7445 ------------- include/ocilibcpp/support.hpp | 201 + include/ocilibcpp/types.hpp | 9042 ++++++++++++++++ 58 files changed, 18499 insertions(+), 17112 deletions(-) create mode 100644 include/ocilibcpp/config.hpp create mode 100644 include/ocilibcpp/detail/Agent.hpp create mode 100644 include/ocilibcpp/detail/BindInfo.hpp create mode 100644 include/ocilibcpp/detail/Collection.hpp create mode 100644 include/ocilibcpp/detail/CollectionElement.hpp create mode 100644 include/ocilibcpp/detail/CollectionIterator.hpp create mode 100644 include/ocilibcpp/detail/Column.hpp create mode 100644 include/ocilibcpp/detail/Connection.hpp create mode 100644 include/ocilibcpp/detail/Date.hpp create mode 100644 include/ocilibcpp/detail/Dequeue.hpp create mode 100644 include/ocilibcpp/detail/DirectPath.hpp create mode 100644 include/ocilibcpp/detail/Enqueue.hpp create mode 100644 include/ocilibcpp/detail/Environment.hpp create mode 100644 include/ocilibcpp/detail/Event.hpp create mode 100644 include/ocilibcpp/detail/Exception.hpp create mode 100644 include/ocilibcpp/detail/File.hpp create mode 100644 include/ocilibcpp/detail/Interval.hpp create mode 100644 include/ocilibcpp/detail/Lob.hpp create mode 100644 include/ocilibcpp/detail/Long.hpp create mode 100644 include/ocilibcpp/detail/Message.hpp create mode 100644 include/ocilibcpp/detail/Mutex.hpp create mode 100644 include/ocilibcpp/detail/Number.hpp create mode 100644 include/ocilibcpp/detail/Object.hpp create mode 100644 include/ocilibcpp/detail/Pool.hpp create mode 100644 include/ocilibcpp/detail/Queue.hpp create mode 100644 include/ocilibcpp/detail/QueueTable.hpp create mode 100644 include/ocilibcpp/detail/Reference.hpp create mode 100644 include/ocilibcpp/detail/Resultset.hpp create mode 100644 include/ocilibcpp/detail/Statement.hpp create mode 100644 include/ocilibcpp/detail/Subscription.hpp create mode 100644 include/ocilibcpp/detail/Thread.hpp create mode 100644 include/ocilibcpp/detail/ThreadKey.hpp create mode 100644 include/ocilibcpp/detail/Timestamp.hpp create mode 100644 include/ocilibcpp/detail/Transaction.hpp create mode 100644 include/ocilibcpp/detail/TypeInfo.hpp create mode 100644 include/ocilibcpp/detail/core/ConcurrentList.hpp create mode 100644 include/ocilibcpp/detail/core/ConcurrentMap.hpp create mode 100644 include/ocilibcpp/detail/core/Enum.hpp create mode 100644 include/ocilibcpp/detail/core/Flags.hpp create mode 100644 include/ocilibcpp/detail/core/HandleHolder.hpp create mode 100644 include/ocilibcpp/detail/core/Lockable.hpp create mode 100644 include/ocilibcpp/detail/core/Locker.hpp create mode 100644 include/ocilibcpp/detail/core/ManagedBuffer.hpp create mode 100644 include/ocilibcpp/detail/core/MemoryDebugInfo.hpp create mode 100644 include/ocilibcpp/detail/core/SmartHandle.hpp create mode 100644 include/ocilibcpp/detail/core/Utils.hpp create mode 100644 include/ocilibcpp/detail/support/BindArray.hpp create mode 100644 include/ocilibcpp/detail/support/BindObject.hpp create mode 100644 include/ocilibcpp/detail/support/BindObjectAdaptor.hpp create mode 100644 include/ocilibcpp/detail/support/BindResolver.hpp create mode 100644 include/ocilibcpp/detail/support/BindTypeAdaptor.hpp create mode 100644 include/ocilibcpp/detail/support/BindsHolder.hpp create mode 100644 include/ocilibcpp/detail/support/NumericTypeResolver.hpp delete mode 100644 include/ocilibcpp/impl.hpp create mode 100644 include/ocilibcpp/support.hpp create mode 100644 include/ocilibcpp/types.hpp diff --git a/include/ocilib.hpp b/include/ocilib.hpp index b1a173dd..f415e57f 100644 --- a/include/ocilib.hpp +++ b/include/ocilib.hpp @@ -26,32 +26,9 @@ * */ -// -// ReSharper inspection rules customization (mainly for C98 backward compatibility) -// -// ReSharper disable CppClassCanBeFinal -// ReSharper disable CppUnusedIncludeDirective -// ReSharper disable CppFunctionIsNotImplemented -// ReSharper disable CppClangTidyReadabilityRedundantDeclaration -// ReSharper disable CppClangTidyHicppSpecialMemberFunctions -// ReSharper disable CppClangTidyCppcoreguidelinesSpecialMemberFunctions -// - #ifndef OCILIBCPP_H_INCLUDED #define OCILIBCPP_H_INCLUDED -/* includes */ - -#include -#include -#include -#include -#include - -extern "C"{ -#include "ocilib.h" -} - /** * @namespace ocilib * @brief OCILIB ++ Namespace @@ -72,7 +49,7 @@ namespace ocilib * @par Introduction * OCILIB++ is a C++ API for Oracle built on top of the C OCILIB API: * - Full C API ported to C++ - * - Implemented as a small set of header files, no library compilation needed + * - Implemented as a set of header files, no library compilation needed * - Based on C++ and STL paradigms (Strong typing, templates, containers, RAII, exception handling, operators, stack objects) * - Based on design patterns (RAII, delegation, reference counting, smart pointers, proxies, singleton) * - No user dynamic object allocation required @@ -80,7 +57,7 @@ namespace ocilib * * @par C++ language requirements * - The OCILIB C++ API requires only C++03 features. - * - There are no dependencies on recent C++11 norm or C++14 draft. + * - It does not required C++11/14/17 but uses some CXX features when target compiler support them * * @par Reference counting model * - API usage is very simple, based on stack objects wrapping OCILIB handles using reference counting. @@ -112,9107 +89,129 @@ namespace ocilib * @} */ -/** - * @defgroup OcilibCppApiMainDemoApplication OCILIB main C++ demo application code - * @{ - * - * Main C++ demo source - * @include ocilib_demo.cpp - * - * @} - */ - -/** - * @defgroup OcilibCppApiDemoListApplication Some OCILIB C++ sample codes - * @{ - * - * Here are some C++ samples code. More samples can be found under the demo folder of ocilib packages. - * - * @par Fetching data - * @include fetch.cpp - * - * @par Binding vectors - * @include array.cpp - * - * @par Using collections - * @include coll.cpp - * - * @par Using connection pools - * @include pool.cpp - * - * @par Oracle 12c Implicit resultsets - * @include implicit_resultset.cpp - * - * @par Using Oracle objects - * @include object.cpp - * - * @par Database notifications - * @include notification.cpp - * - * @} - */ - -/** -* -* @} -*/ - -/** - * @typedef ocilib::ostring - * - * @brief - * string class wrapping the OCILIB otext * type and OTEXT() macros ( see @ref OcilibCApiSupportedCharsets ) - * - * @note - * - for ANSI builds, ocilib::ostring is equivalent to std::string - * - for UNICODE builds, ocilib::ostring is equivalent to std::wstring - * - */ -typedef std::basic_string, std::allocator > ostring; - -/** - * @typedef ocilib::AnyPointer - * - * @brief - * Alias for the generic void pointer - * - */ -typedef void * AnyPointer; - -/** -* @typedef ocilib::Raw -* -* @brief -* C++ counterpart of SQL RAW data type -* -*/ -typedef std::vector Raw; - -/** - * @typedef ocilib::MutexHandle - * - * @brief - * Alias for an OCI_Mutex pointer - * - */ -typedef OCI_Mutex * MutexHandle; - -/** - * @typedef ocilib::ThreadHandle - * - * @brief - * Alias for an OCI_Thread pointer - * - */ -typedef OCI_Thread * ThreadHandle; - -/** -* @typedef ocilib::ThreadId -* -* @brief -* Thread Unique ID -* -*/ -typedef const void * ThreadId; - -/** - * @typedef ocilib::CallbackPointer - * - * @brief - * Alias used for storing user callback method pointers - * - */ -typedef void * CallbackPointer; - } -/* Including core classes */ - -#include "ocilibcpp/core.hpp" - -/* Defining public classes */ - -namespace ocilib -{ - -/** -* @brief -* Oracle Version enumerated values -* -*/ -enum OracleVersionValues -{ - Oracle80 = OCI_8_0, - Oracle8i = OCI_8_1, - Oracle9iR1 = OCI_9_0, - Oracle9iR2 = OCI_9_2, - Oracle10gR1 = OCI_10_1, - Oracle10gR2 = OCI_10_2, - Oracle11gR1 = OCI_11_1, - Oracle11gR2 = OCI_11_2, - Oracle12cR1 = OCI_12_1, - Oracle12cR2 = OCI_12_2, - Oracle18cR1 = OCI_18_1, - Oracle18cR2 = OCI_18_2, - Oracle18cR3 = OCI_18_3, - Oracle18cR4 = OCI_18_4 -}; - -/** -* @brief -* Oracle Version -* -* Possible values are DataTypeValues -* -*/ -typedef Enum OracleVersion; - -/** -* @brief -* Data type enumerated values -* -*/ -enum DataTypeValues -{ - /** NUMERIC */ - TypeNumeric = OCI_CDT_NUMERIC, - /** DATE */ - TypeDate = OCI_CDT_DATETIME, - /** TEXT */ - TypeString = OCI_CDT_TEXT, - /** LONG / LONG RAW */ - TypeLong = OCI_CDT_LONG, - /** SQL CURSOR */ - TypeStatement = OCI_CDT_CURSOR, - /** CLOB or BLOB */ - TypeLob = OCI_CDT_LOB, - /** FILE */ - TypeFile = OCI_CDT_FILE, - /** TIMESTAMP */ - TypeTimestamp = OCI_CDT_TIMESTAMP, - /** INTERVAL */ - TypeInterval = OCI_CDT_INTERVAL, - /** RAW */ - TypeRaw = OCI_CDT_RAW, - /** Object type */ - TypeObject = OCI_CDT_OBJECT, - /** Collection */ - TypeCollection = OCI_CDT_COLLECTION, - /** Object REF */ - TypeReference = OCI_CDT_REF, - /** PL/SQL boolean */ - TypeBoolean = OCI_CDT_BOOLEAN -}; - -/** -* @brief -* Column data type -* -* Possible values are DataTypeValues -* -*/ -typedef Enum DataType; - -/** -* @brief -* Numeric type enumerated values -* -*/ -enum NumericTypeValues -{ - /** Signed short */ - NumericShort = OCI_NUM_SHORT, - /** Signed Integer */ - NumericInt = OCI_NUM_INT, - /** Signed Big Integer (Integer or Long Integer depending on the compiler )*/ - NumericBigInt = OCI_NUM_BIGINT, - /** Unsigned short */ - NumericUnsignedShort = OCI_NUM_USHORT, - /** Unsigned Integer */ - NumericUnsignedInt = OCI_NUM_UINT, - /** Unsigned Big Integer (Integer or Long Integer depending on the compiler )*/ - NumericUnsignedBigInt = OCI_NUM_BIGUINT, - /** Double */ - NumericDouble = OCI_NUM_DOUBLE, - /** Float */ - NumericFloat = OCI_NUM_FLOAT, - /** Number */ - NumericNumber = OCI_NUM_NUMBER -}; - -/** -* @brief -* Numeric data type -* -* Possible values are NumericTypeValues -* -*/ -typedef Enum NumericType; - -/** -* @brief -* Charset form enumerated values -* -*/ -enum CharsetFormValues -{ - /** Database character set will be converted to the server national character set */ - CharsetFormDefault = OCI_CSF_DEFAULT, - /** Client national character set will be converted to the server national character set */ - CharsetFormNational = OCI_CSF_NATIONAL -}; - -/** -* @brief -* Type of charsetForm -* -* Possible values are CharsetFormValues -* -*/ -typedef Enum CharsetForm; - -/** -* @brief -* Collation ID enumerated values -* -*/ -enum CollationIDValues -{ - /** None */ - CollationIDNone = OCI_CCI_NONE, - /** Compare */ - CollationIDNlsComp = OCI_CCI_NLS_COMP, - /** Sort */ - CollationIDNlsSort = OCI_CCI_NLS_SORT, - /** Sort CI */ - CollationIDNlsSortCI = OCI_CCI_NLS_SORT_CI, - /** Sort AI */ - CollationIDNlsSortAI = OCI_CCI_NLS_SORT_AI, - /** Sort CS */ - CollationIDNlsSortCS = OCI_CCI_NLS_SORT_CS, - /** Sort VAR 1 */ - CollationIDNlsSortVar1 = OCI_CCI_NLS_SORT_VAR1, - /** Sort VAR 1 CI */ - CollationIDNlsSortVar1CI = OCI_CCI_NLS_SORT_VAR1_CI, - /** Sort VAR 1 AI */ - CollationIDNlsSortVar1AI = OCI_CCI_NLS_SORT_VAR1_AI, - /** Sort VAR 1 CS */ - CollationIDNlsSortVar1CS = OCI_CCI_NLS_SORT_VAR1_CS, - /** Binary */ - CollationIDBinary = OCI_CCI_BINARY, - /** Binary CI */ - CollationIDBinaryCI = OCI_CCI_BINARY_CI, - /** Binary AI */ - CollationIDBinaryAI = OCI_CCI_BINARY_AI -}; - -/** -* @brief -* Type of Collation ID -* -* Possible values are CollationIDValues -* -*/ -typedef Enum CollationID; - - -/** -* @brief -* Seek Modes enumerated values -* -*/ -enum SeekModeValues -{ - /** Set the current position within the stream to the given position */ - SeekSet = OCI_SEEK_SET, - /** Set the current position within the stream begin position */ - SeekEnd = OCI_SEEK_END, - /** Set the current position within the stream to the given value offset from the current position */ - SeekOffset = OCI_SEEK_CUR -}; - -/** -* @brief -* Seek Modes -* -* Possible values are SeekModeValues -* -*/ -typedef Enum SeekMode; - -/** -* @brief -* Open Modes enumerated values -* -*/ -enum OpenModeValues -{ - /** Stream is opened for read access */ - ReadOnly = OCI_LOB_READONLY, - /** Stream is opened for read / write access */ - ReadWrite = OCI_LOB_READWRITE -}; - -/** -* @brief -* Open Modes -* -* Possible values are OpenModeValues -* -*/ -typedef Enum OpenMode; - -/** -* @brief -* Lob types enumerated values -* -*/ -enum LobTypeValues -{ - /** */ - LobBinary = OCI_BLOB, - /** */ - LobCharacter = OCI_CLOB, - /** */ - LobNationalCharacter = OCI_NCLOB -}; - -/** -* @brief -* Type of Lob -* -* Possible values are LobTypeValues -* -*/ -typedef Enum LobType; - -/** -* @brief -* Long types enumerated values -* -*/ -enum LongTypeValues -{ - /** */ - LongBinary = OCI_BLONG, - /** */ - LongCharacter = OCI_CLONG -}; - -/** -* @brief -* Type of Long -* -* Possible values are LongTypeValues -* -*/ -typedef Enum LongType; - -/** -* @brief -* Format type enumerated values -* -*/ -enum FormatTypeValues -{ - /** Date */ - FormatDate = OCI_FMT_DATE, - /** Timestamp */ - FormatTimestamp = OCI_FMT_TIMESTAMP, - /** All numeric types */ - FormatNumeric = OCI_FMT_NUMERIC, - /** BinaryDouble */ - FormatBinaryDouble = OCI_FMT_BINARY_DOUBLE, - /** Binary Float */ - FormatBinaryFloat = OCI_FMT_BINARY_FLOAT -}; - -/** -* @brief -* Format type -* -* Possible values are FormatTypeValues -* -*/ -typedef Enum FormatType; - -/** - * - * @brief - * Exception class handling all OCILIB errors - * - * This class wraps the OCILIB object handle OCI_Error and its related methods - * - */ -class Exception : public std::exception -{ - template - friend T Check(T result); - friend class Statement; - -public: - - /** - * @brief - * Exception type enumerated values - * - */ - enum ExceptionTypeValues - { - /** Exception caused by an Oracle error */ - OracleError = OCI_ERR_ORACLE, - /** Exception caused by an Ocilib error */ - OcilibError = OCI_ERR_OCILIB, - /** Exception caused by an Oracle Warning */ - OracleWarning = OCI_ERR_WARNING - }; - - /** - * @brief - * Type of Exception - * - * Possible values are Exception::ExceptionTypeValues - * - */ - typedef Enum ExceptionType; - - /** - * @brief - * Retrieve the error message - * - */ - ostring GetMessage() const; - - /** - * - * @brief - * Return the Exception type - * - */ - ExceptionType GetType() const; - - /** - * @brief - * Return the Oracle error code - * - */ - int GetOracleErrorCode() const; - - /** - * @brief - * Return the OCILIB error code - * - */ - int GetInternalErrorCode() const; - - /** - * @brief - * Return the statement within the error occurred - * - */ - Statement GetStatement() const; - - /** - * @brief - * Return the connection within the error occurred - * - */ - Connection GetConnection() const; - - /** - * @brief - * Return the row index which caused an error during statement execution - * - * @warning - * Row index start at 1. - * - * @return - * - 0 if the error is not related to array DML - * - otherwise the index of the given row which caused the error - * - */ - unsigned int GetRow() const; - - /** - * @brief - * Override the std::exception::what() method - * - * @return - * - The same content as GetMessage() but as using const char * type - * - */ - const char *what() const noexcept override; - - Exception(const Exception& other) noexcept; - - Exception& operator = (const Exception &other) noexcept; - - /** - * @brief - * Virtual destructor required for deriving from std::exception - * - */ - virtual ~Exception() noexcept; - -private: - - Exception() noexcept; - Exception(OCI_Error *err) noexcept; - - void SetWhat(const otext* value) noexcept; - - otext* _what; - OCI_Statement *_pStatement; - OCI_Connection *_pConnnection; - unsigned int _row; - ExceptionType _type; - int _errLib; - int _errOracle; -}; - -/** - * @brief - * Static class in charge of library initialization / cleanup - * - */ -class Environment -{ - friend class Mutex; - friend class Connection; - friend class Pool; - friend class Subscription; - friend class Dequeue; - template - friend class HandleHolder; - -public: - - /** - * @brief - * HA Event sources enumerated values - * - */ - enum HAEventSourceValues - { - /** The event has been generated by an Oracle instance */ - SourceInstance = OCI_HES_INSTANCE, - /** The event has been generated by an Oracle database */ - SourceDatabase = OCI_HES_DATABASE, - /** The event has been generated by an Oracle Node */ - SourceNode = OCI_HES_NODE, - /** The event has been generated by an Oracle service */ - SourceService = OCI_HES_SERVICE, - /** The event has been generated by an Oracle service member */ - SourceServiceMember = OCI_HES_SERVICE_MEMBER, - /** The event has been generated by an Oracle ASM instance */ - SourceASMInstance = OCI_HES_ASM_INSTANCE, - /** The event has been generated at service pre connecting stage */ - SourcePreConnect = OCI_HES_PRECONNECT - }; - - /** - * @brief - * Source of HA events - * - * Possible values are Environment::HAEventSourceValues - * - */ - typedef Enum HAEventSource; - - /** - * @brief - * HA Event types enumerated values - * - */ - enum HAEventTypeValues - { - /** The source of the event is down */ - EventDown = OCI_HET_DOWN, - /** The source of the event is up (not generated yet by Oracle) */ - EventUp = OCI_HET_UP - }; - - /** - * @brief - * Type of HA events - * - * Possible values are Environment::HAEventTypeValues - * - */ - typedef Enum HAEventType; - - /** - * @brief - * Environment Flags enumerated values - * - */ - enum EnvironmentFlagsValues - { - /** Default mode */ - Default = OCI_ENV_DEFAULT, - /** Enable support for multi-threading */ - Threaded = OCI_ENV_THREADED, - /** Enable support for events related to subscriptions, HA and AQ notifications */ - Events = OCI_ENV_EVENTS - }; - - /** - * @brief - * Environment Flags - * - * Possible values are Environment::EnvironmentFlagsValues - * - */ - typedef Flags EnvironmentFlags; - - /** - * @brief - * OCI libraries import mode enumerated values - * - */ - enum ImportModeValues - { - /** OCI libraries are linked at compile time */ - ImportLinkage = OCI_IMPORT_MODE_LINKAGE, - /** OCI libraries are dynamically loaded at runtime */ - ImportRuntime = OCI_IMPORT_MODE_RUNTIME - }; - - /** - * @brief - * OCI libraries import mode - * - * Possible values are Environment::ImportMode - * - */ - typedef Enum ImportMode; - - /** - * @brief - * Charset mode enumerated values - * - */ - enum CharsetModeValues - { - /** Environment is ANSI string or UTF8 string */ - CharsetAnsi = OCI_CHAR_ANSI, - /** Environment is UNICODE using wide character string */ - CharsetWide = OCI_CHAR_WIDE - }; - - /** - * @brief - * Environment charset mode - * - * Possible values are Environment::CharsetModeValues - * - */ - typedef Enum CharsetMode; - - /** - * @brief - * Session flags enumerated values - * - */ - enum SessionFlagsValues - { - /** Default session mode */ - SessionDefault = OCI_SESSION_DEFAULT, - /** Requested session will be created through the XA interface */ - SessionXa = OCI_SESSION_XA, - /** the user is authenticated for SYSDBA access. */ - SessionSysDba = OCI_SESSION_SYSDBA, - /** the user is authenticated for SYSOPER access */ - SessionSysOper = OCI_SESSION_SYSOPER, - /** the user is authenticated for SYSASM access */ - SessionSysAsm = OCI_SESSION_SYSASM, - /** the user is authenticated for SYSBKP access */ - SessionSysBkp = OCI_SESSION_SYSBKP, - /** the user is authenticated for SYSDGD access */ - SessionSysDgD = OCI_SESSION_SYSDGD, - /** the user is authenticated for SYSKMT access */ - SessionSysKmt = OCI_SESSION_SYSKMT, - /** the user is authenticated for SYSRAC access */ - SessionSysRac = OCI_SESSION_SYSRAC, - /** the user is authenticated for PRELIM_AUTH access */ - SessionPreAuth = OCI_SESSION_PRELIM_AUTH - }; - - /** - * @brief - * Sessions flags - * - * Possible values are Environment::SessionFlagsValues - * - */ - typedef Flags SessionFlags; - - /** - * @brief - * Oracle instance start modes enumerated values - * - */ - enum StartModeValues - { - /** Start the instance without mounting and opening it */ - StartOnly = OCI_DB_SPM_START, - /** Mount (only) the instance */ - StartMount = OCI_DB_SPM_MOUNT, - /** Open (only) the instance */ - StartOpen = OCI_DB_SPM_OPEN, - /** Start, mount and open the instance */ - StartFull = OCI_DB_SPM_FULL - }; - - /** - * @brief - * Oracle instance start modes - * - * Possible values are Environment::StartModeValues - * - */ - typedef Flags StartMode; - - /** - * @brief - * Oracle instance start flags enumerated values - * - */ - enum StartFlagsValues - { - /** Default start flags */ - StartDefault = OCI_DB_SPF_DEFAULT, - /** Shuts down a running instance (if needed) using ABORT command and starts a new instance */ - StartForce = OCI_DB_SPF_FORCE, - /** Allows database access only to users with both CREATE SESSION and RESTRICTED SESSION privileges */ - StartRestrict = OCI_DB_SPF_RESTRICT - }; - - /** - * @brief - * Oracle instance start flags - * - * Possible values are Environment::StartFlagsValues - * - */ - typedef Flags StartFlags; - - /** - * @brief - * Oracle instance shutdown modes enumerated values - * - */ - enum ShutdownModeValues - { - /** Shutdown the instance */ - ShutdownOnly = OCI_DB_SDM_SHUTDOWN, - /** Close (only) the instance */ - ShutdownClose = OCI_DB_SDM_CLOSE, - /** Dismount (only) the instance */ - ShutdownDismount = OCI_DB_SDM_DISMOUNT, - /** Shutdown, close and dismount the instance */ - ShutdownFull = OCI_DB_SDM_FULL - }; - - /** - * @brief - * Oracle instance shutdown modes - * - * Possible values are Environment::ShutdownModeValues - * - */ - typedef Flags ShutdownMode; - - /** - * @brief - * Oracle instance shutdown flags enumerated values - * - */ - enum ShutdownFlagsValues - { - /** - Further connects are prohibited. - * - Waits for users to disconnect from the database */ - ShutdowntDefault = OCI_DB_SDF_DEFAULT, - /** - Further connects are prohibited - * - No new transactions are allowed. */ - ShutdowTrans = OCI_DB_SDF_TRANS, - /** - Further connects are prohibited - * - No new transactions are allowed. - * - Waits for active transactions to complete */ - ShutdownTransLocal = OCI_DB_SDF_TRANS_LOCAL, - /** - Does not wait for current calls to complete or users to disconnect from the database. - * - All uncommitted transactions are terminated and rolled back */ - ShutdownImmediate = OCI_DB_SDF_IMMEDIATE, - /** - Does not wait for current calls to complete or users to disconnect from the database. - * - All uncommitted transactions are terminated and are not rolled back. - * - This is the fastest possible way to shut down the database, but the next - * database startup may require instance recovery. - * - Therefore, this option should be used only in unusual circumstances */ - ShutdownAbort = OCI_DB_SDF_ABORT - }; - - /** - * @brief - * Oracle instance shutdown flags - * - * Possible values are Environment::ShutdownFlagsValues - * - */ - typedef Flags ShutdownFlags; - - /** - * @brief - * Allocated Bytes enumerated values - * - */ - enum AllocatedBytesValues - { - /** Allocated bytes by Oracle Client*/ - OracleClientBytes = OCI_MEM_ORACLE, - /** Allocated bytes by OCILIB */ - OcilibBytes = OCI_MEM_OCILIB, - /** All Allocated bytes */ - AllBytes = OCI_MEM_ALL - }; - - /** - * @brief - * Allocated Bytes - * - * Possible values are Environment::AllocatedBytesValues - * - */ - typedef Flags AllocatedBytesFlags; - - /** - * @typedef HAHandlerProc - * - * @brief - * User callback for HA event notifications - * - */ - typedef void(*HAHandlerProc) (Connection &con, HAEventSource eventSource, HAEventType eventType, Timestamp &time); - - /** - * @brief - * Initialize the OCILIB environment - * - * @param mode - Environment mode - * @param libpath - Oracle shared library path (optional) - * - * @note - * This function must be called before any other OCILIB library function. - * - * @warning - * - It should be called ONCE per application - * - It is not thread safe - * - * @note - * - The parameter 'libpath' is only used if OCILIB has been built with the option OCI_IMPORT_RUNTIME - * - If the parameter 'lib_path' is NULL, the Oracle library is loaded from system environment variables - * - */ - static void Initialize(EnvironmentFlags mode = Environment::Default, const ostring& libpath = OTEXT("")); - - /** - * @brief - * Clean up all resources allocated by the environment - * - * @note - * This function must be the last OCILIB library function call. - * - It deallocates objects not explicitly freed by the program (connections, statements, ...) - * - It unloads the Oracle shared library if it has been dynamically loaded - * - * @warning - * - It should be called ONCE per application - * - It is not thread safe - * - */ - static void Cleanup(); - - /** - * @brief - * Return the Environment mode flags - * - * @note - * It returns the value of the parameter 'mode' passed to Initialize() - * - */ - static Environment::EnvironmentFlags GetMode(); - - /** - * @brief - * Return the Oracle shared library import mode - * - */ - static Environment::ImportMode GetImportMode(); - - /** - * @brief - * Return the OCILIB charset type - * - */ - static Environment::CharsetMode GetCharset(); - - /** - * @brief - * Return maximum size for a character - * - * @note - * When Charset is Environment::CharsetAnsi and NLS_LANG is UTF8 based, return value is 4 - * Otherwise, it is sizeof(ostring::value_type) - * - */ - static unsigned int GetCharMaxSize(); - - /** - * @brief - * Return the current number of bytes allocated internally in the library - * - * @param type : type of memory to request - * - */ - static big_uint GetAllocatedBytes(AllocatedBytesFlags type); - - /** - * @brief - * Return true if the environment has been successfully initialized - * - */ - static bool Initialized(); - - /** - * @brief - * Return the version of OCI used for compiling OCILIB - * - * @note - * - with linkage build option, the version is determined from the oci.h header through different ways - * - with runtime loading build option, the version is set to the highest version - * of OCI needed by OCILIB, not necessarily the real OCI version - * - */ - static OracleVersion GetCompileVersion(); - - /** - * @brief - * Return the major version number of OCI used for compiling OCILIB - * - */ - static unsigned int GetCompileMajorVersion(); - - /** - * @brief - * Return the minor version number of OCI used for compiling OCILIB - * - */ - static unsigned int GetCompileMinorVersion(); - - /** - * @brief - * Return the revision version number of OCI used for compiling OCILIB - * - */ - static unsigned int GetCompileRevisionVersion(); - - /** - * @brief - * Return the version of OCI used at runtime - * - * @note - * - with linkage build option, the version is determined from the oci.h header through different ways - * - with runtime loading build option, the version determined from the symbols dynamically loaded. - * - */ - static OracleVersion GetRuntimeVersion(); - - /** - * @brief - * Return the major version number of OCI used at runtime - * - */ - static unsigned int GetRuntimeMajorVersion(); - - /** - * @brief - * Return the minor version number of OCI used at runtime - * - */ - static unsigned int GetRuntimeMinorVersion(); - - /** - * @brief - * Return the revision version number of OCI used at runtime - * - */ - static unsigned int GetRuntimeRevisionVersion(); - - /** - * @brief - * Enable or disable Oracle warning notifications - * - * @param value - enable/disable warnings - * - * @note - * Default value is false - * - */ - static void EnableWarnings(bool value); - - /** - * @brief - * Set the format string for implicit string conversions of the given type - * - * @param formatType - Type of format - * @param format - Format string - * - * Formats can set at 2 levels: - * - Environment level - * - Connection level - * - * When the library needs to perform a string conversion, it search for a valid format using the - * following order: - * - Connection format - * - Library format - * - Default format - * - * @note - * Default format values are : - * - OCI_FMT_DATE : constant OCI_STRING_FORMAT_DATE - * - OCI_FMT_TIMESTAMP : constant OCI_STRING_FORMAT_TIMESTAMP - * - OCI_FMT_NUMERIC : constant OCI_STRING_FORMAT_NUMERIC - * - OCI_FMT_BINARY_DOUBLE : constant OCI_STRING_FORMAT_BINARY_DOUBLE - * - OCI_FMT_BINARY FLOAT : constant OCI_STRING_FORMAT_BINARY_FLOAT - * - * @note - * Conversions are performed by Oracle built-in functions whenever possible. - * For DATE, TIMESTAMP and numeric types, see documentation of Oracle SQL to_char() function for more details - * For BINARY_DOUBLE and BINARY_FLOAT, refer to the C Standard Library printf() family documentation - * - */ - static bool SetFormat(FormatType formatType, const ostring& format); - - /** - * @brief - * Return the format string for implicit string conversions of the given type - * - * @param formatType - Type of format - * - * @note - * See SetFormat() for possible values - * - */ - static ostring GetFormat(FormatType formatType); - - /** - * @brief - * Start a database instance - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param startFlags - Start flags - * @param startMode - Start mode - * @param sessionFlags - Session Flags - * @param spfile - Client-side spfile to start up the database (optional) - * - * @note - * The only valid modes for sessionFlags are SessionSysDba and SessionSysOper. - * - * @note - * Start modes and flags parameters values can be combined. - * - * @note - * External credentials are supported by supplying a empty strings for the 'user' and 'pwd' parameters - * If the parameter 'db' is empty then a connection to the default local DB is done. - * - * @note - * If the client side spfile is not provided, the database is started with its server-side spfile. - * - */ - static void StartDatabase(const ostring &db, const ostring &user, const ostring& pwd, - Environment::StartFlags startFlags, - Environment::StartMode startMode, - Environment::SessionFlags sessionFlags = SessionSysDba, - const ostring& spfile = OTEXT("")); - - /** - * @brief - * Shutdown a database instance - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param shutdownFlags - Shutdown flags - * @param shutdownMode - Shutdown mode - * @param sessionFlags - Session flags - * - * @note - * The only valid modes for sessionFlags are SessionSysDba and SessionSysOper. - * - * @note - * Shutdown modes values can be combined. - * - * @note - * Shutdown flag values are exclusive. - * - * @note - * External credentials are supported by supplying a empty strings for the 'user' and 'pwd' parameters - * If the param 'db' is empty then a connection to the default local DB is done. - * - */ - static void ShutdownDatabase(const ostring& db, const ostring& user, const ostring& pwd, - Environment::ShutdownFlags shutdownFlags, - Environment::ShutdownMode shutdownMode, - Environment::SessionFlags sessionFlags = SessionSysDba); - - /** - * @brief - * Change the password of the given user on the given database - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param newPwd - Oracle User New password - * - */ - static void ChangeUserPassword(const ostring& db, const ostring& user, const ostring& pwd, const ostring& newPwd); - - /** - * @brief - * Set the High availability (HA) user handler - * - * @param handler - HA handler procedure - * - * @note - * See POCI_HA_HANDLER documentation for more details - * - * @note - * EnvMode::Events flag must be passed to Initialize() to be able to use HA events - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - static void SetHAHandler(HAHandlerProc handler); - -private: - - class EnvironmentHandle : HandleHolder < AnyPointer > - { - friend class Environment; - }; - - static void HAHandler(OCI_Connection *pConnection, unsigned int source, unsigned int event, OCI_Timestamp *pTimestamp); - static unsigned int TAFHandler(OCI_Connection *pConnection, unsigned int type, unsigned int event); - static void NotifyHandler(OCI_Event *pEvent); - static void NotifyHandlerAQ(OCI_Dequeue *pDequeue); - - template - static T GetUserCallback(AnyPointer ptr); - - template - static void SetUserCallback(AnyPointer ptr, T callback); - - template - static void SetSmartHandle(AnyPointer ptr, T handle); - - template - static T GetSmartHandle(AnyPointer ptr); - - static Handle * GetEnvironmentHandle(); - - static Environment& GetInstance(); - - Environment(); - - void SelfInitialize(EnvironmentFlags mode, const ostring& libpath); - void SelfCleanup(); - - Locker _locker; - EnvironmentHandle _handle; - ConcurrentMap _handles; - ConcurrentMap _callbacks; - EnvironmentFlags _mode; - unsigned int _charMaxSize; - bool _initialized; -}; - -/** - * @brief - * static class allowing to manipulate threads - * - * This class wraps the OCILIB object handle OCI_Thread and its related methods - * - * @note - * See @ref OcilibCApiThreading for more details on Oracle multi-threading support - * - */ -class Thread -{ -public: - - /** - * @typedef ThreadProc - * - * @brief Thread callback - * - */ - typedef POCI_THREAD ThreadProc; - - /** - * @brief - * Create a Thread - * - * @return - * Thread handle on success or NULL on failure - * - */ - static ThreadHandle Create(); - - /** - * @brief - * Destroy a thread - * - * @param handle - Thread handle - * - */ - static void Destroy(ThreadHandle handle); - - /** - * @brief - * Execute the given routine within the given thread - * - * @param handle - Thread handle - * @param func - routine to execute - * @param arg - parameter to pass to the routine - * - */ - static void Run(ThreadHandle handle, ThreadProc func, AnyPointer arg); - - /** - * @brief - * Join the given thread - * - * @param handle - Thread handle - * - * @note - * This function waits for the given thread to finish - * - */ - static void Join(ThreadHandle handle); - - /** - * @brief - * Return the system Thread ID of the given thread handle - * - * @param handle - Thread handle - * - */ - static ThreadId GetThreadId(ThreadHandle handle); -}; - -/** - * @brief - * Static class allowing managing mutexes - * - * This class wraps the OCILIB object handle OCI_Mutex and its related methods +/* + * IMPORTANT NOTICE * - * See @ref OcilibCApiThreading for more details on Oracle multi-threading support + * This C++ header defines C++ wrapper classes around the OCILIB C API + * It requires a compatible version of OCILIB * */ -class Mutex -{ -public: - /** - * @brief - * Create a Mutex handle - * - * @return - * Mutex handle on success or NULL on failure - * - */ - static MutexHandle Create(); +/* Including declarations */ - /** - * @brief - * Destroy a mutex handle - * - * @param handle - Mutex handle - * - */ - static void Destroy(MutexHandle handle); - - /** - * @brief - * Acquire a mutex lock - * - * @param handle - Mutex handle - * - */ - static void Acquire(MutexHandle handle); - - /** - * @brief - * Release a mutex lock - * - * @param handle - Mutex handle - * - */ - static void Release(MutexHandle handle); -}; +#include "ocilibcpp/config.hpp" +#include "ocilibcpp/core.hpp" +#include "ocilibcpp/support.hpp" +#include "ocilibcpp/types.hpp" + +/* Including core implementations */ + +#include "ocilibcpp/detail/core/Utils.hpp" +#include "ocilibcpp/detail/core/Enum.hpp" +#include "ocilibcpp/detail/core/Flags.hpp" +#include "ocilibcpp/detail/core/ManagedBuffer.hpp" +#include "ocilibcpp/detail/core/HandleHolder.hpp" +#include "ocilibcpp/detail/core/Locker.hpp" +#include "ocilibcpp/detail/core/Lockable.hpp" +#include "ocilibcpp/detail/core/ConcurrentMap.hpp" +#include "ocilibcpp/detail/core/ConcurrentList.hpp" +#include "ocilibcpp/detail/core/SmartHandle.hpp" +#include "ocilibcpp/detail/core/MemoryDebugInfo.hpp" + +/* Including supoprt implementations */ + +#include "ocilibcpp/detail/support/BindResolver.hpp" +#include "ocilibcpp/detail/support/BindObject.hpp" +#include "ocilibcpp/detail/support/BindArray.hpp" +#include "ocilibcpp/detail/support/BindObjectAdaptor.hpp" +#include "ocilibcpp/detail/support/BindTypeAdaptor.hpp" +#include "ocilibcpp/detail/support/BindsHolder.hpp" +#include "ocilibcpp/detail/support/NumericTypeResolver.hpp" + +/* Including types implementations */ + +#include "ocilibcpp/detail/Exception.hpp" +#include "ocilibcpp/detail/Environment.hpp" +#include "ocilibcpp/detail/Mutex.hpp" +#include "ocilibcpp/detail/Thread.hpp" +#include "ocilibcpp/detail/ThreadKey.hpp" +#include "ocilibcpp/detail/Pool.hpp" +#include "ocilibcpp/detail/Connection.hpp" +#include "ocilibcpp/detail/Transaction.hpp" +#include "ocilibcpp/detail/Number.hpp" +#include "ocilibcpp/detail/Date.hpp" +#include "ocilibcpp/detail/Interval.hpp" +#include "ocilibcpp/detail/Timestamp.hpp" +#include "ocilibcpp/detail/Lob.hpp" +#include "ocilibcpp/detail/File.hpp" +#include "ocilibcpp/detail/TypeInfo.hpp" +#include "ocilibcpp/detail/Object.hpp" +#include "ocilibcpp/detail/Reference.hpp" +#include "ocilibcpp/detail/Collection.hpp" +#include "ocilibcpp/detail/CollectionIterator.hpp" +#include "ocilibcpp/detail/CollectionElement.hpp" +#include "ocilibcpp/detail/Long.hpp" +#include "ocilibcpp/detail/BindInfo.hpp" +#include "ocilibcpp/detail/Statement.hpp" +#include "ocilibcpp/detail/Resultset.hpp" +#include "ocilibcpp/detail/Column.hpp" +#include "ocilibcpp/detail/Subscription.hpp" +#include "ocilibcpp/detail/Event.hpp" +#include "ocilibcpp/detail/Agent.hpp" +#include "ocilibcpp/detail/Message.hpp" +#include "ocilibcpp/detail/Enqueue.hpp" +#include "ocilibcpp/detail/Dequeue.hpp" +#include "ocilibcpp/detail/DirectPath.hpp" +#include "ocilibcpp/detail/Queue.hpp" +#include "ocilibcpp/detail/QueueTable.hpp" /** - * @brief - * Static class allowing to set/get thread local storage (TLS) values for a given unique key - * - * This class wraps the OCILIB object handle OCI_ThreadKey and its related methods + * @defgroup OcilibCppApiMainDemoApplication OCILIB main C++ demo application code + * @{ * - * @note - * See @ref OcilibCApiThreading for more details on Oracle multi-threading support + * Main C++ demo source + * @include ocilib_demo.cpp * + * @} */ -class ThreadKey -{ -public: - - /** - * @typedef ThreadKeyFreeProc - * - * @brief Thread Key callback for freeing resources - * - */ - typedef POCI_THREADKEYDEST ThreadKeyFreeProc; - - /** - * @brief - * Create a thread key object - * - * @param name - Thread key name - * @param freeProc - Thread key value destructor function - * - * @note - * Parameter freeProc is optional. It's called when the thread terminates to allow - * the program to deal with the thread specific value of the key - * - */ - static void Create(const ostring& name, ThreadKeyFreeProc freeProc = nullptr); - /** - * @brief - * Set a thread key value - * - * @param name - Thread key name - * @param value - user value to set - * - */ - static void SetValue(const ostring& name, AnyPointer value); - - /** - * @brief - * Get a thread key value - * - * @param name - Thread key name - * - * @return - * Thread key value on success otherwise FALSE - * - */ - static AnyPointer GetValue(const ostring& name); -}; - -/** - * @brief - * A connection or session Pool. + /** + * @defgroup OcilibCppApiDemoListApplication Some OCILIB C++ sample codes + * @{ + * + * Here are some C++ samples code. More samples can be found under the demo folder of ocilib packages. + * + * @par Fetching data + * @include fetch.cpp + * + * @par Binding vectors + * @include array.cpp + * + * @par Using collections + * @include coll.cpp + * + * @par Using connection pools + * @include pool.cpp * - * This class wraps the OCILIB object handle OCI_Pool and its related methods + * @par Oracle 12c Implicit resultsets + * @include implicit_resultset.cpp * + * @par Using Oracle objects + * @include object.cpp + * + * @par Database notifications + * @include notification.cpp + * + * @} */ -class Pool : public HandleHolder -{ -public: - - /** - * @brief - * Pool type enumerated values - * - */ - enum PoolTypeValues - { - /** Pool of Connections */ - ConnectionPool = OCI_POOL_CONNECTION, - /** Pool of stateless sessions */ - SessionPool = OCI_POOL_SESSION - }; - - /** - * @brief - * Type of Pool - * - * Possible values are Pool::PoolTypeValues - * - */ - typedef Enum PoolType; - - /** - * @brief - * Default constructor - * - */ - Pool(); - - /** - * @brief - * Constructor that creates an underlying pool with the given information - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param poolType - Type of pool - * @param sessionFlags - session Flags - * @param minSize - minimum number of connections/sessions that can be opened. - * @param maxSize - maximum number of connections/sessions that can be opened. - * @param increment - next increment for connections/sessions to be opened - * - * @note - * it calls Open() with the given parameters - * - */ - Pool(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, - unsigned int minSize, unsigned int maxSize, unsigned int increment = 1, - Environment::SessionFlags sessionFlags = Environment::SessionDefault); - - /** - * @brief - * Create an Oracle pool of connections or sessions - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param poolType - Type of pool - * @param sessionFlags - session Flags - * @param minSize - minimum number of connections/sessions that can be opened. - * @param maxSize - maximum number of connections/sessions that can be opened. - * @param increment - next increment for connections/sessions to be opened - * - * @note - * External credentials are supported by supplying an empty string for the 'user' and 'pwd' parameters - * If the param 'db' is empty then a connection to the default local DB is done - * - */ - void Open(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, - unsigned int minSize, unsigned int maxSize, unsigned int increment = 1, - Environment::SessionFlags sessionFlags = Environment::SessionDefault); - /** - * @brief - * Destroy the current Oracle pool of connections or sessions - * - */ - void Close(); - - /** - * @brief - * Get a connection from the pool - * - * @param sessionTag - Session user tag string - * - * @par Session tagging - * - * Session pools have a nice feature called 'session tagging' - * It's possible to tag a session with a string identifier - * when the session is returned to the pool, it keeps its tags. - * When requesting a connection from the session pool, it's - * possible to request a session that has the given 'tag' parameter - * If one exists, it is returned. If not and if an untagged session - * is available, it is then returned. So check the connection tag - * property with OCI_GetSessionTag() to find out if the returned - * connection is tagged or not. - * - * This features is described in the OCI developer guide as the following : - * - * "The tags provide a way for users to customize sessions in the pool. - * A client may get a default or untagged session from a pool, set certain - * attributes on the session (such as NLS settings), and return the session - * to the pool, labeling it with an appropriate tag. - * The user may request a session with the same tags in order to have a - * session with the same attributes" - * - */ - Connection GetConnection(const ostring& sessionTag = OTEXT("")); - - /** - * @brief - * Get the idle timeout for connections/sessions in the pool - * - * @note - * Connections/sessions idled for more than this time value (in seconds) are terminated - * - * @note - * Timeout is not available for internal pooling implementation (client < 9i) - * - */ - unsigned int GetTimeout() const; - - /** - * @brief - * Set the connections/sessions idle timeout - * - * @param value - Timeout value - * - * @note - * connections/sessions idle for more than this time value (in seconds) are terminated - * - * @note - * This call has no effect if pooling is internally implemented (client < 9i) - * - */ - void SetTimeout(unsigned int value); - - /** - * @brief - * Get the waiting mode used when no more connections/sessions are available from the pool - * - * @return - * - true to wait for an available object if the pool is saturated - * - false to not wait for an available object - * - */ - bool GetNoWait() const; - - /** - * @brief - * Set the waiting mode used when no more connections/sessions are available from the pool - * - * @param value - wait for object - * - * @note - * For parameter value, pass : - * - true to wait for an available object if the pool is saturated - * - false to not wait for an available object - * - */ - void SetNoWait(bool value); - - /** - * @brief - * Return the current number of busy connections/sessions - * - */ - unsigned int GetBusyConnectionsCount() const; - - /** - * @brief - * Return the current number of opened connections/sessions - * - */ - unsigned int GetOpenedConnectionsCount() const; - - /** - * @brief - * Return the minimum number of connections/sessions that can be opened to the database - * - */ - unsigned int GetMinSize() const; - - /** - * @brief - * Return the maximum number of connections/sessions that can be opened to the database - * - */ - unsigned int GetMaxSize() const; - - /** - * @brief - * Return the increment for connections/sessions to be opened to the database when the pool is not full - * - */ - unsigned int GetIncrement() const; - - /** - * @brief - * Return the maximum number of statements to keep in the pool's statement cache - * - * @note - * Default value is 20 (value from Oracle Documentation) - * - */ - unsigned int GetStatementCacheSize() const; - - /** - * @brief - * Set the maximum number of statements to keep in the pool's statement cache - * - * @param value - maximum number of statements in the cache - * - */ - void SetStatementCacheSize(unsigned int value); -}; - -/** - * @brief - * A connection or session with a specific database. - * - * This class wraps the OCILIB object handle OCI_Connection and its related methods - * - */ -class Connection : public HandleHolder -{ - friend class Environment; - friend class Exception; - friend class Statement; - friend class File; - friend class Timestamp; - friend class Pool; - friend class Object; - friend class TypeInfo; - friend class Reference; - friend class Resultset; - friend class Subscription; - - template - friend class Lob; - template - friend class Collection; -public: - - /** - * @brief - * Timeout enumerated values - * - */ - enum TimeoutTypeValues - { - /** - * - Time to wait for send operations completion to the database server - * - Requires Oracle 12cR1 client - */ - TimeoutSend = OCI_NTO_SEND, - /** - * - Time to wait for read operations completion from the database server - * - Requires Oracle 12cR1 client - */ - TimeoutReceive = OCI_NTO_RECEIVE, - /** - * - Time to wait for a database round-trip to complete ( Client processing is not taken into account) - * - Requires Oracle 18c client - */ - TimeoutCall = OCI_NTO_CALL - }; - - /** - * @brief - * Timeout Types - * - * Possible values are Connection::TimeoutValues - * - */ - typedef Enum TimeoutType; - - /** - * @brief - * Failover request enumerated values - * - */ - enum FailoverRequestValues - { - /** User has requested only session failover */ - FailoverRequestSession = OCI_FOT_SESSION, - /** User has requested select failover as well */ - FailoverRequestSelect = OCI_FOT_SELECT - }; - - /** - * @brief - * Failover requests - * - * Possible values are Connection::FailoverRequestValues - * - */ - typedef Enum FailoverRequest; - - /** - * @brief - * Failover events enumerated values - * - */ - enum FailoverEventValues - { - /** Successful completion of failover */ - FailoverEventEnd = OCI_FOE_END, - /** Failover was unsuccessful. Retrying is not allowed */ - FailoverEventAbort = OCI_FOE_ABORT, - /** Multiple authentication and failover has occurred after the original authentication. User has been re authenticated */ - FailoverEventReauthentificate = OCI_FOE_REAUTH, - /** Failover has detected a lost connection and failover is starting */ - FailoverEventBegin = OCI_FOE_BEGIN, - /** Failover was unsuccessful. Retrying is allowed */ - FailoverEventError = OCI_FOE_ERROR - }; - - /** - * @brief - * Failover events - * - * Possible values are Connection::FailoverEventValues - * - */ - typedef Enum FailoverEvent; - - /** - * @brief - * Failover callback results enumerated values - * - */ - enum FailoverResultValues - { - /** Default acknowledgment of a failover event */ - FailoverOk = OCI_FOC_OK, - /** Triggers a new failover attempt */ - FailoverRetry = OCI_FOC_RETRY - }; - - /** - * @brief - * Failover callback results - * - * Possible values are Connection::FailoverResultValues - * - */ - typedef Enum FailoverResult; - - /** - * @brief - * Session trace enumerated values - * - */ - enum SessionTraceValues - { - /** Specifies the user defined identifier in the session. It's recorded in the column CLIENT_IDENTIFIER of the system view V$SESSION */ - TraceIdentity = OCI_TRC_IDENTITY, - /** Name of the current module in the client application. It's recorded in the column MODULE of the system view V$SESSION */ - TraceModule = OCI_TRC_MODULE, - /** Name of the current action within the current module. It's recorded in the column ACTION of the system view V$SESSION */ - TraceAction = OCI_TRC_ACTION, - /** Client application additional information. It's recorded in the column CLIENT_INFO of the system view V$SESSION */ - TraceDetail = OCI_TRC_DETAIL - }; - - /** - * @brief - * Session traces - * - * Possible values are Connection::SessionTraceValues - * - */ - typedef Enum SessionTrace; - - /** - * @typedef TAFHandlerProc - * - * @brief - * User callback for TAF event notifications - * - */ - typedef FailoverResult(*TAFHandlerProc) (Connection &con, FailoverRequest failoverRequest, FailoverEvent failoverEvent); - - /** - * @brief - * Default constructor - * - */ - Connection(); - - /** - * @brief - * Constructor that creates an opens an underlying DB connection with the given information - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param sessionFlags - Session Flags - * - * @note - * it calls Open() with the given parameters - * - */ - Connection(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags = Environment::SessionDefault); - - /** - * @brief - * Create a physical connection to an Oracle database server - * - * @param db - Oracle Service Name - * @param user - Oracle User name - * @param pwd - Oracle User password - * @param sessionFlags - Session Flags - * * - * @note - * External credentials are supported by supplying an empty string for the 'user' and 'pwd' parameters - * If the param 'db' is empty then a connection to the default local DB is done - * - * @par Oracle XA support - * OCILIB supports Oracle XA connectivity. In order to get a connection using - * the XA interface : - * - For parameter 'db' : pass the value of the 'DB' parameter of the given - * XA connection string passed to the Transaction Processing Monitor (TPM) - * - Pass empty strings for 'user' and 'pwd' parameters - * - Use SessionFlags::SessionXa for parameter 'sessionFlags' - * - * @par Oracle XA Connection String - * - * The XA connection string used in a transaction monitor to connect to Oracle must - * be compatible with OCILIB : - * - the XA parameter 'Objects' MUST be set to 'true' - * - If EnvMode::Threaded is passed to Environment::Initialize(), the XA parameter 'Threads' must - * be set to 'true', otherwise to 'false' - * - If EnvMode::Events is passed to Environment::Initialize(), the XA parameter 'Events' must - * be set to 'true', otherwise to 'false' - * - As Oracle does not support Unicode UTF16 character set through the XA interface, - * Only OCI_CHARSET_ANSI builds of OCILIB can be used - * - You still can use UTF8 if the NLS_LANG environment variable is set with a valid - * UTF8 NLS value - * - DO NOT USE UNICODE OCILIB builds with XA connections - * - * @note - * On success, a local transaction is automatically created and started ONLY for regular - * standalone connections and connections retrieved from connection pools. - * No transaction is created for a XA connection or q connection retrieved from session pools. - * - */ - void Open(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags = Environment::SessionDefault); - - /** - * @brief - * Close the physical connection to the DB server - * - */ - void Close(); - - /** - * @brief - * Commit current pending changes - * - */ - void Commit(); - - /** - * @brief - * Cancel current pending changes - * - */ - void Rollback(); - - /** - * @brief - * Perform an immediate abort of any currently Oracle OCI call on the given connection - * - * @note - * The current call will abort and will raise an exception - * - */ - void Break(); - - /** - * @brief - * Enable or disable auto commit mode (implicit commits after every SQL execution) - * - * @param enabled - auto commit new status - * - */ - void SetAutoCommit(bool enabled); - - /** - * @brief - * Indicates if auto commit is currently activated - * - */ - bool GetAutoCommit() const; - - /** - * @brief - * Indicate if the connection is still connected to the server - * - * @note - * the returned value is not real-time and is based on client library last heart beat status - * - */ - bool IsServerAlive() const; - - /** - * @brief - * Performs a round trip call to the server to confirm that the connection to the server is still valid. - * - * @warning - * This call is supported from Oracle 10g. - * - */ - bool PingServer() const; - - /** - * @brief - * Return the name of the connected database/service name - * - * @note - * The returned value is the value of the 'db' parameter of the Open() method - * - */ - ostring GetConnectionString() const; - - /** - * @brief - * Return the current logged user name - * - * @note - * The returned value is the value of the 'user' parameter of the Open() method - * - */ - ostring GetUserName() const; - - /** - * @brief - * Return the current logged user password - * - * @note - * The returned value is the value of the 'pwd' parameter of the Open() method - * - */ - ostring GetPassword() const; - - /** - * @brief - * Return the connected database server string version - * - * @note - * The returned value is the server version banner displayed by SQL*PLUS when connected to a DB server - * - */ - ostring GetServerVersion() const; - - /** - * @brief - * Return the Oracle version supported by the connection - * - * @note - * The supported version is the lower version between client and server: - * - */ - OracleVersion GetVersion() const; - - /** - * @brief - * Return the major version number of the connected database server - * - */ - unsigned int GetServerMajorVersion() const; - - /** - * @brief - * Return the minor version number of the connected database server - * - */ - unsigned int GetServerMinorVersion() const; - - /** - * @brief - * Return the revision version number of the connected database server - * - */ - unsigned int GetServerRevisionVersion() const; - - /** - * @brief - * Change the password of the logged user - * - * @param newPwd - New password - * - */ - void ChangePassword(const ostring& newPwd); - - /** - * @brief - * Return the tag associated with the given connection - * - */ - ostring GetSessionTag() const; - - /** - * @brief - * Associate a tag to the given connection/session - * - * @param tag - user tag string - * - * @note - * Use this call only for connections retrieved from a session pool - * See Pool::GetConnection() for more details - * - * @note - * To untag a session, call SetSessionTag() with an empty 'tag' parameter - * - */ - void SetSessionTag(const ostring& tag); - - /** - * @brief - * Return the current transaction of the connection - * - */ - Transaction GetTransaction() const; - - /** - * @brief - * Set a transaction to a connection - * - * @param transaction - Transaction to assign - * - * @note - * The current transaction (if any) is automatically stopped but the newly assigned is not started or resumed - * - * @warning - * Do not set a transaction to a XA connection or a connection retrieved from a session pool - * - */ - void SetTransaction(const Transaction &transaction); - - /** - * @brief - * Set the format string for implicit string conversions of the given type - * - * @param formatType - Type of format - * @param format - Format string - * - * Formats can set at 2 levels: - * - Environment level - * - Connection level - * - * When the library needs to perform a string conversion, it search for a valid format using the - * following order: - * - Connection format - * - Environment format - * - Default format - * - * @note - * Default format values are : - * - OCI_FMT_DATE : constant OCI_STRING_FORMAT_DATE - * - OCI_FMT_TIMESTAMP : constant OCI_STRING_FORMAT_TIMESTAMP - * - OCI_FMT_NUMERIC : constant OCI_STRING_FORMAT_NUMERIC - * - OCI_FMT_BINARY_DOUBLE : constant OCI_STRING_FORMAT_BINARY_DOUBLE - * - OCI_FMT_BINARY FLOAT : constant OCI_STRING_FORMAT_BINARY_FLOAT - * - * @note - * Conversions are performed by Oracle built-in functions whenever possible. - * For DATE, TIMESTAMP and numeric types, see documentation of Oracle SQL to_char() function for more details - * For BINARY_DOUBLE and BINARY_FLOAT, refer to the C Standard Library printf() family documentation - * - */ - bool SetFormat(FormatType formatType, const ostring& format); - - /** - * @brief - * Return the format string for implicit string conversions of the given type - * - * @param formatType - Type of format - * - * @note - * See SetFormat() for possible values - * - */ - ostring GetFormat(FormatType formatType); - - /** - * @brief - * Enable the server output - * - * @param bufsize - server buffer max size (server side) - * @param arrsize - number of lines to retrieve per server round-trip - * @param lnsize - maximum size of one line - * - * @note - * This call is equivalent to the command 'set serveroutput on' in SQL*PLUS - * - * @note - * - 'bufsize' minimum value is 2000, maximum 1000000 with Oracle < 10.2g and can be unlimited above - * - 'lnsize' maximum value is 255 with Oracle < 10g R2 and 32767 above - * - * @warning - * If EnableServerOutput() is not called, GetServerOutput() will return false - * - */ - void EnableServerOutput(unsigned int bufsize, unsigned int arrsize, unsigned int lnsize); - - /** - * @brief - * Disable the server output - * - * @note - * After this call, GetServerOutput() will return false. - * - */ - void DisableServerOutput(); - - /** - * @brief - * Retrieve one line of the server buffer - * - * @return - * true if a line has been retrieved otherwise false (server buffer is empty or all lines have been retrieved) - * - */ - bool GetServerOutput(ostring &line) const; - - /** - * @brief - * Retrieve all remaining lines of the server buffer - * - */ - void GetServerOutput(std::vector &lines) const; - - /** - * @brief - * Set tracing information for the session - * - * @param trace - trace type - * @param value - trace content - * - * Store current trace information to the given connection handle. - * These information: - * - * - is stored in the system view V$SESSION - * - can be retrieved from the connection property of an OCI_Error handle - * - * system view V$SESSION - * - * @warning - * The system view V$SESSION is updated on Oracle versions >= 10g - * - * @warning - * Oracle limits the size of these traces content and thus OCILIB will truncate - * the given values if needed : - * - * - TraceIdentity : 64 bytes - * - TraceModule : 48 bytes - * - TraceAction : 32 bytes - * - TraceDetail : 64 bytes - * - */ - void SetTrace(SessionTrace trace, const ostring& value); - - /** - * @brief - * Get the current trace for the trace type from the given connection. - * - * @param trace - trace type - * - * @note - * See SetTrace() for more details. - * - */ - ostring GetTrace(SessionTrace trace) const; - - /** - * @brief - * Return the Oracle server database name of the connected database/service name - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - ostring GetDatabase() const; - - /** - * @brief - * Return the Oracle server Instance name of the connected database/service name - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - ostring GetInstance() const; - - /** - * @brief - * Return the Oracle server Service name of the connected database/service name - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - ostring GetService() const; - - /** - * @brief - * Return the Oracle server Hos name of the connected database/service name - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - ostring GetServer() const; - - /** - * @brief - * Return the Oracle server Domain name of the connected database/service name - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - ostring GetDomain() const; - - /** - * @brief - * Return the date and time (Timestamp) server instance start of the - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - Timestamp GetInstanceStartTime() const; - - /** - * @brief - * Return the maximum number of statements to keep in the statement cache - * - * @note - * Default value is 20 (value from Oracle Documentation) - * - * @warning - * Requires Oracle Client 9.2 or above - * - */ - unsigned int GetStatementCacheSize() const; - - /** - * @brief - * Set the maximum number of statements to keep in the statement cache - * - * @param value - maximum number of statements in the cache - * - * @warning - * Requires Oracle Client 9.2 or above - * - */ - void SetStatementCacheSize(unsigned int value); - - /** - * @brief - * Return the default LOB prefetch buffer size for the connection - * - * @warning - * Requires Oracle Client AND Server 11gR1 or above - * - * @note - * Prefetch size is: - * - number of bytes for BLOBs (Blob) and BFILEs (File) - * - number of characters for CLOBs (Clob / NClob). - * - * @note - * Default is 0 (pre-fetching disabled) - * - */ - unsigned int GetDefaultLobPrefetchSize() const; - - /** - * @brief - * Enable or disable pre-fetching for all LOBs fetched in the connection - * - * @param value - default prefetch buffer size - * - * @note - * If parameter 'value': - * - is == 0, it disables pre-fetching for all LOBs fetched in the connection. - * - is > 0, it enables pre-fetching for all LOBs fetched in the connection - * and the given buffer size is used for pre-fetching LOBs - * - * @note - * LOBs pre-fetching is disabled by default - * - * @warning - * Requires Oracle Client AND Server 11gR1 or above. - * - * @note - * Prefetch size is: - * - number of bytes for BLOBs (Blob) and BFILEs (File) - * - number of characters for CLOBs (Clob / NClob). - * - */ - void SetDefaultLobPrefetchSize(unsigned int value); - - /** - * @brief - * Return the maximum number of SQL statements that can be opened in one session - * - * @warning - * Requires Oracle Client AND Server 12cR1 or above - * - * @note - * the returned value is the same as the db parameter 'open_cursors' from server's parameter file - * - * @note - * Return 0 if the client and server version are < 12cR1 - * - */ - unsigned int GetMaxCursors() const; - - /** - * @brief - * Verify if the connection support TAF events - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - bool IsTAFCapable() const; - - /** - * @brief - * Set the Transparent Application Failover (TAF) user handler - * - * @param handler - TAF handler procedure - * - * @note - * See TAFHandlerProc documentation for more details - * - * @warning - * This call is supported from Oracle 10gR2. - * - */ - void SetTAFHandler(TAFHandlerProc handler); - - /** - * @brief - * Return the pointer to user data previously associated with the connection - * - */ - AnyPointer GetUserData(); - - /** - * @brief - * Associate a pointer to user data to the given connection - * - * @param value - User data pointer - * - */ - void SetUserData(AnyPointer value); - - /** - * @brief - * Returns the requested timeout value for OCI calls that require server round-trips to the given database - * - * @param timeout - Type of timeout - * - * @note: - * See Connection::SetTimeout() for more information - * - * @return - * The given timeout value if supported, otherwise 0 - * - */ - unsigned int GetTimeout(TimeoutType timeout); - - /** - * @brief - * Set a given timeout for OCI calls that require server round-trips to the given database - * - * @param timeout - Type of timeout to set - * @param value - Timeout in milliseconds - * - * OCI client raises an timeout type related error when a given timeout is reached. - * - * @note - * To disable a given timeout, pass the value 0 - * - * @warning - * OCI client is using the following precedence rules when applying timeouts: - * - 1 - Timeout set using TimeoutCall (all other timeouts are discarded) - * - 2 - Timeouts set using TimeoutSend and/or TimeoutReceive - * - 3 - Timeouts set in sqlnet.ora file - * - * Here is a summary: - * - * FLAG | Min. Version | OCI Error raised | OCI Error description | sqlnet.ora equivalent | - * --------------- | ------------ | ---------------- | ------------------------------ | --------------------- | - * TimeoutSend | OCI_12_1 | ORA-12608 | TNS: Send timeout occurred | SQLNET.SEND_TIMEOUT | - * TimeoutReceive | OCI_12_1 | ORA-12609 | TNS: Receive timeout occurred | SQLNET.RECV_TIMEOUT | - * TimeoutCall | OCI_18_1 | ORA-03136 | inbound connection timed out | --- | - * - */ - void SetTimeout(TimeoutType timeout, unsigned int value); - -private: - - Connection(OCI_Connection *con, Handle *parent); -}; - -/** - * @brief - * Oracle Transaction object - * - * This class wraps the OCILIB object handle OCI_Transaction and its related methods - * - */ -class Transaction : public HandleHolder -{ - friend class Connection; - -public: - - /** - * @brief - * Transaction flags enumerated values - * - */ - enum TransactionFlagsValues - { - Unknown = OCI_UNKNOWN, - /** (Global) Specifies tightly coupled and migratable branch */ - New = OCI_TRS_NEW, - /** (Global) Specifies a tightly coupled branch */ - Tight = OCI_TRS_TIGHT, - /** (Global) Specifies a loosely coupled branch */ - Loose = OCI_TRS_LOOSE, - /** (Global and local) start a read-only transaction */ - ReadOnly = OCI_TRS_READONLY, - /** (Global and local) start a read-write transaction */ - ReadWrite = OCI_TRS_READWRITE, - /** (Global and local) start a serializable transaction */ - Serializable = OCI_TRS_SERIALIZABLE - }; - - /** - * @brief - * Transaction flags - * - * Possible values are Transaction::TransactionFlagsValues - * - */ - typedef Flags TransactionFlags; - - /** - * @brief - * Create a new global transaction or a serializable/read-only local transaction - * - * @param connection - Connection - * @param timeout - Time that a transaction stays inactive after being stopped - * @param flags - Transaction flags - * @param pxid - pointer to a global transaction identifier structure - * - * @note - * For local transaction, don't use the 'pxid' parameter - * - */ - Transaction(const Connection &connection, unsigned int timeout, TransactionFlags flags, OCI_XID *pxid = nullptr); - - /** - * @brief - * Prepare a global transaction validation - * - */ - void Prepare(); - - /** - * @brief - * Start global transaction - * - */ - void Start(); - - /** - * @brief - * Stop current global transaction - * - */ - void Stop(); - - /** - * @brief - * Resume a stopped global transaction - * - */ - void Resume(); - - /** - * @brief - * Cancel the prepared global transaction validation - * - */ - void Forget(); - - /** - * @brief - * Return the transaction mode. - * - * @note: - * see Transaction() for possible values - * - */ - TransactionFlags GetFlags() const; - - /** - * @brief - * Return the transaction Timeout - * - */ - unsigned int GetTimeout() const; - -private: - - Transaction(OCI_Transaction *trans); -}; - -/** -* @brief -* Object identifying the SQL data type NUMBER. -* -* This class wraps the OCILIB object handle OCI_Number and its related methods -* -* NUMBERs can be handled using native scalar types -* This class is optional and exposes some special NUMBER properties -* -*/ -class Number : public HandleHolder, public Streamable -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class Collection; - -public: - - /** - * @brief - * Create an empty null number object - * - * @param create - Indicates if a Oracle Number object must be must be created - * - */ - Number(bool create = false); - - /** - * @brief - * Create a Number object with the value provided by the input Number string - * - * @param str - String Number - * @param format - format of the Number provided in parameter 'data' - * - * @note - * For Number formats, refer to the Oracle SQL documentation - * - * @note - * Default connection Number format is computed from Environment::GetFormat() - * - */ - Number(const otext* str, const otext* format = OTEXT("")); - - /** - * @brief - * Create a Number object with the value provided by the input Number string - * - * @param str - String Number - * @param format - format of the Number provided in parameter 'data' - * - * @note - * ForNumber formats, refer to the Oracle SQL documentation - * - * @note - * Default connection Number format is computed from Environment::GetFormat() - * - */ - Number(const ostring& str, const ostring& format = OTEXT("")); - - /** - * @brief - * Assign to the number object the value provided by the input number time string - * - * @param str - String number time - * @param format - format of the number time provided in parameter 'data' - * - * @note - * For number formats, refer to the Oracle SQL documentation - * - * @note - * Default connection number format is computed from Environment::GetFormat() - * - */ - void FromString(const ostring& str, const ostring& format = OTEXT("")) const; - - /** - * @brief - * Convert the number value to a string using the given format - * - * @param format - number time format to use - * - * @note - * For number formats, refer to the Oracle SQL documentation - * - */ - ostring ToString(const ostring& format) const; - - /** - * @brief - * Convert the number value to a string using default format OCI_STRING_FORMAT_NUMERIC - * - * @note - * For number formats, refer to the Oracle SQL documentation - * - */ - ostring ToString() const override; - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Number Clone() const; - - Number& operator ++ (); - Number& operator -- (); - Number operator ++ (int); - Number operator -- (int); - - bool operator == (const Number& other) const; - bool operator != (const Number& other) const; - bool operator > (const Number& other) const; - bool operator < (const Number& other) const; - bool operator >= (const Number& other) const; - bool operator <= (const Number& other) const; - - template::Type::type* = nullptr> - Number& operator = (const T &lhs); - - template::Type::type* = nullptr> - operator T() const; - - template::Type::type* = nullptr> - Number operator - (const T &value); - - template::Type::type* = nullptr> - Number operator + (const T &value); - - template::Type::type* = nullptr> - Number operator * (const T &value); - - template::Type::type* = nullptr> - Number operator / (const T &value); - - template::Type::type* = nullptr> - Number& operator += (const T &value); - - template::Type::type* = nullptr> - Number& operator -= (const T &value); - - template::Type::type* = nullptr> - Number& operator *= (const T &value); - - template::Type::type* = nullptr> - Number& operator /= (const T &value); - -private: - - template - static AnyPointer GetNativeValue(const T& value); - - Number(OCI_Number *pNumber, Handle *parent = nullptr); - - void Allocate(); - - int Compare(const Number& other) const; - - template - inline T GetValue() const; - - template - Number& SetValue(const T &value); - - template - void Add(const T &value); - - template - void Sub(const T &value); - - template - void Multiply(const T &value); - - template - void Divide(const T &value); - - Number& operator = (OCI_Number * &lhs); -}; - -/** - * @brief - * Object identifying the SQL data type DATE. - * - * This class wraps the OCILIB object handle OCI_Date and its related methods - * - */ -class Date : public HandleHolder, public Streamable -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class Collection; - friend class Message; - -public: - - /** - * @brief - * Return the current system date time - * - */ - static Date SysDate(); - - /** - * @brief - * Create an empty null Date object - * - * @param create - Indicates if a Oracle Date object must be must be created - * - */ - Date(bool create = false); - - /** - * @brief - * Create a date object with the value provided by the input date time string - * - * @param str - String date time - * @param format - format of the date time provided in parameter 'data' - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - * @note - * Default connection date format is computed from Environment::GetFormat() - * - */ - Date(const otext* str, const otext* format = OTEXT("")); - - /** - * @brief - * Create a date object with the value provided by the input date time string - * - * @param str - String date time - * @param format - format of the date time provided in parameter 'data' - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - * @note - * Default connection date format is computed from Environment::GetFormat() - * - */ - - Date(const ostring& str, const ostring& format = OTEXT("")); - - /** - * @brief - * Check if the given date is valid - * - */ - bool IsValid() const; - - /** - * @brief - * Return the date year value - * - */ - int GetYear() const; - - /** - * @brief - * Set the date year value - * - */ - void SetYear(int value); - - /** - * @brief - * Return the date month value - * - */ - int GetMonth() const; - - /** - * @brief - * Set the date month value - * - */ - void SetMonth(int value); - - /** - * @brief - * Return the date day value - * - */ - int GetDay() const; - - /** - * @brief - * Set the date day value - * - */ - void SetDay(int value); - - /** - * @brief - * Return the date hours value - * - */ - int GetHours() const; - - /** - * @brief - * Set the date hours value - * - */ - void SetHours(int value); - - /** - * @brief - * Return the date minutes value - * - */ - int GetMinutes() const; - - /** - * @brief - * Set the date minutes value - * - */ - void SetMinutes(int value); - - /** - * @brief - * Return the date seconds value - * - */ - int GetSeconds() const; - - /** - * @brief - * Set the date seconds value - * - */ - void SetSeconds(int value); - - /** - * @brief - * Return the number of days with the given date - * - * @param other - date to compare - * - */ - int DaysBetween(const Date& other) const; - - /** - * @brief - * Set the date part - * - * @param year - Year value - * @param month - Month value - * @param day - Day value - * - */ - void SetDate(int year, int month, int day); - - /** - * @brief - * Set the time part - * - * @param hour - Hour value - * @param min - Minute value - * @param sec - Second value - * - */ - void SetTime(int hour, int min, int sec); - - /** - * @brief - * Set the date and time part - * - * @param year - Year value - * @param month - Month value - * @param day - Day value - * @param hour - Hour value - * @param min - Minute value - * @param sec - Second value - * - */ - void SetDateTime(int year, int month, int day, int hour, int min, int sec); - - /** - * @brief - * Extract the date parts - * - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * - */ - void GetDate(int &year, int &month, int &day) const; - - /** - * @brief - * Extract time parts - * - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * - */ - void GetTime(int &hour, int &min, int &sec) const; - - /** - * @brief - * Extract the date and time parts - * - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * - */ - void GetDateTime(int &year, int &month, int &day, int &hour, int &min, int &sec) const; - - /** - * @brief - * Add or subtract days - * - * @param days - Number of days to add/remove - * - */ - void AddDays(int days); - - /** - * @brief - * Add or subtract months - * - * @param months - Number of months to add/remove - * - */ - void AddMonths(int months); - - /** - * @brief - * Return the date of next day of the week, after the current date object - * - * @param day - Day of the week - * - */ - Date NextDay(const ostring& day) const; - - /** - * @brief - * Return the last day of month from the current date object - * - */ - Date LastDay() const; - - /** - * @brief - * Convert the date from one zone to another zone - * - * @param tzSrc - Source zone - * @param tzDst - Destination zone - * - */ - void ChangeTimeZone(const ostring& tzSrc, const ostring& tzDst); - - /** - * @brief - * Assign to the date object the value provided by the input date time string - * - * @param str - String date time - * @param format - format of the date time provided in parameter 'data' - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - * @note - * Default connection date format is computed from Environment::GetFormat() - * - */ - void FromString(const ostring& str, const ostring& format = OTEXT("")); - - /** - * @brief - * Convert the date value to a string using the given format - * - * @param format - date time format to use - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - */ - ostring ToString(const ostring& format) const; - - /** - * @brief - * Convert the date value to a string using default format OCI_STRING_FORMAT_DATE - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - */ - ostring ToString() const override; - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Date Clone() const; - - /** - * @brief - * Increment the date by 1 day - * - */ - Date& operator ++ (); - - /** - * @brief - * Increment the date by 1 day - * - */ - Date operator ++ (int); - - /** - * @brief - * Decrement the date by 1 day - * - */ - Date& operator -- (); - - /** - * @brief - * Decrement the date by 1 day - * - */ - Date operator -- (int); - - /** - * @brief - * Return a new date holding the current date value incremented by the given number of days - * - */ - Date operator + (int value) const; - - /** - * @brief - * Return a new date holding the current date value decremented by the given number of days - * - */ - Date operator - (int value) const; - - /** - * @brief - * Increment the date by the given number of days - * - */ - Date& operator += (int value); - - /** - * @brief - * Decrement the date by the given number of days - * - */ - Date& operator -= (int value); - - /** - * @brief - * Indicates if the current date value is equal to the given date value - * - */ - bool operator == (const Date& other) const; - - /** - * @brief - * Indicates if the current date value is not equal the given date value - * - */ - bool operator != (const Date& other) const; - - /** - * @brief - * Indicates if the current date value is superior to the given date value - * - */ - bool operator > (const Date& other) const; - - /** - * @brief - * Indicates if the current date value is inferior to the given date value - * - */ - bool operator < (const Date& other) const; - - /** - * @brief - * Indicates if the current date value is superior or equal to the given date value - * - */ - bool operator >= (const Date& other) const; - - /** - * @brief - * Indicates if the current date value is inferior or equal to the given date value - * - */ - bool operator <= (const Date& other) const; - -private: - - int Compare(const Date& other) const; - - Date(OCI_Date *pDate, Handle *parent = nullptr); - - void Allocate(); -}; - -/** - * @brief - * Object identifying the SQL data type INTERVAL. - * - * This class wraps the OCILIB object handle OCI_Interval and its related methods - * - */ -class Interval : public HandleHolder, public Streamable -{ - friend class Environment; - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class Collection; - -public: - - /** - * @brief - * Interval types enumerated values - * - */ - enum IntervalTypeValues - { - /** Interval unit range is months -> years */ - YearMonth = OCI_INTERVAL_YM, - /** Interval unit range is seconds -> days */ - DaySecond = OCI_INTERVAL_DS - }; - - /** - * @brief - * Interval types - * - * Possible values are Interval::IntervalTypeValues - * - */ - typedef Enum IntervalType; - - /** - * @brief - * Create an empty null Interval instance - * - */ - Interval(); - - /** - * @brief - * Create a new instance of the given type - * - * @param type - Interval type to create - * - */ - Interval(IntervalType type); - - /** - * @brief - * Create an interval object with the value provided by the input interval string - * - * @param type - Interval type to create - * @param data - String interval - * - * @note - * For interval format, refer to the Oracle SQL documentation - * - */ - Interval(IntervalType type, const ostring& data); - - /** - * @brief - * Return the type of the given interval object - * - */ - IntervalType GetType() const; - - /** - * @brief - * Check if the given interval is valid - * - */ - bool IsValid() const; - - /** - * @brief - * Return the interval year value - * - * @warning - * this call is only permitted if the current interval type is Interval::YearMonth - * - */ - int GetYear() const; - - /** - * @brief - * Set the interval year value - * - * @warning - * this call is only permitted if the current interval type is Interval::YearMonth - * - */ - void SetYear(int value); - - /** - * @brief - * Return the interval month value - * - * @warning - * this call is only permitted if the current interval type is Interval::YearMonth - * - */ - int GetMonth() const; - - /** - * @brief - * Set the interval month value - * - * @warning - * this call is only permitted if the current interval type is Interval::YearMonth - * - */ - void SetMonth(int value); - - /** - * @brief - * Return the interval day value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - int GetDay() const; - - /** - * @brief - * Set the interval day value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - void SetDay(int value); - - /** - * @brief - * Return the interval hours value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - int GetHours() const; - - /** - * @brief - * Set the interval hours value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - void SetHours(int value); - - /** - * @brief - * Return the interval minutes value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - int GetMinutes() const; - - /** - * @brief - * Set the interval minutes value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - void SetMinutes(int value); - - /** - * @brief - * Return the interval seconds value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - int GetSeconds() const; - - /** - * @brief - * Set the interval seconds value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - void SetSeconds(int value); - - /** - * @brief - * Return the interval seconds value - * - */ - int GetMilliSeconds() const; - - /** - * @brief - * Set the interval milliseconds value - * - */ - void SetMilliSeconds(int value); - - /** - * @brief - * Extract the date / second parts from the interval value - * - * @param day - Place holder for Day value - * @param hour - Place holder for Hour value - * @param min - Place holder for Minutes value - * @param sec - Place holder for Seconds value - * @param fsec - Place holder for Milliseconds value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - void GetDaySecond(int &day, int &hour, int &min, int &sec, int &fsec) const; - - /** - * @brief - * Set the Day / Second parts - * - * @param day - Day value - * @param hour - Hour value - * @param min - Minutes value - * @param sec - Seconds value - * @param fsec - Milliseconds value - * - * @warning - * this call is only permitted if the current interval type is Interval::DaySecond - * - */ - void SetDaySecond(int day, int hour, int min, int sec, int fsec); - - /** - * @brief - * Extract the year / month parts from the interval value - * - * @param year - Place holder for year value - * @param month - Place holder for month value - * - * @warning - * this call is only permitted if the current interval type is Interval::YearMonth - * - */ - void GetYearMonth(int &year, int &month) const; - - /** - * @brief - * Set the Year / Month parts - * - * @param year - Year value - * @param month - Month value - * - * @warning - * this call is only permitted if the current interval type is Interval::YearMonth - * - */ - void SetYearMonth(int year, int month); - - /** - * @brief - * Update the interval value with the given time zone - * - * @param timeZone - Time zone name - * - */ - void UpdateTimeZone(const ostring& timeZone); - - /** - * @brief - * Assign to the interval object the value provided by the input interval string - * - * @param data - String interval - * - * @note - * For interval format, refer to the Oracle SQL documentation - * - */ - void FromString(const ostring& data); - - /** - * @brief - * Convert the interval value to a string using the given precisions - * - * @param leadingPrecision - leading precision - * @param fractionPrecision - fraction precision - * - */ - ostring ToString(int leadingPrecision, int fractionPrecision) const; - - /** - * @brief - * Convert the interval value to a string using the default precisions of 10 - * - */ - ostring ToString() const override; - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Interval Clone() const; - - /** - * @brief - * Return a new Interval holding the sum of the current Interval value and the given Interval value - * - */ - Interval operator + (const Interval& other) const; - - /** - * @brief - * Return a new Interval holding the difference of the current Interval value and the given Interval value - * - */ - Interval operator - (const Interval& other) const; - - /** - * @brief - * Increment the current Value with the given Interval value - * - */ - Interval& operator += (const Interval& other); - - /** - * @brief - * Decrement the current Value with the given Interval value - * - */ - Interval& operator -= (const Interval& other); - - /** - * @brief - * Indicates if the current Interval value is equal to the given Interval value - * - */ - bool operator == (const Interval& other) const; - - /** - * @brief - * Indicates if the current Interval value is not equal the given Interval value - * - */ - bool operator != (const Interval& other) const; - - /** - * @brief - * Indicates if the current Interval value is superior to the given Interval value - * - */ - bool operator > (const Interval& other) const; - - /** - * @brief - * Indicates if the current Interval value is inferior to the given Interval value - * - */ - bool operator < (const Interval& other) const; - - /** - * @brief - * Indicates if the current Interval value is superior or equal to the given Interval value - * - */ - bool operator >= (const Interval& other) const; - - /** - * @brief - * Indicates if the current Interval value is inferior or equal to the given Interval value - * - */ - bool operator <= (const Interval& other) const; - -private: - - int Compare(const Interval& other) const; - - Interval(OCI_Interval *pInterval, Handle *parent = nullptr); -}; - -/** - * - * @brief - * Object identifying the SQL data type TIMESTAMP. - * - * This class wraps the OCILIB object handle OCI_Timestamp and its related methods - * - */ -class Timestamp : public HandleHolder, public Streamable -{ - friend class Environment; - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - friend class Connection; - template - friend class Collection; - -public: - - /** - * @brief - * Interval types enumerated values - * - */ - enum TimestampTypeValues - { - /** Timestamp does not contains any time zone information */ - NoTimeZone = OCI_TIMESTAMP, - /** Timestamp contains a given time zone */ - WithTimeZone = OCI_TIMESTAMP_TZ, - /** Timestamp contains the user's local session time zone */ - WithLocalTimeZone = OCI_TIMESTAMP_LTZ - }; - - /** - * @brief - * Type of timestamp - * - * Possible values are Timestamp::TimestampTypeValues - * - */ - typedef Enum TimestampType; - - /** - * @brief - * return the current system timestamp - * - * @param type - Timestamp type to create - * - */ - static Timestamp SysTimestamp(TimestampType type = NoTimeZone); - - /** - * @brief - * Create an empty null timestamp instance - * - */ - Timestamp(); - - /** - * @brief - * Create a new instance of the given type - * - * @param type - Timestamp type to create - * - */ - Timestamp(TimestampType type); - - /** - * @brief - * Creates a timestamp object with the value provided by the input date time string - * - * @param type - Timestamp type to create - * @param data - String date time - * @param format - format of the date time provided in parameter 'data' - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - */ - Timestamp(TimestampType type, const ostring& data, const ostring& format = OTEXT("")); - - /** - * @brief - * Return the type of the given timestamp object - * - */ - TimestampType GetType() const; - - /** - * @brief - * Convert the current timestamp to the type of the given timestamp. - * - * @param other - Timestamp to use for the type conversion - * - */ - void Convert(const Timestamp& other); - - /** - * @brief - * Check if the given timestamp is valid - * - */ - bool IsValid() const; - - /** - * @brief - * Return the timestamp year value - * - */ - int GetYear() const; - - /** - * @brief - * Set the timestamp year value - * - */ - void SetYear(int value); - - /** - * @brief - * Return the timestamp month value - * - */ - int GetMonth() const; - - /** - * @brief - * Set the timestamp month value - * - */ - void SetMonth(int value); - - /** - * @brief - * Return the timestamp day value - * - */ - int GetDay() const; - - /** - * @brief - * Set the timestamp day value - * - */ - void SetDay(int value); - - /** - * @brief - * Return the timestamp hours value - * - */ - int GetHours() const; - - /** - * @brief - * Set the timestamp hours value - * - */ - void SetHours(int value); - - /** - * @brief - * Return the timestamp minutes value - * - */ - int GetMinutes() const; - - /** - * @brief - * Set the timestamp minutes value - * - */ - void SetMinutes(int value); - - /** - * @brief - * Return the timestamp seconds value - * - */ - int GetSeconds() const; - - /** - * @brief - * Set the timestamp seconds value - * - */ - void SetSeconds(int value); - - /** - * @brief - * Return the timestamp seconds value - * - */ - int GetMilliSeconds() const; - - /** - * @brief - * Set the timestamp milliseconds value - * - */ - void SetMilliSeconds(int value); - - /** - * @brief - * Extract the date parts - * - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * - */ - void GetDate(int &year, int &month, int &day) const; - - /** - * @brief - * Extract time parts - * - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * @param fsec - Place holder for fractional part of the seconds - * - */ - void GetTime(int &hour, int &min, int &sec, int &fsec) const; - - /** - * @brief - * Set the date part - * - * @param year - Year value - * @param month - Month value - * @param day - Day value - * - */ - void SetDate(int year, int month, int day); - - /** - * @brief - * Set the time part - * - * @param hour - Hour value - * @param min - Minute value - * @param sec - Second value - * @param fsec - Place holder for fractional part of the seconds - * - */ - void SetTime(int hour, int min, int sec, int fsec); - - /** - * @brief - * Extract date and time parts - * - * @param year - Place holder for year value - * @param month - Place holder for month value - * @param day - Place holder for day value - * @param hour - Place holder for hour value - * @param min - Place holder for minute value - * @param sec - Place holder for second value - * @param fsec - Place holder for fractional part of the seconds - * - */ - void GetDateTime(int &year, int &month, int &day, int &hour, int &min, int &sec, int &fsec) const; - - /** - * @brief - * Set the timestamp value from given date time parts - * - * @param year - Year value - * @param month - Month value - * @param day - Day value - * @param hour - Hour value - * @param min - Minutes value - * @param sec - Seconds value - * @param fsec - Fractional part of seconds value - * @param timeZone - name of a time zone to use [optional] - * - */ - void SetDateTime(int year, int month, int day, int hour, int min, int sec, int fsec, const ostring& timeZone = OTEXT("")); - - /** - * @brief - * Return the name of the current time zone - * - * @warning - * Returns an empty string if the timestamp type is TimeStamp::NoTimeZone - * - */ - ostring GetTimeZone() const; - - /** - * @brief - * Set the given time zone to the timestamp - * - * @warning - * - The timestamp must have a valid value before setting the timezone - * - Applies to TimeStamp::WithTimeZone only - * - */ - void SetTimeZone(const ostring& timeZone); - - /** - * @brief - * Return the time zone (hour, minute) offsets - * - * @param hour - Place holder for hour value - * @param min - Place holder for min value - * - */ - void GetTimeZoneOffset(int &hour, int &min) const; - - /** - * @brief - * Subtract the given two timestamp and store the result into the given Interval - * - * @param lsh - Timestamp value - * @param rsh - Timestamp to subtract - * @param result - result difference - * - * @note - * the Interval object type must match the type of range resulting from the timestamp difference - * - */ - static void Substract(const Timestamp &lsh, const Timestamp &rsh, Interval &result); - - /** - * @brief - * Assign to the timestamp object the value provided by the input date time string - * - * @param data - String date time - * @param format - format of the date time provided in parameter 'data' - * - * @note - * For date time formats, refer to the Oracle SQL documentation - * - */ - void FromString(const ostring& data, const ostring& format = OCI_STRING_FORMAT_DATE); - - /** - * @brief - * Convert the timestamp value to a string using the given format and precision - * - * @param format - date time / timestamp format to use - * @param precision - precision for milliseconds - * - * @note - * For date time / timestamp formats, refer to the Oracle SQL documentation - * - */ - ostring ToString(const ostring& format, int precision) const; - - /** - * @brief - * Convert the timestamp value to a string using default date format and no precision - * - */ - ostring ToString() const override; - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Timestamp Clone() const; - - /** - * @brief - * Increment the timestamp by 1 day - * - */ - Timestamp& operator ++ (); - - /** - * @brief - * Increment the timestamp by 1 day - * - */ - Timestamp operator ++ (int); - - /** - * @brief - * Decrement the Timestamp by 1 day - * - */ - Timestamp& operator -- (); - - /** - * @brief - * Decrement the Timestamp by 1 day - * - */ - Timestamp operator -- (int); - - /** - * @brief - * Return a new Timestamp holding the current Timestamp value incremented by the given number of days - * - */ - Timestamp operator + (int value) const; - - /** - * @brief - * Return a new Timestamp holding the current Timestamp value decremented by the given number of days - * - */ - Timestamp operator - (int value) const; - - /** - * @brief - * Return an interval storing the difference between the current timestamp and the given one - * - */ - Interval operator - (const Timestamp& other); - - /** - * @brief - * Increment the Timestamp by the given number of days - * - */ - Timestamp& operator += (int value); - - /** - * @brief - * Decrement the Timestamp by the given number of days - * - */ - Timestamp& operator -= (int value); - - /** - * @brief - * Return a new Timestamp holding the sum of the current Timestamp value and the given Interval value - * - */ - Timestamp operator + (const Interval& other) const; - - /** - * @brief - * Return a new Timestamp holding the difference of the current Timestamp value and the given Interval value - * - */ - Timestamp operator - (const Interval& other) const; - - /** - * @brief - * Increment the current Value with the given Interval value - * - */ - Timestamp& operator += (const Interval& other); - - /** - * @brief - * Decrement the current Value with the given Interval value - * - */ - Timestamp& operator -= (const Interval& other); - - /** - * @brief - * Indicates if the current Timestamp value is equal to the given Timestamp value - * - */ - bool operator == (const Timestamp& other) const; - - /** - * @brief - * Indicates if the current Timestamp value is not equal the given Timestamp value - * - */ - bool operator != (const Timestamp& other) const; - - /** - * @brief - * Indicates if the current Timestamp value is superior to the given Timestamp value - * - */ - bool operator > (const Timestamp& other) const; - - /** - * @brief - * Indicates if the current Timestamp value is inferior to the given Timestamp value - * - */ - bool operator < (const Timestamp& other) const; - - /** - * @brief - * Indicates if the current Timestamp value is superior or equal to the given Timestamp value - * - */ - bool operator >= (const Timestamp& other) const; - - /** - * @brief - * Indicates if the current Timestamp value is inferior or equal to the given Timestamp value - * - */ - bool operator <= (const Timestamp& other) const; - -private: - - int Compare(const Timestamp& other) const; - - Timestamp(OCI_Timestamp *pTimestamp, Handle *parent = nullptr); -}; - -/** - * @brief - * Object identifying the SQL data type LOB (CLOB, NCLOB and BLOB) - * - * This class wraps the OCILIB object handle OCI_Lob and its related methods - * - */ -template -class Lob : public HandleHolder -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class Collection; - -public: - - /** - * @brief - * Create an empty null Lob instance - * - */ - Lob(); - - /** - * @brief - * Parametrized constructor - * - * @param connection - Parent connection - * - * @note - * the lob object must not be accessed anymore once the parent connection object gets out of scope - * - */ - Lob(const Connection &connection); - - /** - * @brief - * Read a portion of a lob - * - * @param length - Maximum number of characters or bytes to read - * - * @return - * The content read from the lob - * - */ - T Read(unsigned int length); - - /** - * @brief - * Write the given content at the current position within the lob - * - * @param content - content to write - * - * @return - * Number of character or bytes written into the lob - * - */ - unsigned int Write(const T &content); - - /** - * @brief - * Append the given content to the lob - * - * @param content - content to write - * - * @return - * Number of character or bytes written into the lob - * - */ - unsigned int Append(const T& content); - - /** - * @brief - * Append the given lob content to the lob - * - * @param other - source lob - * - */ - void Append(const Lob& other); - - /** - * @brief - * Move the current position within the lob for read/write operations - * - * @param seekMode - Seek mode - * @param offset - offset from current position - * - * @note - * Positions start at 0. - * - * @return - * true on success otherwise false - * - */ - bool Seek(SeekMode seekMode, big_uint offset); - - /** - * @brief - * return the type of lob - * - */ - LobType GetType() const; - - /** - * @brief - * Returns the current R/W offset within the lob - * - */ - big_uint GetOffset() const; - - /** - * @brief - * Returns the number of characters or bytes contained in the lob - * - */ - big_uint GetLength() const; - - /** - * @brief - * Returns the lob maximum possible size - * - */ - big_uint GetMaxSize() const; - - /** - * @brief - * Returns the current lob chunk size - * - * @note - * This chunk size corresponds to the chunk size used by the LOB data layer - * when accessing and modifying the LOB value. According to Oracle - * documentation, performance will be improved if the application issues - * read or write requests using a multiple of this chunk size - * - */ - big_uint GetChunkSize() const; - - /** - * @brief - * Return the lob parent connection - * - */ - Connection GetConnection() const; - - /** - * @brief - * Truncate the lob to a shorter length - * - * @param length - New length in characters or bytes - * - */ - void Truncate(big_uint length); - - /** - * @brief - * Erase a portion of the lob at a given position - * - * @param offset - Absolute position in source lob - * @param length - Number of bytes or characters to erase - * - * @note - * Absolute position starts at 0. - * Erasing means that space or null values overwrite the existing LOB value. - * - * @return - * Number of characters or bytes erased - * - */ - big_uint Erase(big_uint offset, big_uint length); - - /** - * @brief - * Copy the given portion of the lob content to another one - * - * @param dest - Destination lob - * @param offset - Absolute position in the lob - * @param offsetDest - Absolute position in the destination lob - * @param length - Number of characters or bytes to copy - * - * @note - * Absolute position starts at 0. - * - */ - void Copy(Lob &dest, big_uint offset, big_uint offsetDest, big_uint length) const; - - /** - * @brief - * Check if the given lob is a temporary lob - * - */ - bool IsTemporary() const; - - /** - * @brief - * Check if the given lob is a remote lob - * - */ - bool IsRemote() const; - - /** - * @brief - * Open explicitly a Lob - * - * @param mode - open mode - * - * @note - * - A call to Open() is not necessary to manipulate a Lob. - * - If a lob has not been opened explicitly, triggers are fired and - * indexes updated at every read/write/append operation - * - */ - void Open(OpenMode mode); - - /** - * @brief - * Flush the lob content to the server (if applicable) - * - */ - void Flush(); - - /** - * @brief - * Close explicitly a Lob - * - * @note - * - A call to Close() is not necessary to manipulate a Lob. - * - */ - void Close(); - - /** - * @brief - * Enable / disable buffering mode on the given lob object - * - * @param value - Enable/disable buffering mode - * - * @note - * Oracle "LOB Buffering Subsystem" allows client applications - * to speedup read/write of small buffers on Lobs Objects. - * Check Oracle Documentation for more details on "LOB Buffering Subsystem". - * This reduces the number of network round trips and LOB versions, thereby - * improving LOB performance significantly. - * - * @warning - * According to Oracle documentation the following operations are not permitted - * on Lobs when buffering is on : Copy(), Append(), Erase(), GetLength(), Truncate() - * - */ - void EnableBuffering(bool value); - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Lob Clone() const; - - /** - * @brief - * Appending the given lob content to the current lob content - * - */ - Lob& operator += (const Lob& other); - - /** - * @brief - * Indicates if the current lob value is equal to the given lob value - * - */ - bool operator == (const Lob& other) const; - - /** - * @brief - * Indicates if the current lob value is not equal the given lob value - * - */ - bool operator != (const Lob& other) const; - -private: - - bool Equals(const Lob &other) const; - - Lob(OCI_Lob *pLob, Handle *parent = nullptr); - -}; - -/** -* -* @brief -* Class handling CLOB oracle type -* -* @note -* Length and size arguments / returned values are expressed in number of characters -* -*/ -typedef Lob Clob; - -/** -* -* @brief -* Class handling NCLOB oracle type -* -* @note -* Length and size arguments / returned values are expressed in number of characters -* -*/ -typedef Lob NClob; - -/** -* -* @brief -* Class handling BLOB oracle type -* -* @note -* Length and size arguments / returned values are expressed in number of bytes -* -*/ -typedef Lob Blob; - -/** - * - * @brief - * Object identifying the SQL data type BFILE. - * - * This class wraps the OCILIB object handle OCI_File and its related methods - * - */ -class File : public HandleHolder -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class Collection; - -public: - - /** - * @brief - * Create an empty null File instance - * - */ - File(); - - /** - * @brief - * Parametrized constructor - * - * @param connection - Parent connection - * - * @note - * the file object must not be accessed anymore once the parent connection object gets out of scope - * - */ - File(const Connection &connection); - - /** - * @brief - * Parametrized constructor - * - * @param connection - Parent connection - * @param directory - File directory - * @param name - File name - * - * this convenient constructor calls File::SetInfos() - * - * @note - * the file object must not be accessed anymore once the parent connection object gets out of scope - * - */ - File(const Connection &connection, const ostring& directory, const ostring& name); - - /** - * @brief - * Read a portion of a file - * - * @param size - Maximum number of bytes to read - * - * @return - * The content read from the file - * - */ - Raw Read(unsigned int size); - - /** - * @brief - * Move the current position within the file for read/write operations - * - * @param seekMode - Seek mode - * @param offset - offset from current position - * - * @note - * Positions start at 0. - * - * @return - * true on success otherwise false - * - */ - bool Seek(SeekMode seekMode, big_uint offset); - - /** - * @brief - * Check if the given file exists on server - * - * @note - * For local FILEs object, SetInfos() must be called before calling Exists() - * - */ - bool Exists() const; - - /** - * @brief - * Returns the current R/W offset within the file - * - */ - big_uint GetOffset() const; - - /** - * @brief - * Returns the number of bytes contained in the file - * - */ - big_uint GetLength() const; - - /** - * @brief - * Return the file parent connection - * - */ - Connection GetConnection() const; - - /** - * @brief - * Set the directory and file name of our file object - * - * @param directory - File directory - * @param name - File name - * - * @note - * - For local FILEs only - * - Files fetched from resultset can't be assigned a new directory and name - * - */ - void SetInfos(const ostring& directory, const ostring& name); - - /** - * @brief - * Return the file name - * - */ - ostring GetName() const; - - /** - * @brief - * Return the file directory - * - */ - ostring GetDirectory() const; - - /** - * @brief - * Open a file for reading on the server - * - */ - void Open(); - - /** - * @brief - * Close the file on the server - * - */ - void Close(); - - /** - * @brief - * Check if the specified file is currently opened on the server by our object - * - */ - bool IsOpened() const; - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - File Clone() const; - - /** - * @brief - * Indicates if the current file value is equal the given file value - * - */ - bool operator == (const File& other) const; - - /** - * @brief - * Indicates if the current file value is not equal the given file value - * - */ - bool operator != (const File& other) const; - -private: - - bool Equals(const File &other) const; - - File(OCI_File *pFile, Handle *parent = nullptr); -}; - -/** - * @brief - * Provides type information on Oracle Database objects - * - * This class wraps the OCILIB object handle OCI_TypeInfo and its related methods - * - */ -class TypeInfo : public HandleHolder -{ - friend class Object; - friend class Reference; - template - friend class Collection; - friend class Column; -public: - - /** - * @brief - * Type of object information enumerated values - * - */ - enum TypeInfoTypeValues - { - /** Database Table information */ - Table = OCI_TIF_TABLE, - /** Database View information */ - View = OCI_TIF_VIEW, - /** Database type information */ - Type = OCI_TIF_TYPE - }; - - /** - * @brief - * Type of object information - * - * Possible values are TypeInfo::TypeInfoTypeValues - * - */ - typedef Enum TypeInfoType; - - /** - * @brief - * Parametrized constructor - * - * @param connection - Parent connection - * @param name - Type name - * @param type - Kind of type to retrieve - * - * @note - * the TypeInfo object must not be accessed anymore once the parent connection object gets out of scope - * - */ - TypeInfo(const Connection &connection, const ostring& name, TypeInfoType type); - - /** - * @brief - * Return the type of the given TypeInfo object - * - */ - TypeInfoType GetType() const; - - /** - * @brief - * Return the type info name - * - */ - ostring GetName() const; - - /** - * @brief - * Return the connection associated with a statement - * - */ - Connection GetConnection() const; - - /** - * @brief - * Return the number of columns contained in the type - * - * @note - * - For table and views, it is the number of columns - * - For types, it is the number of member properties - * - */ - unsigned int GetColumnCount() const; - - /** - * @brief - * Return the column from its index in the resultset - * - * @param index - Column index - * - * @note - * Column position starts at 1. - * - * @note - * - For table and views, the returned column object describes a table/view column - * - For types, the returned column object describes an object property - * - */ - Column GetColumn(unsigned int index) const; - - /** - * @brief - * Indicate if the given UDT type is final - * - * @note - * Non-final types are virtual UDT type that can be inherited - * - * @return - * - For table and views, it returns true - * - For types, it returns true if the type is final and false if it is virtual - * - */ - boolean IsFinalType() const; - - /** - * @brief - * Return the super type of the given type (e.g. parent type for a derived ORACLE UDT type) - * - * @note - * This property is only valid for types - * - * @return - * - For table and views, it return a null TypeInfo object - * - For types: - * - returns a valid TypeInfo object wrapping the parent super type - * - returns a null TypeInfo object if the given type is NOT deriving from a base type - * - */ - TypeInfo GetSuperType() const; - -private: - - TypeInfo(OCI_TypeInfo *pTypeInfo); -}; - -/** - * @brief - * Object identifying the SQL data type OBJECT. - * - * This class wraps the OCILIB object handle OCI_Object and its related methods - * - */ -class Object : public HandleHolder, public Streamable -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Reference; - template - friend class Collection; - friend class Message; - -public: - - /** - * @brief - * Object Type enumerated values - * - */ - enum ObjectTypeValues - { - /** The object is persistent in the database */ - Persistent = OCI_OBJ_PERSISTENT, - /** The object is Transient */ - Transient = OCI_OBJ_TRANSIENT, - /** The object is a value member of another object */ - Value = OCI_OBJ_VALUE - }; - - /** - * @brief - * Object Type - * - * Possible values are Object::ObjectTypeValues - * - */ - typedef Enum ObjectType; - - /** - * @brief - * Create an empty null Object instance - * - */ - Object(); - - /** - * @brief - * Parametrized constructor - * - * @param typeInfo - type info descriptor - * - */ - Object(const TypeInfo &typeInfo); - - /** - * @brief - * Check if an object attribute is null - * - * @param name - Attribute name - * - */ - bool IsAttributeNull(const ostring& name) const; - - /** - * @brief - * Set the given object attribute to null - * - * @param name - Attribute name - * - */ - void SetAttributeNull(const ostring& name); - - /** - * @brief - * Return the TypeInfo object describing the object - * - */ - TypeInfo GetTypeInfo() const; - - /** - * @brief - * Creates a reference on the current object - * - */ - Reference GetReference() const; - - /** - * @brief - * Return the type of the given object - * - */ - ObjectType GetType() const; - - /** - * @brief - * Return the given object attribute value - * - * @tparam T - C++ object type to retrieve - * - * @param name - Attribute name - * - * @note - * Specialized version of this template function are provided for all supported types - * - */ - template - T Get(const ostring& name) const; - - /** - * @brief - * Assign the given value with the given object attribute value - * - * @tparam T - C++ object type to retrieve - * - * @param name - Attribute name - * @param value - value to assign - * - * @note - * Specialized version of this template function are provided for all supported types - * - */ - template - void Get(const ostring& name, T &value) const; - - /** - * @brief - * Assign the given collection with the given object attribute value of type collection - * - * @tparam T - C++ object type of the collection to retrieve - * - * @param name - Attribute name - * @param value - value to assign - * - * @note - * Specialized version of this template function are provided for all supported types - * - */ - template - void Get(const ostring& name, Collection &value) const; - - /** - * @brief - * Set the given object attribute value - * - * @tparam T - C++ object type to set - * - * @param name - Attribute name - * @param value - Attribute value - * - * @note - * Specialized version of this template function are provided for all supported types - * - */ - template - void Set(const ostring& name, const T &value); - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Object Clone() const; - - /** - * @brief - * return a string representation of the current object - * - */ - ostring ToString() const override; - -private: - - Object(OCI_Object *pObject, Handle *parent = nullptr); -}; - -/** - * @brief - * Object identifying the SQL data type REF. - * - * This class wraps the OCILIB object handle OCI_Ref and its related methods - * - */ -class Reference : public HandleHolder, public Streamable -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class Collection; - -public: - - /** - * @brief - * Create an empty null Reference instance - * - */ - Reference(); - - /** - * @brief - * Parametrized constructor - * - * @param typeInfo - type info descriptor - * - */ - Reference(const TypeInfo &typeInfo); - - /** - * @brief - * Return the TypeInfo object describing the referenced object - * - */ - TypeInfo GetTypeInfo() const; - - /** - * @brief - * Returns the object pointed by the reference - * - * @return - * The object may bu null is the current reference value is null - * - */ - Object GetObject() const; - - /** - * @brief - * Check if the reference points to an object or not. - * - */ - bool IsReferenceNull() const; - - /** - * @brief - * Nullify the given Ref handle - * - * @note - * this call clears the reference to object pointed by the reference object. - * - */ - void SetReferenceNull(); - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Reference Clone() const; - - /** - * @brief - * return a string representation of the current reference - * - */ - ostring ToString() const override; - -private: - - Reference(OCI_Ref *pRef, Handle *parent = nullptr); -}; - -/** -* @brief -* Class used for handling transient collection value. -* it is used internally by the Collection class: -* - the Collection<> indexer operator in order to provide lvalue for read/write access -* - the CollectionIterator class -* -*/ -template -class CollectionElement -{ - template - friend class CollectionIterator; - -public: - - typedef T ValueType; - typedef Collection CollectionType; - - CollectionElement(); - CollectionElement(CollectionType *coll, unsigned int pos); - operator T() const; - CollectionElement& operator = (const ValueType& other); - CollectionElement& operator = (const CollectionElement& other); - bool IsNull() const; - void SetNull(); - -private: - - CollectionType* _coll; - unsigned int _pos; -}; - -/** -* @brief -* STL compliant Collection Random iterator class -* -* @warning this iterator does not support the operator[] -* -*/ -template -class CollectionIterator -{ -public: - - template - friend class Collection; - - typedef typename T::ValueType value_type; - typedef Collection CollectionType; - - typedef std::random_access_iterator_tag iterator_category; - typedef ptrdiff_t difference_type; - typedef ptrdiff_t distance_type; - typedef value_type* pointer; - typedef value_type& reference; - - CollectionIterator(); - CollectionIterator(const CollectionIterator& other); - - CollectionIterator& operator = (const CollectionIterator& other); - - CollectionIterator& operator += (difference_type value); - CollectionIterator& operator -= (difference_type value); - - T& operator*(); - T* operator->(); - - CollectionIterator& operator++(); - CollectionIterator& operator--(); - - CollectionIterator operator++(int); - CollectionIterator operator--(int); - - CollectionIterator operator + (difference_type value); - CollectionIterator operator - (difference_type value); - - difference_type operator - (const CollectionIterator & other); - - bool operator == (const CollectionIterator& other); - bool operator != (const CollectionIterator& other); - bool operator > (const CollectionIterator& other); - bool operator < (const CollectionIterator& other); - bool operator >= (const CollectionIterator& other); - bool operator <= (const CollectionIterator& other); - -protected: - - CollectionIterator(CollectionType *collection, unsigned int pos); - - T _elem; -}; - -/** - * @brief - * Object identifying the SQL data types VARRAY and NESTED TABLE. - * - * This class wraps the OCILIB object handle OCI_Coll and its related methods - * - */ -template -class Collection : public HandleHolder, public Streamable -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - friend class Object; - template - friend class CollectionIterator; - template - friend class Collection; - -public: - - /** - * @brief - * Collection type enumerated values - * - */ - enum CollectionTypeValues - { - /** Collection is a VARRAY */ - Varray = OCI_COLL_VARRAY, - /** Collection is a NESTED TABLE */ - NestedTable = OCI_COLL_NESTED_TABLE, - /** Collection is a PL/SQL TABLE INDEX BY */ - IndexedTable = OCI_COLL_INDEXED_TABLE - }; - - /** - * @brief - * Collection type - * - * Possible values are Collection::CollectionTypeValues - * - */ - typedef Enum CollectionType; - - /** - * @brief - * Create an empty null Collection instance - * - */ - Collection(); - - /** - * @brief - * Parametrized constructor - * - * @param typeInfo - type info descriptor - * - */ - Collection(const TypeInfo &typeInfo); - - /** - * @brief - * Return the type of the collection - * - */ - CollectionType GetType() const; - - /** - * @brief - * Returns the maximum number of elements for the collection - * - */ - unsigned int GetMax() const; - - /** - * @brief - * Returns the total number of elements in the collection - * - */ - unsigned int GetSize() const; - - /** - * @brief - * Returns the current number of elements in the collection - * - * @note - * - For VARRAYs, it returns the same value than GetSize() as VARRAYs cannot contains holes - * - For Nested Tables that are spare collections that can have holes, it returns the total number - * of elements minus the total of deleted elements - * - */ - unsigned int GetCount() const; - - /** - * @brief - * Trim the given number of elements from the end of the collection - * - * @param size - Number of elements to trim - * - */ - void Truncate(unsigned int size); - - /** - * @brief - * Clear all items of the collection - * - */ - - void Clear(); - - /** - * @brief - * check if the element at the given index is null - * - * @param index - Index of the element - * - * @note - * Collection Index start at 1 - * - */ - bool IsElementNull(unsigned int index) const; - - /** - * @brief - * Nullify the element at the given index - * - * @param index - Index of the element - * - * @note - * Collection Index start at 1 - * - */ - void SetElementNull(unsigned int index); - - /** - * @brief - * Delete the element at the given position in the Nested Table Collection - * - * @param index - Index of the element to delete - * - * @note - * Collection indexes start at position 1. - * - * @warning - * Delete() is only valid for nested tables (e.g. when collection type is Collection::NestedTable - * - * @return - * - if the input collection is a nested table, it returns true if the element is successfully deleted - * - if the input collection is a VARRAY, it always returns false - * - */ - bool Delete(unsigned int index) const; - - /** - * @brief - * Return the collection element value at the given position - * - * @param index - Index of the element - * - */ - T Get(unsigned int index) const; - - /** - * @brief - * Set the collection element value at the given position - * - * @param index - Index of the element - * @param value - Value to set - * - */ - void Set(unsigned int index, const T &value); - - /** - * @brief - * Append the given element value at the end of the collection - * - * @param value - Value to add - * - * - */ - void Append(const T &value); - - /** - * @brief - * Return the type information object associated to the collection - * - */ - TypeInfo GetTypeInfo() const; - - /** - * @brief - * Clone the current instance to a new one performing deep copy - * - */ - Collection Clone() const; - - /** - * @brief - * return a string representation of the current collection - * - */ - ostring ToString() const override; - - /** - * @brief - * Common iterator declaration - * - */ - typedef CollectionIterator > iterator; - - /** - * @brief - * Common const iterator declaration - * - */ - typedef CollectionIterator > const_iterator; - - /** - * @brief - * Returns an iterator pointing to the first element in the collection - * - */ - iterator begin(); - - /** - * @brief - * Returns a const iterator pointing to the first element in the collection - * - */ - const_iterator begin() const; - - /** - * @brief - * Returns an iterator referring to the past-the-end element in the collection - * - */ - iterator end(); - - /** - * @brief - * Returns a const iterator referring to the past-the-end element in the collection - * - */ - const_iterator end() const; - - /** - * @brief - * Returns the element at a given position in the collection. - * - */ - CollectionElement operator [] (unsigned int index); - - /** - * @brief - * Returns the element at a given position in the collection. - * - */ - CollectionElement operator [](unsigned int index) const; - -private: - - static T GetElem(OCI_Elem *elem, Handle *parent); - - static void SetElem(OCI_Elem *elem, const T &value); - - Collection(OCI_Coll *pColl, Handle *parent = nullptr); -}; - -/** - * @brief - * Object identifying the SQL data type LONG. - * - * This class wraps the OCILIB object handle OCI_LONG of type OCI_CLONG and its related methods - * - */ -template -class Long : public HandleHolder -{ - friend class Statement; - friend class Resultset; - friend class BindArray; - -public: - - /** - * @brief - * Create an empty null Long instance - * - */ - Long(); - - /** - * @brief - * Constructor - * - * @param statement - statement object that will handle operations on the long buffer - * - */ - Long(const Statement &statement); - - /** - * @brief - * Write the given string into the long Object - * - * @param content - string to write - * - * @return - * Number of character written - * - */ - unsigned int Write(const T& content); - - /** - * @brief - * Return the buffer length - * - */ - unsigned int GetLength() const; - - /** - * @brief - * Return the string read from a fetch sequence - * - */ - T GetContent() const; - -private: - - Long(OCI_Long *pLong, Handle *parent = nullptr); -}; - -/** - * @brief - * Provides SQL bind information - * - * This class wraps the OCILIB object handle OCI_Bind and its related methods - * - */ -class BindInfo : public HandleHolder -{ - friend class Statement; - -public: - - /** - * @brief - * Bind direction enumerated values - * - */ - enum BindDirectionValues - { - /** Input bind variable (will be not modified as it is an input value for the server) */ - In = OCI_BDM_IN, - /** Output bind variable (will be modified as it is an output value by the server ) */ - Out = OCI_BDM_OUT, - /** Input / Output bind variable (can be modified as it is an input value that can be modified by the server) */ - InOut = OCI_BDM_IN_OUT - }; - - /** - * @brief - * Bind direction - * - * Possible values are BindInfo::BindDirectionValues - * - */ - typedef Enum BindDirection; - - /** - * @brief - * Vector type values - * - */ - enum VectorTypeValues - { - /** Vector is binded as an array in a regular DML array operation */ - AsArray = 1, - /** Vector is binded as a PL/SQL index by table */ - AsPlSqlTable = 2 - }; - - /** - * @brief - * Vector type - * - * Possible values are BindInfo::VectorTypeValues - * - */ - typedef Enum VectorType; - - /** - * @brief - * Return the name of the bind object - * - */ - ostring GetName() const; - - /** - * @brief - * Return the OCILIB type of the data associated with the bind object - * - */ - DataType GetType() const; - - /** - * @brief - * Return the OCILIB object subtype of a column - * - * @note - * This call is valid for the following OCILIB types: - * - Scalar numeric types - * - Clong and Blong - * - Clob, NClob and Blob - * - File - * - Timestamp - * - Interval - * - * @warning - * - Cast returned values to the matching C++ class GetType() property type. - * - For scalar numeric types, cast returned value to ocilib::NumericType values. - * - For a non valid type, it returns 0. - * - */ - unsigned int GetSubType() const; - - /** - * @brief - * Return the number of elements associated with the bind object - * - * @return - * - For single binds, it returns 1 - * - For vector binds, it returns the number of element in the bind array - * - */ - unsigned int GetDataCount() const; - - /** - * @brief - * Return the statement associated with the bind object - * - */ - Statement GetStatement() const; - - /** - * @brief - * Mark as null or not null the current bind real value(s) used in SQL statements - * - * @param value - null status value - * @param index - Only valid for vectors : index of the element to check - * - * @note - * There is no notion of null value in C C++ for scalar types. - * It's necessary to explicitly tell Oracle that the bind has a null value. - * It must be done before an Execute() call - * - * @warning - * For handled based data types (non scalar types), OCILIB performs an extra - * check on handles and set the bind status to null is the handle is null - * - * @warning - * Index starts with 1 - * - */ - void SetDataNull(bool value, unsigned int index = 1); - - /** - * @brief - * Check if the current bind value(s) used in SQL statements is marked as NULL - * - * @param index - Only valid for vectors : index of the element to check - * - * @note - * If the bind is related to a single host variable, don't use the parameter index - * If the bind is related to host vectors, the parameter 'index' refers to the index in the vector - * - * @warning - * Index starts with 1 - * - */ - bool IsDataNull(unsigned int index = 1) const; - - /** - * @brief - * Set the charset form of the given character based bind object - * - * @param value - charset form - * - * @note - * This call has to be made after Statement::Prepare() but before Statement::Execute() - * - * @warning - * This call does nothing the bind data type is not ocilib::TypeString or ocilib::TypeLong - * - */ - void SetCharsetForm(CharsetForm value); - - /** - * @brief - * Get the direction mode - * - */ - BindDirection GetDirection() const; - -private: - - BindInfo(OCI_Bind *pBind, Handle *parent); -}; - -/** -* @brief -* Object used for executing SQL or PL/SQL statement and returning the produced results. -* -* This class wraps the OCILIB object handle OCI_Statement and its related methods -* -*/ -class Statement : public HandleHolder -{ - friend class Exception; - friend class Resultset; - template - friend class Long; - friend class BindInfo; - friend class BindObject; - -public: - - /** - * @brief - * Statement Type enumerated values - * - */ - enum StatementTypeValues - { - /** SELECT statement */ - TypeSelect = OCI_CST_SELECT, - /** UPDATE statement */ - TypeUpdate = OCI_CST_UPDATE, - /** DELETE statement */ - TypeDelete = OCI_CST_DELETE, - /** INSERT statement */ - TypeInsert = OCI_CST_INSERT, - /** CREATE statement */ - TypeCreate = OCI_CST_CREATE, - /** DROP statement */ - TypeDrop = OCI_CST_DROP, - /** ALTER statement */ - TypeAlter = OCI_CST_ALTER, - /** BEGIN statement */ - TypeBegin = OCI_CST_BEGIN, - /** DECLARE statement */ - TypeDeclare = OCI_CST_DECLARE, - /** CALL statement */ - TypeCall = OCI_CST_CALL, - /** MERGE statement */ - TypeMerge = OCI_CST_MERGE - }; - - /** - * @brief - * Statement Type - * - * Possible values are Statement::StatementTypeValues - * - */ - typedef Enum StatementType; - - /** - * @brief - * Fetch Modes enumerated values - * - */ - enum FetchModeValues - { - /** Statement is forward only */ - FetchForward = OCI_SFM_DEFAULT, - /** Statement is scrollable */ - FetchScrollable = OCI_SFM_SCROLLABLE - }; - - /** - * @brief - * Fetch Modes - * - * Possible values are Statement::FetchModeValues - * - */ - typedef Enum FetchMode; - - /** - * @brief - * Bind Modes enumerated values - * - */ - enum BindModeValues - { - /** Bind variables are binded by name */ - BindByPosition = OCI_BIND_BY_POS, - /** Bind variables are binded by position */ - BindByName = OCI_BIND_BY_NAME - }; - - /** - * @brief - * Bind Modes - * - * Possible values are Statement::BindModeValues - * - */ - typedef Enum BindMode; - - /** - * @brief - * LONG data type mapping modes enumerated values - * - */ - enum LongModeValues - { - /** LONG and LONG RAW are mapped to Long objects */ - LongExplicit = OCI_LONG_EXPLICIT, - /** LONG and LONG RAW are mapped to ostring objects */ - LongImplicit = OCI_LONG_IMPLICIT - }; - - /** - * @brief - * LONG data type mapping modes - * - * Possible values are Statement::LongModeValues - * - */ - typedef Enum LongMode; - - /** - * @brief - * Create an empty null Statement instance - * - */ - Statement(); - - /** - * @brief - * Parametrized constructor - * - * @param connection - Parent connection - * - * @note - * - The statement object must not be accessed anymore once the parent connection object gets out of scope - * - */ - Statement(const Connection &connection); - - /** - * @brief - * Return the connection associated with a statement - * - */ - Connection GetConnection() const; - - /** - * @brief - * Describe the select list of a SQL select statement. - * - * @param sql - SELECT sql statement - * - * @note - * This call sends the SELECT SQL order to the server for retrieving the - * description of the select order only. - * The command is not executed. - * This call is only useful to retrieve information on the associated resultset - * Call GetResultset() after Describe() to access to SELECT list information - * - * @note - * This call prepares the statement (internal call to Prepare()) and ask - * the Oracle server to describe the output SELECT list. - * Execute() can be called after Describe() in order to execute the - * statement, which means that the server will parse, and describe again the SQL - * order. - * - * @warning - * Do not use Describe() unless you're only interested in the resultset - * information because the statement will be parsed again when executed and thus - * leading to unnecessary server round trips and less performance - * - */ - void Describe(const ostring& sql); - - /** - * @brief - * Parse a SQL statement or PL/SQL block. - * - * @param sql - SQL order - PL/SQL block - * - * @note - * This call sends the SQL or PL/SQL command to the server for parsing only. - * The command is not executed. - * This call is only useful to check is a command is valid or not. - * - * @note - * This call prepares the statement (internal call to Prepare()) and ask - * the Oracle server to parse its SQL or PL/SQL command. - * Execute() can be call after Parse() in order to execute the - * statement, which means that the server will parse again the command. - * - * @warning - * Do not use Parse() unless you're only interested in the parsing result - * because the statement will be parsed again when executed and thus leading to - * unnecessary server round trips and less performance - * - */ - void Parse(const ostring& sql); - - /** - * @brief - * Prepare a SQL statement or PL/SQL block. - * - * @param sql - SQL order or PL/SQL block - * - * @note - * With version 1.3.0 and above, do not call this function for fetched statements (REF cursors) - * - */ - void Prepare(const ostring& sql); - - /** - * @brief - * Execute a prepared SQL statement or PL/SQL block. - * - */ - void ExecutePrepared(); - - /** - * @brief - * Prepare and execute a SQL statement or PL/SQL block. - * - * @param sql - SQL order - PL/SQL block - * - */ - void Execute(const ostring& sql); - - /** - * @brief - * Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets - * - * @tparam TFetchCallback - type of the fetch callback - * - * @param callback - User defined callback - * - * @note - * The user defined callback function must conform to the following prototype: - * bool callback(const Resultset &) - * It shall return true to continue fetching the resultset or false to stop the fetch - * - * @return - * The number of rows fetched - * - */ - template - unsigned int ExecutePrepared(T callback); - - /** - * @brief - * Execute the prepared statement, retrieve all resultsets, and call the given callback - * with adapted type wit for each row of each resultsets - * - * @tparam TAdapter - type of the adapter callback - * @tparam TFetchCallback - type of the fetch callback - * - * @param callback - User defined callback - * @param adapter - User defined adapter function - * - * @note - * The user defined callback function must conform to the following prototype: - * bool callback(const Resultset &) - * It shall return true to continue fetching the resultset or false to stop the fetch - * - * @return - * The number of rows fetched - * - */ - template - unsigned int ExecutePrepared(T callback, U adapter); - - /** - * @brief - * Execute the given SQL statement, retrieve all resultsets, and call the given callback for each row of each resultsets - * - * @tparam TFetchCallback - type of the fetch callback - * - * @param sql - SQL order - PL/SQL block - * @param callback - User defined callback - * - * @note - * The user defined callback function must conform to the following prototype: - * bool callback(const Resultset &) - * It shall return true to continue fetching the resultset or false to stop the fetch - * - * @return - * The number of rows fetched - * - */ - template - unsigned int Execute(const ostring& sql, T callback); - - /** - * @brief - * Execute the given SQL statement, retrieve all resultsets, and call the given callback - * with adapted type wit for each row of each resultsets - * - * @tparam TAdapter - type of the adapter callback - * @tparam TFetchCallback - type of the fetch callback - * - * @param sql - SQL order - PL/SQL block - * @param callback - User defined callback - * @param adapter - User defined adapter function - * - * @note - * The user defined callback function must conform to the following prototype: - * bool callback(const Resultset &) - * It shall return true to continue fetching the resultset or false to stop the fetch - * - * @return - * The number of rows fetched - * - */ - template - unsigned int Execute(const ostring& sql, T callback, U adapter); - - /** - * @brief - * Return the number of rows affected by the SQL statement - * - * - * The returned value is : - * - For UPDATEs : number of rows updated - * - For INSERTs : number of rows inserted - * - For DELETEs : number of rows deleted - * - * @note - * For SELECTs statements, use GetRowCount() instead - * - */ - unsigned int GetAffectedRows() const; - - /** - * @brief - * Return the last SQL or PL/SQL statement prepared or executed by the statement - * - */ - ostring GetSql() const; - - /** - * @brief - * Return the server SQL_ID of the last SQL or PL/SQL statement prepared or executed by the statement - * - */ - ostring GetSqlIdentifier() const; - - /** - * @brief - * Retrieve the resultset from an executed statement - * - * @note - * See @ref OcilibCApiFetching for more details about what statements can return resultsets - * - * @warning - * If the statement has not been prepared and executed, null resultset object will be returned - * - */ - Resultset GetResultset(); - - /** - * @brief - * Retrieve the next available resultset - * - * @note - * it is only valid for the following statements: - * - Statements executing SQL UPDATE/DELETE using a RETURNING INTO clause - * - Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using - * DBMS_SQL.RETURN_RESULT() - * - * @note - * SQL statements with a 'returning' clause can return multiple resultsets. - * When arrays of program variables are binded to the statement, Oracle will - * execute the statement for every row (iteration). - * Each iteration generates a resultset that can be fetched like regular ones. - * - * @note - * Starting withOracle 12cR1, PL/SQ procedure and blocks can return multiple implicit resultsets - * Refer to Oracle documentation for more information. - * - */ - Resultset GetNextResultset(); - - /** - * @brief - * Set the input array size for bulk operations - * - * @param size - Array size - * - * @warning - * Do not use SetBindArraySize() for PL/SQL tables binding - * - * @note - * SetBindArraySize() is used to set the size of input bind array when using - * arrays for DML statements. - * SetBindArraySize() MUST be called to set the maximum size of the arrays - * to bind to the statement before any of its execution. This initial call must - * be bone AFTER OPrepare() and BEFORE any Bind() call taking vectors as parameter. - * - * @note - * SetBindArraySize() can optionally be called before any later Execute() - * call in order to notify the statement of the exact number of elements - * populating the input arrays for the next execution. The array size passed to - * later SetBindArraySize() calls cannot be greater than the initial size - * otherwise an exception will be thrown. - * - */ - void SetBindArraySize(unsigned int size); - - /** - * @brief - * Return the current input array size for bulk operations - * - */ - unsigned int GetBindArraySize() const; - - /** - * @brief - * Allow different host variables to be binded using the same bind name or - * position between executions of a prepared statement - * - * @param value - Rebinding mode allowed - * - * @note - * Default value is false - * - * @warning - * When using rebinding feature, host variable re-binded to a previously allocated - * bind MUST be of the same data type ! - * - */ - void AllowRebinding(bool value); - - /** - * @brief - * Indicate if rebinding is allowed on the statement - * - * @note - * See AllowRebinding() for more details - * - */ - bool IsRebindingAllowed() const; - - /** - * @brief - * Return the index of the bind from its name belonging to the statement - * - * @param name - Bind variable name - * - * @warning - * The bind name is case insensitive - * - * @note - * Bind indexes start with 1 in OCILIB - * - * @return - * Bind index on success or zero if the bind does not exists - * - */ - unsigned int GetBindIndex(const ostring& name) const; - - /** - * @brief - * Return the number of binds currently associated to a statement - * - */ - unsigned int GetBindCount() const; - - /** - * @brief - * Return the bind at the given index in the internal array of bind objects - * - * @param index - Bind position - * - * @warning - * Index starts at 1. - * - * @note - * Bind handle are created sequentially. For example, the third call to a - * Bind() call generates a bind object of index 3. - * - */ - BindInfo GetBind(unsigned int index) const; - - /** - * @brief - * Return a bind handle from its name - * - * @param name - Bind variable name - * - * @note - * Bind names must include a semicolon at the beginning. - * - */ - BindInfo GetBind(const ostring& name) const; - - /** - * @brief - * Bind an host variable - * - * @tparam T - C++ type of the host variable - * - * @param name - Bind name - * @param value - Host variable - * @param mode - bind direction mode - * - * @warning - * This method has built-in specialized versions for all supported types except ostring, Clong and Blong variables. - * For binding ostring, Clong and Blong variables, use the version with an extra parameter. - * - * @note - * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved - * automatically from the arguments. - * - */ - template - void Bind(const ostring& name, T &value, BindInfo::BindDirection mode); - - /** - * @brief - * Bind an host variable with more information - * - * @tparam T - C++ type of the host variable - * @tparam TExtraInfo - C++ type if the extra information needed for the bind call - * - * @param name - Bind name - * @param value - Host variable - * @param extraInfo - Extra information needed for the bind call - * @param mode - bind direction mode - * - * @warning - * This method has built-in specialized versions for ostring, Clong and Blong variables. - * Pass the maximum length/size of the variable in the parameter extraInfo - * - * @note - * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved - * automatically from the arguments. - * - */ - template - void Bind(const ostring& name, T &value,U extraInfo, BindInfo::BindDirection mode); - - /** - * @brief - * Bind a host collection variable - * - * @tparam T - C++ type of the host collection variable - * - * @param name - Bind name - * @param value - Host Collection variable - * @param mode - bind direction mode - * - */ - template - void Bind(const ostring& name, Collection &value, BindInfo::BindDirection mode); - - /** - * @brief - * Bind a vector of host variables - * - * @tparam T - C++ type of the host variable - * - * @param name - Bind name - * @param values - Vector of host variables - * @param mode - bind direction mode - * @param type - vector type (regular array or PL/SQL table) - * - * @warning - * This method has built-in specialized versions for all C++ native scalar types, Date time and Statement objects. - * For others types (ostring, Clong, Blong, Raw, Object, Reference, Collection, Timestamp, Interval), use versions with extra parameters. - * - * @note - * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved - * automatically from the arguments. - * - */ - template - void Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); - - /** - * @brief - * Bind a vector of host variables with Oracle type information - * - * @tparam T - C++ type of the host variable - * - * @param name - Bind name - * @param values - Vector of host variables - * @param typeInfo - Object type information - * @param mode - bind direction mode - * @param type - vector type (regular array or PL/SQL table) - * - * @warning - * This method has built-in specialized versions for Object, Reference. - * - * @note - * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved - * automatically from the arguments. - * - */ - template - void Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); - - /** - * @brief - * Bind a vector of host collection variables with Oracle type information - * - * @tparam T - collection C++ type of the host collection variables - * - * @param name - Bind name - * @param values - Vector of host collection variables - * @param typeInfo - Object type information - * @param mode - bind direction mode - * @param type - vector type (regular array or PL/SQL table) - * - */ - template - void Bind(const ostring& name, std::vector > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); - - /** - * @brief - * Bind a vector of host variables with more information - * - * @tparam T - C++ type of the host variable - * @tparam TExtraInfo - C++ type if the extra information needed for the bind call - * - * @param name - Bind name - * @param values - Vector of host variables - * @param extraInfo - Extra information needed for the bind call - * @param mode - bind direction mode - * @param type - vector type (regular array or PL/SQL table) - * - * @warning - * This method has built-in specialized versions for ostring, Raw , Clong, Blong, Timestamp, Interval variables. - * - For ostring, Clong, Blong, Raw : Pass the maximum length/size of variables in the parameter extraInfo - * - For Timestamp, Interval : Pass a value of the matching C++ class GetType() property type OR the underlying enumeration type. - * - * @note - * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved - * automatically from the arguments. - * - */ - template - void Bind(const ostring& name, std::vector &values, U extraInfo, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); - - /** - * @brief - * Register a host variable as an output for a column present in a SQL RETURNING INTO clause - * - * @tparam T - C++ type of the host variable - * - * @param name - Bind name - * - * @warning - * This method has built-in specialized versions for all supported types except: - * - Timestamp and Interval, Object and Reference : use the version that takes a TypeInfo parameter - * - ostring and Raw : use the version that takes an extraInfo parameter - * - * @note - * Statement, Blong and Clong are not supported for register calls - * - * @warning - * It is necessary to specify the template data type in the register call - * - */ - template - void Register(const ostring& name); - - /** - * @brief - * Register a host variable with Oracle type information as an output for a column present in a SQL RETURNING INTO clause - * - * @tparam T - C++ type of the host variable - * @tparam TExtraInfo - C++ type if the extra information needed for the bind call - * - * @param name - Bind name - * @param extraInfo - Extra information needed for the bind call - * - * @warning - * This method has built-in specialized versions for Object and Reference. - * - * @warning - * It is necessary to specify the template data type in the register call - * - */ - template - void Register(const ostring& name, U& extraInfo); - - /** - * @brief - * Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause - * - * @tparam T - C++ type of the host variable - * @tparam TExtraInfo - C++ type if the extra information needed for the bind call - * - * @param name - Bind name - * @param extraInfo - Extra information needed for the bind call - * - * @warning - * This method has built-in specialized versions for ostring and Raw variables. - * Pass the maximum length/size of variables in the parameter extraInfo - * - * @note - * It is necessary to specify the template data type in the register call - * - */ - template - void Register(const ostring& name, U extraInfo); - - /** - * @brief - * Return the type of a SQL statement - * - */ - StatementType GetStatementType() const; - - /** - * @brief - * Return the error position (in terms of characters) in the SQL statement - * where the error occurred in case of SQL parsing error - * - * @note - * Positions start at 1. - * - */ - unsigned int GetSqlErrorPos() const; - - /** - * @brief - * Set the fetch mode of a SQL statement - * - * @param value - fetch mode value - * - * @warning - * SetFetchMode() MUST be called before any Execute() call - * - */ - void SetFetchMode(FetchMode value); - - /** - * @brief - * Return the fetch mode of a SQL statement - * - * @note - * Default value is Statement::FetchForward - * - */ - FetchMode GetFetchMode() const; - - /** - * @brief - * Set the binding mode of a SQL statement - * - * @param value - binding mode value - * - */ - void SetBindMode(BindMode value); - - /** - * @brief - * Return the binding mode of a SQL statement - * - * @note - * Default value is Statement::BindByName - * - */ - BindMode GetBindMode() const; - - /** - * @brief - * Set the number of rows fetched per internal server fetch call - * - * @param value - number of rows to fetch - * - */ - void SetFetchSize(unsigned int value); - - /** - * @brief - * Return the number of rows fetched per internal server fetch call - * - * @note - * Default value is set to constant OCI_FETCH_SIZE - * - */ - unsigned int GetFetchSize() const; - - /** - * @brief - * Set the number of rows pre-fetched by OCI Client - * - * @param value - number of rows to pre-fetch - * - * @note - * To turn off pre-fetching, set both attributes (size and memory) to 0. - * - */ - void SetPrefetchSize(unsigned int value); - - /** - * @brief - * Return the number of rows pre-fetched by OCI Client - * - * @note - * Default value is set to constant OCI_PREFETCH_SIZE - * - */ - unsigned int GetPrefetchSize() const; - - /** - * @brief - * Set the amount of memory pre-fetched by OCI Client - * - * @param value - amount of memory to fetch - * - * @note - * Default value is 0 and the pre-fetch size attribute is used instead. - * When both attributes are set (pre-fetch size and memory) and pre-fetch memory - * value can hold more rows than specified by pre-fetch size, OCI uses pre-fetch - * size instead. - * - * @note - * OCILIB set pre-fetch attribute to OCI_PREFETCH_SIZE when a statement is created. - * To setup a big value for SetPrefetchMemory(), you must call - * SetPrefetchSize() to 0 to make OCI consider this attribute. - * - */ - void SetPrefetchMemory(unsigned int value); - - /** - * @brief - * Return the amount of memory used to retrieve rows pre-fetched by OCI Client - * - * @note - * Default value is 0 - * - */ - unsigned int GetPrefetchMemory() const; - - /** - * @brief - * Set the LONG data type piece buffer size - * - * @param value - maximum size for long buffer - * - */ - void SetLongMaxSize(unsigned int value); - - /** - * @brief - * Return the LONG data type piece buffer size - * - * @note - * Default value is set to constant OCI_SIZE_LONG - * - */ - unsigned int GetLongMaxSize() const; - - /** - * @brief - * Set the long data type handling mode of a SQL statement - * - * @param value - long mode value - * - * @note - * LONG RAWs can't be handled with Statement::LongImplicit mode - * - */ - void SetLongMode(LongMode value); - - /** - * @brief - * Return the long data type handling mode of a SQL statement - * - */ - LongMode GetLongMode() const; - - /** - * @brief - * Return the Oracle SQL code the command held by the statement - * - * @warning - * GetSQLCommand() must be called after the statement has be executed - * because that's the server engine that computes the SQL command code - * - * @note - * The SQL command list is available in Oracle documentations and guides - * - */ - unsigned int GetSQLCommand() const; - - /** - * @brief - * Return the verb of the SQL command held by the statement - * - * @warning - * GetSQLVerb() must be called after the statement has been executed - * because that's the server engine that computes the SQL verb - * - * @note - * The SQL verb list is available in Oracle documentations and guides - * - */ - ostring GetSQLVerb() const; - - /** - * @brief - * Returns all errors that occurred within a DML array statement execution - * - */ - void GetBatchErrors(std::vector &exceptions); - -private: - - static bool IsResultsetHandle(Handle *handle); - static void OnFreeSmartHandle(SmartHandle *smartHandle); - - Statement(OCI_Statement *stmt, Handle *parent = nullptr); - - BindsHolder *GetBindsHolder(bool create) const; - - void ReleaseResultsets() const; - - void SetLastBindMode(BindInfo::BindDirection mode); - - void SetInData() const; - void SetOutData() const; - void ClearBinds() const; - - template - void Bind1 (M &method, const ostring& name, T& value, BindInfo::BindDirection mode); - - template - void Bind2 (M &method, const ostring& name, T &value, BindInfo::BindDirection mode); - - template - void BindVector1(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type); - - template - void BindVector2(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, U subType, BindInfo::VectorType type); - - template - unsigned int Fetch(T callback); - - template - unsigned int Fetch(T callback, U adapter); -}; - -/** - * @brief - * Database resultset - * - * This class wraps the OCILIB object handle OCI_Resultset and its related methods - * - */ -class Resultset : public HandleHolder -{ - friend class Statement; -public: - - /** - * @brief - * Seek Modes enumerated values - * - */ - enum SeekModeValues - { - /** Seek is performed using a given absolute offset. The statement must be scrollable */ - SeekAbsolute = OCI_SFD_ABSOLUTE, - /** Seek is performed using a given relative offset from the current position. The statement must be scrollable */ - SeekRelative = OCI_SFD_RELATIVE - }; - - /** - * @brief - * Seek Modes - * - * Possible values are Resultset::SeekModeValues - * - */ - typedef Enum SeekMode; - - /** - * @brief - * Return the current value of the column at the given index in the resultset - * - * @tparam T - C++ type of the value to retrieve - * - * @param index - Column position - * - * @note - * Column position starts at 1. - * - */ - template - T Get(unsigned int index) const; - - /** - * @brief - * Assign to the current value of the column at the given index in the resultset - * - * @tparam T - C++ type of the value to retrieve - * - * @param index - Column position - * @param value - value to fill - * - * @note - * Column position starts at 1. - * - */ - template - void Get(unsigned int index, T &value) const; - - /** - * @brief - * Return the current value of the column from its name in the resultset - * - * @tparam T - C++ type of the value to retrieve - * - * @param name - Column name - * - * @note - * The column name is case insensitive. - * - */ - template - T Get(const ostring& name) const; - - /** - * @brief - * Assign to the current value of the column from its name in the resultset - * - * @tparam T - C++ type of the value to retrieve - * - * @param name - Column name - * @param value - value to fill - * - */ - template - void Get(const ostring &name, T &value) const; - - /** - * @brief - * Return a given user type from the current fetched row. - * It allow translating row column values returned by a query to a user defined type using the given adapter type - * - * @param value - User defined type value to be filled by the adapter function - * @param adapter - User defined adapter function - * - * @note - * The user defined adapter function must conform to the following prototype: - * bool adapter (const Resultset &, T &) - * It shall return true if it has filled the value from the resultset otherwise false - * - */ - template - bool Get(T& value, U adapter) const; - - /** - * @brief - * Fetch all rows in the resultset and call the given callback for row - * - * @param callback - User defined callback - * - * @note - * The user defined callback function must conform to the following prototype: - * bool callback(const Resultset &) - * It shall return true to continue fetching the resultset or false to stop the fetch - * - * @return - * The number of rows fetched - * - */ - template - unsigned int ForEach(T callback); - - /** - * @brief - * Fetch all rows in the resultset and call the given callback for row - * It allow translating row column values returned by a query to a user defined type using the given adapter type - * - * @param callback - User defined callback - * @param adapter - User defined adapter function - * - * @note - * The user defined adapter function must conform to the following prototype: - * [UserDefinedType] adapter (const Resultset &) - * The return value type must match the parameter of the callback method - * - * @note - * The user defined callback function must conform to the following prototype: - * bool callback(const [UserDefinedType] &) - * It shall return true to continue fetching the resultset or false to stop the fetch - * - * @return - * The number of rows fetched - * - */ - template - unsigned int ForEach(T callback, U adapter); - - /** - * @brief - * Fetch the next row of the resultset - * - * @note - * Next() works for normal and scrollable resultsets - * - * @return - * true on success otherwise false if : - * - Empty resultset - * - Last row already fetched - * - */ - bool Next(); - - /** - * @brief - * Fetch the previous row of the resultset - * - * @note - * Prev() works ONLY for scrollable resultsets - * - * @return - * true on success otherwise false if : - * - Empty resultset - * - First row already fetched - * - */ - bool Prev(); - - /** - * @brief - * Fetch the first row of the resultset - * - * @note - * First() works ONLY for scrollable resultsets - * - * @return - * true on success otherwise false if the resultset is empty - * - */ - bool First(); - - /** - * @brief - * Fetch the last row of the resultset - * - * @note - * Last() works ONLY for scrollable resultsets - * - * @return - * true on success otherwise false if the resultset is empty - * - */ - bool Last(); - - /** - * @brief - * Custom Fetch of the resultset - * - * @param mode - Fetch direction - * @param offset - Fetch offset - * - * @warning - * hSeek() works ONLY for scrollable resultsets - * - * @note - * If you intend to use Seek() on a scrollable statement and if any of the - * selected columns is a ref cursor or a nested table, you must set the fetching size - * to 1 using Statement::SetFetchSize() before calling Statement::GetResultset() - * Otherwise Seek() will fails with a OCI-10002 error - * - * @return - * true on success otherwise false the resultset is empty or seek offset out of bounds - * - */ - bool Seek(SeekMode mode, int offset); - - /** - * @brief - * Retrieve the number of rows fetched so far - * - */ - unsigned int GetCount() const; - - /** - * @brief - * Retrieve the current row index - * - * @note - * - GetCurrentRow() returns the current row number starting from 1 - * - If the resultset has not been fetched or if the resultset is empty, it returns 0 - * - If the resultset has been fully fetched, it returns the last fetched row number - * - */ - unsigned int GetCurrentRow() const; - - /** - * @brief - * Return the index of the column in the result from its name - * - * @param name - Column name - * - * @warning - * The column name is case insensitive - * - * @note - * Column position starts at 1. - * - */ - unsigned int GetColumnIndex(const ostring& name) const; - - /** - * @brief - * Return the number of columns in the resultset - * - */ - unsigned int GetColumnCount() const; - - /** - * @brief - * Return the column from its index in the resultset - * - * @param index - Column index - * - * @note - * Column position starts at 1. - * - */ - Column GetColumn(unsigned int index) const; - - /** - * @brief - * Return the column from its name in the resultset - * - * @param name - Column name - * - * @note - * The column name is case insensitive - * - */ - Column GetColumn(const ostring& name) const; - - /** - * @brief - * Check if the current row value is null for the column at the given index - * - * @param index - Column index - * - * @note - * Column position starts at 1. - * - */ - bool IsColumnNull(unsigned int index) const; - - /** - * @brief - * Check if the current row value is null for the column of the given name - * - * @param name - Column name - * - */ - bool IsColumnNull(const ostring& name) const; - - /** - * @brief - * Return the statement associated with the resultset - * - */ - Statement GetStatement() const; - - /** - * @brief - * Convenient operator overloading that performs a call to Next() - * - */ - bool operator ++ (int); - - /** - * @brief - * Convenient operator overloading that performs a call to Prev() - * - */ - bool operator -- (int); - - /** - * @brief - * Convenient operator overloading that performs a call to Seek() - * with Resultset::SeekRelative and the given offset - * - */ - bool operator += (int offset); - - /** - * @brief - * Convenient operator overloading that performs a call to Seek() - * with Resultset::SeekRelative and the given offset that is internally negated - * - */ - bool operator -= (int offset); - -private: - - Resultset(OCI_Resultset *resultset, Handle *parent); -}; - -/** - * @brief - * Encapsulate a Resultset column or object member properties - * - * This class wraps the OCILIB object handle OCI_Column and its related methods + /** * + * @} */ -class Column : public HandleHolder -{ - friend class TypeInfo; - friend class Resultset; - -public: - - /** - * @brief - * Column properties flags values - * - */ - enum PropertyFlagsValues - { - /** The column has no flags or the OCI client does not support it */ - NoFlags = OCI_CPF_NONE, - /** - If Set, the column is an IDENTITY column - - Otherwise, it is not an IDENTITY column */ - IsIdentity = OCI_CPF_IS_IDENTITY, - /** Only valid when IsIdentity is set: - - If set, means that the value is "ALWAYS GENERATED" - - Otherwise means that the value is "GENERATED BY" */ - IsGeneratedAlways = OCI_CPF_IS_GEN_ALWAYS, - /** Only valid when IsIdentity is set: - - If set, means that the value is generated by default on NULL */ - IsGeneratedByDefaultOnNull = OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL, - /** If set, Column is an implicitly generated logical partitioning column for container_map enabled object */ - IsLogicalPartitioning = OCI_CPF_IS_LPART, - /** If set, Column is a CON_ID column implicitly generated by CONTAINERS() or is an ORIGIN_CON_ID column implicitly generated for Extended Data Link */ - IsGeneratedByContainers = OCI_CPF_IS_CONID - }; - - /** - * @brief - * Column properties flags - * - * Possible values are Column::PropertyFlagsValues - * - */ - typedef Flags PropertyFlags; - - /** - * @brief - * Return the Column name - * - */ - ostring GetName() const; - - /** - * @brief - * Return the Oracle SQL type name of the column data type - * - * @note - * For possible values, consults Oracle Documentation - * - */ - ostring GetSQLType() const; - - /** - * @brief - * Return the Oracle SQL Full name including precision and size of the - * column data type - * - * @note - * This function returns a description that matches the one given by SQL*Plus - * - */ - ostring GetFullSQLType() const; - - /** - * @brief - * Return the type of the given column - * - */ - DataType GetType() const; - - /** - * @brief - * Return the OCILIB object subtype of a column - * - * @note - * This call is valid for the following OCILIB types: - * - Clong and Blong - * - Clob, NClob and Blob - * - File - * - Timestamp - * - Interval - * - * @warning - * - Cast returned values to the matching C++ class GetType() property type. - * - For a non valid type, it returns 0. - * - */ - unsigned int GetSubType() const; - - /** - * @brief - * Return the charset form of the given column - * - */ - CharsetForm GetCharsetForm() const; - - /** - * @brief - * Return the collation ID of the given column - * - */ - CollationID GetCollationID() const; - - /** - * @brief - * Return the size of the column - * - * @note - * For all types, the size is expressed is bytes, excepted for character - * based columns that were created with a character based size or of type NCHAR/NVARCHAR - * - */ - unsigned int GetSize() const; - - /** - * @brief - * Return the scale of the column for numeric columns - * - */ - int GetScale() const; - - /** - * @brief - * Return the precision of the column for numeric columns - * - */ - int GetPrecision() const; - - /** - * @brief - * Return the fractional precision of the column for Timestamp and Interval columns - * - */ - int GetFractionalPrecision() const; - - /** - * @brief - * Return the leading precision of the column for Interval columns - * - */ - int GetLeadingPrecision() const; - - /** - * @brief - * Return the column property flags - * - * @note - * This was introduced in Oracle 12cR1. - * It is currently used for identifying Identity columns. - * For earlier versions, it always return Columns::NoFlags - * - */ - PropertyFlags GetPropertyFlags() const; - - /** - * @brief - * Return true if the column is nullable otherwise false - * - */ - bool IsNullable() const; - - /** - * @brief - * Return true if the length of the column is character-length or false if it is byte-length - * - * @note - * This was introduced in Oracle 9i. So for version that are not supporting this - * property, it always return false - * - */ - bool IsCharSemanticUsed() const; - - /** - * @brief - * Return the type information object associated to the column - * - * @note - * This call is used only for Named Object typed and collection columns. - * It returns a null object if the column is not a Named Object or a collection. - * - */ - TypeInfo GetTypeInfo() const; - -private: - - Column(OCI_Column *pColumn, Handle *parent); -}; - -/** -* @brief -* Subscription to database or objects changes -* -* This class wraps the OCILIB object handle OCI_Subscription and its related methods -* -* @warning -* Environment::Events flag must be passed to Environment::Initialize() to be able to use subscriptions - -*/ -class Subscription : public HandleHolder -{ - friend class Event; - -public: - - /** - * @typedef NotifyHandlerProc - * - * @brief - * User callback for subscriptions event notifications - * - */ - typedef void (*NotifyHandlerProc) (Event &evt); - - /** - * @brief - * Subscription changes flags values - * - */ - enum ChangeTypesValues - { - /** Request for changes at objects (e.g. tables) level (DDL / DML) */ - ObjectChanges = OCI_CNT_OBJECTS, - /** Request for changes at rows level (DML) */ - RowChanges = OCI_CNT_ROWS, - /** Request for changes at database level (startup, shutdown) */ - DatabaseChanges = OCI_CNT_DATABASES, - /** Request for all changes */ - AllChanges = OCI_CNT_ALL - }; - - /** - * @brief - * Subscription changes flags - * - * Possible values are Subscription::ChangeTypesValues - * - */ - typedef Flags ChangeTypes; - - /** - * @brief - * Default constructor - * - */ - Subscription(); - - /** - * @brief - * Register a notification against the given database - * - * @param connection - Connection handle - * @param name - Notification name - * @param changeTypes - Subscription type - * @param handler - User handler callback - * @param port - Port to use for notifications - * @param timeout - notification timeout - * - * @note - * Requires Oracle Client 10gR2 or above - * - */ - void Register(const Connection &connection, const ostring& name, ChangeTypes changeTypes, NotifyHandlerProc handler, unsigned int port = 0, unsigned int timeout = 0); - - /** - * @brief - * Unregister a previously registered notification - * - * @note - * Environment::Cleanup() will automatically unregister any non unregistered subscriptions - * - * @note - * If the database connection passed to Register() - * has been closed by the time that the application calls - * Unregister(), the library internally reconnects - * to the given database, performs the unregistration and then disconnects - * - */ - void Unregister(); - - /** - * @brief - * Add a SQL query to monitor - * - */ - void Watch(const ostring& sql); - - /** - * @brief - * Return the name of the given registered subscription - * - */ - ostring GetName() const; - - /** - * @brief - * Return the timeout of the given registered subscription - * - */ - unsigned int GetTimeout() const; - - /** - * @brief - * Return the port used by the notification - * - */ - unsigned int GetPort() const; - - /** - * @brief - * Return the connection associated with a subscription handle - * - * @note - * It may return a null connection object if the connection used at Register() time has been closed - * - */ - Connection GetConnection() const; - -private: - - Subscription(OCI_Subscription *pSubcription); -}; - -/** -* @brief -* Subscription Event -* -* This class wraps the OCILIB object handle OCI_Event and its related methods -* -* @warning -* Environment::Events flag must be passed to Environment::Initialize() to be able to use subscriptions -* -*/ -class Event : public HandleHolder -{ - friend class Subscription; - friend class Environment; - -public: - - /** - * @brief - * Event type enumerated values - * - */ - enum EventTypeValues - { - /** A database has been started up */ - DatabaseStart = OCI_ENT_STARTUP, - /** A database has been shut down */ - DatabaseShutdown = OCI_ENT_SHUTDOWN, - /** A database has been shut down (RAC) */ - DatabaseShutdownAny = OCI_ENT_SHUTDOWN_ANY, - /** A database has been dropped */ - DatabaseDrop = OCI_ENT_DROP_DATABASE, - /** The notification is timed out */ - Unregister = OCI_ENT_DEREGISTER, - /** A database object has been modified */ - ObjectChanged = OCI_ENT_OBJECT_CHANGED - }; - - /** - * @brief - * Event type - * - * Possible values are Event::EventTypeValues - * - */ - typedef Enum EventType; - - /** - * @brief - * Object events enumerated values - * - */ - enum ObjectEventValues - { - /** An insert has been performed */ - ObjectInserted = OCI_ONT_INSERT, - /** An update has been performed */ - ObjectUpdated = OCI_ONT_UPDATE, - /** A delete has been performed */ - ObjectDeleted = OCI_ONT_DELETE, - /** An alter has been performed */ - ObjectAltered = OCI_ONT_ALTER, - /** A drop has been performed */ - ObjectDropped = OCI_ONT_DROP, - /** Generic undefined action * */ - ObjectGeneric = OCI_ONT_GENERIC - }; - - /** - * @brief - * Object events - * - * Possible values are Event::ObjectEventValues - * - */ - typedef Enum ObjectEvent; - - /** - * @brief - * Return the type of event reported by a notification - * - */ - EventType GetType() const; - - /** - * @brief - * Return the type of operation reported by a notification - - * @note - * This call is only valid when GetType() reports the event type Event::ObjectChanged - * - */ - ObjectEvent GetObjectEvent() const; - - /** - * @brief - * Return the name of the database that generated the event - * - */ - ostring GetDatabaseName() const; - - /** - * @brief - * Return the name of the object that generated the event - * - * @note - * Database object name follows the pattern "[schema_name].object_name" - * - */ - ostring GetObjectName() const; - - /** - * @brief - * Return the rowid of the altered database object row - * - */ - ostring GetRowID() const; - - /** - * @brief - * Return the subscription that generated this event - * - */ - Subscription GetSubscription() const; - -private: - - Event(OCI_Event *pEvent); -}; - -/** -* @brief -* AQ identified agent for messages delivery -* -* This class wraps the OCILIB object handle OCI_Agent and its related methods -* -*/ -class Agent : public HandleHolder -{ - friend class Message; - friend class Dequeue; - -public: - - /** - * @brief - * Create an AQ agent object - * - * @param connection - Connection object - * @param name - Agent name - * @param address - Agent address - * - * @note - * An AQ agent object is : - * - used as recipient information when enqueuing a message - * - used as sender information when dequeuing a message - * - used for listening message only from identified senders - * - * @note - * the AQ agent address can be any Oracle identifier, up to 128 bytes. - * the AQ agent name can be any Oracle identifier, up to 30 bytes. - * - * @note - * the Agent object must not be accessed anymore once the parent connection object gets out of scope - * - */ - Agent(const Connection &connection, const ostring& name = OTEXT(""), const ostring& address = OTEXT("")); - - /** - * @brief - * Get the given AQ agent name - * - */ - ostring GetName() const; - - /** - * @brief - * Set the given AQ agent name - * - * @param value - AQ agent name - * - * @note - * the AQ agent name is used to identified an message send or recipient when enqueuing/dequeuing a message - * - * @note - * the AQ agent name can be any Oracle identifier, up to 30 bytes. - * - */ - void SetName(const ostring& value); - - /** - * @brief - * Get the given AQ agent address - * - * @note - * See SetAddress() for more details - * - */ - ostring GetAddress() const; - - /** - * @brief - * Set the given AQ agent address - * - * @param value - AQ agent address - * - * @note - * the parameter 'address' must be of the form : [schema.]queue_name[\@dblink] - * - * @note - * the AQ agent address can be any Oracle identifier, up to 128 bytes. - * - */ - void SetAddress(const ostring& value); - -private: - - Agent(OCI_Agent *pAgent, Handle *parent); -}; - -/** -* @brief -* AQ message -* -* This class wraps the OCILIB object handle OCI_Msg and its related methods -* -*/ -class Message : public HandleHolder -{ - friend class Dequeue; - -public: - - /** - * @brief - * Message state enumerated values - * - */ - enum MessageStateValues - { - /** The message is ready to be processed */ - Ready = OCI_AMS_READY, - /** The message delay has not yet completed */ - Waiting = OCI_AMS_WAITING, - /** The message has been processed */ - Processed = OCI_AMS_PROCESSED, - /** The message has moved to exception queue */ - Expired = OCI_AMS_EXPIRED - }; - - /** - * @brief - * Message state - * - * Possible values are Message::MessageStateValues - * - */ - typedef Enum MessageState; - - /** - * @brief - * Create a message object based on the given payload type - * - * @param typeInfo - Type info object - * - * @note - * OCILIB supports 2 type of message payload : - * - Oracle types (UDT) - * - RAW data - * - * @note - * Oracle Type AnyData is not supported in the current version of OCILIB - * - * @note - * the parameter 'typinf' indicates the type of payload : - * - For object payload, retrieve the object type information object from the given type name - * - For RAW payload, you MUST pass the object type information object from the type name "SYS.RAW" as object type name - * - * @warning - * Newly created Message handles have NULL payloads. - * For Message handling Objects payloads, Get() returns a null Object until an object is assigned to the message. - * - * @note - * When a local Message object handle is enqueued, it keeps its attributes. If it's enqueued again, another - * identical message is posted into the queue. - * To reset a message and empty all its properties, call Reset() - * - */ - Message(const TypeInfo &typeInfo); - - /** - * @brief - * Reset all attributes of the message - * - * @warning - * Reset() clears the message payload and set it to NULL - * - */ - void Reset(); - - /** - * @brief - * Get the object payload of the message - * - */ - template - T GetPayload(); - - /** - * @brief - * Set the object payload of the message - * - * @param value - Object payload - * - */ - template - void SetPayload(const T &value); - - /** - * @brief - * return the time the message was enqueued - * - * @note - * Only use this function for message dequeued from queues - * - */ - Date GetEnqueueTime() const; - - /** - * @brief - * Return the number of attempts that have been made to dequeue the message - * - */ - int GetAttemptCount() const; - - /** - * @brief - * Return the state of the message at the time of the dequeue - * - */ - MessageState GetState() const; - - /** - * @brief - * Return the ID of the message - * - * @note - * The message ID is : - * - generated when the message is enqueued in the queue - * - retrieved when the message is dequeued from the queue - * - */ - Raw GetID() const; - - /** - * @brief - * Return the duration that the message is available for dequeuing - * - * @note - * see SetExpiration() for more details - * - */ - int GetExpiration() const; - - /** - * @brief - * set the duration that the message is available for dequeuing - * - * @param value - duration in seconds - * - * @note - * This parameter is an offset from the delay (see SetEnqueueDelay()) - * While waiting for expiration, the message state is set to Message::Ready. - * If the message is not dequeued before it expires, it will be moved to the exception queue - * with the state Message::Expired. - * - * @note - * If parameter 'value' is set to -1 (default value), the message will not expire - * - * @warning - * Expiration processing requires the queue monitor to be started. - * - */ - void SetExpiration(int value); - - /** - * @brief - * Return the number of seconds that a message is delayed for dequeuing - * - * @note - * see SetEnqueueDelay() for more details - * - */ - int GetEnqueueDelay() const; - - /** - * @brief - * set the number of seconds to delay the enqueued message - * - * @param value - Delay in seconds - * - * @note - * The delay represents the number of seconds after which a message is available for dequeuing. - * When the message is enqueued, its state is set to Message::Waiting. - * When the delay expires, its state is set to Message::Ready. - * - * @note - * If parameter 'value' is set to zero (default value), the message will be immediately available - * for dequeuing - * - * @warning - * Dequeuing by Message ID overrides the delay specification. - * - * @warning - * Delaying processing requires the queue monitor to be started. - * - */ - void SetEnqueueDelay(int value); - - /** - * @brief - * Return the priority of the message - * - * @note - * see SetPriority() for more details - * - */ - int GetPriority() const; - - /** - * @brief - * Set the priority of the message - * - * @param value - Message priority - * - * @note - * - The priority can be any number, including negative numbers. - * - A smaller number indicates higher priority. - * - Default value is zero. - * - */ - void SetPriority(int value); - - /** - * @brief - * Return the original ID of the message in the last queue that generated this message - * - * @warning - * When a message is propagated from/to different queues, this ID is the one generated for the - * message in the previous queue. - * - */ - Raw GetOriginalID() const; - - /** - * @brief - * Set the original ID of the message in the last queue that generated this message - * - * @param value - Message ID - * - * @warning - * When a message is propagated from/to different queues, this ID is the one generated for the - * message in the previous queue. - * - */ - void SetOriginalID(const Raw &value); - - /** - * @brief - * Get the correlation identifier of the message - * - * @note - * see SetCorrelation() for more details - * - */ - ostring GetCorrelation() const; - - /** - * @brief - * Set the correlation identifier of the message - * - * @param value - Message correlation text - * - * @note - * see Dequeue::SetCorrelation() for more details - * - */ - void SetCorrelation(const ostring& value); - - /** - * @brief - * Get the Exception queue name of the message - * - * @warning - * When calling this function on a message retrieved with Dequeue::Get(), the returned value is - * empty if the default exception queue associated with the current queue is used (e.g. no user - * defined specified at enqueue time for the message) - * - * @note - * see SetExceptionQueue() for more details - * - */ - ostring GetExceptionQueue() const; - - /** - * @brief - * Set the name of the queue to which the message is moved to if it cannot be - * processed successfully - * - * @param value - Exception queue name - * - * @warning - * From Oracle Documentation : - * - * "Messages are moved into exception queues in two cases : - * - If the number of unsuccessful dequeue attempts has exceeded the attribute 'max_retries' of - * given queue - * - if the message has expired. - * - * All messages in the exception queue are in the EXPIRED state. - * - * The default is the exception queue associated with the queue table. - * - * If the exception queue specified does not exist at the time of the move the message will be - * moved to the default exception queue associated with the queue table and a warning will be - * logged in the alert file. - * - * This attribute must refer to a valid queue name." - * - */ - void SetExceptionQueue(const ostring& value); - - /** - * @brief - * Return the original sender of the message - * - * @return - * Valid agent object if set at enqueue time otherwise a null agent object - * - */ - Agent GetSender() const; - - /** - * @brief - * Set the original sender of the message - * - * @param agent - Message sender - * - */ - void SetSender(const Agent &agent); - - /** - * @brief - * Set the recipient list of a message to enqueue - * - * @param agents - Recipients list - * - * @warning - * This function should only be used for queues which allow multiple consumers. - * The default recipients are the queue subscribers. - * - */ - void SetConsumers(std::vector &agents); - -private: - - Message(OCI_Msg *pMessage, Handle *parent); -}; - -/** -* @brief -* Enqueue object for queuing messages into an Oracle Queue -* -* This class wraps the OCILIB object handle OCI_Enqueue and its related methods -* -*/ -class Enqueue : public HandleHolder -{ -public: - - /** - * @brief - * Message enqueuing mode enumerated values - * - */ - enum EnqueueModeValues - { - /** Enqueue message before another message */ - Before = OCI_ASD_BEFORE, - /** Enqueue message before all messages */ - OnTop = OCI_ASD_TOP - }; - - /** - * @brief - * Message enqueuing mode - * - * Possible values are Enqueue::EnqueueModeValues - * - */ - typedef Enum EnqueueMode; - - /** - * @brief - * Message visibility enumerated values - * - */ - enum EnqueueVisibilityValues - { - /** Enqueue is an independent transaction */ - Immediate = OCI_AMV_IMMEDIATE, - /** Enqueue is part of current transaction */ - OnCommit = OCI_AMV_ON_COMMIT - }; - - /** - * @brief - * Message visibility after begin queued - * - * Possible values are Enqueue::EnqueueVisibilityValues - * - */ - typedef Enum EnqueueVisibility; - - /** - * @brief - * Create a Enqueue object for the given queue - * - * @param typeInfo - Type info handle - * @param queueName - Queue name - * - * @note - * OCILIB supports 2 types of message payload : - * - Oracle types (UDT) - * - RAW data - * - * @note - * Oracle Type AnyData is not supported in the current version of OCILIB - * - * @note - * the parameter 'typeInfo' indicates the type of payload to enqueue to the given queue : - * - For object payload, retrieve the object type information object from the given type name - * - For RAW payload, you MUST pass the object type information object from the type name "SYS.RAW" as object type name - * - */ - Enqueue(const TypeInfo &typeInfo, const ostring& queueName); - - /** - * @brief - * Enqueue a message the on queue associated to the Enqueue object - * - * @param message - Message to enqueue - * - */ - void Put(const Message &message); - - /** - * @brief - * Get the enqueuing/locking behavior - * - * @note - * see SetVisibility() for more details - * - */ - EnqueueVisibility GetVisibility() const; - - /** - * @brief - * Set whether the new message is enqueued as part of the current transaction - * - * @param value - Enqueuing visibility - * - * @note - * Default value is Enqueue::OnCommit - * - */ - void SetVisibility(EnqueueVisibility value); - - /** - * @brief - * Return the enqueuing mode of messages to enqueue - * - * @note - * see SetMode() for more details - * - */ - EnqueueMode GetMode() const; - - /** - * @brief - * Set the enqueuing mode of messages to put in the queue - * - * @param value - enqueuing mode - * - * @note - * Default value is Enqueue::OnTop - * - * @note - * if the parameter 'value' is set to Enqueue::Before, the application must - * call SetRelativeMsgID() before enqueuing the next message in the queue. - * - * @note - * In order to stop enqueuing message using a sequence deviation, call - * SetMode() with the value Enqueue::OnTop - * - */ - void SetMode(EnqueueMode value); - - /** - * @brief - * Get the current associated message identifier used for enqueuing messages - * using a sequence deviation - * - * @note - * see SetRelativeMsgID() for more details - * - */ - - Raw GetRelativeMsgID() const; - - /** - * @brief - * Set a message identifier to use for enqueuing messages using a sequence deviation - * - * @param value - message identifier - * - * @note - * This call is only valid if SetMode() has been called with the value Enqueue::Before - * - * @note - * see SetMode() for more details - * - */ - void SetRelativeMsgID(const Raw &value); -}; - -/** -* @brief -* Dequeue object for dequeuing messages into an Oracle Queue -* -* This class wraps the OCILIB object handle OCI_Dequeue and its related methods -* -*/ -class Dequeue : public HandleHolder -{ - friend class Environment; - -public: - - /** - * @typedef NotifyAQHandlerProc - * - * @brief - * User callback for dequeue event notifications - * - */ - typedef void (*NotifyAQHandlerProc) (Dequeue &dequeue); - - /** - * @brief - * Dequeue mode enumerated values - * - */ - enum DequeueModeValues - { - /** Read message without acquiring a lock */ - Browse = OCI_ADM_BROWSE, - /** Read and obtain write lock on message */ - Locked = OCI_ADM_LOCKED, - /** Read the message and delete it */ - Remove = OCI_ADM_REMOVE, - /** Confirm receipt of the message, but do not deliver the actual message content */ - Confirm = OCI_ADM_REMOVE_NODATA - }; - - /** - * @brief - * Dequeue mode - * - * Possible values are Dequeue::DequeueModeValues - * - */ - typedef Enum DequeueMode; - - /** - * @brief - * Message visibility enumerated values - * - */ - enum DequeueVisibilityValues - { - /** Dequeue is an independent transaction */ - Immediate = OCI_AMV_IMMEDIATE, - /** Dequeue is part of current transaction */ - OnCommit = OCI_AMV_ON_COMMIT - }; - - /** - * @brief - * Message visibility after begin dequeued - * - * Possible values are Dequeue::DequeueVisibilityValues - * - */ - typedef Enum DequeueVisibility; - - /** - * @brief - * Navigation Mode enumerated values - * - */ - enum NavigationModeValues - { - /** Retrieves the first message which is available */ - FirstMessage = OCI_ADN_FIRST_MSG, - /** Retrieves the next message which is available */ - NextMessage = OCI_ADN_NEXT_MSG, - /** Skips the remainder of the current transaction group (if any) - and retrieves the first message of the next transaction group.*/ - NextTransaction = OCI_ADN_NEXT_TRANSACTION - }; - - /** - * @brief - * Navigation Mode - * - * Possible values are Dequeue::NavigationModeValues - * - */ - typedef Enum NavigationMode; - - /** - * @brief - * Parametrized constructor - * - * @param typeInfo - Payload type info - * @param queueName - Queue name - * - */ - Dequeue(const TypeInfo &typeInfo, const ostring& queueName); - - /** - * @brief - * Dequeue messages from the given queue - * - * @warning - * When dequeuing from a multiple consumer queue, you need - * to set the navigation mode to NavigationMode::FirstMessage using - * SetNavigation() - * - * @return - * A valid Message handle on success otherwise a null Message on timeout - * - */ - Message Get(); - - /** - * @brief - * Listen for messages that match any recipient of the associated Agent list - * - * @param timeout - Timeout in second - * - * @note - * If an Agent handle is returned, messages are available for this agent. - * In order to retrieve its messages : - * - call SetConsumer() with the name of agent using Agent::GetName() - * - call Get() to dequeue it's pending messages - * - * @return - * An Agent handle for who messages are available on success otherwise an null agent object - */ - Agent Listen(int timeout); - - /** - * @brief - * Get the current consumer name associated with the dequeuing process. - * - * @note - * see SetConsumer() for more details - * - */ - ostring GetConsumer() const; - - /** - * @brief - * Set the current consumer name to retrieve message for. - * - * @param value - consumer name - * - * @warning - * If a queue is not set up for multiple consumers, SetConsumer() - * should not be called or called with an empty value - * - */ - void SetConsumer(const ostring& value); - - /** - * @brief - * Get the correlation identifier of the message to be dequeued - * - * @note - * see SetCorrelation() for more details - * - */ - ostring GetCorrelation() const; - - /** - * @brief - * set the correlation identifier of the message to be dequeued - * - * @param value - correlation identifier - * - * @note - * Special pattern matching characters, such as "%" or "_" can be used. - * If more than one message satisfies the pattern, the order of dequeuing is undetermined. - * - */ - void SetCorrelation(const ostring& value); - - /** - * @brief - * Get the message identifier of the message to be dequeued - * - * @note - * see SetRelativeMsgID() for more details - * - */ - Raw GetRelativeMsgID() const; - - /** - * @brief - * Set the message identifier of the message to be dequeued - * - * @param value - message identifier - * - */ - void SetRelativeMsgID(const Raw &value); - - /** - * @brief - * Get the dequeuing/locking behavior - * - * @note - * see SetVisibility() for more details - * - */ - DequeueVisibility GetVisibility() const; - - /** - * @brief - * Set whether the new message is dequeued as part of the current transaction - * - * @param value - dequeuing mode - * - * @warning - * The visibility parameter is ignored when using the dequeuing - * mode is Dequeue::Browse - * - * @note - * Default value is Dequeue::OnCommit - * - */ - void SetVisibility(DequeueVisibility value); - - /** - * @brief - * Get the dequeuing/locking behavior - * - * @note - * see SetMode() for more details - * - */ - DequeueMode GetMode() const; - - /** - * @brief - * Set the dequeuing/locking behavior - * - * @param value - dequeuing mode - * - * @note - * Default value is Dequeue::Remove - * - */ - void SetMode(DequeueMode value); - - /** - * @brief - * Return the navigation position of messages to retrieve from the queue - * - * @note - * see SetNavigation() for more details - * - */ - NavigationMode GetNavigation() const; - - /** - * @brief - * Set the position of messages to be retrieved. - * - * @param value - navigation position - * - * @note - * The dequeuing uses the following sequence : - * - find messages using the navigation position - * - apply search criteria (message correlation) - * - get message - * - * @note - * Default value is Dequeue::NextMessage - * - * @warning - * Dequeue::NextTransaction can only be used if message grouping is enabled for the given queue. - * - */ - void SetNavigation(NavigationMode value); - - /** - * @brief - * Return the time that Get() waits for messages if no messages are currently available - * - * @note - * see SetWaitTime() for more details - * - */ - int GetWaitTime() const; - - /** - * @brief - * Set the time that Get() waits for messages if no messages are currently available - * - * @param value - timeout in seconds - * - *@note - * - Any positive values in seconds are valid. - * - The value 0 is accepted and means Get() does not wait for - * messages and returns immediately if no messages are available - * - The value -1 is accepted and means Get() waits for ever (until - * a message is available in the queue) - * - * @note - * Default value is -1 (wait for ever) - * - */ - void SetWaitTime(int value); - - /** - * @brief - * Set the Agent list to listen to message for - * - * @param agents - vector of agents - * - */ - void SetAgents(std::vector &agents); - - /** - * @brief - * Subscribe for asynchronous messages notifications - * - * @param port - Port to use for notifications - * @param timeout - notification timeout - * @param handler - User handler callback fired when messages are ready to be dequeued - * - * @note - * Environment::Events flag must be passed to Environment::Initialize() to be able to use - * asynchronous messages notifications - * - * @note - * Requires Oracle Client 10gR2 or above - * - */ - void Subscribe(unsigned int port, unsigned int timeout, NotifyAQHandlerProc handler); - - /** - * @brief - * Unsubscribe for asynchronous messages notifications - * - * @note - * Requires Oracle Client 10gR2 or above - * - */ - void Unsubscribe(); - -private: - - Dequeue(OCI_Dequeue *pDequeue); -}; - -/** -* @brief -* Class allowing the administration of Oracle Queues -* -*/ -class Queue -{ -public: - - /** - * @brief - * Queue Type enumerated values - * - */ - enum QueueTypeValues - { - /** Normal queue */ - NormalQueue = OCI_AQT_NORMAL, - /** Exception queue */ - ExceptionQueue = OCI_AQT_EXCEPTION, - /** Non persistent queue */ - NonPersistentQueue = OCI_AQT_NON_PERSISTENT - }; - - /** - * @brief - * Queue Type - * - * Possible values are Queue::QueueTypeValues - * - */ - typedef Enum QueueType; - - /** - * @brief - * Create a queue - * - * @param connection - Database connection - * @param queue - Queue name - * @param table - Queue table name - * @param type - Queue type - * @param maxRetries - Maximum number of attempts to dequeue a message - * @param retryDelay - Number of seconds between attempts to dequeue a message - * @param retentionTime - number of seconds a message is retained in the queue table after - * being dequeued from the queue - * @param dependencyTracking - Parameter reserved for future use by Oracle (MUST be set to FALSE) - * @param comment - Description of the queue - * - * @note - * Parameter 'queue' can specify the schema where to create to queue ([schema.]queue_name) - * Queue names cannot be longer than 24 characters (Oracle limit for user queues) - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Create(const Connection &connection, const ostring& queue, const ostring& table, QueueType type = NormalQueue, - unsigned int maxRetries = 0, unsigned int retryDelay = 0, unsigned int retentionTime = 0, - bool dependencyTracking = false, const ostring& comment = OTEXT("")); - - /** - * @brief - * Alter the given queue - * - * @param connection - Database connection - * @param queue - Queue name - * @param maxRetries - Maximum number of attempts to dequeue a message - * @param retryDelay - Number of seconds between attempts to dequeue a message - * @param retentionTime - number of seconds a message is retained in the queue table after - * being dequeued from the queue - * @param comment - Description of the queue - * - * @note - * See Create() for more details - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Alter(const Connection &connection, const ostring& queue, - unsigned int maxRetries= 0, unsigned int retryDelay= 0, - unsigned int retentionTime= 0, const ostring& comment = OTEXT("")); - - /** - * @brief - * Drop the given queue - * - * @param connection - Database connection - * @param queue - Queue name - * - * @warning - * A queue can be dropped only if it has been stopped before. - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Drop(const Connection &connection, const ostring& queue); - - /** - * @brief - * Start the given queue - * - * @param connection - Database connection - * @param queue - Queue name - * @param enableEnqueue - Enable enqueue - * @param enableDequeue - Enable dequeue - * - * @warning - * For exception queues, only enqueuing is allowed - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.START_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Start(const Connection &connection, const ostring& queue, bool enableEnqueue = true, bool enableDequeue = true); - - /** - * @brief - * Stop enqueuing or dequeuing or both on the given queue - * - * @param connection - Database connection - * @param queue - Queue name - * @param stopEnqueue - Disable enqueue - * @param stopDequeue - Disable dequeue - * @param wait - Wait for current pending enqueues/dequeues - * - * @warning - * A queue cannot be stopped if there are pending transactions against the queue. - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.STOP_QUEUE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Stop(const Connection &connection, const ostring& queue, bool stopEnqueue = true, bool stopDequeue = true, bool wait = true); -}; - -/** -* @brief -* Class allowing the administration of Oracle Queue tables -* -*/ -class QueueTable -{ -public: - - /** - * - * @brief - * Grouping mode enumerated values - * - */ - enum GroupingModeValues - { - /** Each message is treated individually */ - None = OCI_AGM_NONE, - /** All messages enqueued in one transaction are considered part of - the same group and can be dequeued as a group of related messages */ - Transactionnal = OCI_AGM_TRANSACTIONNAL - }; - - /** - * @brief - * Grouping Mode - * - * Possible values are QueueTable::GroupingModeValues - * - */ - typedef Enum GroupingMode; - - /** - * - * @brief - * Purge mode enumerated values - * - */ - enum PurgeModeValues - { - /** Purge only buffered messages */ - Buffered = OCI_APM_BUFFERED, - /** Purge only persistent messages */ - Persistent = OCI_APM_PERSISTENT, - /** Purge all messages */ - All = OCI_APM_ALL - }; - - /** - * @brief - * Purge mode - * - * Possible values are QueueTable::PurgeModeValues - * - */ - typedef Enum PurgeMode; - - /** - * @brief - * Create a queue table for messages of the given type - * - * @param connection - Database connection - * @param table - Queue table name - * @param payloadType - Message type name - * @param multipleConsumers - Enable multiple consumers for each messages - * @param storageClause - Optional Additional clauses for the table storage - * @param sortList - Optional Additional columns name to use for sorting - * @param groupingMode - Optional Specifies if messages are grouped within a transaction - * @param comment - Optional Description of the queue table - * @param primaryInstance - Optional primary owner (instance) of the queue table - * @param secondaryInstance - Optional Owner of the queue table if the primary instance is not available - * @param compatible - Optional lowest database version with which the queue table is compatible - * - * @note - * Parameter 'table' can specify the schema where to create to queue table ([schema.]queue_table) - * Queue table names cannot be longer than 24 characters (Oracle limit for user queue tables) - * - * @note - * Possible values for parameter 'payloadType' : - * - For Oracle types (UDT) : use the type name ([schema.]type_name) - * - For RAW data : use "SYS.RAW" or "RAW" - * - * @note - * Possible values for parameter 'compatible' : - * - "8.0", "8.1", "10.0" - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Create(const Connection &connection, const ostring& table, const ostring& payloadType, bool multipleConsumers, - const ostring& storageClause = OTEXT(""), const ostring& sortList = OTEXT(""), - GroupingMode groupingMode = None, const ostring& comment = OTEXT(""), - unsigned int primaryInstance = 0, unsigned int secondaryInstance = 0, - const ostring& compatible = OTEXT("")); - - /** - * @brief - * Alter the given queue table - * - * @param connection - Database connection - * @param table - Queue table name - * @param comment - Optional Description of the queue table - * @param primaryInstance - Optional primary owner (instance) of the queue table - * @param secondaryInstance - Optional Owner of the queue table if the primary instance is not available - * - * @note - * See Create() from more details - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Alter(const Connection &connection, const ostring& table, const ostring& comment, unsigned int primaryInstance = 0, unsigned int secondaryInstance = 0); - - /** - * @brief - * Drop the given queue table - * - * @param connection - Database connection - * @param table - Queue table name - * @param force - Force the deletion of objects related to the queue table - * - * @note - * Possible values for 'force' : - * - true : all queues using the queue table and their associated propagation schedules are - * dropped automatically - * - false : All the queues using the given queue table must be stopped and dropped before the - * queue table can be dropped. - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Drop(const Connection &connection, const ostring& table, bool force = true); - - /** - * @brief - * Purge messages from the given queue table - * - * @param connection - Database connection - * @param table - Queue table name - * @param mode - Type of message to purge - * @param block - Lock all queues using the queue table while doing the purge - * @param condition - Optional SQL based conditions (see notes) - * - * @note - * For more information about the SQL purge conditions, refer to - * Oracle Streams - Advanced Queuing User's Guide for more details - * - * @warning - * This feature is only available from Oracle 10gR2. - * This function does nothing and returns TRUE is the server version is < Oracle 10gR2 - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.PURGE_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Purge(const Connection &connection, const ostring& table, PurgeMode mode, const ostring& condition = OTEXT(""), bool block = true); - - /** - * @brief - * Migrate a queue table from one version to another - * - * @param connection - Database connection - * @param table - Queue table name - * @param compatible - Optional database version with witch the queue table has to migrate - * - * @note - * Possible values for parameter 'compatible' : - * - "8.0", "8.1", "10.0" - * - * @note - * this call wraps the PL/SQL procedure DBMS_AQADM.MIGRATE_QUEUE_TABLE(). - * Refer to Oracle Streams - Advanced Queuing User's Guide for more details - * - */ - static void Migrate(const Connection &connection, const ostring& table, const ostring& compatible = OTEXT("")); -}; - -/** -* @brief -* Oracle Direct path loading encapsulation -* -* This class wraps the OCILIB object handle OCI_DirPath and its related methods -* -*/ -class DirectPath : public HandleHolder -{ -public: - - /** - * @brief - * Conversion mode enumerated values - * - */ - enum ConversionModeValues - { - /** Conversion fails on error */ - Default = OCI_DCM_DEFAULT, - /** Conversion does not fail on error */ - Force = OCI_DCM_FORCE - }; - - /** - * @brief - * Conversion Mode - * - * Possible values are DirectPath::ConversionModeValues - * - */ - typedef Enum ConversionMode; - - /** - * @brief - * Direct Operation Result enumerated values - * - */ - enum ResultValues - { - /** Conversion/load has been successful */ - ResultComplete = OCI_DPR_COMPLETE, - /** An error happened while converting/loading data */ - ResultError = OCI_DPR_ERROR, - /** The internal stream is full*/ - ResultFull = OCI_DPR_FULL , - /** A column has not been fully filled yet */ - ResultPartial = OCI_DPR_PARTIAL, - /** No data was found to convert/load */ - ResultEmpty = OCI_DPR_EMPTY - }; - - /** - * @brief - * Direct Operation Result - * - * Possible values are DirectPath::ResultValues - * - */ - typedef Enum Result; - - /** - * @brief - * Constructor - * - * @param typeInfo - Table type info object - * @param nbCols - Number of columns to load - * @param nbRows - Maximum of rows to handle per load operation - * @param partition - Partition name - * - * @note - * The partition name is not mandatory - * - * @note - * Parameter 'nbRows' is ignored for Oracle 8i. Prior to Oracle 9i, it's the - * OCI client that decides of the number of rows to process per convert/load calls. - * From Oracle 9i, OCI allows application to specify this value. Note that, the - * OCI client might not accept the input value. After Prepare() has - * been successfully called, GetMaxRows() returns the final number - * of rows used for the given direct path operation. - * - */ - DirectPath(const TypeInfo &typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring& partition = OTEXT("")); - - /** - * @brief - * Describe a column to load into the given table - * - * @param colIndex - Column index - * @param name - Column name - * @param maxSize - Maximum input value size for a column entry - * @param format - Date or numeric format to use - * - * @note - * An error is thrown if : - * - If the column specified by the 'name' parameter is not found in the table - * referenced by the type info handle passed to the constructor - * - the index is out of bounds (= 0 or >= number of columns) - * - */ - void SetColumn(unsigned int colIndex, const ostring& name, unsigned int maxSize, const ostring& format = OTEXT("")); - - /** - * @brief - * Set the value of the given row/column array entry from the given string - * - * @tparam T - type of data to set (only supported types are ostring and Raw) - * - * @param rowIndex - Row index - * @param colIndex - Column index - * @param value - Value to set - * @param complete - Is the entry content fully provided ? - * - * @note - * Rows and columns indexes start at 1. - * - * @note - * Direct path support piece loading for LONGs and LOBs columns. When filling - * these columns, it's possible to provide input buffer piece by piece. In order - * to do so : - * - set the 'complete' parameter to false - * - Repeat calls to SetEntry() until the data is totally provided - * - The last call that set the last piece or an entry must specify the value - * true for the 'complete' parameter - * - * @warning - * Current Direct Path OCILIB implementation DOES NOT support setting entry - * content piece by piece as mentioned above. It was planned in the original design - * but not supported yet. So, always set the complete parameter to true. - * Setting entries content piece by piece may be supported in future releases - * - */ - template - void SetEntry(unsigned int rowIndex, unsigned int colIndex, const T& value, bool complete = true); - - /** - * @brief - * Reset internal arrays and streams to prepare another load - * - * @note - * Once some data have been converted or loaded, Reset() resets - * internal OCI structures in order to prepare another load operation - * (set entries, convert and load) - * - */ - void Reset(); - - /** - * @brief - * Prepares the OCI direct path load interface before any rows can be converted or loaded - * - */ - void Prepare(); - - /** - * @brief - * Convert provided user data to the direct path stream format - * - * @par Behavior - * - When using conversion mode DirectPath::Default, Convert() stops when - * any error is encountered and returns ResultError - * - When using conversion mode DirectPath::Force, Convert() does not stop - * on errors. Instead it discards any erred rows and returns ResultComplete once - * all rows are processed. - * - * @note - * List of faulted rows and columns can be retrieved using GetErrorRow() and GetErrorColumn() - * - * @note - * GetAffectedRows() returns the number of rows converted in the last call. - * - */ - DirectPath::Result Convert(); - - /** - * @brief - * Loads the data converted to direct path stream format - * - * @note - * List of faulted rows can be retrieved using GetErrorRow() - * - * @note - * GetAffectedRows() returns the number of rows successfully loaded in the last call. - * - */ - DirectPath::Result Load(); - - /** - * @brief - * Terminate a direct path operation and commit changes into the database - * - * @warning - * The direct path object cannot be used anymore after this call for any more loading operations - * - */ - void Finish(); - - /** - * @brief - * Terminate a direct path operation without committing changes - * - * @note - * Any pending loaded data are canceled. - * Any load completion operations, such as index maintenance operations, are not performed. - * - * @warning - * The direct path object cannot be used anymore after this call for any more loading operations - * - */ - void Abort(); - - /** - * @brief - * Execute a data save-point (server side) - * - * @note - * Executing a data save-point is not allowed for LOBs - * - */ - void Save(); - - /** - * @brief - * Flushes a partially loaded row from server - * - */ - void FlushRow(); - - /** - * @brief - * Set the current number of rows to convert and load - * - * @param value - Number of row to process - * - * @warning - * An OCILIB error will be thrown if the value exceeds the maximum number of - * rows in the internals arrays - * - */ - void SetCurrentRows(unsigned int value); - - /** - * @brief - * Return the current number of rows used in the OCILIB internal arrays of rows - * - * @return - * Internal current array size on SUCCESS otherwise 0 - * - */ - unsigned int GetCurrentRows() const; - - /** - * @brief - * Return the maximum number of rows allocated in the OCI and OCILIB internal arrays of rows - * - * @return - * Internal maximum array size on SUCCESS otherwise 0 - * - */ - unsigned int GetMaxRows() const; - - /** - * @brief - * Return the number of rows successfully loaded into the database so far - * - * @note - * Insertions are committed with Finish() - * - */ - unsigned int GetRowCount() const; - - /** - * @brief - * return the number of rows successfully processed during in the last - * conversion or loading call - * - * @note - * This function called after : - * - * - Convert(), returns the number of converted rows - * - Load(), returns the number of loaded rows - * - */ - unsigned int GetAffectedRows() const; - - /** - * @brief - * Set the default date format string for input conversion - * - * @param format - date format - * - * @note - * For string to date conversion, Oracle uses : - * - Column date format - * - Default date format (modified by this call) - * - Default global support environment setting - * - */ - void SetDateFormat(const ostring& format); - - /** - * @brief - * Set the parallel loading mode - * - * @param value - enable/disable parallel mode - * - * @note - * Default value is false. - * - * @note - * Setting the value to TRUE allows multiple load sessions to load the same - * segment concurrently - * - * @par Parallel loading mode (From Oracle documentation) - * - * A direct load operation requires that the object being loaded is locked to - * prevent DML on the object. - * Note that queries are lock-free and are allowed while the object is being loaded. - * - For a table load, if the option is set to: - * - false, then the table DML X-Lock is acquired. - * - true, then the table DML S-Lock is acquired. - * - For a partition load, if the option is set to: - * - false, then the table DML SX-Lock and partition DML X-Lock is acquired. - * - true, then the table DML SS-Lock and partition DML S-Lock is acquired. - * - */ - void SetParallel(bool value); - - /** - * @brief - * Set the logging mode for the loading operation - * - * @param value - enable/disable logging - * - * @par Logging mode (from Oracle Documentation) - * - * The NOLOG attribute of each segment determines whether image redo or - * invalidation redo is generated: - * - false : Use the attribute of the segment being loaded. - * - true : No logging. Overrides DDL statement, if necessary. - * - */ - void SetNoLog(bool value); - - /** - * @brief - * Set number of elements in the date cache - * - * @param value - Buffer size - * - * @note - * Default value is 0. - * - * @note - * Setting the value to 0 disables the cache - * - */ - void SetCacheSize(unsigned int value); - - /** - * @brief - * Set the size of the internal stream transfer buffer - * - * @param value - Buffer size - * - * @note - * Default value is 64KB. - * - */ - void SetBufferSize(unsigned int value); - - /** - * @brief - * Set the direct path conversion mode - * - * @param value - Conversion mode - * - * @note - * See Convert() for conversion mode details - * - * @note - * Default value is ConversionMode::Default - * - */ - void SetConversionMode(ConversionMode value); - - /** - * @brief - * Return the index of a column which caused an error during data conversion - * - * @warning - * Direct path column indexes start at 1. - * - * @note - * Errors may happen while data is converted to direct path stream format - * using Convert(). - * - * @par Usage after a Convert() call - * - When using conversion mode DirectPath::Default, Convert() returns - * DirectPath::ResultError on error and GetErrorColumn() returns the column index that - * caused the error. - * - When using conversion mode DirectPath::Force, Convert() returns - * DirectPath::ResultComplete even on errors. In order to retrieve the list of all column - * indexes that have erred, the application can call GetErrorColumn() - * repeatedly until it returns 0. - * - * @note - * The internal value is reset to 0 when calling Convert() - * - * @return - * 0 is no error occurs otherwise the index of the given column which caused an - * error - * - */ - unsigned int GetErrorColumn(); - - /** - * @brief - * Return the index of a row which caused an error during data conversion - * - * @warning - * Direct path row indexes start at 1. - * - * @note - * Errors may happen : - * - while data is converted to direct path stream format using Convert() - * - while data is loaded to database using Load() - * - * @par Usage after a Convert() call - * - When using conversion mode DirectPath::Default, Convert() returns - * DirectPath::ResultError on error and GetErrorRow() returns the row index that - * caused the error. - * - When using conversion mode DirectPath::Force, Convert() returns - * DirectPath::ResultComplete even on errors. In order to retrieve the list of all row - * indexes that have erred, the application can call GetErrorRow() repeatedly until it returns 0. - * - * @par Usage after a Load() call - * After a call to Load(), in order to retrieve the list of all faulted rows - * indexes, the application can call GetErrorRow() repeatedly until it returns 0. - * - * @note - * The internal value is reset to 0 when calling Convert(),Reset() or Load() - * - * @return - * 0 is no error occurs otherwise the index of the given row which caused an - * error - * - */ - - unsigned int GetErrorRow(); -}; - -} -#include "ocilibcpp/impl.hpp" #endif diff --git a/include/ocilibcpp/config.hpp b/include/ocilibcpp/config.hpp new file mode 100644 index 00000000..c3cfd4da --- /dev/null +++ b/include/ocilibcpp/config.hpp @@ -0,0 +1,224 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +/* Including C API declarations */ + +extern "C" { +#include "ocilib.h" +} + +/* Try to guess C++ Compiler capabilities ... */ + +#define OCILIBPP_CPP_98 199711L +#define OCILIBPP_CPP_11 201103L +#define OCILIBPP_CPP_14 201402L + +#if __cplusplus < OCILIBPP_CPP_11 + + // GCC +#if defined(__GNUC__) +#if defined(__GXX_EXPERIMENTAL_CXX0X__) +#define OCILIBPP_HAS_CXX +#endif +// MSVC +#elif defined(_MSC_VER) +#if _MSVC_LANG >= OCILIBPP_CPP_11 +#define OCILIBPP_HAS_CXX +#endif +#endif + +#else + +#define OCILIBPP_HAS_CXX + +#endif + +#ifdef OCILIBPP_HAS_CXX + +#define OCILIBPP_HAS_ENABLEIF +#define OCILIBPP_HAS_VARIADIC + +#ifdef OCILIBCPP_DEBUG_MEMORY + +#include +#define OCILIBPP_DEBUG_MEMORY_ENABLED + +#endif + +#else + +#define OCILIBPP_DEFINE_CXX_KEYWORDS + +#endif + +#ifdef OCILIBPP_TEST_CPP98 + +#ifdef OCILIBPP_DEFINE_CXX_KEYWORDS +#undef OCILIBPP_DEFINE_CXX_KEYWORDS +#endif + +#ifdef OCILIBPP_HAS_ENABLEIF +#undef OCILIBPP_HAS_ENABLEIF +#endif + +#ifdef OCILIBPP_HAS_VARIADIC +#undef OCILIBPP_HAS_VARIADIC +#endif + +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED +#undef OCILIBPP_DEBUG_MEMORY_ENABLED +#endif + +#endif + +#ifdef OCILIBPP_DEFINE_CXX_KEYWORDS + +#define nullptr 0 +#define override +#define noexcept + +#endif + +namespace ocilib +{ + +/** + * @typedef ocilib::ostring + * + * @brief + * string class wrapping the OCILIB otext * type and OTEXT() macros ( see @ref OcilibCApiSupportedCharsets ) + * + * @note + * - for ANSI builds, ocilib::ostring is equivalent to std::string + * - for UNICODE builds, ocilib::ostring is equivalent to std::wstring + * + */ +typedef std::basic_string, std::allocator > ostring; + +/** + * @typedef ocilib::AnyPointer + * + * @brief + * Alias for the generic void pointer + * + */ +typedef void * AnyPointer; + +/** +* @typedef ocilib::Raw +* +* @brief +* C++ counterpart of SQL RAW data type +* +*/ +typedef std::vector Raw; + +/** + * @typedef ocilib::MutexHandle + * + * @brief + * Alias for an OCI_Mutex pointer + * + */ +typedef OCI_Mutex * MutexHandle; + +/** + * @typedef ocilib::ThreadHandle + * + * @brief + * Alias for an OCI_Thread pointer + * + */ +typedef OCI_Thread * ThreadHandle; + +/** +* @typedef ocilib::ThreadId +* +* @brief +* Thread Unique ID +* +*/ +typedef const void * ThreadId; + +/** + * @typedef ocilib::CallbackPointer + * + * @brief + * Alias used for storing user callback method pointers + * + */ +typedef void * CallbackPointer; + +/* class forward declarations */ + +class Exception; +class Connection; +class Transaction; +class Environment; +class Statement; +class Resultset; +class Date; +class Timestamp; +class Interval; +class Number; +class TypeInfo; +class Reference; +class Object; +template +class Element; +template +class Iterator; +template +class Collection; +template +class Lob; +class File; +class Pool; +template +class Long; +class Column; +class Subscription; +class Event; +class Agent; +class Message; +class Enqueue; +class Dequeue; +class Queue; +class QueueTable; +class DirectPath; +class Thread; +class ThreadKey; +class Mutex; +class BindInfo; + + +/** +* Catch silently any exception thrown in the given expression +* Used for compliance with the standard (copy constructor, assignment operator, destructor) +* +*/ +#define SILENT_CATCH(exp) try { exp; } catch (...) {} + +} diff --git a/include/ocilibcpp/core.hpp b/include/ocilibcpp/core.hpp index 22c93afa..fbd8e309 100644 --- a/include/ocilibcpp/core.hpp +++ b/include/ocilibcpp/core.hpp @@ -18,675 +18,371 @@ * limitations under the License. */ -/* - * IMPORTANT NOTICE - * - * This C++ header defines C++ wrapper classes around the OCILIB C API - * It requires a compatible version of OCILIB - * - */ - -// -// ReSharper inspection rules customization (mainly for C98 backward compatibility) -// -// ReSharper disable CppClassCanBeFinal -// ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage -// ReSharper disable CppClangTidyHicppSpecialMemberFunctions -// ReSharper disable CppClangTidyHicppUseEqualsDefault -// ReSharper disable CppClangTidyCppcoreguidelinesSpecialMemberFunctions -// ReSharper disable CppClangTidyModernizePassByValue -// ReSharper disable CppClangTidyModernizeUseEqualsDefault -// - #pragma once +#include #include - -/* Try to guess C++ Compiler capabilities ... */ - -#define OCILIBPP_CPP_98 199711L -#define OCILIBPP_CPP_11 201103L -#define OCILIBPP_CPP_14 201402L - -#if __cplusplus < OCILIBPP_CPP_11 - - // GCC - #if defined(__GNUC__) - #if defined(__GXX_EXPERIMENTAL_CXX0X__) - #define OCILIBPP_HAS_CXX - #endif - // MSVC - #elif defined(_MSC_VER) - #if _MSVC_LANG >= OCILIBPP_CPP_11 - #define OCILIBPP_HAS_CXX - #endif - #endif - -#else - - #define OCILIBPP_HAS_CXX - -#endif - -#ifdef OCILIBPP_HAS_CXX - - #define OCILIBPP_HAS_ENABLEIF - #define OCILIBPP_HAS_VARIADIC - - #ifdef OCILIBCPP_DEBUG_MEMORY - - #include - #define OCILIBPP_DEBUG_MEMORY_ENABLED - - #endif - -#else - - #define OCILIBPP_DEFINE_CXX_KEYWORDS - -#endif - -#ifdef OCILIBPP_TEST_CPP98 - - #ifdef OCILIBPP_DEFINE_CXX_KEYWORDS - #undef OCILIBPP_DEFINE_CXX_KEYWORDS - #endif - - #ifdef OCILIBPP_HAS_ENABLEIF - #undef OCILIBPP_HAS_ENABLEIF - #endif - - #ifdef OCILIBPP_HAS_VARIADIC - #undef OCILIBPP_HAS_VARIADIC - #endif - -#endif - -#ifdef OCILIBPP_DEFINE_CXX_KEYWORDS - - #define nullptr 0 - #define override - #define noexcept - -#endif +#include "ocilibcpp/config.hpp" namespace ocilib { + namespace core + { #ifdef OCILIBPP_HAS_ENABLEIF - template - using EnableIf = std::enable_if; + template + using EnableIf = std::enable_if; - template - using IsSame = std::is_same; + template + using IsSame = std::is_same; #else - - template - struct EnableIf {}; - template - struct EnableIf { typedef T type; }; + template + struct EnableIf {}; - template - struct BoolConstant { static const bool value = B; }; + template + struct EnableIf { typedef T type; }; - template - struct IsSame : BoolConstant {}; + template + struct BoolConstant { static const bool value = B; }; - template - struct IsSame : BoolConstant {}; + template + struct IsSame : BoolConstant {}; -#endif + template + struct IsSame : BoolConstant {}; +#endif #define ARG_NOT_USED(a) (a) = (a) -/* class forward declarations */ - -class Exception; -class Connection; -class Transaction; -class Environment; -class Statement; -class Resultset; -class Date; -class Timestamp; -class Interval; -class Number; -class TypeInfo; -class Reference; -class Object; -template -class Element; -template -class Iterator; -template -class Collection; -template -class Lob; -class File; -class Pool; -template -class Long; -class Column; -class Subscription; -class Event; -class Agent; -class Message; -class Enqueue; -class Dequeue; -class Queue; -class QueueTable; -class DirectPath; -class Thread; -class ThreadKey; -class Mutex; -class BindInfo; - -template -struct SupportedNumeric -{ - typedef EnableIf::value || - IsSame::value || - IsSame::value || - IsSame::value || - IsSame::value || - IsSame::value || - IsSame::value || - IsSame::value || - IsSame::value> Type; -}; - -/** -* @brief Internal usage. -* Allow resolving a native type used by C API from a C++ type in binding operations -*/ -template struct BindResolver {}; - -/** - * @brief Internal usage. - * Checks if the last OCILIB function call has raised an error. - * If so, it raises a C++ exception using the retrieved error handle - */ -template -static T Check(T result); - -/** - * @brief Internal usage. - * Constructs a C++ string object from the given OCILIB string pointer - */ -ostring MakeString(const otext *result, int size = -1); - -/** -* @brief Internal usage. -* Constructs a C++ Raw object from the given OCILIB raw buffer -*/ -Raw MakeRaw(AnyPointer result, unsigned int size); - -/** - * @brief - * Template class providing OCILIB handles auto memory, life cycle and scope management - */ -template -class HandleHolder; - -/** - * @brief - * Template Enumeration template class providing some type safety to some extends for manipulating enumerated variables - */ -template -class Enum -{ -public: - - typedef T Type; - - Enum(); - Enum(T value); - - T GetValue(); - - operator T (); - operator unsigned int () const; + /** + * @brief Internal usage. + * Checks if the last OCILIB function call has raised an error. + * If so, it raises a C++ exception using the retrieved error handle + */ + template + static T Check(T result); - bool operator == (const Enum& other) const; - bool operator != (const Enum& other) const; + /** + * @brief Internal usage. + * Constructs a C++ string object from the given OCILIB string pointer + */ + ostring MakeString(const otext* result, int size = -1); - bool operator == (const T& other) const; - bool operator != (const T& other) const; + /** + * @brief Internal usage. + * Constructs a C++ Raw object from the given OCILIB raw buffer + */ + Raw MakeRaw(AnyPointer result, unsigned int size); + + template + struct SupportedNumeric + { + typedef EnableIf::value || + IsSame::value || + IsSame::value || + IsSame::value || + IsSame::value || + IsSame::value || + IsSame::value || + IsSame::value || + IsSame::value> Type; + }; -private: + /** + * @brief + * Template Enumeration template class providing some type safety to some extends for manipulating enumerated variables + */ + template + class Enum + { + public: - T _value; -}; + typedef T Type; -/** - * @brief - * Template Flags template class providing some type safety to some extends for manipulating flags set variables - */ -template -class Flags -{ -public: - - typedef T Type; - - Flags(); - Flags(T flag); - Flags(const Flags& other); - - Flags& operator = (const Flags& other) noexcept; - - Flags operator~ () const; - - Flags operator | (T other) const; - Flags operator & (T other) const; - Flags operator ^ (T other) const; - - Flags operator | (const Flags& other) const; - Flags operator & (const Flags& other) const; - Flags operator ^ (const Flags& other) const; - - Flags& operator |= (T other); - Flags& operator &= (T other); - Flags& operator ^= (T other); - - Flags& operator |= (const Flags& other); - Flags& operator &= (const Flags& other); - Flags& operator ^= (const Flags& other); - - bool operator == (T other) const; - bool operator == (const Flags& other) const; - - unsigned int GetValues() const; - - bool IsSet(T other) const; - -private: - - Flags(unsigned int flags); - - unsigned int _flags; -}; - -template< typename T> -class ManagedBuffer -{ -public: - ManagedBuffer(); - ManagedBuffer(size_t size); - ManagedBuffer(T *buffer, size_t size); - - ~ManagedBuffer() noexcept; - - operator T* (); - -private: - - T* _buffer; - size_t _size; -}; - -class Locker -{ -public: - - Locker(); - virtual ~Locker() noexcept; - - void Lock() const; - void Unlock() const; + Enum(); + Enum(T value); - void SetAccessMode(bool threaded); + T GetValue(); -private: + operator T (); + operator unsigned int() const; - MutexHandle _mutex; -}; + bool operator == (const Enum& other) const; + bool operator != (const Enum& other) const; -class Lockable -{ -public: - - Lockable(); - virtual ~Lockable() noexcept; + bool operator == (const T& other) const; + bool operator != (const T& other) const; - void SetLocker(Locker *locker); + private: - void Lock() const; - void Unlock() const; + T _value; + }; -private: + /** + * @brief + * Template Flags template class providing some type safety to some extends for manipulating flags set variables + */ + template + class Flags + { + public: - Locker *_locker; -}; + typedef T Type; -template -class ConcurrentMap : public Lockable -{ -public: + Flags(); + Flags(T flag); + Flags(const Flags& other); - ConcurrentMap(); - virtual ~ConcurrentMap() noexcept; + Flags& operator = (const Flags& other) noexcept; - void Remove(K key); - V Get(K key); - void Set(K key, V value); - void Clear(); - size_t GetSize(); + Flags operator~ () const; -private: + Flags operator | (T other) const; + Flags operator & (T other) const; + Flags operator ^ (T other) const; - std::map _map; + Flags operator | (const Flags& other) const; + Flags operator & (const Flags& other) const; + Flags operator ^ (const Flags& other) const; -}; + Flags& operator |= (T other); + Flags& operator &= (T other); + Flags& operator ^= (T other); -template -class ConcurrentList : public Lockable -{ -public: + Flags& operator |= (const Flags& other); + Flags& operator &= (const Flags& other); + Flags& operator ^= (const Flags& other); - ConcurrentList(); - virtual ~ConcurrentList() noexcept; + bool operator == (T other) const; + bool operator == (const Flags& other) const; - void Add(T value); - void Remove(T value); - void Clear(); - size_t GetSize(); - bool Exists(const T &value); + unsigned int GetValues() const; - template - bool FindIf(P predicate, T &value); + bool IsSet(T other) const; - template - void ForEach(A action); + private: -private: + Flags(unsigned int flags); - std::list _list; -}; - -class Handle -{ -public: - - virtual ~Handle() noexcept {} - virtual ConcurrentList & GetChildren() = 0; - virtual void DetachFromHolders() = 0; - virtual void DetachFromParent() = 0; -}; - -/** -* @brief -* Smart pointer class with reference counting for managing OCILIB object handles -*/ -template -class HandleHolder -{ -public: + unsigned int _flags; + }; - bool IsNull() const; + template< typename T> + class ManagedBuffer + { + public: + ManagedBuffer(); + ManagedBuffer(size_t size); + ManagedBuffer(T* buffer, size_t size); - operator bool(); - operator bool() const; + ~ManagedBuffer() noexcept; - operator T(); - operator T() const; + operator T* (); -protected: + private: - class SmartHandle; + T* _buffer; + size_t _size; + }; - HandleHolder(const HandleHolder &other); - HandleHolder(); - ~HandleHolder() noexcept; + class Locker + { + public: - HandleHolder& operator= (const HandleHolder& other) noexcept; - - typedef boolean(OCI_API *HandleFreeFunc)(AnyPointer handle); - - typedef void(*SmartHandleFreeNotifyFunc)(SmartHandle *smartHandle); - - Handle* GetHandle() const; - - void Acquire(T handle, HandleFreeFunc handleFreefunc, SmartHandleFreeNotifyFunc freeNotifyFunc, Handle *parent); - void Acquire(HandleHolder &other); - void Release(); - - class SmartHandle : public Handle - { - public: + Locker(); + virtual ~Locker() noexcept; - SmartHandle(HandleHolder *holder, T handle, HandleFreeFunc handleFreefunc, SmartHandleFreeNotifyFunc freeNotifyFunc, Handle *parent); - virtual ~SmartHandle() noexcept; + void Lock() const; + void Unlock() const; - void Acquire(HandleHolder *holder); - void Release(HandleHolder *holder); + void SetAccessMode(bool threaded); - void Destroy(); + private: - T GetHandle() const; + MutexHandle _mutex; + }; - Handle *GetParent() const; + class Lockable + { + public: - AnyPointer GetExtraInfos() const; - void SetExtraInfos(AnyPointer extraInfo); + Lockable(); + virtual ~Lockable() noexcept; - ConcurrentList & GetChildren() override; - void DetachFromHolders() override; - void DetachFromParent() override; + void SetLocker(Locker* locker); - private: + void Lock() const; + void Unlock() const; - static void DeleteHandle(Handle *handle); - static void ResetHolder(HandleHolder *holder); + private: - ConcurrentList _holders; - ConcurrentList _children; + Locker* _locker; + }; - Locker _locker; + template + class ConcurrentMap : public Lockable + { + public: - T _handle; - HandleFreeFunc _handleFreeFunc; - SmartHandleFreeNotifyFunc _freeNotifyFunc; - Handle *_parent; - AnyPointer _extraInfo; - }; + ConcurrentMap(); + virtual ~ConcurrentMap() noexcept; - SmartHandle *_smartHandle; - }; + void Remove(K key); + V Get(K key); + void Set(K key, V value); + void Clear(); + size_t GetSize(); -/** -* @brief -* Abstract class allowing derived classes to be compatible -* with any type supporting the operator << ocilib::ostring -*/ -class Streamable -{ -public: + private: - virtual ~Streamable() noexcept {} + std::map _map; - operator ostring() const - { - return ToString(); - } + }; - virtual ostring ToString() const = 0; + template + class ConcurrentList : public Lockable + { + public: - template - friend T& operator << (T &lhs, const Streamable &rhs) - { - lhs << static_cast(rhs); - return lhs; - } -}; + ConcurrentList(); + virtual ~ConcurrentList() noexcept; -class BindObject -{ -public: + void Add(T value); + void Remove(T value); + void Clear(); + size_t GetSize(); + bool Exists(const T& value); - BindObject(const Statement &statement, const ostring& name, unsigned int mode); + template + bool FindIf(P predicate, T& value); - virtual ~BindObject() noexcept; + template + void ForEach(A action); - ostring GetName() const; + private: - Statement GetStatement() const; + std::list _list; + }; - unsigned int GetMode() const; + class Handle + { + public: - virtual void SetInData() = 0; - virtual void SetOutData() = 0; + virtual ~Handle() noexcept {} + virtual ConcurrentList& GetChildren() = 0; + virtual void DetachFromHolders() = 0; + virtual void DetachFromParent() = 0; + }; -protected: + /** + * @brief + * Smart pointer class with reference counting for managing OCILIB object handles + */ + template + class HandleHolder + { + public: - const Statement& _statement; - ostring _name; - unsigned int _mode; -}; + bool IsNull() const; -class BindArray : public BindObject -{ -public: + operator bool(); + operator bool() const; - BindArray(const Statement &statement, const ostring& name, unsigned int mode); - virtual ~BindArray() noexcept; + operator T(); + operator T() const; - template - void SetVector(std::vector & vector, bool isPlSqlTable, unsigned int elemSize); - - template - typename BindResolver::OutputType * GetData() const; + protected: - void SetInData() override; - void SetOutData() override; + class SmartHandle; - unsigned int GetSize() const; - unsigned int GetSizeForBindCall() const; + HandleHolder(const HandleHolder& other); + HandleHolder(); + ~HandleHolder() noexcept; -private: + HandleHolder& operator= (const HandleHolder& other) noexcept; - class AbstractBindArrayObject - { - public: - virtual ~AbstractBindArrayObject() {}; - virtual void SetInData() = 0; - virtual void SetOutData() = 0; - virtual ostring GetName() const = 0; - virtual bool IsHandleObject() const = 0; - virtual unsigned int GetSize() const = 0; - virtual unsigned int GetSizeForBindCall() const = 0; - }; - - template - class BindArrayObject : public AbstractBindArrayObject - { - public: - - typedef T ObjectType; - typedef std::vector ObjectVector; - typedef typename BindResolver::OutputType NativeType; - - BindArrayObject(const Statement &statement, const ostring &name, ObjectVector &vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize); - virtual ~BindArrayObject() noexcept; - void SetInData() override; - void SetOutData() override; - ostring GetName()const override; - bool IsHandleObject() const override; - unsigned int GetSize() const override; - unsigned int GetSizeForBindCall() const override; - - operator ObjectVector & () const; - operator NativeType * () const; - - private: - - void AllocData(); - void FreeData() const; - - const Statement& _statement; - ostring _name; - ObjectVector& _vector; - NativeType *_data; - bool _isPlSqlTable; - unsigned int _mode; - unsigned int _elemCount; - unsigned int _elemSize; - }; - - AbstractBindArrayObject * _object; -}; - -template -class BindObjectAdaptor : public BindObject -{ - friend class Statement; + typedef boolean(OCI_API* HandleFreeFunc)(AnyPointer handle); -public: + typedef void(*SmartHandleFreeNotifyFunc)(SmartHandle* smartHandle); - typedef T ObjectType; - typedef typename BindResolver::OutputType NativeType; + Handle* GetHandle() const; - operator NativeType *() const; + void Acquire(T handle, HandleFreeFunc handleFreefunc, SmartHandleFreeNotifyFunc freeNotifyFunc, Handle* parent); + void Acquire(HandleHolder& other); + void Release(); - void SetInData() override; - void SetOutData() override; + class SmartHandle : public Handle + { + public: - BindObjectAdaptor(const Statement &statement, const ostring& name, unsigned int mode, ObjectType &object, unsigned int size); - virtual ~BindObjectAdaptor() noexcept; + SmartHandle(HandleHolder* holder, T handle, HandleFreeFunc handleFreefunc, SmartHandleFreeNotifyFunc freeNotifyFunc, Handle* parent); + virtual ~SmartHandle() noexcept; -private: + void Acquire(HandleHolder* holder); + void Release(HandleHolder* holder); - ObjectType& _object; - NativeType* _data; - unsigned int _size; -}; + void Destroy(); -template -class BindTypeAdaptor : public BindObject -{ - friend class Statement; + T GetHandle() const; -public: + Handle* GetParent() const; - typedef T ObjectType; - typedef typename BindResolver::OutputType NativeType; + AnyPointer GetExtraInfos() const; + void SetExtraInfos(AnyPointer extraInfo); - operator NativeType *() const; + ConcurrentList& GetChildren() override; + void DetachFromHolders() override; + void DetachFromParent() override; - void SetInData() override; - void SetOutData() override; + private: - BindTypeAdaptor(const Statement &statement, const ostring& name, unsigned int mode, ObjectType &object); - virtual ~BindTypeAdaptor() noexcept; + static void DeleteHandle(Handle* handle); + static void ResetHolder(HandleHolder* holder); -private: + ConcurrentList _holders; + ConcurrentList _children; - ObjectType& _object; - NativeType* _data; -}; + Locker _locker; -class BindsHolder -{ -public: + T _handle; + HandleFreeFunc _handleFreeFunc; + SmartHandleFreeNotifyFunc _freeNotifyFunc; + Handle* _parent; + AnyPointer _extraInfo; + }; - BindsHolder(const Statement &statement); - ~BindsHolder() noexcept; + SmartHandle* _smartHandle; + }; - void Clear(); + /** + * @brief + * Abstract class allowing derived classes to be compatible + * with any type supporting the operator << ocilib::ostring + */ + class Streamable + { + public: - void AddBindObject(BindObject *bindObject); + virtual ~Streamable() noexcept {} - void SetOutData(); - void SetInData(); + operator ostring() const + { + return ToString(); + } -private: + virtual ostring ToString() const = 0; - std::vector _bindObjects; - const Statement& _statement; -}; + template + friend T& operator << (T& lhs, const Streamable& rhs) + { + lhs << static_cast(rhs); + return lhs; + } + }; -} + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/Agent.hpp b/include/ocilibcpp/detail/Agent.hpp new file mode 100644 index 00000000..2ebd64ba --- /dev/null +++ b/include/ocilibcpp/detail/Agent.hpp @@ -0,0 +1,58 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Agent::Agent(const Connection &connection, const ostring& name, const ostring& address) +{ + Acquire(core::Check(OCI_AgentCreate(connection, name.c_str(), address.c_str())), reinterpret_cast(OCI_AgentFree), nullptr, nullptr); +} + +inline Agent::Agent(OCI_Agent *pAgent, core::Handle *parent) +{ + Acquire(pAgent, nullptr, nullptr, parent); +} + +inline ostring Agent::GetName() const +{ + return core::MakeString(core::Check(OCI_AgentGetName(*this))); +} + +inline void Agent::SetName(const ostring& value) +{ + core::Check(OCI_AgentSetName(*this, value.c_str())); +} + +inline ostring Agent::GetAddress() const +{ + return core::MakeString(core::Check(OCI_AgentGetAddress(*this))); +} + +inline void Agent::SetAddress(const ostring& value) +{ + core::Check(OCI_AgentSetAddress(*this, value.c_str())); +} + +} diff --git a/include/ocilibcpp/detail/BindInfo.hpp b/include/ocilibcpp/detail/BindInfo.hpp new file mode 100644 index 00000000..87fa0d45 --- /dev/null +++ b/include/ocilibcpp/detail/BindInfo.hpp @@ -0,0 +1,85 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline BindInfo::BindInfo(OCI_Bind *pBind, core::Handle *parent) +{ + Acquire(pBind, nullptr, nullptr, parent); +} + +inline ostring BindInfo::GetName() const +{ + return core::MakeString(core::Check(OCI_BindGetName(*this))); +} + +inline DataType BindInfo::GetType() const +{ + return DataType(static_cast(core::Check(OCI_BindGetType(*this)))); +} + +inline unsigned int BindInfo::GetSubType() const +{ + return core::Check(OCI_BindGetSubtype(*this)); +} + +inline unsigned int BindInfo::GetDataCount() const +{ + return core::Check(OCI_BindGetDataCount(*this)); +} + +inline Statement BindInfo::GetStatement() const +{ + return Statement(core::Check(OCI_BindGetStatement(*this))); +} + +inline void BindInfo::SetDataNull(bool value, unsigned int index) +{ + if (value) + { + core::Check(OCI_BindSetNullAtPos(*this, index)); + } + else + { + core::Check(OCI_BindSetNotNullAtPos(*this, index)); + } +} + +inline bool BindInfo::IsDataNull(unsigned int index) const +{ + return (core::Check(OCI_BindIsNullAtPos(*this, index)) == TRUE); +} + +inline void BindInfo::SetCharsetForm(CharsetForm value) +{ + core::Check(OCI_BindSetCharsetForm(*this, value)); +} + +inline BindInfo::BindDirection BindInfo::GetDirection() const +{ + return BindDirection(static_cast(core::Check(OCI_BindGetDirection(*this)))); +} + +} diff --git a/include/ocilibcpp/detail/Collection.hpp b/include/ocilibcpp/detail/Collection.hpp new file mode 100644 index 00000000..d5d80b6c --- /dev/null +++ b/include/ocilibcpp/detail/Collection.hpp @@ -0,0 +1,492 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +template +Collection::Collection() +{ +} + +template +Collection::Collection(const TypeInfo &typeInfo) +{ + Acquire(core::Check(OCI_CollCreate(typeInfo)), reinterpret_cast(OCI_CollFree), nullptr, typeInfo.GetConnection().GetHandle()); +} + +template +Collection::Collection(OCI_Coll *pColl, core::Handle *parent) +{ + Acquire(pColl, nullptr, nullptr, parent); +} + +template +Collection Collection::Clone() const +{ + Collection result(GetTypeInfo()); + + core::Check(OCI_CollAssign(result, *this)); + + return result; +} + +template +TypeInfo Collection::GetTypeInfo() const +{ + return TypeInfo(core::Check(OCI_CollGetTypeInfo(*this))); +} + +template +typename Collection::CollectionType Collection::GetType() const +{ + return CollectionType(core::Check(OCI_CollGetType(*this))); +} + +template +unsigned int Collection::GetMax() const +{ + return core::Check(OCI_CollGetMax(*this)); +} + +template +unsigned int Collection::GetSize() const + +{ + return core::Check(OCI_CollGetSize(*this)); +} + +template +unsigned int Collection::GetCount() const + +{ + return core::Check(OCI_CollGetCount(*this)); +} + +template +void Collection::Truncate(unsigned int size) +{ + core::Check(OCI_CollTrim(*this, size)); +} + +template +void Collection::Clear() +{ + core::Check(OCI_CollClear(*this)); +} + +template +bool Collection::IsElementNull(unsigned int index) const +{ + return (core::Check(OCI_ElemIsNull(core::Check(OCI_CollGetElem(*this, index)))) == TRUE); +} + +template +void Collection::SetElementNull(unsigned int index) +{ + core::Check(OCI_ElemSetNull(core::Check(OCI_CollGetElem(*this, index)))); +} + +template +bool Collection::Delete(unsigned int index) const +{ + return (core::Check(OCI_CollDeleteElem(*this, index)) == TRUE); +} + +template +typename Collection::iterator Collection::begin() +{ + return iterator(this, 1); +} + +template +typename Collection::const_iterator Collection::begin() const +{ + return const_iterator(const_cast(this), 1); +} + +template +typename Collection::iterator Collection::end() +{ + return iterator(const_cast(this), GetCount() + 1); +} + +template +typename Collection::const_iterator Collection::end() const +{ + return const_iterator(const_cast(this), GetCount() + 1); +} + +template +T Collection::Get(unsigned int index) const +{ + return GetElem(core::Check(OCI_CollGetElem(*this, index)), GetHandle()); +} + +template +void Collection::Set(unsigned int index, const T & value) +{ + OCI_Elem * elem = core::Check(OCI_CollGetElem(*this, index)); + + SetElem(elem, value); + + core::Check(OCI_CollSetElem(*this, index, elem)); +} + +template +void Collection::Append(const T &value) +{ + OCI_Elem * elem = core::Check(OCI_ElemCreate(OCI_CollGetTypeInfo(*this))); + + SetElem(elem, value); + + core::Check(OCI_CollAppend(*this, elem)); + core::Check(OCI_ElemFree(elem)); +} + +template<> +inline bool Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return (core::Check(OCI_ElemGetBoolean(elem)) == TRUE); +} + +template<> +inline short Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetShort(elem)); +} + +template<> +inline unsigned short Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetUnsignedShort(elem)); +} + +template<> +inline int Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetInt(elem)); +} + +template<> +inline unsigned int Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetUnsignedInt(elem)); +} + +template<> +inline big_int Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetBigInt(elem)); +} + +template<> +inline big_uint Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetUnsignedBigInt(elem)); +} + +template<> +inline float Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetFloat(elem)); +} + +template<> +inline double Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::Check(OCI_ElemGetDouble(elem)); +} + +template<> +inline Number Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Number(core::Check(OCI_ElemGetNumber(elem)), parent); +} + +template<> +inline ostring Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + return core::MakeString(core::Check(OCI_ElemGetString(elem))); +} + +template<> +inline Raw Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + ARG_NOT_USED(parent); + + unsigned int size = core::Check(OCI_ElemGetRawSize(elem)); + + core::ManagedBuffer buffer(static_cast(size + 1)); + + size = core::Check(OCI_ElemGetRaw(elem, static_cast(buffer), size)); + + return core::MakeRaw(buffer, size); +} + +template<> +inline Date Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Date(core::Check(OCI_ElemGetDate(elem)), parent); +} + +template<> +inline Timestamp Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Timestamp(core::Check(OCI_ElemGetTimestamp(elem)), parent); +} + +template<> +inline Interval Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Interval(core::Check(OCI_ElemGetInterval(elem)), parent); +} + +template<> +inline Object Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Object(core::Check(OCI_ElemGetObject(elem)), parent); +} + +template<> +inline Reference Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Reference(core::Check(OCI_ElemGetRef(elem)), parent); +} + +template<> +inline Clob Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Clob(core::Check(OCI_ElemGetLob(elem)), parent); +} + +template<> +inline NClob Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return NClob(core::Check(OCI_ElemGetLob(elem)), parent); +} +template<> +inline Blob Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return Blob(core::Check(OCI_ElemGetLob(elem)), parent); +} + +template<> +inline File Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return File(core::Check(OCI_ElemGetFile(elem)), parent); +} + +template + T Collection::GetElem(OCI_Elem *elem, core::Handle *parent) +{ + return T(core::Check(OCI_ElemGetColl(elem)), parent); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const bool &value) +{ + core::Check(OCI_ElemSetBoolean(elem, static_cast(value))); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const short &value) +{ + core::Check(OCI_ElemSetShort(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const unsigned short &value) +{ + core::Check(OCI_ElemSetUnsignedShort(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const int &value) +{ + core::Check(OCI_ElemSetInt(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const unsigned int &value) +{ + core::Check(OCI_ElemSetUnsignedInt(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const big_int &value) +{ + core::Check(OCI_ElemSetBigInt(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const big_uint &value) +{ + core::Check(OCI_ElemSetUnsignedBigInt(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const float &value) +{ + core::Check(OCI_ElemSetFloat(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const double &value) +{ + core::Check(OCI_ElemSetDouble(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Number &value) +{ + core::Check(OCI_ElemSetNumber(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const ostring& value) +{ + core::Check(OCI_ElemSetString(elem, value.c_str())); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Raw &value) +{ + const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; + + core::Check(OCI_ElemSetRaw(elem, data, static_cast(value.size()))); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Date &value) +{ + core::Check(OCI_ElemSetDate(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Timestamp &value) +{ + core::Check(OCI_ElemSetTimestamp(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Interval &value) +{ + core::Check(OCI_ElemSetInterval(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Object &value) +{ + core::Check(OCI_ElemSetObject(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Reference &value) +{ + core::Check(OCI_ElemSetRef(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Clob &value) +{ + core::Check(OCI_ElemSetLob(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const NClob &value) +{ + core::Check(OCI_ElemSetLob(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const Blob &value) +{ + core::Check(OCI_ElemSetLob(elem, value)); +} + +template<> +inline void Collection::SetElem(OCI_Elem *elem, const File &value) +{ + core::Check(OCI_ElemSetFile(elem, value)); +} + +template +void Collection::SetElem(OCI_Elem *elem, const T &value) +{ + core::Check(OCI_ElemSetColl(elem, value)); +} + +template +ostring Collection::ToString() const +{ + if (!IsNull()) + { + unsigned int len = 0; + + core::Check(OCI_CollToText(*this, &len, nullptr)); + + core::ManagedBuffer buffer(static_cast(len + 1)); + + core::Check(OCI_CollToText(*this, &len, buffer)); + + return core::MakeString(static_cast(buffer), static_cast(len)); + } + + return OCI_STRING_NULL; +} + +template +CollectionElement Collection::operator [] (unsigned int index) +{ + return CollectionElement(this, index); +} + +template +CollectionElement Collection::operator [](unsigned int index) const +{ + return CollectionElement(this, index); +} + +} diff --git a/include/ocilibcpp/detail/CollectionElement.hpp b/include/ocilibcpp/detail/CollectionElement.hpp new file mode 100644 index 00000000..88523e33 --- /dev/null +++ b/include/ocilibcpp/detail/CollectionElement.hpp @@ -0,0 +1,80 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +template +CollectionElement::CollectionElement() : _coll(nullptr), _pos(0) +{ + +} + +template +CollectionElement::CollectionElement(CollectionType *coll, unsigned int pos) : _coll(coll), _pos(pos) +{ + +} + +template +CollectionElement::operator T() const +{ + return _coll->Get(_pos); +} + +template +CollectionElement& CollectionElement::operator = (const ValueType& other) +{ + if (this != &other) + { + _coll->Set(_pos, other); + } + + return *this; +} + +template +CollectionElement& CollectionElement::operator = (const CollectionElement &other) +{ + if (this != &other) + { + _coll->Set(_pos, static_cast(other)); + } + + return *this; +} + +template +bool CollectionElement::IsNull() const +{ + return _coll->IsElementNull(_pos); +} + +template +void CollectionElement::SetNull() +{ + _coll->SetElementNull(_pos); +} + +} diff --git a/include/ocilibcpp/detail/CollectionIterator.hpp b/include/ocilibcpp/detail/CollectionIterator.hpp new file mode 100644 index 00000000..14e08ed2 --- /dev/null +++ b/include/ocilibcpp/detail/CollectionIterator.hpp @@ -0,0 +1,168 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +template +CollectionIterator::CollectionIterator() : _elem() +{ + +} + +template +CollectionIterator::CollectionIterator(CollectionType *collection, unsigned int pos) : _elem(collection, pos) +{ + +} + +template +CollectionIterator::CollectionIterator(const CollectionIterator& other) : _elem(other._elem) +{ + +} + +template +CollectionIterator& CollectionIterator::operator = (const CollectionIterator& other) +{ + if (this != &other) + { + _elem._pos = other._elem._pos; + _elem._coll = other._elem._coll; + } + + return *this; +} + +template +CollectionIterator& CollectionIterator::operator += (difference_type value) +{ + _elem._pos += static_cast(value); + return *this; +} + +template +CollectionIterator& CollectionIterator::operator -= (difference_type value) +{ + _elem._pos -= static_cast(value); + return *this; +} + +template +T& CollectionIterator::operator*() +{ + return _elem; +} + +template +T* CollectionIterator::operator->() +{ + return &_elem; +} + +template +CollectionIterator& CollectionIterator::operator--() +{ + --_elem._pos; + return *this; +} + +template +CollectionIterator& CollectionIterator::operator++() +{ + ++*(const_cast(&_elem._pos)); + return *this; +} + +template +CollectionIterator CollectionIterator::operator++(int) +{ + CollectionIterator res(_elem._coll, _elem._pos); + ++(*this); + return res; +} + +template +CollectionIterator CollectionIterator::operator--(int) +{ + CollectionIterator res(_elem); + --(*this); + return res; +} + +template +CollectionIterator CollectionIterator::operator + (difference_type value) +{ + return CollectionIterator(_elem._coll, _elem._pos + static_cast(value)); +} + +template +CollectionIterator CollectionIterator::operator - (difference_type value) +{ + return CollectionIterator(_elem._coll, _elem._pos - static_cast(value)); +} + +template +typename CollectionIterator::difference_type CollectionIterator::operator - (const CollectionIterator & other) +{ + return static_cast(_elem._pos - other._elem._pos); +} + +template +bool CollectionIterator::operator == (const CollectionIterator& other) +{ + return _elem._pos == other._elem._pos && (static_cast(*_elem._coll)) == (static_cast(*other._elem._coll)); +} + +template +bool CollectionIterator::operator != (const CollectionIterator& other) +{ + return !(*this == other); +} + +template +bool CollectionIterator::operator > (const CollectionIterator& other) +{ + return _elem._pos > other._elem._pos; +} + +template +bool CollectionIterator::operator < (const CollectionIterator& other) +{ + return _elem._pos < other._elem._pos; +} + +template +bool CollectionIterator::operator >= (const CollectionIterator& other) +{ + return _elem._pos >= other._elem._pos; +} + +template +bool CollectionIterator::operator <= (const CollectionIterator& other) +{ + return _elem._pos <= other._elem._pos; +} + +} diff --git a/include/ocilibcpp/detail/Column.hpp b/include/ocilibcpp/detail/Column.hpp new file mode 100644 index 00000000..a37b4736 --- /dev/null +++ b/include/ocilibcpp/detail/Column.hpp @@ -0,0 +1,119 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Column::Column(OCI_Column *pColumn, core::Handle *parent) +{ + Acquire(pColumn, nullptr, nullptr, parent); +} + +inline ostring Column::GetName() const +{ + return core::MakeString(core::Check(OCI_ColumnGetName(*this))); +} + +inline ostring Column::GetSQLType() const +{ + return core::MakeString(core::Check(OCI_ColumnGetSQLType(*this))); +} + +inline ostring Column::GetFullSQLType() const +{ + const unsigned int size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_ColumnGetFullSQLType(*this, buffer, size)); + + return core::MakeString(static_cast(buffer)); +} + +inline DataType Column::GetType() const +{ + return DataType(static_cast(core::Check(OCI_ColumnGetType(*this)))); +} + +inline unsigned int Column::GetSubType() const +{ + return core::Check(OCI_ColumnGetSubType(*this)); +} + +inline CharsetForm Column::GetCharsetForm() const +{ + return CharsetForm(static_cast(core::Check(OCI_ColumnGetCharsetForm(*this)))); +} + +inline CollationID Column::GetCollationID() const +{ + return CollationID(static_cast(core::Check(OCI_ColumnGetCollationID(*this)))); +} + +inline unsigned int Column::GetSize() const +{ + return core::Check(OCI_ColumnGetSize(*this)); +} + +inline int Column::GetScale() const +{ + return core::Check(OCI_ColumnGetScale(*this)); +} + +inline int Column::GetPrecision() const +{ + return core::Check(OCI_ColumnGetPrecision(*this)); +} + +inline int Column::GetFractionalPrecision() const +{ + return core::Check(OCI_ColumnGetFractionalPrecision(*this)); +} + +inline int Column::GetLeadingPrecision() const +{ + return core::Check(OCI_ColumnGetLeadingPrecision(*this)); +} + +inline Column::PropertyFlags Column::GetPropertyFlags() const +{ + return PropertyFlags(static_cast(core::Check(OCI_ColumnGetPropertyFlags(*this)))); +} + +inline bool Column::IsNullable() const +{ + return (core::Check(OCI_ColumnGetNullable(*this)) == TRUE); +} + +inline bool Column::IsCharSemanticUsed() const +{ + return (core::Check(OCI_ColumnGetCharUsed(*this)) == TRUE); +} + +inline TypeInfo Column::GetTypeInfo() const +{ + return TypeInfo(core::Check(OCI_ColumnGetTypeInfo(*this))); +} + +} diff --git a/include/ocilibcpp/detail/Connection.hpp b/include/ocilibcpp/detail/Connection.hpp new file mode 100644 index 00000000..2e2b790e --- /dev/null +++ b/include/ocilibcpp/detail/Connection.hpp @@ -0,0 +1,291 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Connection::Connection() +{ + +} + +inline Connection::Connection(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags) +{ + Open(db, user, pwd, sessionFlags); +} + +inline Connection::Connection(OCI_Connection *con, core::Handle *parent) +{ + Acquire(con, reinterpret_cast(parent ? OCI_ConnectionFree : nullptr), nullptr, parent); +} + +inline void Connection::Open(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags) +{ + Acquire(core::Check(OCI_ConnectionCreate(db.c_str(), user.c_str(), pwd.c_str(), sessionFlags.GetValues())), + reinterpret_cast(OCI_ConnectionFree), nullptr, Environment::GetEnvironmentHandle()); +} + +inline void Connection::Close() +{ + Release(); +} + +inline void Connection::Commit() +{ + core::Check(OCI_Commit(*this)); +} + +inline void Connection::Rollback() +{ + core::Check(OCI_Rollback(*this)); +} + +inline void Connection::Break() +{ + core::Check(OCI_Break(*this)); +} + +inline void Connection::SetAutoCommit(bool enabled) +{ + core::Check(OCI_SetAutoCommit(*this, enabled)); +} + +inline bool Connection::GetAutoCommit() const +{ + return (core::Check(OCI_GetAutoCommit(*this)) == TRUE); +} + +inline bool Connection::IsServerAlive() const +{ + return (core::Check(OCI_IsConnected(*this)) == TRUE); +} + +inline bool Connection::PingServer() const +{ + return( core::Check(OCI_Ping(*this)) == TRUE); +} + +inline ostring Connection::GetConnectionString() const +{ + return core::MakeString(core::Check(OCI_GetDatabase(*this))); +} + +inline ostring Connection::GetUserName() const +{ + return core::MakeString(core::Check(OCI_GetUserName(*this))); +} + +inline ostring Connection::GetPassword() const +{ + return core::MakeString(core::Check(OCI_GetPassword(*this))); +} + +inline OracleVersion Connection::GetVersion() const +{ + return OracleVersion(static_cast(core::Check(OCI_GetVersionConnection(*this)))); +} + +inline ostring Connection::GetServerVersion() const +{ + return core::MakeString(core::Check(OCI_GetVersionServer(*this))); +} + +inline unsigned int Connection::GetServerMajorVersion() const +{ + return core::Check(OCI_GetServerMajorVersion(*this)); +} + +inline unsigned int Connection::GetServerMinorVersion() const +{ + return core::Check(OCI_GetServerMinorVersion(*this)); +} + +inline unsigned int Connection::GetServerRevisionVersion() const +{ + return core::Check(OCI_GetServerRevisionVersion(*this)); +} + +inline void Connection::ChangePassword(const ostring& newPwd) +{ + core::Check(OCI_SetPassword(*this, newPwd.c_str())); +} + +inline ostring Connection::GetSessionTag() const +{ + return core::MakeString(core::Check(OCI_GetSessionTag(*this))); +} + +inline void Connection::SetSessionTag(const ostring& tag) +{ + core::Check(OCI_SetSessionTag(*this, tag.c_str())); +} + +inline Transaction Connection::GetTransaction() const +{ + return Transaction(core::Check(OCI_GetTransaction(*this))); +} + +inline void Connection::SetTransaction(const Transaction &transaction) +{ + core::Check(OCI_SetTransaction(*this, transaction)); +} + +inline bool Connection::SetFormat(FormatType formatType, const ostring& format) +{ + return core::Check(OCI_SetFormat(*this, formatType, format.c_str()) == TRUE); +} + +inline ostring Connection::GetFormat(FormatType formatType) +{ + return core::MakeString(core::Check(OCI_GetFormat(*this, formatType))); +} + +inline void Connection::EnableServerOutput(unsigned int bufsize, unsigned int arrsize, unsigned int lnsize) +{ + core::Check(OCI_ServerEnableOutput(*this, bufsize, arrsize, lnsize)); +} + +inline void Connection::DisableServerOutput() +{ + core::Check(OCI_ServerDisableOutput(*this)); +} + +inline bool Connection::GetServerOutput(ostring &line) const +{ + const otext * str = core::Check(OCI_ServerGetOutput(*this)); + + line = core::MakeString(str); + + return (str != nullptr); +} + +inline void Connection::GetServerOutput(std::vector &lines) const +{ + const otext * str = core::Check(OCI_ServerGetOutput(*this)); + + while (str) + { + lines.push_back(str); + str = core::Check(OCI_ServerGetOutput(*this)); + } +} + +inline void Connection::SetTrace(SessionTrace trace, const ostring& value) +{ + core::Check(OCI_SetTrace(*this, trace, value.c_str())); +} + +inline ostring Connection::GetTrace(SessionTrace trace) const +{ + return core::MakeString(core::Check(OCI_GetTrace(*this, trace))); +} + +inline ostring Connection::GetDatabase() const +{ + return core::MakeString(core::Check(OCI_GetDBName(*this))); +} + +inline ostring Connection::GetInstance() const +{ + return core::Check(OCI_GetInstanceName(*this)); +} + +inline ostring Connection::GetService() const +{ + return core::MakeString(core::Check(OCI_GetServiceName(*this))); +} + +inline ostring Connection::GetServer() const +{ + return core::Check(OCI_GetServerName(*this)); +} + +inline ostring Connection::GetDomain() const +{ + return core::MakeString(core::Check(OCI_GetDomainName(*this))); +} + +inline Timestamp Connection::GetInstanceStartTime() const +{ + return Timestamp(core::Check(OCI_GetInstanceStartTime(*this)), GetHandle()); +} + +inline unsigned int Connection::GetStatementCacheSize() const +{ + return core::Check(OCI_GetStatementCacheSize(*this)); +} + +inline void Connection::SetStatementCacheSize(unsigned int value) +{ + core::Check(OCI_SetStatementCacheSize(*this, value)); +} + +inline unsigned int Connection::GetDefaultLobPrefetchSize() const +{ + return core::Check(OCI_GetDefaultLobPrefetchSize(*this)); +} + +inline void Connection::SetDefaultLobPrefetchSize(unsigned int value) +{ + core::Check(OCI_SetDefaultLobPrefetchSize(*this, value)); +} + +inline unsigned int Connection::GetMaxCursors() const +{ + return core::Check(OCI_GetMaxCursors(*this)); +} + +inline bool Connection::IsTAFCapable() const +{ + return (core::Check(OCI_IsTAFCapable(*this)) == TRUE); +} + +inline void Connection::SetTAFHandler(TAFHandlerProc handler) +{ + core::Check(OCI_SetTAFHandler(*this, static_cast(handler != nullptr ? Environment::TAFHandler : nullptr))); + + Environment::SetUserCallback(static_cast(*this), handler); +} + +inline AnyPointer Connection::GetUserData() +{ + return core::Check(OCI_GetUserData(*this)); +} + +inline void Connection::SetUserData(AnyPointer value) +{ + core::Check(OCI_SetUserData(*this, value)); +} + +inline unsigned int Connection::GetTimeout(TimeoutType timeout) +{ + return core::Check(OCI_GetTimeout(*this, timeout)); +} + +inline void Connection::SetTimeout(TimeoutType timeout, unsigned int value) +{ + core::Check(OCI_SetTimeout(*this, timeout, value)); +} + +} diff --git a/include/ocilibcpp/detail/Date.hpp b/include/ocilibcpp/detail/Date.hpp new file mode 100644 index 00000000..325281c6 --- /dev/null +++ b/include/ocilibcpp/detail/Date.hpp @@ -0,0 +1,374 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Date::Date(bool create) +{ + if (create) + { + Allocate(); + } +} + +inline Date::Date(const ostring& str, const ostring& format) +{ + Allocate(); + + FromString(str, format); +} + +inline Date::Date(const otext* str, const otext* format) +{ + Allocate(); + + FromString(str, format); +} + +inline Date::Date(OCI_Date *pDate, core::Handle *parent) +{ + Acquire(pDate, nullptr, nullptr, parent); +} + +inline void Date::Allocate() +{ + Acquire(core::Check(OCI_DateCreate(nullptr)), reinterpret_cast(OCI_DateFree), nullptr, nullptr); +} + +inline Date Date::SysDate() +{ + Date result; + + result.Allocate(); + + core::Check(OCI_DateSysDate(result)); + + return result; +} + +inline Date Date::Clone() const +{ + Date result; + + result.Allocate(); + + core::Check(OCI_DateAssign(result, *this)); + + return result; +} + +inline int Date::Compare(const Date& other) const +{ + return core::Check(OCI_DateCompare(*this, other)); +} + +inline bool Date::IsValid() const +{ + return (core::Check(OCI_DateCheck(*this)) == 0); +} + +inline int Date::GetYear() const +{ + int year = 0, month = 0, day = 0; + + GetDate(year, month, day); + + return year; +} + +inline void Date::SetYear(int value) +{ + int year = 0, month = 0, day = 0; + + GetDate(year, month, day); + SetDate(value, month, day); +} + +inline int Date::GetMonth() const +{ + int year = 0, month = 0, day = 0; + + GetDate(year, month, day); + + return month; +} + +inline void Date::SetMonth(int value) +{ + int year = 0, month = 0, day = 0; + + GetDate(year, month, day); + SetDate(year, value, day); +} + +inline int Date::GetDay() const +{ + int year = 0, month = 0, day = 0; + + GetDate(year, month, day); + + return day; +} + +inline void Date::SetDay(int value) +{ + int year = 0, month = 0, day = 0; + + GetDate(year, month, day); + SetDate(year, month, value); +} + +inline int Date::GetHours() const +{ + int hour = 0, minutes = 0, seconds = 0; + + GetTime(hour, minutes, seconds); + + return hour; +} + +inline void Date::SetHours(int value) +{ + int hour = 0, minutes = 0, seconds = 0; + + GetTime(hour, minutes, seconds); + SetTime(value, minutes, seconds); +} + +inline int Date::GetMinutes() const +{ + int hour = 0, minutes = 0, seconds = 0; + + GetTime(hour, minutes, seconds); + + return minutes; +} + +inline void Date::SetMinutes(int value) +{ + int hour = 0, minutes = 0, seconds = 0; + + GetTime(hour, minutes, seconds); + SetTime(hour, value, seconds); +} + +inline int Date::GetSeconds() const +{ + int hour = 0, minutes = 0, seconds = 0; + + GetTime(hour, minutes, seconds); + + return seconds; +} + +inline void Date::SetSeconds(int value) +{ + int hour = 0, minutes = 0, seconds = 0; + + GetTime(hour, minutes, seconds); + SetTime(hour, minutes, value); +} + +inline int Date::DaysBetween(const Date& other) const +{ + return core::Check(OCI_DateDaysBetween(*this, other)); +} + +inline void Date::SetDate(int year, int month, int day) +{ + core::Check(OCI_DateSetDate(*this, year, month, day)); +} + +inline void Date::SetTime(int hour, int min, int sec) +{ + core::Check(OCI_DateSetTime(*this, hour, min , sec)); +} + +inline void Date::SetDateTime(int year, int month, int day, int hour, int min, int sec) +{ + core::Check(OCI_DateSetDateTime(*this, year, month, day, hour, min , sec)); +} + +inline void Date::GetDate(int &year, int &month, int &day) const +{ + core::Check(OCI_DateGetDate(*this, &year, &month, &day)); +} + +inline void Date::GetTime(int &hour, int &min, int &sec) const +{ + core::Check(OCI_DateGetTime(*this, &hour, &min , &sec)); +} + +inline void Date::GetDateTime(int &year, int &month, int &day, int &hour, int &min, int &sec) const +{ + core::Check(OCI_DateGetDateTime(*this, &year, &month, &day, &hour, &min , &sec)); +} + +inline void Date::AddDays(int days) +{ + core::Check(OCI_DateAddDays(*this, days)); +} + +inline void Date::AddMonths(int months) +{ + OCI_DateAddMonths(*this, months); +} + +inline Date Date::NextDay(const ostring& day) const +{ + Date result = Clone(); + + core::Check(OCI_DateNextDay(result, day.c_str())); + + return result; +} + +inline Date Date::LastDay() const +{ + Date result = Clone(); + + core::Check(OCI_DateLastDay(result)); + + return result; +} + +inline void Date::ChangeTimeZone(const ostring& tzSrc, const ostring& tzDst) +{ + core::Check(OCI_DateZoneToZone(*this, tzSrc.c_str(), tzDst.c_str())); +} + +inline void Date::FromString(const ostring& str, const ostring& format) +{ + core::Check(OCI_DateFromText(*this, str.c_str(), format.empty() ? Environment::GetFormat(FormatDate).c_str() : format.c_str())); +} + +inline ostring Date::ToString(const ostring& format) const +{ + if (!IsNull()) + { + const size_t size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_DateToText(*this, format.c_str(), static_cast(size), buffer)); + + return core::MakeString(static_cast(buffer)); + } + + return OCI_STRING_NULL; +} + +inline ostring Date::ToString() const +{ + return ToString(Environment::GetFormat(FormatDate)); +} + +inline Date& Date::operator ++ () +{ + return *this += 1; +} + +inline Date Date::operator ++ (int) +{ + Date result = Clone(); + + *this += 1; + + return result; +} + +inline Date& Date::operator -- () +{ + return *this -= 1; +} + +inline Date Date::operator -- (int) +{ + Date result = Clone(); + + *this -= 1; + + return result; +} + +inline Date Date::operator + (int value) const +{ + Date result = Clone(); + return result += value; +} + +inline Date Date::operator - (int value) const +{ + Date result = Clone(); + return result -= value; +} + +inline Date& Date::operator += (int value) +{ + AddDays(value); + return *this; +} + +inline Date& Date::operator -= (int value) +{ + AddDays(-value); + return *this; +} + +inline bool Date::operator == (const Date& other) const +{ + return Compare(other) == 0; +} + +inline bool Date::operator != (const Date& other) const +{ + return !(*this == other); +} + +inline bool Date::operator > (const Date& other) const +{ + return Compare(other) > 0; +} + +inline bool Date::operator < (const Date& other) const +{ + return Compare(other) < 0; +} + +inline bool Date::operator >= (const Date& other) const +{ + const int res = Compare(other); + + return res == 0 || res > 0; +} + +inline bool Date::operator <= (const Date& other) const +{ + const int res = Compare(other); + + return res == 0 || res < 0; +} + +} diff --git a/include/ocilibcpp/detail/Dequeue.hpp b/include/ocilibcpp/detail/Dequeue.hpp new file mode 100644 index 00000000..d6497779 --- /dev/null +++ b/include/ocilibcpp/detail/Dequeue.hpp @@ -0,0 +1,153 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Dequeue::Dequeue(const TypeInfo &typeInfo, const ostring& queueName) +{ + Acquire(core::Check(OCI_DequeueCreate(typeInfo, queueName.c_str())), reinterpret_cast(OCI_DequeueFree), nullptr, nullptr); +} + +inline Dequeue::Dequeue(OCI_Dequeue *pDequeue) +{ + Acquire(pDequeue, nullptr, nullptr, nullptr); +} + +inline Message Dequeue::Get() +{ + return Message(core::Check(OCI_DequeueGet(*this)), nullptr); +} + +inline Agent Dequeue::Listen(int timeout) +{ + return Agent(core::Check(OCI_DequeueListen(*this, timeout)), nullptr); +} + +inline ostring Dequeue::GetConsumer() const +{ + return core::MakeString(core::Check(OCI_DequeueGetConsumer(*this))); +} + +inline void Dequeue::SetConsumer(const ostring& value) +{ + core::Check(OCI_DequeueSetConsumer(*this, value.c_str())); +} + +inline ostring Dequeue::GetCorrelation() const +{ + return core::MakeString(core::Check(OCI_DequeueGetCorrelation(*this))); +} + +inline void Dequeue::SetCorrelation(const ostring& value) +{ + core::Check(OCI_DequeueSetCorrelation(*this, value.c_str())); +} + +inline Raw Dequeue::GetRelativeMsgID() const +{ + unsigned int size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(size + 1); + + core::Check(OCI_DequeueGetRelativeMsgID(*this, static_cast(buffer), &size)); + + return core::MakeRaw(buffer, size); +} + +inline void Dequeue::SetRelativeMsgID(const Raw &value) +{ + const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; + + core::Check(OCI_DequeueSetRelativeMsgID(*this, data, static_cast(value.size()))); +} + +inline Dequeue::DequeueVisibility Dequeue::GetVisibility() const +{ + return DequeueVisibility(static_cast(core::Check(OCI_DequeueGetVisibility(*this)))); +} + +inline void Dequeue::SetVisibility(DequeueVisibility value) +{ + core::Check(OCI_DequeueSetVisibility(*this, value)); +} + +inline Dequeue::DequeueMode Dequeue::GetMode() const +{ + return DequeueMode(static_cast(core::Check(OCI_DequeueGetMode(*this)))); +} + +inline void Dequeue::SetMode(DequeueMode value) +{ + core::Check(OCI_DequeueSetMode(*this, value)); +} + +inline Dequeue::NavigationMode Dequeue::GetNavigation() const +{ + return NavigationMode(static_cast(core::Check(OCI_DequeueGetNavigation(*this)))); +} + +inline void Dequeue::SetNavigation(NavigationMode value) +{ + core::Check(OCI_DequeueSetNavigation(*this, value)); +} + +inline int Dequeue::GetWaitTime() const +{ + return core::Check(OCI_DequeueGetWaitTime(*this)); +} + +inline void Dequeue::SetWaitTime(int value) +{ + core::Check(OCI_DequeueSetWaitTime(*this, value)); +} + +inline void Dequeue::SetAgents(std::vector &agents) +{ + const size_t size = agents.size(); + core::ManagedBuffer buffer(size); + + OCI_Agent ** pAgents = static_cast(buffer); + + for (size_t i = 0; i < size; ++i) + { + pAgents[i] = static_cast(agents[i]); + } + + core::Check(OCI_DequeueSetAgentList(*this, pAgents, static_cast(size))); +} + +inline void Dequeue::Subscribe(unsigned int port, unsigned int timeout, NotifyAQHandlerProc handler) +{ + core::Check(OCI_DequeueSubscribe(*this, port, timeout, static_cast(handler != nullptr ? Environment::NotifyHandlerAQ : nullptr))); + + Environment::SetUserCallback(static_cast(*this), handler); +} + +inline void Dequeue::Unsubscribe() +{ + core::Check(OCI_DequeueUnsubscribe(*this)); +} + +} diff --git a/include/ocilibcpp/detail/DirectPath.hpp b/include/ocilibcpp/detail/DirectPath.hpp new file mode 100644 index 00000000..d6fae08f --- /dev/null +++ b/include/ocilibcpp/detail/DirectPath.hpp @@ -0,0 +1,149 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline DirectPath::DirectPath(const TypeInfo &typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring& partition) +{ + Acquire(core::Check(OCI_DirPathCreate(typeInfo, partition.c_str(), nbCols, nbRows)), reinterpret_cast(OCI_DirPathFree), nullptr, nullptr); +} + +inline void DirectPath::SetColumn(unsigned int colIndex, const ostring& name, unsigned int maxSize, const ostring& format) +{ + core::Check(OCI_DirPathSetColumn(*this, colIndex, name.c_str(), maxSize, format.c_str())); +} + +template +inline void DirectPath::SetEntry(unsigned int rowIndex, unsigned int colIndex, const T &value, bool complete) +{ + core::Check(OCI_DirPathSetEntry(*this, rowIndex, colIndex, static_cast(const_cast(value.c_str())), static_cast(value.size()), complete)); +} + +inline void DirectPath::Reset() +{ + core::Check(OCI_DirPathReset(*this)); +} + +inline void DirectPath::Prepare() +{ + core::Check(OCI_DirPathPrepare(*this)); +} + +inline DirectPath::Result DirectPath::Convert() +{ + return Result(static_cast(core::Check(OCI_DirPathConvert(*this)))); +} + +inline DirectPath::Result DirectPath::Load() +{ + return Result(static_cast(core::Check(OCI_DirPathLoad(*this)))); +} + +inline void DirectPath::Finish() +{ + core::Check(OCI_DirPathFinish(*this)); +} + +inline void DirectPath::Abort() +{ + core::Check(OCI_DirPathAbort(*this)); +} + +inline void DirectPath::Save() +{ + core::Check(OCI_DirPathSave(*this)); +} + +inline void DirectPath::FlushRow() +{ + core::Check(OCI_DirPathFlushRow(*this)); +} + +inline void DirectPath::SetCurrentRows(unsigned int value) +{ + core::Check(OCI_DirPathSetCurrentRows(*this, value)); +} + +inline unsigned int DirectPath::GetCurrentRows() const +{ + return core::Check(OCI_DirPathGetCurrentRows(*this)); +} + +inline unsigned int DirectPath::GetMaxRows() const +{ + return core::Check(OCI_DirPathGetMaxRows(*this)); +} + +inline unsigned int DirectPath::GetRowCount() const +{ + return core::Check(OCI_DirPathGetRowCount(*this)); +} + +inline unsigned int DirectPath::GetAffectedRows() const +{ + return core::Check(OCI_DirPathGetAffectedRows(*this)); +} + +inline void DirectPath::SetDateFormat(const ostring& format) +{ + core::Check(OCI_DirPathSetDateFormat(*this, format.c_str())); +} + +inline void DirectPath::SetParallel(bool value) +{ + core::Check(OCI_DirPathSetParallel(*this, value)); +} + +inline void DirectPath::SetNoLog(bool value) +{ + core::Check(OCI_DirPathSetNoLog(*this, value)); +} + +inline void DirectPath::SetCacheSize(unsigned int value) +{ + core::Check(OCI_DirPathSetCacheSize(*this, value)); +} + +inline void DirectPath::SetBufferSize(unsigned int value) +{ + core::Check(OCI_DirPathSetBufferSize(*this, value)); +} + +inline void DirectPath::SetConversionMode(ConversionMode value) +{ + core::Check(OCI_DirPathSetConvertMode(*this, value)); +} + +inline unsigned int DirectPath::GetErrorColumn() +{ + return core::Check(OCI_DirPathGetErrorColumn(*this)); +} + +inline unsigned int DirectPath::GetErrorRow() +{ + return core::Check(OCI_DirPathGetErrorRow(*this)); +} + +} diff --git a/include/ocilibcpp/detail/Enqueue.hpp b/include/ocilibcpp/detail/Enqueue.hpp new file mode 100644 index 00000000..5ed4a760 --- /dev/null +++ b/include/ocilibcpp/detail/Enqueue.hpp @@ -0,0 +1,76 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Enqueue::Enqueue(const TypeInfo &typeInfo, const ostring& queueName) +{ + Acquire(core::Check(OCI_EnqueueCreate(typeInfo, queueName.c_str())), reinterpret_cast(OCI_EnqueueFree), nullptr, nullptr); +} + +inline void Enqueue::Put(const Message &message) +{ + core::Check(OCI_EnqueuePut(*this, message)); +} + +inline Enqueue::EnqueueVisibility Enqueue::GetVisibility() const +{ + return EnqueueVisibility(static_cast(core::Check(OCI_EnqueueGetVisibility(*this)))); +} + +inline void Enqueue::SetVisibility(EnqueueVisibility value) +{ + core::Check(OCI_EnqueueSetVisibility(*this, value)); +} + +inline Enqueue::EnqueueMode Enqueue::GetMode() const +{ + return EnqueueMode(static_cast(core::Check(OCI_EnqueueGetSequenceDeviation(*this)))); +} + +inline void Enqueue::SetMode(EnqueueMode value) +{ + core::Check(OCI_EnqueueSetSequenceDeviation(*this, value)); +} + +inline Raw Enqueue::GetRelativeMsgID() const +{ + unsigned int size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_EnqueueGetRelativeMsgID(*this, static_cast(buffer), &size)); + + return core::MakeRaw(buffer, size); +} + +inline void Enqueue::SetRelativeMsgID(const Raw &value) +{ + const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; + + core::Check(OCI_EnqueueSetRelativeMsgID(*this, data, static_cast(value.size()))); +} + +} diff --git a/include/ocilibcpp/detail/Environment.hpp b/include/ocilibcpp/detail/Environment.hpp new file mode 100644 index 00000000..d451dfd7 --- /dev/null +++ b/include/ocilibcpp/detail/Environment.hpp @@ -0,0 +1,313 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline void Environment::Initialize(EnvironmentFlags mode, const ostring& libpath) +{ + GetInstance().SelfInitialize(mode, libpath); +} + +inline void Environment::Cleanup() +{ + GetInstance().SelfCleanup(); + + Environment* handle = static_cast(OCI_GetUserData(nullptr)); + OCI_SetUserData(nullptr, handle); + +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + + core::GetMemoryDebugInfo().PrintAllocations(); + +#endif + +} + +inline Environment::EnvironmentFlags Environment::GetMode() +{ + return GetInstance()._mode; +} + +inline Environment::ImportMode Environment::GetImportMode() +{ + return ImportMode(static_cast(core::Check(OCI_GetImportMode()))); +} + +inline Environment::CharsetMode Environment::GetCharset() +{ + return CharsetMode(static_cast(core::Check(OCI_GetCharset()))); +} + +inline unsigned int Environment::GetCharMaxSize() +{ + return GetInstance()._charMaxSize; +} + +inline big_uint Environment::GetAllocatedBytes(AllocatedBytesFlags type) +{ + return core::Check(OCI_GetAllocatedBytes(type.GetValues())); +} + +inline bool Environment::Initialized() +{ + return GetInstance()._initialized; +} + +inline OracleVersion Environment::GetCompileVersion() +{ + return OracleVersion(static_cast(core::Check(OCI_GetOCICompileVersion()))); +} + +inline OracleVersion Environment::GetRuntimeVersion() +{ + return OracleVersion(static_cast(core::Check(OCI_GetOCIRuntimeVersion()))); +} + +inline unsigned int Environment::GetCompileMajorVersion() +{ + return OCI_VER_MAJ(core::Check(OCI_GetOCICompileVersion())); +} + +inline unsigned int Environment::GetCompileMinorVersion() +{ + return OCI_VER_MIN(core::Check(OCI_GetOCICompileVersion())); +} + +inline unsigned int Environment::GetCompileRevisionVersion() +{ + return OCI_VER_REV(core::Check(OCI_GetOCICompileVersion())); +} + +inline unsigned int Environment::GetRuntimeMajorVersion() +{ + return OCI_VER_MAJ(core::Check(OCI_GetOCIRuntimeVersion())); +} + +inline unsigned int Environment::GetRuntimeMinorVersion() +{ + return OCI_VER_MIN(core::Check(OCI_GetOCIRuntimeVersion())); +} + +inline unsigned int Environment::GetRuntimeRevisionVersion() +{ + return OCI_VER_REV(core::Check(OCI_GetOCIRuntimeVersion())); +} + +inline void Environment::EnableWarnings(bool value) +{ + OCI_EnableWarnings(static_cast(value)); +} + +inline bool Environment::SetFormat(FormatType formatType, const ostring& format) +{ + return core::Check(OCI_SetFormat(nullptr, formatType, format.c_str()) == TRUE); +} + +inline ostring Environment::GetFormat(FormatType formatType) +{ + return core::MakeString(core::Check(OCI_GetFormat(nullptr, formatType))); +} + +inline void Environment::StartDatabase(const ostring& db, const ostring& user, const ostring &pwd, Environment::StartFlags startFlags, + Environment::StartMode startMode, Environment::SessionFlags sessionFlags, const ostring& spfile) +{ + core::Check(OCI_DatabaseStartup(db.c_str(), user.c_str(), pwd.c_str(), sessionFlags.GetValues(), + startMode.GetValues(), startFlags.GetValues(), spfile.c_str() )); +} + +inline void Environment::ShutdownDatabase(const ostring& db, const ostring& user, const ostring &pwd, Environment::ShutdownFlags shutdownFlags, + Environment::ShutdownMode shutdownMode, Environment::SessionFlags sessionFlags) +{ + core::Check(OCI_DatabaseShutdown(db.c_str(), user.c_str(), pwd.c_str(), sessionFlags.GetValues(), + shutdownMode.GetValues(), shutdownFlags.GetValues() )); +} + +inline void Environment::ChangeUserPassword(const ostring& db, const ostring& user, const ostring& pwd, const ostring& newPwd) +{ + core::Check(OCI_SetUserPassword(db.c_str(), user.c_str(), pwd.c_str(), newPwd.c_str())); +} + +inline void Environment::SetHAHandler(HAHandlerProc handler) +{ + core::Check(OCI_SetHAHandler(static_cast(handler != nullptr ? Environment::HAHandler : nullptr))); + + SetUserCallback(GetEnvironmentHandle(), handler); +} + +inline void Environment::HAHandler(OCI_Connection *pConnection, unsigned int source, unsigned int event, OCI_Timestamp *pTimestamp) +{ + const HAHandlerProc handler = GetUserCallback(GetEnvironmentHandle()); + + if (handler) + { + Connection connection(pConnection, nullptr); + Timestamp timestamp(pTimestamp, connection.GetHandle()); + + handler(connection, + HAEventSource(static_cast(source)), + HAEventType (static_cast (event)), + timestamp); + } +} + +inline unsigned int Environment::TAFHandler(OCI_Connection *pConnection, unsigned int type, unsigned int event) +{ + unsigned int res = OCI_FOC_OK; + + const Connection::TAFHandlerProc handler = GetUserCallback(core::Check(pConnection)); + + if (handler) + { + Connection connection(pConnection, nullptr); + + res = handler(connection, + Connection::FailoverRequest( static_cast (type)), + Connection::FailoverEvent ( static_cast (event))); + } + + return res; +} + +inline void Environment::NotifyHandler(OCI_Event *pEvent) +{ + const Subscription::NotifyHandlerProc handler = GetUserCallback((core::Check(OCI_EventGetSubscription(pEvent)))); + + if (handler) + { + Event evt(pEvent); + handler(evt); + } +} + +inline void Environment::NotifyHandlerAQ(OCI_Dequeue *pDequeue) +{ + const Dequeue::NotifyAQHandlerProc handler = GetUserCallback(core::Check(pDequeue)); + + if (handler) + { + Dequeue dequeue(pDequeue); + handler(dequeue); + } +} + +template +T Environment::GetUserCallback(AnyPointer ptr) +{ + return reinterpret_cast(GetInstance()._callbacks.Get(ptr)); +} + +template +void Environment::SetUserCallback(AnyPointer ptr, T callback) +{ + if (callback) + { + GetInstance()._callbacks.Set(ptr, reinterpret_cast(callback)); + } + else + { + GetInstance()._callbacks.Remove(ptr); + } +} + +template +void Environment::SetSmartHandle(AnyPointer ptr, T handle) +{ + if (handle) + { + GetInstance()._handles.Set(ptr, handle); + } + else + { + GetInstance()._handles.Remove(ptr); + } +} + +template +T Environment::GetSmartHandle(AnyPointer ptr) +{ + return dynamic_cast(GetInstance()._handles.Get(ptr)); +} + +inline core::Handle * Environment::GetEnvironmentHandle() +{ + return GetInstance()._handle.GetHandle(); +} + +inline Environment& Environment::GetInstance() +{ + Environment* handle = static_cast(OCI_GetUserData(nullptr)); + if (handle != nullptr) + { + return *handle; + } + + static Environment environment; + + OCI_SetUserData(nullptr,&environment); + + return environment; +} + +inline Environment::Environment() : _charMaxSize(0), _initialized(false) +{ + +} + +inline void Environment::SelfInitialize(EnvironmentFlags mode, const ostring& libpath) +{ + _mode = mode; + + core::Check(OCI_Initialize(nullptr, libpath.c_str(), _mode.GetValues() | OCI_ENV_CONTEXT)); + + _initialized = true; + + _locker.SetAccessMode((_mode & Environment::Threaded) == Environment::Threaded); + + _callbacks.SetLocker(&_locker); + _handles.SetLocker(&_locker); + + _handle.Acquire(const_cast(core::Check(OCI_HandleGetEnvironment())), nullptr, nullptr, nullptr); + + _charMaxSize = ComputeCharMaxSize(GetCharset()); +} + +inline void Environment::SelfCleanup() +{ + _locker.SetAccessMode(false); + + _callbacks.SetLocker(nullptr); + _handles.SetLocker(nullptr); + + _handle.Release(); + + if (_initialized) + { + core::Check(OCI_Cleanup()); + } + + _initialized = false; +} + +} diff --git a/include/ocilibcpp/detail/Event.hpp b/include/ocilibcpp/detail/Event.hpp new file mode 100644 index 00000000..8d51711f --- /dev/null +++ b/include/ocilibcpp/detail/Event.hpp @@ -0,0 +1,63 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Event::Event(OCI_Event *pEvent) +{ + Acquire(pEvent, nullptr, nullptr, nullptr); +} + +inline Event::EventType Event::GetType() const +{ + return EventType(static_cast(core::Check(OCI_EventGetType(*this)))); +} + +inline Event::ObjectEvent Event::GetObjectEvent() const +{ + return ObjectEvent(static_cast(core::Check(OCI_EventGetOperation(*this)))); +} + +inline ostring Event::GetDatabaseName() const +{ + return core::MakeString(core::Check(OCI_EventGetDatabase(*this))); +} + +inline ostring Event::GetObjectName() const +{ + return core::MakeString(core::Check(OCI_EventGetObject(*this))); +} + +inline ostring Event::GetRowID() const +{ + return core::MakeString(core::Check(OCI_EventGetRowid(*this))); +} + +inline Subscription Event::GetSubscription() const +{ + return Subscription(core::Check(OCI_EventGetSubscription(*this))); +} + +} diff --git a/include/ocilibcpp/detail/Exception.hpp b/include/ocilibcpp/detail/Exception.hpp new file mode 100644 index 00000000..37702d1e --- /dev/null +++ b/include/ocilibcpp/detail/Exception.hpp @@ -0,0 +1,129 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Exception::Exception() noexcept + : _what(nullptr), + _pStatement(nullptr), + _pConnnection(nullptr), + _row(0), + _type(static_cast(0)), + _errLib(0), + _errOracle(0) +{ + +} + +inline Exception::Exception(OCI_Error *err) noexcept + : _what(nullptr), + _pStatement(OCI_ErrorGetStatement(err)), + _pConnnection(OCI_ErrorGetConnection(err)), + _row(OCI_ErrorGetRow(err)), + _type(static_cast(OCI_ErrorGetType(err))), + _errLib(OCI_ErrorGetInternalCode(err)), + _errOracle(OCI_ErrorGetOCICode(err)) +{ + SetWhat(OCI_ErrorGetString(err)); +} + +inline Exception::Exception(const Exception& other) noexcept : Exception(nullptr) +{ + SetWhat(other._what); +} + +inline Exception::~Exception() noexcept +{ + delete [] _what; +} + +inline Exception& Exception::operator = (const Exception& other) noexcept +{ + if (this != &other) + { + _what = ostrdup(other._what); + } + + return *this; +} + +inline void Exception::SetWhat(const otext* value) noexcept +{ + if (!value) + { + return; + } + + const size_t len = ostrlen(value); + _what = new (std::nothrow) otext[len + 1]; + if (_what) + { + memcpy(_what, value, (len + 1) * (sizeof(otext))); + } +} + +inline const char * Exception::what() const noexcept +{ + return _what; +} + +inline ostring Exception::GetMessage() const +{ + const otext* str = what(); + + return str ? str : ostring{}; +} + +inline Exception::ExceptionType Exception::GetType() const +{ + return _type; +} + +inline int Exception::GetOracleErrorCode() const +{ + return _errOracle; +} + +inline int Exception::GetInternalErrorCode() const +{ + return _errLib; +} + +inline Statement Exception::GetStatement() const +{ + return Statement(_pStatement, nullptr); +} + +inline Connection Exception::GetConnection() const +{ + return Connection(_pConnnection, nullptr); +} + +inline unsigned int Exception::GetRow() const +{ + return _row; +} + +} diff --git a/include/ocilibcpp/detail/File.hpp b/include/ocilibcpp/detail/File.hpp new file mode 100644 index 00000000..e1e13a8b --- /dev/null +++ b/include/ocilibcpp/detail/File.hpp @@ -0,0 +1,137 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline File::File() +{ +} + +inline File::File(const Connection &connection) +{ + Acquire(core::Check(OCI_FileCreate(connection, OCI_BFILE)), reinterpret_cast(OCI_FileFree), nullptr, connection.GetHandle()); +} + +inline File::File(const Connection &connection, const ostring& directory, const ostring& name) +{ + Acquire(core::Check(OCI_FileCreate(connection, OCI_BFILE)), reinterpret_cast(OCI_FileFree), nullptr, connection.GetHandle()); + + SetInfos(directory, name); +} + +inline File::File(OCI_File *pFile, core::Handle *parent) +{ + Acquire(pFile, nullptr, nullptr, parent); +} + +inline Raw File::Read(unsigned int size) +{ + core::ManagedBuffer buffer(static_cast(size + 1)); + + size = core::Check(OCI_FileRead(*this, static_cast(buffer), size)); + + return core::MakeRaw(buffer, size); +} + +inline bool File::Seek(SeekMode seekMode, big_uint offset) +{ + return (core::Check(OCI_FileSeek(*this, offset, seekMode)) == TRUE); +} + +inline File File::Clone() const +{ + File result(GetConnection()); + + core::Check(OCI_FileAssign(result, *this)); + + return result; +} + +inline bool File::Equals(const File &other) const +{ + return (core::Check(OCI_FileIsEqual(*this, other)) == TRUE); +} + +inline big_uint File::GetOffset() const +{ + return core::Check(OCI_FileGetOffset(*this)); +} + +inline big_uint File::GetLength() const +{ + return core::Check(OCI_FileGetSize(*this)); +} + +inline Connection File::GetConnection() const +{ + return Connection(core::Check(OCI_FileGetConnection(*this)), nullptr); +} + +inline bool File::Exists() const +{ + return (core::Check(OCI_FileExists(*this)) == TRUE); +} + +inline void File::SetInfos(const ostring& directory, const ostring& name) +{ + core::Check(OCI_FileSetName(*this, directory.c_str(), name.c_str())); +} + +inline ostring File::GetName() const +{ + return core::MakeString(core::Check(OCI_FileGetName(*this))); +} + +inline ostring File::GetDirectory() const +{ + return core::MakeString(core::Check(OCI_FileGetDirectory(*this))); +} + +inline void File::Open() +{ + core::Check(OCI_FileOpen(*this)); +} + +inline bool File::IsOpened() const +{ + return (core::Check(OCI_FileIsOpen(*this)) == TRUE); +} + +inline void File::Close() +{ + core::Check(OCI_FileClose(*this)); +} + +inline bool File::operator == (const File& other) const +{ + return Equals(other); +} + +inline bool File::operator != (const File& other) const +{ + return (!(*this == other)); +} + +} diff --git a/include/ocilibcpp/detail/Interval.hpp b/include/ocilibcpp/detail/Interval.hpp new file mode 100644 index 00000000..b829b4a8 --- /dev/null +++ b/include/ocilibcpp/detail/Interval.hpp @@ -0,0 +1,300 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Interval::Interval() +{ +} + +inline Interval::Interval(IntervalType type) +{ + Acquire(core::Check(OCI_IntervalCreate(nullptr, type)), reinterpret_cast(OCI_IntervalFree), nullptr, nullptr); +} + +inline Interval::Interval(IntervalType type, const ostring& data) +{ + Acquire(core::Check(OCI_IntervalCreate(nullptr, type)), reinterpret_cast(OCI_IntervalFree), nullptr, nullptr); + + FromString(data); +} + +inline Interval::Interval(OCI_Interval *pInterval, core::Handle *parent) +{ + Acquire(pInterval, nullptr, nullptr, parent); +} + +inline Interval Interval::Clone() const +{ + Interval result(GetType()); + + core::Check(OCI_IntervalAssign(result, *this)); + + return result; +} + +inline int Interval::Compare(const Interval& other) const +{ + return core::Check(OCI_IntervalCompare(*this, other)); +} + +inline Interval::IntervalType Interval::GetType() const +{ + return IntervalType(static_cast(core::Check(OCI_IntervalGetType(*this)))); +} + +inline bool Interval::IsValid() const +{ + return (core::Check(OCI_IntervalCheck(*this)) == 0); +} + +inline int Interval::GetYear() const +{ + int year = 0, month = 0; + + GetYearMonth(year, month); + + return year; +} + +inline void Interval::SetYear(int value) +{ + int year = 0, month = 0; + + GetYearMonth(year, month); + SetYearMonth(value, month); +} + +inline int Interval::GetMonth() const +{ + int year = 0, month = 0; + + GetYearMonth(year, month); + + return month; +} + +inline void Interval::SetMonth(int value) +{ + int year = 0, month = 0; + + GetYearMonth(year, month); + SetYearMonth(year, value); +} + +inline int Interval::GetDay() const +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + + return day; +} + +inline void Interval::SetDay(int value) +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + SetDaySecond(value, hour, minutes, seconds, milliseconds); +} + +inline int Interval::GetHours() const +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + + return hour; +} + +inline void Interval::SetHours(int value) +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + SetDaySecond(day, value, minutes, seconds, milliseconds); +} + +inline int Interval::GetMinutes() const +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + + return minutes; +} + +inline void Interval::SetMinutes(int value) +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + SetDaySecond(day, hour, value, seconds, milliseconds); +} + +inline int Interval::GetSeconds() const +{ + int day, hour, minutes, seconds, milliseconds; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + + return seconds; +} + +inline void Interval::SetSeconds(int value) +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + SetDaySecond(day, hour, minutes, value, milliseconds); +} + +inline int Interval::GetMilliSeconds() const +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + + return milliseconds; +} + +inline void Interval::SetMilliSeconds(int value) +{ + int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDaySecond(day, hour, minutes, seconds, milliseconds); + SetDaySecond(day, hour, minutes, seconds, value); +} + +inline void Interval::GetDaySecond(int &day, int &hour, int &min, int &sec, int &fsec) const +{ + core::Check(OCI_IntervalGetDaySecond(*this, &day, &hour, &min, &sec, &fsec)); +} + +inline void Interval::SetDaySecond(int day, int hour, int min, int sec, int fsec) +{ + core::Check(OCI_IntervalSetDaySecond(*this, day, hour, min, sec, fsec)); +} + +inline void Interval::GetYearMonth(int &year, int &month) const +{ + core::Check(OCI_IntervalGetYearMonth(*this, &year, &month)); +} +inline void Interval::SetYearMonth(int year, int month) +{ + core::Check(OCI_IntervalSetYearMonth(*this, year, month)); +} + +inline void Interval::UpdateTimeZone(const ostring& timeZone) +{ + core::Check(OCI_IntervalFromTimeZone(*this, timeZone.c_str())); +} + +inline void Interval::FromString(const ostring& data) +{ + core::Check(OCI_IntervalFromText(*this, data.c_str())); +} + +inline ostring Interval::ToString(int leadingPrecision, int fractionPrecision) const +{ + if (!IsNull()) + { + const size_t size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_IntervalToText(*this, leadingPrecision, fractionPrecision, static_cast(size), buffer)); + + return core::MakeString(static_cast(buffer)); + } + + return OCI_STRING_NULL; +} + +inline ostring Interval::ToString() const +{ + return ToString(OCI_STRING_DEFAULT_PREC, OCI_STRING_DEFAULT_PREC); +} + +inline Interval Interval::operator + (const Interval& other) const +{ + Interval result = Clone(); + return result += other; +} + +inline Interval Interval::operator - (const Interval& other) const +{ + Interval result = Clone(); + return result -= other; +} + +inline Interval& Interval::operator += (const Interval& other) +{ + core::Check(OCI_IntervalAdd(*this, other)); + return *this; +} + +inline Interval& Interval::operator -= (const Interval& other) +{ + core::Check(OCI_IntervalSubtract(*this, other)); + return *this; +} + +inline bool Interval::operator == (const Interval& other) const +{ + return Compare(other) == 0; +} + +inline bool Interval::operator != (const Interval& other) const +{ + return (!(*this == other)); +} + +inline bool Interval::operator > (const Interval& other) const +{ + return (Compare(other) > 0); +} + +inline bool Interval::operator < (const Interval& other) const +{ + return (Compare(other) < 0); +} + +inline bool Interval::operator >= (const Interval& other) const +{ + const int res = Compare(other); + + return (res == 0 || res < 0); +} + +inline bool Interval::operator <= (const Interval& other) const +{ + const int res = Compare(other); + + return (res == 0 || res > 0); +} + +} diff --git a/include/ocilibcpp/detail/Lob.hpp b/include/ocilibcpp/detail/Lob.hpp new file mode 100644 index 00000000..0a1d0cd5 --- /dev/null +++ b/include/ocilibcpp/detail/Lob.hpp @@ -0,0 +1,259 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +template +inline Lob::Lob() +{ +} + +template +Lob::Lob(const Connection &connection) +{ + Acquire(core::Check(OCI_LobCreate(connection, U)), reinterpret_cast(OCI_LobFree), nullptr, connection.GetHandle()); +} + +template +Lob::Lob(OCI_Lob *pLob, core::Handle *parent) +{ + Acquire(pLob, nullptr, nullptr, parent); +} + +template<> +inline ostring Lob::Read(unsigned int length) +{ + core::ManagedBuffer buffer(static_cast(Environment::GetCharMaxSize() * (length + 1))); + + unsigned int charCount = length; + unsigned int byteCount = 0; + + if (core::Check(OCI_LobRead2(*this, static_cast(buffer), &charCount, &byteCount))) + { + length = byteCount / sizeof(otext); + } + + return core::MakeString(static_cast(buffer), static_cast(length)); +} + +template<> +inline ostring Lob::Read(unsigned int length) +{ + core::ManagedBuffer buffer(static_cast(Environment::GetCharMaxSize() * (length + 1))); + + unsigned int charCount = length; + unsigned int byteCount = 0; + + if (core::Check(OCI_LobRead2(*this, static_cast(buffer), &charCount, &byteCount))) + { + length = byteCount / sizeof(otext); + } + + return core::MakeString(static_cast(buffer), static_cast(length)); + +} + +template<> +inline Raw Lob::Read(unsigned int length) +{ + core::ManagedBuffer buffer(length + 1); + + length = core::Check(OCI_LobRead(*this, static_cast(buffer), length)); + + return core::MakeRaw(buffer, length); +} + +template +unsigned int Lob::Write(const T& content) +{ + if (content.empty()) + { + return 0; + } + + unsigned int res = 0; + unsigned int charCount = 0; + unsigned int byteCount = static_cast(content.size() * sizeof(typename T::value_type)); + const AnyPointer buffer = static_cast(const_cast(&content[0])); + + if (core::Check(OCI_LobWrite2(*this, buffer, &charCount, &byteCount))) + { + res = U == LobBinary ? byteCount : charCount; + } + + return res; +} + +template +void Lob::Append(const Lob& other) +{ + core::Check(OCI_LobAppendLob(*this, other)); +} + +template +unsigned int Lob::Append(const T& content) +{ + if (content.empty()) + { + return 0; + } + + const AnyPointer data = static_cast(const_cast(&content[0])); + + return core::Check(OCI_LobAppend(*this, data, static_cast(content.size()))); +} + +template +bool Lob::Seek(SeekMode seekMode, big_uint offset) +{ + return (core::Check(OCI_LobSeek(*this, offset, seekMode)) == TRUE); +} + +template +Lob Lob::Clone() const +{ + Lob result(GetConnection()); + + core::Check(OCI_LobAssign(result, *this)); + + return result; +} + +template +bool Lob::Equals(const Lob &other) const +{ + return (core::Check(OCI_LobIsEqual(*this, other)) == TRUE); +} + +template +LobType Lob::GetType() const +{ + return LobType(static_cast(core::Check(OCI_LobGetType(*this)))); +} + +template +big_uint Lob::GetOffset() const +{ + return core::Check(OCI_LobGetOffset(*this)); +} + +template +big_uint Lob::GetLength() const +{ + return core::Check(OCI_LobGetLength(*this)); +} + +template +big_uint Lob::GetMaxSize() const +{ + return core::Check(OCI_LobGetMaxSize(*this)); +} + +template +big_uint Lob::GetChunkSize() const +{ + return core::Check(OCI_LobGetChunkSize(*this)); +} + +template +Connection Lob::GetConnection() const +{ + return Connection(core::Check(OCI_LobGetConnection(*this)), nullptr); +} + +template +void Lob::Truncate(big_uint length) +{ + core::Check(OCI_LobTruncate(*this, length)); +} + +template +big_uint Lob::Erase(big_uint offset, big_uint length) +{ + return core::Check(OCI_LobErase(*this, offset, length)); +} + +template +void Lob::Copy(Lob &dest, big_uint offset, big_uint offsetDest, big_uint length) const +{ + core::Check(OCI_LobCopy(dest, *this, offsetDest, offset, length)); +} + +template +bool Lob::IsTemporary() const +{ + return (core::Check(OCI_LobIsTemporary(*this)) == TRUE); +} + +template +bool Lob::IsRemote() const +{ + return (core::Check(OCI_LobIsRemote(*this)) == TRUE); +} + +template +void Lob::Open(OpenMode mode) +{ + core::Check(OCI_LobOpen(*this, mode)); +} + +template +void Lob::Flush() +{ + core::Check(OCI_LobFlush(*this)); +} + +template +void Lob::Close() +{ + core::Check(OCI_LobClose(*this)); +} + +template +void Lob::EnableBuffering(bool value) +{ + core::Check(OCI_LobEnableBuffering(*this, value)); +} + +template +Lob& Lob::operator += (const Lob& other) +{ + Append(other); + return *this; +} + +template +bool Lob::operator == (const Lob& other) const +{ + return Equals(other); +} + +template +bool Lob::operator != (const Lob& other) const +{ + return !(*this == other); +} + +} diff --git a/include/ocilibcpp/detail/Long.hpp b/include/ocilibcpp/detail/Long.hpp new file mode 100644 index 00000000..b9fb04c7 --- /dev/null +++ b/include/ocilibcpp/detail/Long.hpp @@ -0,0 +1,74 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +template +Long::Long() +{ +} + +template +Long::Long(const Statement &statement) +{ + Acquire(core::Check(OCI_LongCreate(statement, U)), reinterpret_cast(OCI_LongFree), nullptr, statement.GetHandle()); +} + +template +Long::Long(OCI_Long *pLong, core::Handle* parent) +{ + Acquire(pLong, nullptr, nullptr, parent); +} + +template +unsigned int Long::Write(const T& content) +{ + if (content.empty()) + { + return 0; + } + + return core::Check(OCI_LongWrite(*this, static_cast(const_cast(&content[0])), static_cast(content.size()))); +} + +template +unsigned int Long::GetLength() const +{ + return core::Check(OCI_LongGetSize(*this)); +} + +template<> +inline ostring Long::GetContent() const +{ + return core::MakeString(static_cast(core::Check(OCI_LongGetBuffer(*this)))); +} + +template<> +inline Raw Long::GetContent() const +{ + return core::MakeRaw(core::Check(OCI_LongGetBuffer(*this)), GetLength()); +} + +} diff --git a/include/ocilibcpp/detail/Message.hpp b/include/ocilibcpp/detail/Message.hpp new file mode 100644 index 00000000..71f0627b --- /dev/null +++ b/include/ocilibcpp/detail/Message.hpp @@ -0,0 +1,194 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Message::Message(const TypeInfo &typeInfo) +{ + Acquire(core::Check(OCI_MsgCreate(typeInfo)), reinterpret_cast(OCI_MsgFree), nullptr, nullptr); +} + +inline Message::Message(OCI_Msg *pMessage, core::Handle *parent) +{ + Acquire(pMessage, nullptr, nullptr, parent); +} + +inline void Message::Reset() +{ + core::Check(OCI_MsgReset(*this)); +} + +template<> +inline Object Message::GetPayload() +{ + return Object(core::Check(OCI_MsgGetObject(*this)), nullptr); +} + +template<> +inline void Message::SetPayload(const Object &value) +{ + core::Check(OCI_MsgSetObject(*this, value)); +} + +template<> +inline Raw Message::GetPayload() +{ + unsigned int size = 0; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_MsgGetRaw(*this, static_cast(buffer), &size)); + + return core::MakeRaw(buffer, size); +} + +template<> +inline void Message::SetPayload(const Raw &value) +{ + const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; + + core::Check(OCI_MsgSetRaw(*this, data, static_cast(value.size()))); +} + +inline Date Message::GetEnqueueTime() const +{ + return Date(core::Check(OCI_MsgGetEnqueueTime(*this)), nullptr); +} + +inline int Message::GetAttemptCount() const +{ + return core::Check(OCI_MsgGetAttemptCount(*this)); +} + +inline Message::MessageState Message::GetState() const +{ + return MessageState(static_cast(core::Check(OCI_MsgGetState(*this)))); +} + +inline Raw Message::GetID() const +{ + unsigned int size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_MsgGetID(*this, static_cast(buffer), &size)); + + return core::MakeRaw(buffer, size); +} + +inline int Message::GetExpiration() const +{ + return core::Check(OCI_MsgGetExpiration(*this)); +} + +inline void Message::SetExpiration(int value) +{ + core::Check(OCI_MsgSetExpiration(*this, value)); +} + +inline int Message::GetEnqueueDelay() const +{ + return core::Check(OCI_MsgGetEnqueueDelay(*this)); +} + +inline void Message::SetEnqueueDelay(int value) +{ + core::Check(OCI_MsgSetEnqueueDelay(*this, value)); +} + +inline int Message::GetPriority() const +{ + return core::Check(OCI_MsgGetPriority(*this)); +} + +inline void Message::SetPriority(int value) +{ + core::Check(OCI_MsgSetPriority(*this, value)); +} + +inline Raw Message::GetOriginalID() const +{ + unsigned int size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_MsgGetOriginalID(*this, static_cast(buffer), &size)); + + return core::MakeRaw(buffer, size); +} + +inline void Message::SetOriginalID(const Raw &value) +{ + const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; + + core::Check(OCI_MsgSetOriginalID(*this, data, static_cast(value.size()))); +} + +inline ostring Message::GetCorrelation() const +{ + return core::MakeString(core::Check(OCI_MsgGetCorrelation(*this))); +} + +inline void Message::SetCorrelation(const ostring& value) +{ + core::Check(OCI_MsgSetCorrelation(*this, value.c_str())); +} + +inline ostring Message::GetExceptionQueue() const +{ + return core::MakeString(core::Check(OCI_MsgGetExceptionQueue(*this))); +} + +inline void Message::SetExceptionQueue(const ostring& value) +{ + core::Check(OCI_MsgSetExceptionQueue(*this, value.c_str())); +} + +inline Agent Message::GetSender() const +{ + return Agent(core::Check(OCI_MsgGetSender(*this)), nullptr); +} + +inline void Message::SetSender(const Agent &agent) +{ + core::Check(OCI_MsgSetSender(*this, agent)); +} + +inline void Message::SetConsumers(std::vector &agents) +{ + const size_t size = agents.size(); + core::ManagedBuffer buffer(size); + + OCI_Agent ** pAgents = static_cast(buffer); + + for (size_t i = 0; i < size; ++i) + { + pAgents[i] = static_cast(agents[i]); + } + + core::Check(OCI_MsgSetConsumers(*this, pAgents, static_cast(size))); +} + +} diff --git a/include/ocilibcpp/detail/Mutex.hpp b/include/ocilibcpp/detail/Mutex.hpp new file mode 100644 index 00000000..12521f03 --- /dev/null +++ b/include/ocilibcpp/detail/Mutex.hpp @@ -0,0 +1,48 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline MutexHandle Mutex::Create() +{ + return Environment::GetInstance().Initialized() ? core::Check(OCI_MutexCreate()) : nullptr; +} + +inline void Mutex::Destroy(MutexHandle handle) +{ + core::Check(OCI_MutexFree(handle)); +} + +inline void Mutex::Acquire(MutexHandle handle) +{ + core::Check(OCI_MutexAcquire(handle)); +} + +inline void Mutex::Release(MutexHandle handle) +{ + core::Check(OCI_MutexRelease(handle)); +} + +} diff --git a/include/ocilibcpp/detail/Number.hpp b/include/ocilibcpp/detail/Number.hpp new file mode 100644 index 00000000..619f3379 --- /dev/null +++ b/include/ocilibcpp/detail/Number.hpp @@ -0,0 +1,294 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Number::Number(bool create) +{ + if (create) + { + Allocate(); + } +} + +inline Number::Number(OCI_Number *pNumber, core::Handle *parent) +{ + Acquire(pNumber, nullptr, nullptr, parent); +} + +inline Number::Number(const ostring& str, const ostring& format) +{ + Allocate(); + + FromString(str, format); +} + +inline Number::Number(const otext* str, const otext* format) +{ + Allocate(); + + FromString(str, format); +} + +inline void Number::Allocate() +{ + Acquire(core::Check(OCI_NumberCreate(nullptr)), reinterpret_cast(OCI_NumberFree), nullptr, nullptr); +} + +inline void Number::FromString(const ostring& str, const ostring& format) const +{ + core::Check(OCI_NumberFromText(*this, str.c_str(), format.empty() ? Environment::GetFormat(FormatNumeric).c_str() : format.c_str())); +} + +inline ostring Number::ToString(const ostring& format) const +{ + if (!IsNull()) + { + const size_t size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_NumberToText(*this, format.c_str(), static_cast(size), buffer)); + + return core::MakeString(static_cast(buffer)); + } + + return OCI_STRING_NULL; +} + +inline ostring Number::ToString() const +{ + return ToString(Environment::GetFormat(FormatNumeric)); +} + +inline Number Number::Clone() const +{ + Number result; + + result.Allocate(); + + core::Check(OCI_NumberAssign(result, *this)); + + return result; +} + +template +AnyPointer Number::GetNativeValue(const T& value) +{ + return reinterpret_cast(const_cast(&value)); +} + +template<> +inline AnyPointer Number::GetNativeValue(const Number& value) +{ + return (reinterpret_cast(core::Check(OCI_NumberGetContent(value)))); +} + +inline int Number::Compare(const Number& other) const +{ + return core::Check(OCI_NumberCompare(*this, other)); +} + +template +T Number::GetValue() const +{ + T value; + + core::Check(OCI_NumberGetValue(*this, support::NumericTypeResolver::Value, &value)); + + return value; +} + +template +Number& Number::SetValue(const T &value) +{ + if (IsNull()) + { + Allocate(); + } + + core::Check(OCI_NumberSetValue(*this, support::NumericTypeResolver::Value, GetNativeValue(value))); + + return *this; +} + +template +void Number::Add(const T &value) +{ + core::Check(OCI_NumberAdd(*this, support::NumericTypeResolver::Value, GetNativeValue(value))); +} + +template +void Number::Sub(const T &value) +{ + core::Check(OCI_NumberSub(*this, support::NumericTypeResolver::Value, GetNativeValue(value))); +} + +template +void Number::Multiply(const T &value) +{ + core::Check(OCI_NumberMultiply(*this, support::NumericTypeResolver::Value, GetNativeValue(value))); +} + +template +void Number::Divide(const T &value) +{ + core::Check(OCI_NumberDivide(*this, support::NumericTypeResolver::Value, GetNativeValue(value))); +} + +inline Number& Number::operator = (OCI_Number * &lhs) +{ + Acquire(lhs, reinterpret_cast(OCI_NumberFree), nullptr, nullptr); + return *this; +} + +template::Type::type*> +Number& Number::operator = (const T &lhs) +{ + SetValue(lhs); + return *this; +} + +template::Type::type*> +Number::operator T() const +{ + return GetValue(); +} + +template::Type::type*> +Number Number::operator + (const T &value) +{ + Number result = Clone(); + result.Add(value); + return result; +} + +template::Type::type*> +Number Number::operator - (const T &value) +{ + Number result = Clone(); + result.Sub(value); + return result; +} + +template::Type::type*> +Number Number::operator * (const T &value) +{ + Number result = Clone(); + result.Multiply(value); + return result; +} + +template::Type::type*> +Number Number::operator / (const T &value) +{ + Number result = Clone(); + result.Divide(value); + return result; +} + +template::Type::type*> +Number& Number::operator += (const T &value) +{ + Add(value); + return *this; +} + +template::Type::type*> +Number& Number::operator -= (const T &value) +{ + Sub(value); + return *this; +} + +template::Type::type*> +Number& Number::operator *= (const T &value) +{ + Multiply(value); + return *this; +} + +template::Type::type*> +Number& Number::operator /= (const T &value) +{ + Divide(value); + return *this; +} + +inline Number& Number::operator ++ () +{ + return *this += 1; +} + +inline Number& Number::operator -- () +{ + return *this += 1; +} + +inline Number Number::operator ++ (int) +{ + return *this + 1; +} + +inline Number Number::operator -- (int) +{ + return *this - 1; +} + +inline bool Number::operator == (const Number& other) const +{ + return Compare(other) == 0; +} + +inline bool Number::operator != (const Number& other) const +{ + return !(*this == other); +} + +inline bool Number::operator > (const Number& other) const +{ + return Compare(other) > 0; +} + +inline bool Number::operator < (const Number& other) const +{ + return Compare(other) < 0; +} + +inline bool Number::operator >= (const Number& other) const +{ + const int res = Compare(other); + + return res == 0 || res < 0; +} + +inline bool Number::operator <= (const Number& other) const +{ + const int res = Compare(other); + + return res == 0 || res > 0; +} + +} diff --git a/include/ocilibcpp/detail/Object.hpp b/include/ocilibcpp/detail/Object.hpp new file mode 100644 index 00000000..532a7041 --- /dev/null +++ b/include/ocilibcpp/detail/Object.hpp @@ -0,0 +1,375 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Object::Object() +{ +} + +inline Object::Object(const TypeInfo &typeInfo) +{ + Connection connection = typeInfo.GetConnection(); + Acquire(core::Check(OCI_ObjectCreate(connection, typeInfo)), reinterpret_cast(OCI_ObjectFree), nullptr, connection.GetHandle()); +} + +inline Object::Object(OCI_Object *pObject, core::Handle *parent) +{ + Acquire(pObject, nullptr, nullptr, parent); +} + +inline Object Object::Clone() const +{ + Object result(GetTypeInfo()); + + core::Check(OCI_ObjectAssign(result, *this)); + + return result; +} + +inline bool Object::IsAttributeNull(const ostring& name) const +{ + return (core::Check(OCI_ObjectIsNull(*this, name.c_str())) == TRUE); +} + +inline void Object::SetAttributeNull(const ostring& name) +{ + core::Check(OCI_ObjectSetNull(*this, name.c_str())); +} + +inline TypeInfo Object::GetTypeInfo() const +{ + return TypeInfo(core::Check(OCI_ObjectGetTypeInfo(*this))); +} + +inline Reference Object::GetReference() const +{ + TypeInfo typeInfo = GetTypeInfo(); + Connection connection = typeInfo.GetConnection(); + + OCI_Ref *pRef = OCI_RefCreate(connection, typeInfo); + + core::Check(OCI_ObjectGetSelfRef(*this, pRef)); + + return Reference(pRef, GetHandle()); +} + +inline Object::ObjectType Object::GetType() const +{ + return ObjectType(static_cast(core::Check(OCI_ObjectGetType(*this)))); +} + +template<> +inline bool Object::Get(const ostring& name) const +{ + return (core::Check(OCI_ObjectGetBoolean(*this, name.c_str())) == TRUE); +} + +template<> +inline short Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetShort(*this, name.c_str())); +} + +template<> +inline unsigned short Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetUnsignedShort(*this, name.c_str())); +} + +template<> +inline int Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetInt(*this, name.c_str())); +} + +template<> +inline unsigned int Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetUnsignedInt(*this, name.c_str())); +} + +template<> +inline big_int Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetBigInt(*this, name.c_str())); +} + +template<> +inline big_uint Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetUnsignedBigInt(*this, name.c_str())); +} + +template<> +inline float Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetFloat(*this, name.c_str())); +} + +template<> +inline double Object::Get(const ostring& name) const +{ + return core::Check(OCI_ObjectGetDouble(*this, name.c_str())); +} + +template<> +inline Number Object::Get(const ostring& name) const +{ + return Number(core::Check(OCI_ObjectGetNumber(*this, name.c_str())), GetHandle()); +} + +template<> +inline ostring Object::Get(const ostring& name) const +{ + return core::MakeString(core::Check(OCI_ObjectGetString(*this,name.c_str()))); +} + +template<> +inline Date Object::Get(const ostring& name) const +{ + return Date(core::Check(OCI_ObjectGetDate(*this,name.c_str())), GetHandle()); +} + +template<> +inline Timestamp Object::Get(const ostring& name) const +{ + return Timestamp(core::Check(OCI_ObjectGetTimestamp(*this,name.c_str())), GetHandle()); +} + +template<> +inline Interval Object::Get(const ostring& name) const +{ + return Interval(core::Check(OCI_ObjectGetInterval(*this,name.c_str())), GetHandle()); +} + +template<> +inline Object Object::Get(const ostring& name) const +{ + return Object(core::Check(OCI_ObjectGetObject(*this,name.c_str())), GetHandle()); +} + +template<> +inline Reference Object::Get(const ostring& name) const +{ + return Reference(core::Check(OCI_ObjectGetRef(*this,name.c_str())), GetHandle()); +} + +template<> +inline Clob Object::Get(const ostring& name) const +{ + return Clob(core::Check(OCI_ObjectGetLob(*this,name.c_str())), GetHandle()); +} + +template<> +inline NClob Object::Get(const ostring& name) const +{ + return NClob(core::Check(OCI_ObjectGetLob(*this, name.c_str())), GetHandle()); +} + +template<> +inline Blob Object::Get(const ostring& name) const +{ + return Blob(core::Check(OCI_ObjectGetLob(*this,name.c_str())), GetHandle()); +} + +template<> +inline File Object::Get(const ostring& name) const +{ + return File(core::Check(OCI_ObjectGetFile(*this,name.c_str())), GetHandle()); +} + +template<> +inline Raw Object::Get(const ostring& name) const +{ + unsigned int size = core::Check(OCI_ObjectGetRawSize(*this, name.c_str())); + + core::ManagedBuffer buffer(static_cast(size + 1)); + + size = static_cast(core::Check(OCI_ObjectGetRaw(*this, name.c_str(), static_cast(buffer), size))); + + return core::MakeRaw(buffer, size); +} + +template +T Object::Get(const ostring& name) const +{ + return T(core::Check(OCI_ObjectGetColl(*this, name.c_str())), GetHandle()); +} + +template<> +inline void Object::Set(const ostring& name, const bool &value) +{ + core::Check(OCI_ObjectSetBoolean(*this, name.c_str(), static_cast(value))); +} + +template<> +inline void Object::Set(const ostring& name, const short &value) +{ + core::Check(OCI_ObjectSetShort(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const unsigned short &value) +{ + core::Check(OCI_ObjectSetUnsignedShort(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const int &value) +{ + core::Check(OCI_ObjectSetInt(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const unsigned int &value) +{ + core::Check(OCI_ObjectSetUnsignedInt(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const big_int &value) +{ + core::Check(OCI_ObjectSetBigInt(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const big_uint &value) +{ + core::Check(OCI_ObjectSetUnsignedBigInt(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const float &value) +{ + core::Check(OCI_ObjectSetFloat(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const double &value) +{ + core::Check(OCI_ObjectSetDouble(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Number &value) +{ + core::Check(OCI_ObjectSetNumber(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const ostring &value) +{ + core::Check(OCI_ObjectSetString(*this, name.c_str(), value.c_str())); +} + +template<> +inline void Object::Set(const ostring& name, const Date &value) +{ + core::Check(OCI_ObjectSetDate(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Timestamp &value) +{ + core::Check(OCI_ObjectSetTimestamp(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Interval &value) +{ + core::Check(OCI_ObjectSetInterval(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Object &value) +{ + core::Check(OCI_ObjectSetObject(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Reference &value) +{ + core::Check(OCI_ObjectSetRef(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Clob &value) +{ + core::Check(OCI_ObjectSetLob(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const NClob &value) +{ + core::Check(OCI_ObjectSetLob(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Blob &value) +{ + core::Check(OCI_ObjectSetLob(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const File &value) +{ + core::Check(OCI_ObjectSetFile(*this, name.c_str(), value)); +} + +template<> +inline void Object::Set(const ostring& name, const Raw &value) +{ + const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; + + core::Check(OCI_ObjectSetRaw(*this, name.c_str(), data, static_cast(value.size()))); + +} + +template +void Object::Set(const ostring& name, const T &value) +{ + core::Check(OCI_ObjectSetColl(*this, name.c_str(), value)); +} + +inline ostring Object::ToString() const +{ + if (!IsNull()) + { + unsigned int len = 0; + + core::Check(OCI_ObjectToText(*this, &len, nullptr)); + + core::ManagedBuffer buffer(static_cast(len + 1)); + + core::Check(OCI_ObjectToText(*this, &len, buffer)); + + return core::MakeString(static_cast(buffer), static_cast(len)); + } + + return OCI_STRING_NULL; +} + +} diff --git a/include/ocilibcpp/detail/Pool.hpp b/include/ocilibcpp/detail/Pool.hpp new file mode 100644 index 00000000..fd21d01c --- /dev/null +++ b/include/ocilibcpp/detail/Pool.hpp @@ -0,0 +1,113 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Pool::Pool() +{ + +} + +inline Pool::Pool(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, + unsigned int minSize, unsigned int maxSize, unsigned int increment, Environment::SessionFlags sessionFlags) +{ + Open(db, user, pwd, poolType, minSize, maxSize, increment, sessionFlags); +} + +inline void Pool::Open(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, + unsigned int minSize, unsigned int maxSize, unsigned int increment, Environment::SessionFlags sessionFlags) +{ + Release(); + + Acquire(core::Check(OCI_PoolCreate(db.c_str(), user.c_str(), pwd.c_str(), poolType, sessionFlags.GetValues(), + minSize, maxSize, increment)), reinterpret_cast(OCI_PoolFree), nullptr, Environment::GetEnvironmentHandle()); +} + +inline void Pool::Close() +{ + Release(); +} + +inline Connection Pool::GetConnection(const ostring& sessionTag) +{ + return Connection(core::Check(OCI_PoolGetConnection(*this, sessionTag.c_str())), GetHandle()); +} + +inline unsigned int Pool::GetTimeout() const +{ + return core::Check(OCI_PoolGetTimeout(*this)); +} + +inline void Pool::SetTimeout(unsigned int value) +{ + core::Check(OCI_PoolSetTimeout(*this, value)); +} + +inline bool Pool::GetNoWait() const +{ + return (core::Check(OCI_PoolGetNoWait(*this)) == TRUE); +} + +inline void Pool::SetNoWait(bool value) +{ + core::Check(OCI_PoolSetNoWait(*this, value)); +} + +inline unsigned int Pool::GetBusyConnectionsCount() const +{ + return core::Check(OCI_PoolGetBusyCount(*this)); +} + +inline unsigned int Pool::GetOpenedConnectionsCount() const +{ + return core::Check(OCI_PoolGetOpenedCount(*this)); +} + +inline unsigned int Pool::GetMinSize() const +{ + return core::Check(OCI_PoolGetMin(*this)); +} + +inline unsigned int Pool::GetMaxSize() const +{ + return core::Check(OCI_PoolGetMax(*this)); +} + +inline unsigned int Pool::GetIncrement() const +{ + return core::Check(OCI_PoolGetIncrement(*this)); +} + +inline unsigned int Pool::GetStatementCacheSize() const +{ + return core::Check(OCI_PoolGetStatementCacheSize(*this)); +} + +inline void Pool::SetStatementCacheSize(unsigned int value) +{ + core::Check(OCI_PoolSetStatementCacheSize(*this, value)); +} + +} diff --git a/include/ocilibcpp/detail/Queue.hpp b/include/ocilibcpp/detail/Queue.hpp new file mode 100644 index 00000000..5b9f517c --- /dev/null +++ b/include/ocilibcpp/detail/Queue.hpp @@ -0,0 +1,54 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline void Queue::Create(const Connection &connection, const ostring& queue, const ostring& table, QueueType queueType, unsigned int maxRetries, + unsigned int retryDelay, unsigned int retentionTime, bool dependencyTracking, const ostring& comment) +{ + core::Check(OCI_QueueCreate(connection, queue.c_str(), table.c_str(), queueType, maxRetries, retryDelay, retentionTime, dependencyTracking, comment.c_str())); +} + +inline void Queue::Alter(const Connection &connection, const ostring& queue, unsigned int maxRetries, unsigned int retryDelay, unsigned int retentionTime, const ostring& comment) +{ + core::Check(OCI_QueueAlter(connection, queue.c_str(), maxRetries, retryDelay, retentionTime, comment.c_str())); +} + +inline void Queue::Drop(const Connection &connection, const ostring& queue) +{ + core::Check(OCI_QueueDrop(connection, queue.c_str())); +} + +inline void Queue::Start(const Connection &connection, const ostring& queue, bool enableEnqueue, bool enableDequeue) +{ + core::Check(OCI_QueueStart(connection, queue.c_str(), enableEnqueue, enableDequeue)); +} + +inline void Queue::Stop(const Connection &connection, const ostring& queue, bool stopEnqueue, bool stopDequeue, bool wait) +{ + core::Check(OCI_QueueStop(connection, queue.c_str(), stopEnqueue, stopDequeue, wait)); +} + +} diff --git a/include/ocilibcpp/detail/QueueTable.hpp b/include/ocilibcpp/detail/QueueTable.hpp new file mode 100644 index 00000000..b0d056c3 --- /dev/null +++ b/include/ocilibcpp/detail/QueueTable.hpp @@ -0,0 +1,56 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline void QueueTable::Create(const Connection &connection, const ostring& table, const ostring& payloadType, bool multipleConsumers, const ostring& storageClause, const ostring& sortList, + GroupingMode groupingMode, const ostring& comment, unsigned int primaryInstance, unsigned int secondaryInstance, const ostring& compatible) + +{ + core::Check(OCI_QueueTableCreate(connection, table.c_str(), payloadType.c_str(), storageClause.c_str(), sortList.c_str(), multipleConsumers, + groupingMode, comment.c_str(), primaryInstance, secondaryInstance, compatible.c_str())); +} + +inline void QueueTable::Alter(const Connection &connection, const ostring& table, const ostring& comment, unsigned int primaryInstance, unsigned int secondaryInstance) +{ + core::Check(OCI_QueueTableAlter(connection, table.c_str(), comment.c_str(), primaryInstance, secondaryInstance)); +} + +inline void QueueTable::Drop(const Connection &connection, const ostring& table, bool force) +{ + core::Check(OCI_QueueTableDrop(connection, table.c_str(), force)); +} + +inline void QueueTable::Purge(const Connection &connection, const ostring& table, PurgeMode mode, const ostring& condition, bool block) +{ + core::Check(OCI_QueueTablePurge(connection, table.c_str(), condition.c_str(), block, static_cast(mode))); +} + +inline void QueueTable::Migrate(const Connection &connection, const ostring& table, const ostring& compatible) +{ + core::Check(OCI_QueueTableMigrate(connection, table.c_str(), compatible.c_str())); +} + +} diff --git a/include/ocilibcpp/detail/Reference.hpp b/include/ocilibcpp/detail/Reference.hpp new file mode 100644 index 00000000..8eb10e2b --- /dev/null +++ b/include/ocilibcpp/detail/Reference.hpp @@ -0,0 +1,88 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Reference::Reference() +{ +} + +inline Reference::Reference(const TypeInfo &typeInfo) +{ + Connection connection = typeInfo.GetConnection(); + Acquire(core::Check(OCI_RefCreate(connection, typeInfo)), reinterpret_cast(OCI_RefFree), nullptr, connection.GetHandle()); +} + +inline Reference::Reference(OCI_Ref *pRef, core::Handle *parent) +{ + Acquire(pRef, nullptr, nullptr, parent); +} + +inline TypeInfo Reference::GetTypeInfo() const +{ + return TypeInfo(core::Check(OCI_RefGetTypeInfo(*this))); +} + +inline Object Reference::GetObject() const +{ + return Object(core::Check(OCI_RefGetObject(*this)), GetHandle()); +} + +inline Reference Reference::Clone() const +{ + Reference result(GetTypeInfo()); + + core::Check(OCI_RefAssign(result, *this)); + + return result; +} + +inline bool Reference::IsReferenceNull() const +{ + return (core::Check(OCI_RefIsNull(*this)) == TRUE); +} + +inline void Reference::SetReferenceNull() +{ + core::Check(OCI_RefSetNull(*this)); +} + +inline ostring Reference::ToString() const +{ + if (!IsNull()) + { + const unsigned int size = core::Check(OCI_RefGetHexSize(*this)); + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_RefToText(*this, size, buffer)); + + return core::MakeString(static_cast(buffer), static_cast(size)); + } + + return OCI_STRING_NULL; +} + +} diff --git a/include/ocilibcpp/detail/Resultset.hpp b/include/ocilibcpp/detail/Resultset.hpp new file mode 100644 index 00000000..ce325dd5 --- /dev/null +++ b/include/ocilibcpp/detail/Resultset.hpp @@ -0,0 +1,469 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Resultset::Resultset(OCI_Resultset *resultset, core::Handle *parent) +{ + Acquire(resultset, nullptr, nullptr, parent); +} + +inline bool Resultset::Next() +{ + return (core::Check(OCI_FetchNext(*this)) == TRUE); +} + +inline bool Resultset::Prev() +{ + return (core::Check(OCI_FetchPrev(*this)) == TRUE); +} + +inline bool Resultset::First() +{ + return (core::Check(OCI_FetchFirst(*this)) == TRUE); +} + +inline bool Resultset::Last() +{ + return (core::Check(OCI_FetchLast(*this)) == TRUE); +} + +inline bool Resultset::Seek(SeekMode mode, int offset) +{ + return (core::Check(OCI_FetchSeek(*this, mode, offset)) == TRUE); +} + +inline unsigned int Resultset::GetCount() const +{ + return core::Check(OCI_GetRowCount(*this)); +} + +inline unsigned int Resultset::GetCurrentRow() const +{ + return core::Check(OCI_GetCurrentRow(*this)); +} + +inline unsigned int Resultset::GetColumnIndex(const ostring& name) const +{ + return core::Check(OCI_GetColumnIndex(*this, name.c_str())); +} + +inline unsigned int Resultset::GetColumnCount() const +{ + return core::Check(OCI_GetColumnCount(*this)); +} + +inline Column Resultset::GetColumn(unsigned int index) const +{ + return Column(core::Check(OCI_GetColumn(*this, index)), GetHandle()); +} + +inline Column Resultset::GetColumn(const ostring& name) const +{ + return Column(core::Check(OCI_GetColumn2(*this, name.c_str())), GetHandle()); +} + +inline bool Resultset::IsColumnNull(unsigned int index) const +{ + return (core::Check(OCI_IsNull(*this, index)) == TRUE); +} + +inline bool Resultset::IsColumnNull(const ostring& name) const +{ + return (core::Check(OCI_IsNull2(*this, name.c_str())) == TRUE); +} + +inline Statement Resultset::GetStatement() const +{ + return Statement( core::Check(OCI_ResultsetGetStatement(*this)), nullptr); +} + +inline bool Resultset::operator ++ (int) +{ + return Next(); +} + +inline bool Resultset::operator -- (int) +{ + return Prev(); +} + +inline bool Resultset::operator += (int offset) +{ + return Seek(SeekRelative, offset); +} + +inline bool Resultset::operator -= (int offset) +{ + return Seek(SeekRelative, -offset); +} + +template +void Resultset::Get(unsigned int index, T& value) const +{ + value = Get(index); +} + +template +void Resultset::Get(const ostring &name, T& value) const +{ + value = Get(name); +} + +template +bool Resultset::Get(T& value, TAdapter adapter) const +{ + return adapter(static_cast(*this), value); +} + +template +unsigned int Resultset::ForEach(TCallback callback) +{ + while (Next()) + { + if (!callback(static_cast(*this))) + { + break; + } + } + + return GetCurrentRow(); +} + +template +unsigned int Resultset::ForEach(T callback, U adapter) +{ + while (Next()) + { + if (!callback(adapter(static_cast(*this)))) + { + break; + } + } + + return GetCurrentRow(); +} + +template<> +inline short Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetShort(*this, index)); +} + +template<> +inline short Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetShort2(*this, name.c_str())); +} + +template<> +inline unsigned short Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetUnsignedShort(*this, index)); +} + +template<> +inline unsigned short Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetUnsignedShort2(*this, name.c_str())); +} + +template<> +inline int Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetInt(*this, index)); +} + +template<> +inline int Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetInt2(*this, name.c_str())); +} + +template<> +inline unsigned int Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetUnsignedInt(*this, index)); +} + +template<> +inline unsigned int Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetUnsignedInt2(*this, name.c_str())); +} + +template<> +inline big_int Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetBigInt(*this, index)); +} + +template<> +inline big_int Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetBigInt2(*this, name.c_str())); +} + +template<> +inline big_uint Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetUnsignedBigInt(*this, index)); +} + +template<> +inline big_uint Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetUnsignedBigInt2(*this, name.c_str())); +} + +template<> +inline float Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetFloat(*this, index)); +} + +template<> +inline float Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetFloat2(*this, name.c_str())); +} + +template<> +inline double Resultset::Get(unsigned int index) const +{ + return core::Check(OCI_GetDouble(*this, index)); +} + +template<> +inline double Resultset::Get(const ostring& name) const +{ + return core::Check(OCI_GetDouble2(*this, name.c_str())); +} + +template<> +inline Number Resultset::Get(unsigned int index) const +{ + return Number(core::Check(OCI_GetNumber(*this, index)), GetHandle()); +} + +template<> +inline Number Resultset::Get(const ostring& name) const +{ + return Number(core::Check(OCI_GetNumber2(*this, name.c_str())), GetHandle()); +} + +template<> +inline ostring Resultset::Get(unsigned int index) const +{ + return core::MakeString(core::Check(OCI_GetString(*this, index))); +} + +template<> +inline ostring Resultset::Get(const ostring& name) const +{ + return core::MakeString(core::Check(OCI_GetString2(*this,name.c_str()))); +} + +template<> +inline Raw Resultset::Get(unsigned int index) const +{ + unsigned int size = core::Check(OCI_GetDataLength(*this,index)); + + core::ManagedBuffer buffer(static_cast(size + 1)); + + size = core::Check(OCI_GetRaw(*this, index, static_cast(buffer), size)); + + return core::MakeRaw(buffer, size); +} + +template<> +inline Raw Resultset::Get(const ostring& name) const +{ + unsigned int size = core::Check(OCI_GetDataLength(*this, core::Check(OCI_GetColumnIndex(*this, name.c_str())))); + + core::ManagedBuffer buffer(static_cast(size + 1)); + + size = core::Check(OCI_GetRaw2(*this, name.c_str(), static_cast(buffer), size)); + + return core::MakeRaw(buffer, size); +} + +template<> +inline Date Resultset::Get(unsigned int index) const +{ + return Date(core::Check(OCI_GetDate(*this, index)), GetHandle()); +} + +template<> +inline Date Resultset::Get(const ostring& name) const +{ + return Date(core::Check(OCI_GetDate2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Timestamp Resultset::Get(unsigned int index) const +{ + return Timestamp(core::Check(OCI_GetTimestamp(*this, index)), GetHandle()); +} + +template<> +inline Timestamp Resultset::Get(const ostring& name) const +{ + return Timestamp(core::Check(OCI_GetTimestamp2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Interval Resultset::Get(unsigned int index) const +{ + return Interval(core::Check(OCI_GetInterval(*this, index)), GetHandle()); +} + +template<> +inline Interval Resultset::Get(const ostring& name) const +{ + return Interval(core::Check(OCI_GetInterval2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Object Resultset::Get(unsigned int index) const +{ + return Object(core::Check(OCI_GetObject(*this, index)), GetHandle()); +} + +template<> +inline Object Resultset::Get(const ostring& name) const +{ + return Object(core::Check(OCI_GetObject2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Reference Resultset::Get(unsigned int index) const +{ + return Reference(core::Check(OCI_GetRef(*this, index)), GetHandle()); +} + +template<> +inline Reference Resultset::Get(const ostring& name) const +{ + return Reference(core::Check(OCI_GetRef2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Statement Resultset::Get(unsigned int index) const +{ + return Statement(core::Check(OCI_GetStatement(*this, index)), GetHandle()); +} + +template<> +inline Statement Resultset::Get(const ostring& name) const +{ + return Statement(core::Check(OCI_GetStatement2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Clob Resultset::Get(unsigned int index) const +{ + return Clob(core::Check(OCI_GetLob(*this, index)), GetHandle()); +} + +template<> +inline Clob Resultset::Get(const ostring& name) const +{ + return Clob(core::Check(OCI_GetLob2(*this,name.c_str())), GetHandle()); +} + +template<> +inline NClob Resultset::Get(unsigned int index) const +{ + return NClob(core::Check(OCI_GetLob(*this, index)), GetHandle()); +} + +template<> +inline NClob Resultset::Get(const ostring& name) const +{ + return NClob(core::Check(OCI_GetLob2(*this, name.c_str())), GetHandle()); +} + +template<> +inline Blob Resultset::Get(unsigned int index) const +{ + return Blob(core::Check(OCI_GetLob(*this, index)), GetHandle()); +} + +template<> +inline Blob Resultset::Get(const ostring& name) const +{ + return Blob(core::Check(OCI_GetLob2(*this,name.c_str())), GetHandle()); +} + +template<> +inline File Resultset::Get(unsigned int index) const +{ + return File(core::Check(OCI_GetFile(*this, index)), GetHandle()); +} + +template<> +inline File Resultset::Get(const ostring& name) const +{ + return File(core::Check(OCI_GetFile2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Clong Resultset::Get(unsigned int index) const +{ + return Clong(core::Check(OCI_GetLong(*this, index)), GetHandle()); +} + +template<> +inline Clong Resultset::Get(const ostring& name) const +{ + return Clong(core::Check(OCI_GetLong2(*this,name.c_str())), GetHandle()); +} + +template<> +inline Blong Resultset::Get(unsigned int index) const +{ + return Blong(core::Check(OCI_GetLong(*this, index)), GetHandle()); +} + +template<> +inline Blong Resultset::Get(const ostring& name) const +{ + return Blong(core::Check(OCI_GetLong2(*this,name.c_str())), GetHandle()); +} + +template +T Resultset::Get(unsigned int index) const +{ + return T(core::Check(OCI_GetColl(*this, index)), GetHandle()); +} + +template +T Resultset::Get(const ostring& name) const +{ + return T(core::Check(OCI_GetColl2(*this, name.c_str())), GetHandle()); +} + +} diff --git a/include/ocilibcpp/detail/Statement.hpp b/include/ocilibcpp/detail/Statement.hpp new file mode 100644 index 00000000..b63a9b4f --- /dev/null +++ b/include/ocilibcpp/detail/Statement.hpp @@ -0,0 +1,1026 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam +// ReSharper disable CppClangTidyHicppUseEqualsDefault + +namespace ocilib +{ + +inline Statement::Statement() +{ +} + +inline Statement::Statement(const Connection &connection) +{ + Acquire(core::Check(OCI_StatementCreate(connection)), reinterpret_cast(OCI_StatementFree), OnFreeSmartHandle, connection.GetHandle()); +} + +inline Statement::Statement(OCI_Statement *stmt, core::Handle *parent) +{ + Acquire(stmt, reinterpret_cast(parent ? OCI_StatementFree : nullptr), OnFreeSmartHandle, parent); +} + +inline Connection Statement::GetConnection() const +{ + return Connection(core::Check(OCI_StatementGetConnection(*this)), nullptr); +} + +inline void Statement::Describe(const ostring& sql) +{ + ClearBinds(); + ReleaseResultsets(); + core::Check(OCI_Describe(*this, sql.c_str())); +} + +inline void Statement::Parse(const ostring& sql) +{ + ClearBinds(); + ReleaseResultsets(); + core::Check(OCI_Parse(*this, sql.c_str())); +} + +inline void Statement::Prepare(const ostring& sql) +{ + ClearBinds(); + ReleaseResultsets(); + core::Check(OCI_Prepare(*this, sql.c_str())); +} + +inline void Statement::ExecutePrepared() +{ + ReleaseResultsets(); + SetInData(); + core::Check(OCI_Execute(*this)); + SetOutData(); +} + +template +unsigned int Statement::ExecutePrepared(T callback) +{ + ExecutePrepared(); + + return Fetch(callback); +} + +template +unsigned int Statement::ExecutePrepared(T callback, U adapter) +{ + ExecutePrepared(); + + return Fetch(callback, adapter); +} + +inline void Statement::Execute(const ostring& sql) +{ + ClearBinds(); + ReleaseResultsets(); + core::Check(OCI_ExecuteStmt(*this, sql.c_str())); +} + +template +unsigned int Statement::Execute(const ostring& sql, T callback) +{ + Execute(sql); + + return Fetch(callback); +} + +template +unsigned int Statement::Execute(const ostring& sql, T callback, U adapter) +{ + Execute(sql); + + return Fetch(callback, adapter); +} + +template +unsigned int Statement::Fetch(T callback) +{ + unsigned int res = 0; + + Resultset rs = GetResultset(); + + while (rs) + { + res += rs.ForEach(callback); + rs = GetNextResultset(); + } + + return res; +} + +template +unsigned int Statement::Fetch(T callback, U adapter) +{ + unsigned int res = 0; + + Resultset rs = GetResultset(); + + while (rs) + { + res += rs.ForEach(callback, adapter); + rs = GetNextResultset(); + } + + return res; +} + +inline unsigned int Statement::GetAffectedRows() const +{ + return core::Check(OCI_GetAffectedRows(*this)); +} + +inline ostring Statement::GetSql() const +{ + return core::MakeString(core::Check(OCI_GetSql(*this))); +} + +inline ostring Statement::GetSqlIdentifier() const +{ + return core::MakeString(core::Check(OCI_GetSqlIdentifier(*this))); +} + +inline Resultset Statement::GetResultset() +{ + return Resultset(core::Check(OCI_GetResultset(*this)), GetHandle()); +} + +inline Resultset Statement::GetNextResultset() +{ + return Resultset(core::Check(OCI_GetNextResultset(*this)), GetHandle()); +} + +inline void Statement::SetBindArraySize(unsigned int size) +{ + core::Check(OCI_BindArraySetSize(*this, size)); +} + +inline unsigned int Statement::GetBindArraySize() const +{ + return core::Check(OCI_BindArrayGetSize(*this)); +} + +inline void Statement::AllowRebinding(bool value) +{ + core::Check(OCI_AllowRebinding(*this, value)); +} + +inline bool Statement::IsRebindingAllowed() const +{ + return (core::Check(OCI_IsRebindingAllowed(*this)) == TRUE); +} + +inline unsigned int Statement::GetBindIndex(const ostring& name) const +{ + return core::Check(OCI_GetBindIndex(*this, name.c_str())); +} + +inline unsigned int Statement::GetBindCount() const +{ + return core::Check(OCI_GetBindCount(*this)); +} + +inline BindInfo Statement::GetBind(unsigned int index) const +{ + return BindInfo(core::Check(OCI_GetBind(*this, index)), GetHandle()); +} + +inline BindInfo Statement::GetBind(const ostring& name) const +{ + return BindInfo(core::Check(OCI_GetBind2(*this, name.c_str())), GetHandle()); +} + +template +void Statement::Bind1(M &method, const ostring& name, T& value, BindInfo::BindDirection mode) +{ + core::Check(method(*this, name.c_str(), &value)); + SetLastBindMode(mode); +} + +template +void Statement::Bind2(M &method, const ostring& name, T& value, BindInfo::BindDirection mode) +{ + core::Check(method(*this, name.c_str(), static_cast::OutputType>(value))); + SetLastBindMode(mode); +} + +template +void Statement::BindVector1(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode)); + bnd->SetVector(values, type == BindInfo::AsPlSqlTable, sizeof(typename support::BindResolver::OutputType)); + + const boolean res = method(*this, name.c_str(), bnd->GetData(), bnd->GetSizeForBindCall()); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template +void Statement::BindVector2(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, U subType, BindInfo::VectorType type) +{ + support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode)); + bnd->SetVector(values, type == BindInfo::AsPlSqlTable, sizeof(typename support::BindResolver::OutputType)); + + const boolean res = method(*this, name.c_str(), bnd->GetData(), subType, bnd->GetSizeForBindCall()); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template<> +inline void Statement::Bind(const ostring& name, bool &value, BindInfo::BindDirection mode) +{ + support::BindTypeAdaptor * bnd = core::OnAllocate(new support::BindTypeAdaptor(*this, name, mode, value)); + + const boolean res = OCI_BindBoolean(*this, name.c_str(), static_cast(*bnd)); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template<> +inline void Statement::Bind(const ostring& name, short &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindShort, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, unsigned short &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindUnsignedShort, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, int &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindInt, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, unsigned int &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindUnsignedInt, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, big_int &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindBigInt, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, big_uint &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindUnsignedBigInt, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, float &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindFloat, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, double &value, BindInfo::BindDirection mode) +{ + Bind1(OCI_BindDouble, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Number &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindNumber, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Date &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindDate, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Timestamp &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindTimestamp, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Interval &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindInterval, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Clob &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindLob, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, NClob &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindLob, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Blob &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindLob, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, File &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindFile, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Object &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindObject, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Reference &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindRef, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Statement &value, BindInfo::BindDirection mode) +{ + Bind2(OCI_BindStatement, name, value, mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Clong &value, unsigned int maxSize, BindInfo::BindDirection mode) +{ + core::Check(OCI_BindLong(*this, name.c_str(), value, maxSize)); + SetLastBindMode(mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Clong &value, int maxSize, BindInfo::BindDirection mode) +{ + Bind(name, value, static_cast(maxSize), mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Blong &value, unsigned int maxSize, BindInfo::BindDirection mode) +{ + core::Check(OCI_BindLong(*this, name.c_str(), value, maxSize)); + SetLastBindMode(mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Blong &value, int maxSize, BindInfo::BindDirection mode) +{ + Bind(name, value, static_cast(maxSize), mode); +} + +template<> +inline void Statement::Bind(const ostring& name, ostring &value, unsigned int maxSize, BindInfo::BindDirection mode) +{ + if (maxSize == 0) + { + maxSize = static_cast(value.size()); + } + + value.reserve(maxSize); + + support::BindObjectAdaptor * bnd = core::OnAllocate(new support::BindObjectAdaptor(*this, name, mode, value, maxSize + 1)); + + const boolean res = OCI_BindString(*this, name.c_str(), static_cast(*bnd), maxSize); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template<> +inline void Statement::Bind(const ostring& name, ostring &value, int maxSize, BindInfo::BindDirection mode) +{ + Bind(name, value, static_cast(maxSize), mode); +} + +template<> +inline void Statement::Bind(const ostring& name, Raw &value, unsigned int maxSize, BindInfo::BindDirection mode) +{ + if (maxSize == 0) + { + maxSize = static_cast(value.size()); + } + + value.reserve(maxSize); + + support::BindObjectAdaptor * bnd = core::OnAllocate(new support::BindObjectAdaptor(*this, name, mode, value, maxSize)); + + const boolean res = OCI_BindRaw(*this, name.c_str(), static_cast(*bnd), maxSize); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template<> +inline void Statement::Bind(const ostring& name, Raw &value, int maxSize, BindInfo::BindDirection mode) +{ + Bind(name, value, static_cast(maxSize), mode); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfShorts, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfUnsignedShorts, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfInts, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfUnsignedInts, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfBigInts, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfUnsignedBigInts, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfFloats, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfDoubles, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfDates, name, values, mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector1(OCI_BindArrayOfNumbers, name, values, mode, type); +} + +template +void Statement::Bind(const ostring& name, Collection &value, BindInfo::BindDirection mode) +{ + core::Check(OCI_BindColl(*this, name.c_str(), value)); + SetLastBindMode(mode); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, Timestamp::TimestampTypeValues subType, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfTimestamps, name, values, mode, subType, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, Timestamp::TimestampType subType, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + Bind(name, values, subType.GetValue(), mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, Interval::IntervalTypeValues subType, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfIntervals, name, values, mode, subType, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, Interval::IntervalType subType, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + Bind(name, values, subType.GetValue(), mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast(OCI_CLOB), type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast(OCI_NCLOB), type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast(OCI_BLOB), type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfFiles, name, values, mode, static_cast(OCI_BFILE), type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfObjects, name, values, mode, static_cast(typeInfo), type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfRefs, name, values, mode, static_cast(typeInfo), type); +} + +template +void Statement::Bind(const ostring& name, std::vector > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfColls, name, values, mode, static_cast(typeInfo), type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode)); + bnd->SetVector(values, type == BindInfo::AsPlSqlTable, maxSize+1); + + const boolean res = OCI_BindArrayOfStrings(*this, name.c_str(), bnd->GetData(), maxSize, bnd->GetSizeForBindCall()); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + Bind(name, values, static_cast(maxSize), mode, type); +} + +template<> +inline void Statement::Bind(const ostring& name, std::vector &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + support::BindArray * bnd = core::OnAllocate(new support::BindArray(*this, name, mode)); + bnd->SetVector(values, type == BindInfo::AsPlSqlTable, maxSize); + + const boolean res = OCI_BindArrayOfRaws(*this, name.c_str(), bnd->GetData(), maxSize, bnd->GetSizeForBindCall()); + + if (res) + { + support::BindsHolder *bindsHolder = GetBindsHolder(true); + bindsHolder->AddBindObject(bnd); + SetLastBindMode(mode); + } + else + { + delete core::OnDeallocate(bnd); + } + + core::Check(res); +} + +template +void Statement::Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) +{ + BindVector2(OCI_BindArrayOfColls, name, values, mode, static_cast(typeInfo), GetArraysize(type, values)); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterUnsignedShort(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterShort(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterUnsignedInt(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterInt(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterUnsignedBigInt(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterBigInt(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterFloat(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterDouble(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterNumber(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterDate(*this, name.c_str())); +} + +template<> +inline void Statement::Register(const ostring& name, Timestamp::TimestampTypeValues type) +{ + core::Check(OCI_RegisterTimestamp(*this, name.c_str(), type)); +} + +template<> +inline void Statement::Register(const ostring& name, Timestamp::TimestampType type) +{ + Register(name, type.GetValue()); +} + +template<> +inline void Statement::Register(const ostring& name, Interval::IntervalTypeValues type) +{ + core::Check(OCI_RegisterInterval(*this, name.c_str(), type)); +} + +template<> +inline void Statement::Register(const ostring& name, Interval::IntervalType type) +{ + Register(name, type.GetValue()); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterLob(*this, name.c_str(), OCI_CLOB)); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterLob(*this, name.c_str(), OCI_NCLOB)); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterLob(*this, name.c_str(), OCI_BLOB)); +} + +template<> +inline void Statement::Register(const ostring& name) +{ + core::Check(OCI_RegisterFile(*this, name.c_str(), OCI_BFILE)); +} + +template<> +inline void Statement::Register(const ostring& name, TypeInfo& typeInfo) +{ + core::Check(OCI_RegisterObject(*this, name.c_str(), typeInfo)); +} + +template<> +inline void Statement::Register(const ostring& name, TypeInfo& typeInfo) +{ + core::Check(OCI_RegisterRef(*this, name.c_str(), typeInfo)); +} + +template<> +inline void Statement::Register(const ostring& name, unsigned int len) +{ + core::Check(OCI_RegisterString(*this, name.c_str(), len)); +} + +template<> +inline void Statement::Register(const ostring& name, int len) +{ + Register(name, static_cast(len)); +} + +template<> +inline void Statement::Register(const ostring& name, unsigned int len) +{ + core::Check(OCI_RegisterRaw(*this, name.c_str(), len)); +} + +template<> +inline void Statement::Register(const ostring& name, int len) +{ + Register(name, static_cast(len)); +} + +inline Statement::StatementType Statement::GetStatementType() const +{ + return StatementType(static_cast(core::Check(OCI_GetStatementType(*this)))); +} + +inline unsigned int Statement::GetSqlErrorPos() const +{ + return core::Check(OCI_GetSqlErrorPos(*this)); +} + +inline void Statement::SetFetchMode(FetchMode value) +{ + core::Check(OCI_SetFetchMode(*this, value)); +} + +inline Statement::FetchMode Statement::GetFetchMode() const +{ + return FetchMode(static_cast(core::Check(OCI_GetFetchMode(*this)))); +} + +inline void Statement::SetBindMode(BindMode value) +{ + core::Check(OCI_SetBindMode(*this, value)); +} + +inline Statement::BindMode Statement::GetBindMode() const +{ + return BindMode(static_cast(core::Check(OCI_GetBindMode(*this)))); +} + +inline void Statement::SetFetchSize(unsigned int value) +{ + core::Check(OCI_SetFetchSize(*this, value)); +} + +inline unsigned int Statement::GetFetchSize() const +{ + return core::Check(OCI_GetFetchSize(*this)); +} + +inline void Statement::SetPrefetchSize(unsigned int value) +{ + core::Check(OCI_SetPrefetchSize(*this, value)); +} + +inline unsigned int Statement::GetPrefetchSize() const +{ + return core::Check(OCI_GetPrefetchSize(*this)); +} + +inline void Statement::SetPrefetchMemory(unsigned int value) +{ + core::Check(OCI_SetPrefetchMemory(*this, value)); +} + +inline unsigned int Statement::GetPrefetchMemory() const +{ + return core::Check(OCI_GetPrefetchMemory(*this)); +} + +inline void Statement::SetLongMaxSize(unsigned int value) +{ + core::Check(OCI_SetLongMaxSize(*this, value)); +} + +inline unsigned int Statement::GetLongMaxSize() const +{ + return core::Check(OCI_GetLongMaxSize(*this)); +} + +inline void Statement::SetLongMode(LongMode value) +{ + core::Check(OCI_SetLongMode(*this, value)); +} + +inline Statement::LongMode Statement::GetLongMode() const +{ + return LongMode(static_cast(core::Check(OCI_GetLongMode(*this)))); +} + +inline unsigned int Statement::GetSQLCommand() const +{ + return core::Check(OCI_GetSQLCommand(*this)); +} + +inline ostring Statement::GetSQLVerb() const +{ + return core::MakeString(core::Check(OCI_GetSQLVerb(*this))); +} + +inline void Statement::GetBatchErrors(std::vector &exceptions) +{ + exceptions.clear(); + + OCI_Error *err = core::Check(OCI_GetBatchError(*this)); + + while (err) + { + exceptions.push_back(Exception(err)); + + err = core::Check(OCI_GetBatchError(*this)); + } +} + +inline void Statement::ClearBinds() const +{ + support::BindsHolder *bindsHolder = GetBindsHolder(false); + + if (bindsHolder) + { + bindsHolder->Clear(); + } +} + +inline void Statement::SetOutData() const +{ + support::BindsHolder *bindsHolder = GetBindsHolder(false); + + if (bindsHolder) + { + bindsHolder->SetOutData(); + } +} + +inline void Statement::SetInData() const +{ + support::BindsHolder *bindsHolder = GetBindsHolder(false); + + if (bindsHolder) + { + bindsHolder->SetInData(); + } +} + +inline void Statement::ReleaseResultsets() const +{ + if (_smartHandle) + { + core::Handle *handle = nullptr; + + while (_smartHandle->GetChildren().FindIf(IsResultsetHandle, handle)) + { + if (handle) + { + handle->DetachFromHolders(); + + delete core::OnDeallocate(handle); + + handle = nullptr; + } + } + } +} + +inline bool Statement::IsResultsetHandle(core::Handle *handle) +{ + Resultset::SmartHandle *smartHandle = dynamic_cast(handle); + + return smartHandle != nullptr; +} + +inline void Statement::OnFreeSmartHandle(SmartHandle *smartHandle) +{ + if (smartHandle) + { + support::BindsHolder *bindsHolder = static_cast(smartHandle->GetExtraInfos()); + + smartHandle->SetExtraInfos(nullptr); + + delete core::OnDeallocate(bindsHolder); + } +} + +inline void Statement::SetLastBindMode(BindInfo::BindDirection mode) +{ + core::Check(OCI_BindSetDirection(core::Check(OCI_GetBind(*this, core::Check(OCI_GetBindCount(*this)))), mode)); +} + +inline support::BindsHolder * Statement::GetBindsHolder(bool create) const +{ + support::BindsHolder * bindsHolder = static_cast(_smartHandle->GetExtraInfos()); + + if (bindsHolder == nullptr && create) + { + bindsHolder = core::OnAllocate(new support::BindsHolder(*this)); + _smartHandle->SetExtraInfos(bindsHolder); + } + + return bindsHolder; +} + +} diff --git a/include/ocilibcpp/detail/Subscription.hpp b/include/ocilibcpp/detail/Subscription.hpp new file mode 100644 index 00000000..290aedd9 --- /dev/null +++ b/include/ocilibcpp/detail/Subscription.hpp @@ -0,0 +1,86 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam + +namespace ocilib +{ + +inline Subscription::Subscription() +{ + +} + +inline Subscription::Subscription(OCI_Subscription *pSubcription) +{ + Acquire(pSubcription, nullptr, nullptr, nullptr); +} + +inline void Subscription::Register(const Connection &connection, const ostring& name, ChangeTypes changeTypes, NotifyHandlerProc handler, unsigned int port, unsigned int timeout) +{ + Acquire(core::Check(OCI_SubscriptionRegister(connection, name.c_str(), changeTypes.GetValues(), + static_cast (handler != nullptr ? Environment::NotifyHandler : nullptr), port, timeout)), + reinterpret_cast(OCI_SubscriptionUnregister), nullptr, nullptr); + + Environment::SetUserCallback(static_cast(*this), handler); +} + +inline void Subscription::Unregister() +{ + Environment::SetUserCallback(static_cast(*this), nullptr); + + Release(); +} + +inline void Subscription::Watch(const ostring& sql) +{ + Statement st(GetConnection()); + + st.Execute(sql); + + core::Check(OCI_SubscriptionAddStatement(*this, st)); +} + +inline ostring Subscription::GetName() const +{ + return core::MakeString(core::Check(OCI_SubscriptionGetName(*this))); +} + +inline unsigned int Subscription::GetTimeout() const +{ + return core::Check(OCI_SubscriptionGetTimeout(*this)); +} + +inline unsigned int Subscription::GetPort() const +{ + return core::Check(OCI_SubscriptionGetPort(*this)); +} + +inline Connection Subscription::GetConnection() const +{ + return Connection(core::Check(OCI_SubscriptionGetConnection(*this)), nullptr); +} + +} diff --git a/include/ocilibcpp/detail/Thread.hpp b/include/ocilibcpp/detail/Thread.hpp new file mode 100644 index 00000000..d2a55f46 --- /dev/null +++ b/include/ocilibcpp/detail/Thread.hpp @@ -0,0 +1,53 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline ThreadHandle Thread::Create() +{ + return core::Check(OCI_ThreadCreate()); +} + +inline void Thread::Destroy(ThreadHandle handle) +{ + core::Check(OCI_ThreadFree(handle)); +} + +inline void Thread::Run(ThreadHandle handle, ThreadProc func, AnyPointer arg) +{ + core::Check(OCI_ThreadRun(handle, func, arg)); +} + +inline void Thread::Join(ThreadHandle handle) +{ + core::Check(OCI_ThreadJoin(handle)); +} + +inline ThreadId Thread::GetThreadId(ThreadHandle handle) +{ + return core::Check(OCI_HandleGetThreadID(handle)); +} + +} diff --git a/include/ocilibcpp/detail/ThreadKey.hpp b/include/ocilibcpp/detail/ThreadKey.hpp new file mode 100644 index 00000000..3ebb887e --- /dev/null +++ b/include/ocilibcpp/detail/ThreadKey.hpp @@ -0,0 +1,43 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline void ThreadKey::Create(const ostring& name, ThreadKeyFreeProc freeProc) +{ + core::Check(OCI_ThreadKeyCreate(name.c_str(), freeProc)); +} + +inline void ThreadKey::SetValue(const ostring& name, AnyPointer value) +{ + core::Check(OCI_ThreadKeySetValue(name.c_str(), value)); +} + +inline AnyPointer ThreadKey::GetValue(const ostring& name) +{ + return core::Check(OCI_ThreadKeyGetValue(name.c_str())); +} + +} diff --git a/include/ocilibcpp/detail/Timestamp.hpp b/include/ocilibcpp/detail/Timestamp.hpp new file mode 100644 index 00000000..6d47905a --- /dev/null +++ b/include/ocilibcpp/detail/Timestamp.hpp @@ -0,0 +1,427 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline Timestamp::Timestamp() +{ +} + +inline Timestamp::Timestamp(TimestampType type) +{ + Acquire(core::Check(OCI_TimestampCreate(nullptr, type)), reinterpret_cast(OCI_TimestampFree), nullptr, nullptr); +} + +inline Timestamp::Timestamp(TimestampType type, const ostring& data, const ostring& format) +{ + Acquire(core::Check(OCI_TimestampCreate(nullptr, type)), reinterpret_cast(OCI_TimestampFree), nullptr, nullptr); + FromString(data, format); +} + +inline Timestamp::Timestamp(OCI_Timestamp *pTimestamp, core::Handle *parent) +{ + Acquire(pTimestamp, nullptr, nullptr, parent); +} + +inline Timestamp Timestamp::Clone() const +{ + Timestamp result(GetType()); + + core::Check(OCI_TimestampAssign(result, *this)); + + return result; +} + +inline int Timestamp::Compare(const Timestamp& other) const +{ + return core::Check(OCI_TimestampCompare(*this, other)); +} + +inline Timestamp::TimestampType Timestamp::GetType() const +{ + return TimestampType(static_cast(core::Check(OCI_TimestampGetType(*this)))); +} + +inline void Timestamp::SetDateTime(int year, int month, int day, int hour, int min, int sec, int fsec, const ostring& timeZone) +{ + core::Check(OCI_TimestampConstruct(*this, year, month, day, hour, min,sec, fsec, timeZone.c_str())); +} + +inline void Timestamp::Convert(const Timestamp& other) +{ + core::Check(OCI_TimestampConvert(*this, other)); +} + +inline bool Timestamp::IsValid() const +{ + return (core::Check(OCI_TimestampCheck(*this)) == 0); +} + +inline int Timestamp::GetYear() const +{ + int year, month, day; + + GetDate(year, month, day); + + return year; +} + +inline void Timestamp::SetYear(int value) +{ + int year, month, day; + + GetDate(year, month, day); + SetDate(value, month, day); +} + +inline int Timestamp::GetMonth() const +{ + int year, month, day; + + GetDate(year, month, day); + + return month; +} + +inline void Timestamp::SetMonth(int value) +{ + int year, month, day; + + GetDate(year, month, day); + SetDate(year, value, day); +} + +inline int Timestamp::GetDay() const +{ + int year, month, day; + + GetDate(year, month, day); + + return day; +} + +inline void Timestamp::SetDay(int value) +{ + int year, month, day; + + GetDate(year, month, day); + SetDate(year, month, value); +} + +inline int Timestamp::GetHours() const +{ + int hour, minutes, seconds, milliseconds; + + GetTime(hour, minutes, seconds, milliseconds); + + return hour; +} + +inline void Timestamp::SetHours(int value) +{ + int hour, minutes, seconds, milliseconds; + + GetTime(hour, minutes, seconds, milliseconds); + SetTime(value, minutes, seconds, milliseconds); +} + +inline int Timestamp::GetMinutes() const +{ + int hour, minutes, seconds, milliseconds; + + GetTime(hour, minutes, seconds, milliseconds); + + return minutes; +} + +inline void Timestamp::SetMinutes(int value) +{ + int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetTime(hour, minutes, seconds, milliseconds); + SetTime(hour, value, seconds, milliseconds); +} + +inline int Timestamp::GetSeconds() const +{ + int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetTime(hour, minutes, seconds, milliseconds); + + return seconds; +} + +inline void Timestamp::SetSeconds(int value) +{ + int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetTime(hour, minutes, seconds, milliseconds); + SetTime(hour, minutes, value, milliseconds); +} + +inline int Timestamp::GetMilliSeconds() const +{ + int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetTime(hour, minutes, seconds, milliseconds); + + return milliseconds; +} + +inline void Timestamp::SetMilliSeconds(int value) +{ + int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetTime(hour, minutes, seconds, milliseconds); + SetTime(hour, minutes, seconds, value); +} + +inline void Timestamp::GetDate(int &year, int &month, int &day) const +{ + core::Check(OCI_TimestampGetDate(*this, &year, &month, &day)); +} + +inline void Timestamp::GetTime(int &hour, int &min, int &sec, int &fsec) const +{ + core::Check(OCI_TimestampGetTime(*this, &hour, &min, &sec, &fsec)); +} + +inline void Timestamp::GetDateTime(int &year, int &month, int &day, int &hour, int &min, int &sec, int &fsec) const +{ + core::Check(OCI_TimestampGetDateTime(*this, &year, &month, &day, &hour, &min, &sec, &fsec)); +} + +inline void Timestamp::SetDate(int year, int month, int day) +{ + int tmpYear = 0, tmpMonth = 0, tempDay = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDateTime(tmpYear, tmpMonth, tempDay, hour, minutes, seconds, milliseconds); + SetDateTime(year, month, day, hour, minutes, seconds, milliseconds); +} + +inline void Timestamp::SetTime(int hour, int min, int sec, int fsec) +{ + int year = 0, month = 0, day = 0, tmpHour = 0, tmpMinutes = 0, tmpSeconds = 0, tmpMilliseconds = 0; + + GetDateTime(year, month, day, tmpHour, tmpMinutes, tmpSeconds, tmpMilliseconds); + SetDateTime(year, month, day, hour, min, sec, fsec); +} + +inline void Timestamp::SetTimeZone(const ostring& timeZone) +{ + if (GetType() == WithTimeZone) + { + int year = 0, month = 0, day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; + + GetDateTime(year, month, day, hour, minutes, seconds, milliseconds); + SetDateTime(year, month, day, hour, minutes, seconds, milliseconds, timeZone); + } +} + +inline ostring Timestamp::GetTimeZone() const +{ + if (GetType() != NoTimeZone) + { + const size_t size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_TimestampGetTimeZoneName(*this, static_cast(size), buffer) == TRUE); + + return core::MakeString(static_cast(buffer)); + } + + return ostring(); +} + +inline void Timestamp::GetTimeZoneOffset(int &hour, int &min) const +{ + core::Check(OCI_TimestampGetTimeZoneOffset(*this, &hour, &min)); +} + +inline void Timestamp::Substract(const Timestamp &lsh, const Timestamp &rsh, Interval& result) +{ + core::Check(OCI_TimestampSubtract(lsh, rsh, result)); +} + +inline Timestamp Timestamp::SysTimestamp(TimestampType type) +{ + Timestamp result(type); + + core::Check(OCI_TimestampSysTimestamp(result)); + + return result; +} + +inline void Timestamp::FromString(const ostring& data, const ostring& format) +{ + core::Check(OCI_TimestampFromText(*this, data.c_str(), format.empty() ? Environment::GetFormat(FormatTimestamp).c_str() : format.c_str())); +} + +inline ostring Timestamp::ToString(const ostring& format, int precision = OCI_STRING_DEFAULT_PREC) const +{ + if (!IsNull()) + { + const size_t size = OCI_SIZE_BUFFER; + + core::ManagedBuffer buffer(static_cast(size + 1)); + + core::Check(OCI_TimestampToText(*this, format.c_str(), static_cast(size), buffer, precision)); + + return core::MakeString(static_cast(buffer)); + } + + return OCI_STRING_NULL; +} + +inline ostring Timestamp::ToString() const +{ + return ToString(Environment::GetFormat(FormatTimestamp), OCI_STRING_DEFAULT_PREC); +} + +inline Timestamp& Timestamp::operator ++ () +{ + return *this += 1; +} + +inline Timestamp Timestamp::operator ++ (int) +{ + Timestamp result = Clone(); + + *this += 1; + + return result; +} + +inline Timestamp& Timestamp::operator -- () +{ + return *this -= 1; +} + +inline Timestamp Timestamp::operator -- (int) +{ + Timestamp result = Clone(); + + *this -= 1; + + return result; +} + +inline Timestamp Timestamp::operator + (int value) const +{ + Timestamp result = Clone(); + Interval interval(Interval::DaySecond); + interval.SetDay(1); + return result += value; +} + +inline Timestamp Timestamp::operator - (int value) const +{ + Timestamp result = Clone(); + Interval interval(Interval::DaySecond); + interval.SetDay(1); + return result -= value; +} + +inline Interval Timestamp::operator - (const Timestamp& other) +{ + Interval interval(Interval::DaySecond); + core::Check(OCI_TimestampSubtract(*this, other, interval)); + return interval; +} + +inline Timestamp Timestamp::operator + (const Interval& other) const +{ + Timestamp result = Clone(); + return result += other; +} + +inline Timestamp Timestamp::operator - (const Interval& other) const +{ + Timestamp result = Clone(); + return result -= other; +} + +inline Timestamp& Timestamp::operator += (const Interval& other) +{ + core::Check(OCI_TimestampIntervalAdd(*this, other)); + return *this; +} + +inline Timestamp& Timestamp::operator -= (const Interval& other) +{ + core::Check(OCI_TimestampIntervalSub(*this, other)); + return *this; +} + +inline Timestamp& Timestamp::operator += (int value) +{ + Interval interval(Interval::DaySecond); + interval.SetDay(value); + return *this += interval; +} + +inline Timestamp& Timestamp::operator -= (int value) +{ + Interval interval(Interval::DaySecond); + interval.SetDay(value); + return *this -= interval; +} + +inline bool Timestamp::operator == (const Timestamp& other) const +{ + return Compare(other) == 0; +} + +inline bool Timestamp::operator != (const Timestamp& other) const +{ + return (!(*this == other)); +} + +inline bool Timestamp::operator > (const Timestamp& other) const +{ + return (Compare(other) > 0); +} + +inline bool Timestamp::operator < (const Timestamp& other) const +{ + return (Compare(other) < 0); +} + +inline bool Timestamp::operator >= (const Timestamp& other) const +{ + const int res = Compare(other); + + return (res == 0 || res < 0); +} + +inline bool Timestamp::operator <= (const Timestamp& other) const +{ + const int res = Compare(other); + + return (res == 0 || res > 0); +} + +} diff --git a/include/ocilibcpp/detail/Transaction.hpp b/include/ocilibcpp/detail/Transaction.hpp new file mode 100644 index 00000000..a9ee16b2 --- /dev/null +++ b/include/ocilibcpp/detail/Transaction.hpp @@ -0,0 +1,75 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam + +namespace ocilib +{ + +inline Transaction::Transaction(const Connection &connection, unsigned int timeout, TransactionFlags flags, OCI_XID *pxid) +{ + Acquire(core::Check(OCI_TransactionCreate(connection, timeout, flags.GetValues(), pxid)), reinterpret_cast(OCI_TransactionFree), nullptr, nullptr); +} + +inline Transaction::Transaction(OCI_Transaction *trans) +{ + Acquire(trans, nullptr, nullptr, nullptr); +} + +inline void Transaction::Prepare() +{ + core::Check(OCI_TransactionPrepare(*this)); +} + +inline void Transaction::Start() +{ + core::Check(OCI_TransactionStart(*this)); +} + +inline void Transaction::Stop() +{ + core::Check(OCI_TransactionStop(*this)); +} + +inline void Transaction::Resume() +{ + core::Check(OCI_TransactionResume(*this)); +} + +inline void Transaction::Forget() +{ + core::Check(OCI_TransactionForget(*this)); +} + +inline Transaction::TransactionFlags Transaction::GetFlags() const +{ + return TransactionFlags(static_cast(core::Check(OCI_TransactionGetMode(*this)))); +} + +inline unsigned int Transaction::GetTimeout() const +{ + return core::Check(OCI_TransactionGetTimeout(*this)); +} + +} diff --git a/include/ocilibcpp/detail/TypeInfo.hpp b/include/ocilibcpp/detail/TypeInfo.hpp new file mode 100644 index 00000000..4d390049 --- /dev/null +++ b/include/ocilibcpp/detail/TypeInfo.hpp @@ -0,0 +1,73 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/types.hpp" + +namespace ocilib +{ + +inline TypeInfo::TypeInfo(const Connection &connection, const ostring& name, TypeInfoType type) +{ + Acquire(core::Check(OCI_TypeInfoGet(connection, name.c_str(), type)), static_cast(nullptr), nullptr, connection.GetHandle()); +} + +inline TypeInfo::TypeInfo(OCI_TypeInfo *pTypeInfo) +{ + Acquire(pTypeInfo, nullptr, nullptr, nullptr); +} + +inline TypeInfo::TypeInfoType TypeInfo::GetType() const +{ + return TypeInfoType(static_cast(core::Check(OCI_TypeInfoGetType(*this)))); +} + +inline ostring TypeInfo::GetName() const +{ + return core::Check(OCI_TypeInfoGetName(*this)); +} + +inline Connection TypeInfo::GetConnection() const +{ + return Connection(core::Check(OCI_TypeInfoGetConnection(*this)), nullptr); +} + +inline unsigned int TypeInfo::GetColumnCount() const +{ + return core::Check(OCI_TypeInfoGetColumnCount(*this)); +} + +inline Column TypeInfo::GetColumn(unsigned int index) const +{ + return Column(core::Check(OCI_TypeInfoGetColumn(*this, index)), GetHandle()); +} + +inline boolean TypeInfo::IsFinalType() const +{ + return (core::Check(OCI_TypeInfoIsFinalType(*this)) == TRUE); +} + +inline TypeInfo TypeInfo::GetSuperType() const +{ + return TypeInfo(core::Check(OCI_TypeInfoGetSuperType(*this))); +} + +} diff --git a/include/ocilibcpp/detail/core/ConcurrentList.hpp b/include/ocilibcpp/detail/core/ConcurrentList.hpp new file mode 100644 index 00000000..c9bd4bc3 --- /dev/null +++ b/include/ocilibcpp/detail/core/ConcurrentList.hpp @@ -0,0 +1,122 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + ConcurrentList::ConcurrentList() : _list() + { + + } + + template + ConcurrentList::~ConcurrentList() noexcept + { + SILENT_CATCH(Clear()) + } + + template + void ConcurrentList::Add(T value) + { + Lock(); + _list.push_back(value); + Unlock(); + } + + template + void ConcurrentList::Remove(T value) + { + Lock(); + _list.remove(value); + Unlock(); + } + + template + void ConcurrentList::Clear() + { + Lock(); + _list.clear(); + Unlock(); + } + + template + size_t ConcurrentList::GetSize() + { + Lock(); + const size_t size = _list.size(); + Unlock(); + + return size; + } + + template + bool ConcurrentList::Exists(const T& value) + { + Lock(); + + const bool res = std::find(_list.begin(), _list.end(), value) != _list.end(); + + Unlock(); + + return res; + } + + template + template + bool ConcurrentList::FindIf(P predicate, T& value) + { + bool res = false; + + Lock(); + + typename std::list::iterator it = std::find_if(_list.begin(), _list.end(), predicate); + + if (it != _list.end()) + { + value = *it; + res = true; + } + + Unlock(); + + return res; + } + + template + template + void ConcurrentList::ForEach(A action) + { + Lock(); + + std::for_each(_list.begin(), _list.end(), action); + + Unlock(); + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/ConcurrentMap.hpp b/include/ocilibcpp/detail/core/ConcurrentMap.hpp new file mode 100644 index 00000000..633c0312 --- /dev/null +++ b/include/ocilibcpp/detail/core/ConcurrentMap.hpp @@ -0,0 +1,92 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + ConcurrentMap::ConcurrentMap() + { + + } + + template + ConcurrentMap::~ConcurrentMap() noexcept + { + SILENT_CATCH(Clear()); + } + + template + void ConcurrentMap::Remove(K key) + { + Lock(); + _map.erase(key); + Unlock(); + } + + template + V ConcurrentMap::Get(K key) + { + V value = 0; + + Lock(); + typename std::map< K, V >::const_iterator it = _map.find(key); + if (it != _map.end()) + { + value = it->second; + } + Unlock(); + + return value; + } + + template + void ConcurrentMap::Set(K key, V value) + { + Lock(); + _map[key] = value; + Unlock(); + } + + template + void ConcurrentMap::Clear() + { + Lock(); + _map.clear(); + Unlock(); + } + + template + size_t ConcurrentMap::GetSize() + { + Lock(); + const size_t size = _map.size(); + Unlock(); + + return size; + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/Enum.hpp b/include/ocilibcpp/detail/core/Enum.hpp new file mode 100644 index 00000000..92f6b96e --- /dev/null +++ b/include/ocilibcpp/detail/core/Enum.hpp @@ -0,0 +1,82 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + Enum::Enum() : _value(static_cast(0)) + { + } + + template + Enum::Enum(T value) : _value(value) + { + } + + template + T Enum::GetValue() + { + return _value; + } + + template + Enum::operator T () + { + return GetValue(); + } + + template + Enum::operator unsigned int() const + { + return static_cast(_value); + } + + template + bool Enum::operator == (const Enum& other) const + { + return other._value == _value; + } + + template + bool Enum::operator != (const Enum& other) const + { + return !(*this == other); + } + + template + bool Enum::operator == (const T& other) const + { + return other == _value; + } + + template + bool Enum::operator != (const T& other) const + { + return !(*this == other); + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/Flags.hpp b/include/ocilibcpp/detail/core/Flags.hpp new file mode 100644 index 00000000..7c69d9d0 --- /dev/null +++ b/include/ocilibcpp/detail/core/Flags.hpp @@ -0,0 +1,168 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + Flags::Flags() : _flags(static_cast(0)) + { + } + + template + Flags::Flags(T flag) : _flags(flag) + { + } + + template + Flags::Flags(const Flags& other) : _flags(other._flags) + { + } + + template + Flags::Flags(unsigned int flag) : _flags(static_cast(flag)) + { + } + + template + Flags& Flags::operator = (const Flags& other) noexcept + { + if (this != &other) + { + _flags = other._flags; + } + + return *this; + } + + template + Flags Flags::operator~ () const + { + return Flags(~_flags); + } + + template + Flags Flags::operator | (const Flags& other) const + { + return Flags(_flags | other._flags); + } + + template + Flags Flags::operator & (const Flags& other) const + { + return Flags(_flags & other._flags); + } + + template + Flags Flags::operator ^ (const Flags& other) const + { + return Flags(_flags ^ other._flags); + } + + template + Flags Flags::operator | (T other) const + { + return Flags(_flags | other); + } + + template + Flags Flags::operator & (T other) const + { + return Flags(_flags & other); + } + + template + Flags Flags::operator ^ (T other) const + { + return Flags(_flags ^ other); + } + + template + Flags& Flags::operator |= (const Flags& other) + { + _flags |= other._flags; + return *this; + } + + template + Flags& Flags::operator &= (const Flags& other) + { + _flags &= other._flags; + return *this; + } + + template + Flags& Flags::operator ^= (const Flags& other) + { + _flags ^= other._flags; + return *this; + } + + template + Flags& Flags::operator |= (T other) + { + _flags |= other; + return *this; + } + + template + Flags& Flags::operator &= (T other) + { + _flags &= other; + return *this; + } + + template + Flags& Flags::operator ^= (T other) + { + _flags ^= other; + return *this; + } + + template + bool Flags::operator == (T other) const + { + return _flags == static_cast(other); + } + + template + bool Flags::operator == (const Flags& other) const + { + return _flags == other._flags; + } + + template + bool Flags::IsSet(T other) const + { + return ((_flags & other) == _flags); + } + + template + unsigned int Flags::GetValues() const + { + return _flags; + } + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/HandleHolder.hpp b/include/ocilibcpp/detail/core/HandleHolder.hpp new file mode 100644 index 00000000..d19682ad --- /dev/null +++ b/include/ocilibcpp/detail/core/HandleHolder.hpp @@ -0,0 +1,144 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + HandleHolder::HandleHolder() : _smartHandle(nullptr) + { + } + + template + HandleHolder::HandleHolder(const HandleHolder& other) : _smartHandle(nullptr) + { + Acquire(other, nullptr, nullptr, other._smartHandle ? other._smartHandle->GetParent() : nullptr); + } + + template + HandleHolder::~HandleHolder() noexcept + { + SILENT_CATCH(Release()) + } + + template + HandleHolder& HandleHolder::operator= (const HandleHolder& other) noexcept + { + if (this != &other) + { + Handle* parent = other._smartHandle ? other._smartHandle->GetParent() : nullptr; + SILENT_CATCH(Acquire(other, nullptr, nullptr, parent)) + } + return *this; + } + + template + bool HandleHolder::IsNull() const + { + return (static_cast(*this) == 0); + } + + template + HandleHolder::operator T() + { + return _smartHandle ? _smartHandle->GetHandle() : nullptr; + } + + template + HandleHolder::operator T() const + { + return _smartHandle ? _smartHandle->GetHandle() : nullptr; + } + + template + HandleHolder::operator bool() + { + return !IsNull(); + } + + template + HandleHolder::operator bool() const + { + return !IsNull(); + } + + template + Handle* HandleHolder::GetHandle() const + { + return static_cast(_smartHandle); + } + + template + void HandleHolder::Acquire(T handle, HandleFreeFunc handleFreefunc, SmartHandleFreeNotifyFunc freeNotifyFunc, Handle* parent) + { + if (_smartHandle && _smartHandle->GetHandle() == handle) + { + return; + } + + Release(); + + if (handle) + { + _smartHandle = Environment::GetSmartHandle(handle); + + if (!_smartHandle) + { + _smartHandle = OnAllocate(new SmartHandle(this, handle, handleFreefunc, freeNotifyFunc, parent)); + } + else + { + _smartHandle->Acquire(this); + } + } + } + + template + void HandleHolder::Acquire(HandleHolder& other) + { + if (&other != this && _smartHandle != other._smartHandle) + { + Release(); + + if (other._smartHandle) + { + other._smartHandle->Acquire(this); + _smartHandle = other._smartHandle; + } + } + } + + template + void HandleHolder::Release() + { + if (_smartHandle) + { + _smartHandle->Release(this); + } + + _smartHandle = nullptr; + } + } +} diff --git a/include/ocilibcpp/detail/core/Lockable.hpp b/include/ocilibcpp/detail/core/Lockable.hpp new file mode 100644 index 00000000..d32679ef --- /dev/null +++ b/include/ocilibcpp/detail/core/Lockable.hpp @@ -0,0 +1,61 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + inline Lockable::Lockable() : _locker(nullptr) + { + + } + + inline Lockable::~Lockable() noexcept + { + + } + + inline void Lockable::Lock() const + { + if (_locker) + { + _locker->Lock(); + } + } + + inline void Lockable::Unlock() const + { + if (_locker) + { + _locker->Unlock(); + } + } + + inline void Lockable::SetLocker(Locker* locker) + { + _locker = locker; + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/Locker.hpp b/include/ocilibcpp/detail/core/Locker.hpp new file mode 100644 index 00000000..9eeebf94 --- /dev/null +++ b/include/ocilibcpp/detail/core/Locker.hpp @@ -0,0 +1,69 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + inline Locker::Locker() : _mutex(nullptr) + { + SetAccessMode(false); + } + + inline Locker::~Locker() noexcept + { + SILENT_CATCH(SetAccessMode(false)); + } + + inline void Locker::SetAccessMode(bool threaded) + { + if (threaded && !_mutex) + { + _mutex = Mutex::Create(); + } + else if (!threaded && _mutex) + { + Mutex::Destroy(_mutex); + _mutex = nullptr; + } + } + + inline void Locker::Lock() const + { + if (_mutex) + { + Mutex::Acquire(_mutex); + } + } + + inline void Locker::Unlock() const + { + if (_mutex) + { + Mutex::Release(_mutex); + } + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/ManagedBuffer.hpp b/include/ocilibcpp/detail/core/ManagedBuffer.hpp new file mode 100644 index 00000000..a81e83d5 --- /dev/null +++ b/include/ocilibcpp/detail/core/ManagedBuffer.hpp @@ -0,0 +1,57 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + core::ManagedBuffer::ManagedBuffer() : _buffer(nullptr), _size(0) + { + } + + template + core::ManagedBuffer::ManagedBuffer(T* buffer, size_t size) : _buffer(buffer), _size(size) + { + } + + template + core::ManagedBuffer::ManagedBuffer(size_t size) : _buffer(core::OnAllocate(new T[size], size)), _size(size) + { + memset(_buffer, 0, sizeof(T) * _size); + } + template + core::ManagedBuffer::~ManagedBuffer() noexcept + { + delete core::OnDeallocate(_buffer); + } + + template + core::ManagedBuffer::operator T* () + { + return _buffer; + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/MemoryDebugInfo.hpp b/include/ocilibcpp/detail/core/MemoryDebugInfo.hpp new file mode 100644 index 00000000..e1ae3294 --- /dev/null +++ b/include/ocilibcpp/detail/core/MemoryDebugInfo.hpp @@ -0,0 +1,90 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +namespace ocilib +{ + namespace core + { +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + + struct MemoryAllocation + { + void* Address; + const char* Name; + size_t Size; + size_t Count; + }; + + class MemoryDebugInfo + { + private: + std::vector Allocations; + public: + + template + void OnAllocate(T* address, size_t count) + { + Allocations.push_back({ address, typeid(T).name(), sizeof(T), count }); + } + + template + void OnDeallocate(T* address) + { + auto it = std::find_if(std::begin(Allocations), std::end(Allocations), [address](const auto& alloc) + { + return alloc.Address == address; + }); + if (it != std::end(Allocations)) + { + Allocations.erase(it); + } + } + + void PrintAllocations() + { + if (Allocations.empty()) return; + + std::cout << "Unfreed memory found" << std::endl; + + for (auto& alloc : Allocations) + { + std::cout << "=> Address " << alloc.Address + << " - Size " << alloc.Count + << " - Count " << alloc.Size + << " - Type " << alloc.Name + << std::endl; + } + } + }; + + inline MemoryDebugInfo& GetMemoryDebugInfo() + { + static MemoryDebugInfo memoryDebugInfo; + + return memoryDebugInfo; + } + +#endif + } +} diff --git a/include/ocilibcpp/detail/core/SmartHandle.hpp b/include/ocilibcpp/detail/core/SmartHandle.hpp new file mode 100644 index 00000000..b81825ac --- /dev/null +++ b/include/ocilibcpp/detail/core/SmartHandle.hpp @@ -0,0 +1,171 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + + template + HandleHolder::SmartHandle::SmartHandle + ( + HandleHolder* holder, T handle, HandleFreeFunc handleFreefunc, + SmartHandleFreeNotifyFunc freeNotifyFunc, Handle* parent + ) + : _holders(), _handle(handle), _handleFreeFunc(handleFreefunc), + _freeNotifyFunc(freeNotifyFunc), _parent(parent), _extraInfo(nullptr) + { + _locker.SetAccessMode((Environment::GetMode() & Environment::Threaded) == Environment::Threaded); + + _holders.SetLocker(&_locker); + _children.SetLocker(&_locker); + + Environment::SetSmartHandle(handle, this); + + Acquire(holder); + + if (_parent && _handle) + { + _parent->GetChildren().Add(this); + } + } + + template + HandleHolder::SmartHandle::~SmartHandle() noexcept + { + SILENT_CATCH((Destroy())) + } + + template + void HandleHolder::SmartHandle::Destroy() + { + if (_parent && _handle) + { + _parent->GetChildren().Remove(this); + } + + _children.ForEach(DeleteHandle); + _children.Clear(); + + _holders.SetLocker(nullptr); + _children.SetLocker(nullptr); + + Environment::SetSmartHandle(_handle, nullptr); + + if (_freeNotifyFunc) + { + _freeNotifyFunc(this); + } + + if (_handleFreeFunc && _handle) + { + _handleFreeFunc(_handle); + } + } + + template + void HandleHolder::SmartHandle::DeleteHandle(Handle* handle) + { + if (handle) + { + handle->DetachFromParent(); + handle->DetachFromHolders(); + + delete core::OnDeallocate(handle); + } + } + + template + void HandleHolder::SmartHandle::ResetHolder(HandleHolder* holder) + { + if (holder) + { + holder->_smartHandle = nullptr; + } + } + + template + void HandleHolder::SmartHandle::Acquire(HandleHolder* holder) + { + _holders.Add(holder); + } + + template + void HandleHolder::SmartHandle::Release(HandleHolder* holder) + { + _holders.Remove(holder); + + if (_holders.GetSize() == 0) + { + delete core::OnDeallocate(this); + } + + holder->_smartHandle = nullptr; + } + + template + T HandleHolder::SmartHandle::GetHandle() const + { + return _handle; + } + + template + Handle* HandleHolder::SmartHandle::GetParent() const + { + return _parent; + } + + template + AnyPointer HandleHolder::SmartHandle::GetExtraInfos() const + { + return _extraInfo; + } + + template + void HandleHolder::SmartHandle::SetExtraInfos(AnyPointer extraInfo) + { + _extraInfo = extraInfo; + } + + template + ConcurrentList& HandleHolder::SmartHandle::GetChildren() + { + return _children; + } + + template + void HandleHolder::SmartHandle::DetachFromHolders() + { + _holders.ForEach(ResetHolder); + _holders.Clear(); + } + + template + void HandleHolder::SmartHandle::DetachFromParent() + { + _parent = nullptr; + } + + } +} \ No newline at end of file diff --git a/include/ocilibcpp/detail/core/Utils.hpp b/include/ocilibcpp/detail/core/Utils.hpp new file mode 100644 index 00000000..6291075b --- /dev/null +++ b/include/ocilibcpp/detail/core/Utils.hpp @@ -0,0 +1,111 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace core + { + template + static T* OnAllocate(T* address, size_t count = 1) + { +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + GetMemoryDebugInfo().OnAllocate(address, count); +#endif + + return address; + } + + template + static T* OnDeallocate(T* address) + { +#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED + GetMemoryDebugInfo().OnDeallocate(address); +#endif + + return address; + } + + template + T Check(T result) + { + OCI_Error* err = OCI_GetLastError(); + + if (err) + { + throw Exception(err); + } + + return result; + } + + inline ostring MakeString(const otext* result, int size) + { + return result ? (size >= 0 ? ostring(result, result + size) : ostring(result)) : ostring(); + } + + inline Raw MakeRaw(AnyPointer result, unsigned int size) + { + unsigned char* ptr = static_cast(result); + + return (ptr && size > 0 ? Raw(ptr, ptr + size) : Raw()); + } + + inline unsigned int ComputeCharMaxSize(Environment::CharsetMode charsetMode) + { + const int UTF8_BytesPerChar = 4; + + unsigned int res = sizeof(ostring::value_type); + + if (charsetMode == Environment::CharsetAnsi) + { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4996) +#endif + char* str = getenv("NLS_LANG"); + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + if (str) + { + std::string nlsLang = str; + + for (char &i :nlsLang) + { + i = static_cast(toupper(i)); + } + + if (ostring::npos != nlsLang.find("UTF8")) + { + res = UTF8_BytesPerChar; + } + } + } + + return res; + } + } +} diff --git a/include/ocilibcpp/detail/support/BindArray.hpp b/include/ocilibcpp/detail/support/BindArray.hpp new file mode 100644 index 00000000..84586247 --- /dev/null +++ b/include/ocilibcpp/detail/support/BindArray.hpp @@ -0,0 +1,265 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/support.hpp" + +// ReSharper disable CppClangTidyModernizePassByValue + +namespace ocilib +{ + namespace support + { + inline BindArray::BindArray(const Statement& statement, const ostring& name, unsigned int mode) : BindObject(statement, name, mode), _object(nullptr) + { + + } + + template + void BindArray::SetVector(std::vector& vector, bool isPlSqlTable, unsigned int elemSize) + { + _object = core::OnAllocate(new BindArrayObject(_statement, GetName(), vector, isPlSqlTable, GetMode(), elemSize)); + } + + inline BindArray::~BindArray() noexcept + { + delete core::OnDeallocate(_object); + } + + template + typename BindResolver::OutputType* BindArray::GetData() const + { + return static_cast::OutputType*>(*(dynamic_cast*> (_object))); + } + + inline void BindArray::SetInData() + { + + if (GetMode() & OCI_BDM_IN || _object->IsHandleObject()) + { + _object->SetInData(); + } + } + + inline void BindArray::SetOutData() + { + if (GetMode() & OCI_BDM_OUT) + { + _object->SetOutData(); + } + } + + inline unsigned int BindArray::GetSize() const + { + return _object ? _object->GetSize() : _statement.GetBindArraySize(); + } + + inline unsigned int BindArray::GetSizeForBindCall() const + { + return _object ? _object->GetSizeForBindCall() : 0; + } + + + template + BindArray::BindArrayObject::BindArrayObject(const Statement& statement, const ostring& name, ObjectVector& vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize) + : _statement(statement), _name(name), _vector(vector), _data(nullptr), _isPlSqlTable(isPlSqlTable), _mode(mode), _elemCount(BindArrayObject::GetSize()), _elemSize(elemSize) + { + AllocData(); + } + + template + BindArray::BindArrayObject::~BindArrayObject() noexcept + { + FreeData(); + } + + template + void BindArray::BindArrayObject::AllocData() + { + _data = core::OnAllocate(new NativeType[_elemCount], _elemCount); + + memset(_data, 0, sizeof(NativeType) * _elemCount); + } + + template<> + inline void BindArray::BindArrayObject::AllocData() + { + const size_t count = _elemSize * _elemCount; + + _data = core::OnAllocate(new otext[count], count); + + memset(_data, 0, count * sizeof(otext)); + } + + template<> + inline void BindArray::BindArrayObject ::AllocData() + { + const size_t count = _elemSize * _elemCount; + + _data = core::OnAllocate(new unsigned char[count], count); + + memset(_data, 0, count * sizeof(unsigned char)); + } + + template + void BindArray::BindArrayObject::FreeData() const + { + delete[] core::OnDeallocate(_data); + } + + template + void BindArray::BindArrayObject::SetInData() + { + typename ObjectVector::iterator it, it_end; + + unsigned int index = 0; + const unsigned int currElemCount = GetSize(); + + for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) + { + _data[index] = static_cast(*it); + } + } + + template<> + inline void BindArray::BindArrayObject::SetInData() + { + std::vector::iterator it, it_end; + + unsigned int index = 0; + const unsigned int currElemCount = GetSize(); + + for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) + { + const ostring& value = *it; + + memcpy(_data + (_elemSize * index), value.c_str(), (value.size() + 1) * sizeof(otext)); + } + } + + template<> + inline void BindArray::BindArrayObject::SetInData() + { + std::vector::iterator it, it_end; + + unsigned int index = 0; + const unsigned int currElemCount = GetSize(); + + for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) + { + Raw& value = *it; + + if (!value.empty()) + { + memcpy(_data + (_elemSize * index), &value[0], value.size()); + } + + OCI_BindSetDataSizeAtPos(OCI_GetBind2(_statement, GetName().c_str()), index + 1, static_cast(value.size())); + } + } + + template + void BindArray::BindArrayObject::SetOutData() + { + typename ObjectVector::iterator it, it_end; + + unsigned int index = 0; + const unsigned int currElemCount = GetSize(); + + for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) + { + *it = static_cast(_data[index]); + } + } + + template<> + inline void BindArray::BindArrayObject::SetOutData() + { + std::vector::iterator it, it_end; + + OCI_Bind* pBind = core::Check(OCI_GetBind2(_statement, GetName().c_str())); + + unsigned int index = 0; + const unsigned int currElemCount = GetSize(); + + for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) + { + otext* currData = _data + (_elemSize * sizeof(otext) * index); + + (*it).assign(currData, currData + core::Check(OCI_BindGetDataSizeAtPos(pBind, index + 1))); + } + } + + template<> + inline void BindArray::BindArrayObject::SetOutData() + { + std::vector::iterator it, it_end; + + OCI_Bind* pBind = core::Check(OCI_GetBind2(_statement, GetName().c_str())); + + unsigned int index = 0; + const unsigned int currElemCount = GetSize(); + + for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) + { + unsigned char* currData = _data + (_elemSize * index); + + (*it).assign(currData, currData + core::Check(OCI_BindGetDataSizeAtPos(pBind, index + 1))); + } + } + + template + ostring BindArray::BindArrayObject::GetName() const + { + return _name; + } + + template + bool BindArray::BindArrayObject::IsHandleObject() const + { + return BindResolver::IsHandle; + } + + template + unsigned int BindArray::BindArrayObject::GetSize() const + { + return _isPlSqlTable ? static_cast(_vector.size()) : _statement.GetBindArraySize(); + } + + template + unsigned int BindArray::BindArrayObject::GetSizeForBindCall() const + { + return _isPlSqlTable ? static_cast(_vector.size()) : 0; + } + + template + BindArray::BindArrayObject::operator ObjectVector& () const + { + return _vector; + } + + template + BindArray::BindArrayObject::operator NativeType* () const + { + return _data; + } + } +} diff --git a/include/ocilibcpp/detail/support/BindObject.hpp b/include/ocilibcpp/detail/support/BindObject.hpp new file mode 100644 index 00000000..5bc04650 --- /dev/null +++ b/include/ocilibcpp/detail/support/BindObject.hpp @@ -0,0 +1,54 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/support.hpp" + + // ReSharper disable CppClangTidyModernizePassByValue + +namespace ocilib +{ + namespace support + { + inline BindObject::BindObject(const Statement& statement, const ostring& name, unsigned int mode) : _statement(statement), _name(name), _mode(mode) + { + } + + inline BindObject::~BindObject() noexcept + { + } + + inline ostring BindObject::GetName() const + { + return _name; + } + + inline Statement BindObject::GetStatement() const + { + return _statement; + } + + inline unsigned int BindObject::GetMode() const + { + return _mode; + } + } +} diff --git a/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp b/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp new file mode 100644 index 00000000..5f251c10 --- /dev/null +++ b/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp @@ -0,0 +1,84 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/support.hpp" + +namespace ocilib +{ + namespace support + { + template + void BindObjectAdaptor::SetInData() + { + if (GetMode() & OCI_BDM_IN) + { + size_t size = _object.size(); + + if (size > _size) + { + size = _size; + } + + if (size > 0) + { + memcpy(_data, &_object[0], size * sizeof(NativeType)); + } + + _data[size] = 0; + } + } + + template + void BindObjectAdaptor::SetOutData() + { + if (GetMode() & OCI_BDM_OUT) + { + OCI_Bind* bnd = core::Check(OCI_GetBind2(_statement, _name.c_str())); + size_t size = core::Check(OCI_BindGetDataSize(bnd)); + + _object.assign(_data, _data + size); + } + } + + template + BindObjectAdaptor::BindObjectAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object, unsigned int size) : + BindObject(statement, name, mode), + _object(object), + _data(core::OnAllocate(new NativeType[size + 1], size + 1)), + _size(size) + { + memset(_data, 0, (_size + 1) * sizeof(NativeType)); + } + + template + BindObjectAdaptor::~BindObjectAdaptor() noexcept + { + delete core::OnDeallocate(_data); + } + + template + BindObjectAdaptor::operator NativeType* () const + { + return _data; + } + } +} diff --git a/include/ocilibcpp/detail/support/BindResolver.hpp b/include/ocilibcpp/detail/support/BindResolver.hpp new file mode 100644 index 00000000..b9493916 --- /dev/null +++ b/include/ocilibcpp/detail/support/BindResolver.hpp @@ -0,0 +1,83 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/support.hpp" + +namespace ocilib +{ + namespace support + { + /** + * + * @brief Resolve a bind input / output types + * + */ + template + struct BindResolverType + { + typedef I InputType; + typedef O OutputType; + static const bool IsHandle = B; + }; + + /** + * + * @brief Simplified resolver for scalar types that do not need translation + * + */ + template + struct BindResolverScalarType : BindResolverType {}; + + /** + * + * @brief Simplified resolver for handle types + * + */ + template + struct BindResolverHandleType : BindResolverType {}; + + template<> struct BindResolver : BindResolverType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverScalarType {}; + template<> struct BindResolver : BindResolverType {}; + template<> struct BindResolver : BindResolverType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + } +} diff --git a/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp b/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp new file mode 100644 index 00000000..9b0cd07a --- /dev/null +++ b/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp @@ -0,0 +1,86 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/support.hpp" + +namespace ocilib +{ + namespace support + { + template + void BindTypeAdaptor::SetInData() + { + if (GetMode() & OCI_BDM_IN) + { + *_data = static_cast(_object); + } + } + + template + void BindTypeAdaptor::SetOutData() + { + if (GetMode() & OCI_BDM_OUT) + { + _object = static_cast(*_data); + } + } + + template + BindTypeAdaptor::BindTypeAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object) : + BindObject(statement, name, mode), + _object(object), + _data(core::OnAllocate(new NativeType)) + { + + } + + template + BindTypeAdaptor::~BindTypeAdaptor() noexcept + { + delete core::OnDeallocate(_data); + } + + template + BindTypeAdaptor::operator NativeType* () const + { + return _data; + } + + template<> + inline void BindTypeAdaptor::SetInData() + { + if (GetMode() & OCI_BDM_IN) + { + *_data = (_object == true); + } + } + + template<> + inline void BindTypeAdaptor::SetOutData() + { + if (GetMode() & OCI_BDM_OUT) + { + _object = (*_data == TRUE); + } + } + } +} diff --git a/include/ocilibcpp/detail/support/BindsHolder.hpp b/include/ocilibcpp/detail/support/BindsHolder.hpp new file mode 100644 index 00000000..0f4626fa --- /dev/null +++ b/include/ocilibcpp/detail/support/BindsHolder.hpp @@ -0,0 +1,92 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/support.hpp" + +namespace ocilib +{ + namespace support + { + inline BindsHolder::BindsHolder(const Statement& statement) : _statement(statement) + { + + } + + inline BindsHolder::~BindsHolder() noexcept + { + Clear(); + } + + inline void BindsHolder::Clear() + { + std::vector::iterator it, it_end; + + for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) + { + delete core::OnDeallocate(*it); + } + + _bindObjects.clear(); + } + + inline void BindsHolder::AddBindObject(BindObject* bindObject) + { + if (core::Check(OCI_IsRebindingAllowed(_statement))) + { + std::vector::iterator it, it_end; + + for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) + { + BindObject* previousBindObject = *it; + if (previousBindObject->GetName() == bindObject->GetName()) + { + _bindObjects.erase(it); + delete core::OnDeallocate(previousBindObject); + break; + } + } + } + + _bindObjects.push_back(bindObject); + } + + inline void BindsHolder::SetOutData() + { + std::vector::iterator it, it_end; + + for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) + { + (*it)->SetOutData(); + } + } + + inline void BindsHolder::SetInData() + { + std::vector::iterator it, it_end; + + for (it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) + { + (*it)->SetInData(); + } + } + } +} diff --git a/include/ocilibcpp/detail/support/NumericTypeResolver.hpp b/include/ocilibcpp/detail/support/NumericTypeResolver.hpp new file mode 100644 index 00000000..43125fb3 --- /dev/null +++ b/include/ocilibcpp/detail/support/NumericTypeResolver.hpp @@ -0,0 +1,45 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/config.hpp" + +namespace ocilib +{ + namespace support + { + /** + * @brief Allow resolving a the C API numeric enumerated type from a C++ type + */ + template struct NumericTypeResolver {}; + + template<> struct NumericTypeResolver { enum { Value = NumericNumber }; }; + template<> struct NumericTypeResolver { enum { Value = NumericNumber }; }; + template<> struct NumericTypeResolver { enum { Value = NumericShort }; }; + template<> struct NumericTypeResolver { enum { Value = NumericUnsignedShort }; }; + template<> struct NumericTypeResolver { enum { Value = NumericInt }; }; + template<> struct NumericTypeResolver { enum { Value = NumericUnsignedInt }; }; + template<> struct NumericTypeResolver { enum { Value = NumericBigInt }; }; + template<> struct NumericTypeResolver { enum { Value = NumericUnsignedBigInt }; }; + template<> struct NumericTypeResolver { enum { Value = NumericDouble }; }; + template<> struct NumericTypeResolver { enum { Value = NumericFloat }; }; + } +} diff --git a/include/ocilibcpp/impl.hpp b/include/ocilibcpp/impl.hpp deleted file mode 100644 index 5a51fca7..00000000 --- a/include/ocilibcpp/impl.hpp +++ /dev/null @@ -1,7445 +0,0 @@ -/* - * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) - * - * Website: http://www.ocilib.net - * - * Copyright (c) 2007-2020 Vincent ROGIER - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * IMPORTANT NOTICE - * - * This C++ header defines C++ wrapper classes around the OCILIB C API - * It requires a compatible version of OCILIB - * - */ - -// -// ReSharper inspection rules customization (mainly for C98 backward compatibility) -// -// ReSharper disable CppUseAuto -// ReSharper disable CppParameterMayBeConst -// ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage -// ReSharper disable CppClangTidyModernizeReturnBracedInitList -// ReSharper disable CppClangTidyModernizePassByValue -// ReSharper disable CppClangTidyHicppUseAuto -// ReSharper disable CppClangTidyModernizeUseAuto -// ReSharper disable CppClangTidyReadabilityInconsistentDeclarationParameterName -// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam -// ReSharper disable CppClangTidyHicppUseEqualsDefault -// ReSharper disable CppClangTidyModernizeLoopConvert -// ReSharper disable CppClangTidyModernizeUseEmplace -// ReSharper disable CppClangTidyModernizeUseEqualsDefault -// ReSharper disable CppClangTidyHicppUseEmplace -// ReSharper disable CppClangTidyCertOop54Cpp -// ReSharper disable CppClangTidyMiscMisplacedConst -// ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment -// - -#pragma once - -#include - -namespace ocilib -{ - -/* ********************************************************************************************* * - * IMPLEMENTATION - * ********************************************************************************************* */ - -#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED - -struct MemoryAllocation -{ - void* Address; - const char* Name; - size_t Size; - size_t Count; -}; - -class MemoryDebugInfo -{ -private: - std::vector Allocations; -public: - - template - void OnAllocate(T* address, size_t count) - { - Allocations.push_back({ address, typeid(T).name(), sizeof(T), count }); - } - - template - void OnDeallocate(T* address) - { - auto it = std::find_if(std::begin(Allocations), std::end(Allocations), [address](const auto& alloc) - { - return alloc.Address == address; - }); - if (it != std::end(Allocations)) - { - Allocations.erase(it); - } - } - - void PrintAllocations() - { - if (Allocations.empty()) return; - - std::cout << "Unfreed memory found" << std::endl; - - for (auto& alloc : Allocations) - { - std::cout << "=> Address " << alloc.Address - << " - Size " << alloc.Count - << " - Count " << alloc.Size - << " - Type " << alloc.Name - << std::endl; - } - } -}; - -inline MemoryDebugInfo& GetMemoryDebugInfo() -{ - static MemoryDebugInfo memoryDebugInfo; - - return memoryDebugInfo; -} - -#endif - -template -static T* OnAllocate(T* address, size_t count = 1) -{ -#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED - GetMemoryDebugInfo().OnAllocate(address, count); -#endif - - return address; -} - -template -static T* OnDeallocate(T* address) -{ -#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED - GetMemoryDebugInfo().OnDeallocate(address); -#endif - - return address; -} - - /** - * Catch silently any exception thrown in the given expression - * Used for compliance with the standard (copy constructor, assignment operator, destructor) - * - */ -#define SILENT_CATCH(exp) try { exp; } catch (...) {} - -/** -* -* @brief -* Class handling LONG oracle type -* -* @note -* Length and size arguments / returned values are expressed in number of characters -* -*/ -typedef Long Clong; - -/** -* -* @brief -* Class handling LONG RAW oracle type -* -* @note -* Length and size arguments / returned values are expressed in number of bytes -* -*/ -typedef Long Blong; - -/** -* -* @brief Resolve a bind input / output types -* -*/ -template -struct BindResolverType -{ - typedef I InputType; - typedef O OutputType; - static const bool IsHandle = B; -}; - -/** -* -* @brief Simplified resolver for scalar types that do not need translation -* -*/ -template -struct BindResolverScalarType : BindResolverType {}; - -/** -* -* @brief Simplified resolver for handle types -* -*/ -template -struct BindResolverHandleType : BindResolverType {}; - -template<> struct BindResolver : BindResolverType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverScalarType{}; -template<> struct BindResolver : BindResolverType{}; -template<> struct BindResolver : BindResolverType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; -template<> struct BindResolver : BindResolverHandleType{}; - -/** -* @brief Allow resolving a the C API numeric enumerated type from a C++ type -*/ -template struct NumericTypeResolver{}; - -template<> struct NumericTypeResolver { enum { Value = NumericNumber }; }; -template<> struct NumericTypeResolver { enum { Value = NumericNumber }; }; -template<> struct NumericTypeResolver { enum { Value = NumericShort }; }; -template<> struct NumericTypeResolver { enum { Value = NumericUnsignedShort }; }; -template<> struct NumericTypeResolver { enum { Value = NumericInt }; }; -template<> struct NumericTypeResolver { enum { Value = NumericUnsignedInt }; }; -template<> struct NumericTypeResolver { enum { Value = NumericBigInt }; }; -template<> struct NumericTypeResolver { enum { Value = NumericUnsignedBigInt }; }; -template<> struct NumericTypeResolver { enum { Value = NumericDouble }; }; -template<> struct NumericTypeResolver { enum { Value = NumericFloat }; }; - -template -T Check(T result) -{ - OCI_Error *err = OCI_GetLastError(); - - if (err) - { - throw Exception(err); - } - - return result; -} - -inline ostring MakeString(const otext *result, int size) -{ - return result ? (size >= 0 ? ostring(result, result + size) : ostring(result)) : ostring(); -} - -inline Raw MakeRaw(AnyPointer result, unsigned int size) -{ - unsigned char *ptr = static_cast(result); - - return (ptr && size > 0 ? Raw(ptr, ptr + size) : Raw()); -} - -inline unsigned int ComputeCharMaxSize(Environment::CharsetMode charsetMode) -{ - const int UTF8_BytesPerChar = 4; - - unsigned int res = sizeof(ostring::value_type); - - if (charsetMode == Environment::CharsetAnsi) - { -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4996) -#endif - char *str = getenv("NLS_LANG"); - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - if (str) - { - std::string nlsLang = str; - - for (size_t i = 0, count = nlsLang.size(); i < count; ++i) - { - nlsLang[i] = static_cast(toupper(nlsLang[i])); - } - - if (ostring::npos != nlsLang.find("UTF8")) - { - res = UTF8_BytesPerChar; - } - } - } - - return res; -} - -/* --------------------------------------------------------------------------------------------- * - * Enum - * --------------------------------------------------------------------------------------------- */ - -template -Enum::Enum() : _value(static_cast(0)) -{ -} - -template -Enum::Enum(T value) : _value(value) -{ -} - -template -T Enum::GetValue() -{ - return _value; -} - -template -Enum::operator T () -{ - return GetValue(); -} - -template -Enum::operator unsigned int () const -{ - return static_cast(_value); -} - -template -bool Enum::operator == (const Enum& other) const -{ - return other._value == _value; -} - -template -bool Enum::operator != (const Enum& other) const -{ - return !(*this == other); -} - -template -bool Enum::operator == (const T& other) const -{ - return other == _value; -} - -template -bool Enum::operator != (const T& other) const -{ - return !(*this == other); -} - -/* --------------------------------------------------------------------------------------------- * - * Flags - * --------------------------------------------------------------------------------------------- */ - -template -Flags::Flags() : _flags(static_cast(0)) -{ -} - -template -Flags::Flags(T flag) : _flags( flag) -{ -} - -template -Flags::Flags(const Flags& other) : _flags(other._flags) -{ -} - -template -Flags::Flags(unsigned int flag) : _flags(static_cast(flag)) -{ -} - -template -Flags& Flags::operator = (const Flags& other) noexcept -{ - if (this != &other) - { - _flags = other._flags; - } - - return *this; -} - -template -Flags Flags::operator~ () const -{ - return Flags(~_flags); -} - -template -Flags Flags::operator | (const Flags& other) const -{ - return Flags(_flags | other._flags); -} - -template -Flags Flags::operator & (const Flags& other) const -{ - return Flags(_flags & other._flags); -} - -template -Flags Flags::operator ^ (const Flags& other) const -{ - return Flags(_flags ^ other._flags); -} - -template -Flags Flags::operator | (T other) const -{ - return Flags(_flags | other); -} - -template -Flags Flags::operator & (T other) const -{ - return Flags(_flags & other); -} - -template -Flags Flags::operator ^ (T other) const -{ - return Flags(_flags ^ other); -} - -template -Flags& Flags::operator |= (const Flags& other) -{ - _flags |= other._flags; - return *this; -} - -template -Flags& Flags::operator &= (const Flags& other) -{ - _flags &= other._flags; - return *this; -} - -template -Flags& Flags::operator ^= (const Flags& other) -{ - _flags ^= other._flags; - return *this; -} - -template -Flags& Flags::operator |= (T other) -{ - _flags |= other; - return *this; -} - -template -Flags& Flags::operator &= (T other) -{ - _flags &= other; - return *this; -} - -template -Flags& Flags::operator ^= (T other) -{ - _flags ^= other; - return *this; -} - -template -bool Flags::operator == (T other) const -{ - return _flags == static_cast(other); -} - -template -bool Flags::operator == (const Flags& other) const -{ - return _flags == other._flags; -} - -template -bool Flags::IsSet(T other) const -{ - return ((_flags & other) == _flags); -} - -template -unsigned int Flags::GetValues() const -{ - return _flags; -} - -#define OCI_DEFINE_FLAG_OPERATORS(T) \ -inline Flags operator | (T a, T b) { return Flags(a) | Flags(b); } \ - -OCI_DEFINE_FLAG_OPERATORS(Environment::EnvironmentFlagsValues) -OCI_DEFINE_FLAG_OPERATORS(Environment::SessionFlagsValues) -OCI_DEFINE_FLAG_OPERATORS(Environment::StartFlagsValues) -OCI_DEFINE_FLAG_OPERATORS(Environment::StartModeValues) -OCI_DEFINE_FLAG_OPERATORS(Environment::ShutdownModeValues) -OCI_DEFINE_FLAG_OPERATORS(Environment::ShutdownFlagsValues) -OCI_DEFINE_FLAG_OPERATORS(Environment::AllocatedBytesValues) -OCI_DEFINE_FLAG_OPERATORS(Transaction::TransactionFlagsValues) -OCI_DEFINE_FLAG_OPERATORS(Column::PropertyFlagsValues) -OCI_DEFINE_FLAG_OPERATORS(Subscription::ChangeTypesValues) - -/* --------------------------------------------------------------------------------------------- * - * ManagedBuffer - * --------------------------------------------------------------------------------------------- */ - -template -ManagedBuffer::ManagedBuffer() : _buffer(nullptr), _size(0) -{ -} - -template -ManagedBuffer::ManagedBuffer(T *buffer, size_t size) : _buffer(buffer), _size(size) -{ -} - -template -ManagedBuffer::ManagedBuffer(size_t size) : _buffer(OnAllocate(new T[size], size)), _size(size) -{ - memset(_buffer, 0, sizeof(T) * _size); -} -template -ManagedBuffer::~ManagedBuffer() noexcept -{ - delete OnDeallocate(_buffer); -} - -template -ManagedBuffer::operator T* () -{ - return _buffer; -} - -/* --------------------------------------------------------------------------------------------- * - * Handle - * --------------------------------------------------------------------------------------------- */ - -template -HandleHolder::HandleHolder() : _smartHandle(nullptr) -{ -} - -template -HandleHolder::HandleHolder(const HandleHolder &other) : _smartHandle(nullptr) -{ - Acquire(other, nullptr, nullptr, other._smartHandle ? other._smartHandle->GetParent() : nullptr); -} - -template -HandleHolder::~HandleHolder() noexcept -{ - SILENT_CATCH(Release()) -} - -template -HandleHolder& HandleHolder::operator= (const HandleHolder &other) noexcept -{ - if (this != &other) - { - Handle* parent = other._smartHandle ? other._smartHandle->GetParent() : nullptr; - SILENT_CATCH(Acquire(other, nullptr, nullptr, parent)) - } - return *this; -} - -template -bool HandleHolder::IsNull() const -{ - return (static_cast(*this) == 0); -} - -template -HandleHolder::operator T() -{ - return _smartHandle ? _smartHandle->GetHandle() : nullptr; -} - -template -HandleHolder::operator T() const -{ - return _smartHandle ? _smartHandle->GetHandle() : nullptr; -} - -template -HandleHolder::operator bool() -{ - return !IsNull(); -} - -template -HandleHolder::operator bool() const -{ - return !IsNull(); -} - -template -Handle * HandleHolder::GetHandle() const -{ - return static_cast(_smartHandle); -} - -template -void HandleHolder::Acquire(T handle, HandleFreeFunc handleFreefunc, SmartHandleFreeNotifyFunc freeNotifyFunc, Handle *parent) -{ - if (_smartHandle && _smartHandle->GetHandle() == handle) - { - return; - } - - Release(); - - if (handle) - { - _smartHandle = Environment::GetSmartHandle(handle); - - if (!_smartHandle) - { - _smartHandle = OnAllocate(new SmartHandle(this, handle, handleFreefunc, freeNotifyFunc, parent)); - } - else - { - _smartHandle->Acquire(this); - } - } -} - -template -void HandleHolder::Acquire(HandleHolder &other) -{ - if (&other != this && _smartHandle != other._smartHandle) - { - Release(); - - if (other._smartHandle) - { - other._smartHandle->Acquire(this); - _smartHandle = other._smartHandle; - } - } -} - -template -void HandleHolder::Release() -{ - if (_smartHandle) - { - _smartHandle->Release(this); - } - - _smartHandle = nullptr; -} - -inline Locker::Locker() : _mutex(nullptr) -{ - SetAccessMode(false); -} - -inline Locker::~Locker() noexcept -{ - SILENT_CATCH(SetAccessMode(false)); -} - -inline void Locker::SetAccessMode(bool threaded) -{ - if (threaded && !_mutex) - { - _mutex = Mutex::Create(); - } - else if (!threaded && _mutex) - { - Mutex::Destroy(_mutex); - _mutex = nullptr; - } -} - -inline void Locker::Lock() const -{ - if (_mutex) - { - Mutex::Acquire(_mutex); - } -} - -inline void Locker::Unlock() const -{ - if (_mutex) - { - Mutex::Release(_mutex); - } -} - -inline Lockable::Lockable() : _locker(nullptr) -{ - -} - -inline Lockable::~Lockable() noexcept -{ - -} - -inline void Lockable::Lock() const -{ - if (_locker) - { - _locker->Lock(); - } -} - -inline void Lockable::Unlock() const -{ - if (_locker) - { - _locker->Unlock(); - } -} - -inline void Lockable::SetLocker(Locker *locker) -{ - _locker = locker; -} - -template -ConcurrentMap::ConcurrentMap() -{ - -} - -template -ConcurrentMap::~ConcurrentMap() noexcept -{ - SILENT_CATCH(Clear()); -} - -template -void ConcurrentMap::Remove(K key) -{ - Lock(); - _map.erase(key); - Unlock(); -} - -template -V ConcurrentMap::Get(K key) -{ - V value = 0; - - Lock(); - typename std::map< K, V >::const_iterator it = _map.find(key); - if (it != _map.end()) - { - value = it->second; - } - Unlock(); - - return value; -} - -template -void ConcurrentMap::Set(K key, V value) -{ - Lock(); - _map[key] = value; - Unlock(); -} - -template -void ConcurrentMap::Clear() -{ - Lock(); - _map.clear(); - Unlock(); -} - -template -size_t ConcurrentMap::GetSize() -{ - Lock(); - const size_t size = _map.size(); - Unlock(); - - return size; -} - -template -ConcurrentList::ConcurrentList() : _list() -{ - -} - -template -ConcurrentList::~ConcurrentList() noexcept -{ - SILENT_CATCH(Clear()) -} - -template -void ConcurrentList::Add(T value) -{ - Lock(); - _list.push_back(value); - Unlock(); -} - -template -void ConcurrentList::Remove(T value) -{ - Lock(); - _list.remove(value); - Unlock(); -} - -template -void ConcurrentList::Clear() -{ - Lock(); - _list.clear(); - Unlock(); -} - -template -size_t ConcurrentList::GetSize() -{ - Lock(); - const size_t size = _list.size(); - Unlock(); - - return size; -} - -template -bool ConcurrentList::Exists(const T &value) -{ - Lock(); - - const bool res = std::find(_list.begin(), _list.end(), value) != _list.end(); - - Unlock(); - - return res; -} - -template -template -bool ConcurrentList::FindIf(P predicate, T &value) -{ - bool res = false; - - Lock(); - - typename std::list::iterator it = std::find_if(_list.begin(), _list.end(), predicate); - - if (it != _list.end()) - { - value = *it; - res = true; - } - - Unlock(); - - return res; -} - -template -template -void ConcurrentList::ForEach(A action) -{ - Lock(); - - std::for_each(_list.begin(), _list.end(), action); - - Unlock(); -} - -template -HandleHolder::SmartHandle::SmartHandle -( - HandleHolder *holder, T handle, HandleFreeFunc handleFreefunc, - SmartHandleFreeNotifyFunc freeNotifyFunc, Handle *parent -) - : _holders(), _handle(handle), _handleFreeFunc(handleFreefunc), - _freeNotifyFunc(freeNotifyFunc), _parent(parent), _extraInfo(nullptr) -{ - _locker.SetAccessMode((Environment::GetMode() & Environment::Threaded) == Environment::Threaded); - - _holders.SetLocker(&_locker); - _children.SetLocker(&_locker); - - Environment::SetSmartHandle(handle, this); - - Acquire(holder); - - if (_parent && _handle) - { - _parent->GetChildren().Add(this); - } -} - -template -HandleHolder::SmartHandle::~SmartHandle() noexcept -{ - SILENT_CATCH((Destroy())) -} - -template -void HandleHolder::SmartHandle::Destroy() -{ - if (_parent && _handle) - { - _parent->GetChildren().Remove(this); - } - - _children.ForEach(DeleteHandle); - _children.Clear(); - - _holders.SetLocker(nullptr); - _children.SetLocker(nullptr); - - Environment::SetSmartHandle(_handle, nullptr); - - if (_freeNotifyFunc) - { - _freeNotifyFunc(this); - } - - if (_handleFreeFunc && _handle) - { - _handleFreeFunc(_handle); - } -} - -template -void HandleHolder::SmartHandle::DeleteHandle(Handle *handle) -{ - if (handle) - { - handle->DetachFromParent(); - handle->DetachFromHolders(); - - delete OnDeallocate(handle); - } -} - -template -void HandleHolder::SmartHandle::ResetHolder(HandleHolder *holder) -{ - if (holder) - { - holder->_smartHandle = nullptr; - } -} - -template -void HandleHolder::SmartHandle::Acquire(HandleHolder *holder) -{ - _holders.Add(holder); -} - -template -void HandleHolder::SmartHandle::Release(HandleHolder *holder) -{ - _holders.Remove(holder); - - if (_holders.GetSize() == 0) - { - delete OnDeallocate(this); - } - - holder->_smartHandle = nullptr; -} - -template -T HandleHolder::SmartHandle::GetHandle() const -{ - return _handle; -} - -template -Handle * HandleHolder::SmartHandle::GetParent() const -{ - return _parent; -} - -template -AnyPointer HandleHolder::SmartHandle::GetExtraInfos() const -{ - return _extraInfo; -} - -template -void HandleHolder::SmartHandle::SetExtraInfos(AnyPointer extraInfo) -{ - _extraInfo = extraInfo; -} - -template -ConcurrentList & HandleHolder::SmartHandle::GetChildren() -{ - return _children; -} - -template -void HandleHolder::SmartHandle::DetachFromHolders() -{ - _holders.ForEach(ResetHolder); - _holders.Clear(); -} - -template -void HandleHolder::SmartHandle::DetachFromParent() -{ - _parent = nullptr; -} - -/* --------------------------------------------------------------------------------------------- * - * Exception - * --------------------------------------------------------------------------------------------- */ - -inline Exception::Exception() noexcept - : _what(nullptr), - _pStatement(nullptr), - _pConnnection(nullptr), - _row(0), - _type(static_cast(0)), - _errLib(0), - _errOracle(0) -{ - -} - -inline Exception::Exception(OCI_Error *err) noexcept - : _what(nullptr), - _pStatement(OCI_ErrorGetStatement(err)), - _pConnnection(OCI_ErrorGetConnection(err)), - _row(OCI_ErrorGetRow(err)), - _type(static_cast(OCI_ErrorGetType(err))), - _errLib(OCI_ErrorGetInternalCode(err)), - _errOracle(OCI_ErrorGetOCICode(err)) -{ - SetWhat(OCI_ErrorGetString(err)); -} - -inline Exception::Exception(const Exception& other) noexcept : Exception(nullptr) -{ - SetWhat(other._what); -} - -inline Exception::~Exception() noexcept -{ - delete [] _what; -} - -inline Exception& Exception::operator = (const Exception& other) noexcept -{ - if (this != &other) - { - _what = ostrdup(other._what); - } - - return *this; -} - -inline void Exception::SetWhat(const otext* value) noexcept -{ - if (!value) - { - return; - } - - const size_t len = ostrlen(value); - _what = new (std::nothrow) otext[len + 1]; - if (_what) - { - memcpy(_what, value, (len + 1) * (sizeof(otext))); - } -} - -inline const char * Exception::what() const noexcept -{ - return _what; -} - -inline ostring Exception::GetMessage() const -{ - const otext* str = what(); - - return str ? str : ostring{}; -} - -inline Exception::ExceptionType Exception::GetType() const -{ - return _type; -} - -inline int Exception::GetOracleErrorCode() const -{ - return _errOracle; -} - -inline int Exception::GetInternalErrorCode() const -{ - return _errLib; -} - -inline Statement Exception::GetStatement() const -{ - return Statement(_pStatement, nullptr); -} - -inline Connection Exception::GetConnection() const -{ - return Connection(_pConnnection, nullptr); -} - -inline unsigned int Exception::GetRow() const -{ - return _row; -} - -/* --------------------------------------------------------------------------------------------- * - * Environment - * --------------------------------------------------------------------------------------------- */ - -inline void Environment::Initialize(EnvironmentFlags mode, const ostring& libpath) -{ - GetInstance().SelfInitialize(mode, libpath); -} - -inline void Environment::Cleanup() -{ - GetInstance().SelfCleanup(); - - Environment* handle = static_cast(OCI_GetUserData(nullptr)); - OCI_SetUserData(nullptr, handle); - -#ifdef OCILIBPP_DEBUG_MEMORY_ENABLED - - ocilib::GetMemoryDebugInfo().PrintAllocations(); - -#endif - -} - -inline Environment::EnvironmentFlags Environment::GetMode() -{ - return GetInstance()._mode; -} - -inline Environment::ImportMode Environment::GetImportMode() -{ - return ImportMode(static_cast(Check(OCI_GetImportMode()))); -} - -inline Environment::CharsetMode Environment::GetCharset() -{ - return CharsetMode(static_cast(Check(OCI_GetCharset()))); -} - -inline unsigned int Environment::GetCharMaxSize() -{ - return GetInstance()._charMaxSize; -} - -inline big_uint Environment::GetAllocatedBytes(AllocatedBytesFlags type) -{ - return Check(OCI_GetAllocatedBytes(type.GetValues())); -} - -inline bool Environment::Initialized() -{ - return GetInstance()._initialized; -} - -inline OracleVersion Environment::GetCompileVersion() -{ - return OracleVersion(static_cast(Check(OCI_GetOCICompileVersion()))); -} - -inline OracleVersion Environment::GetRuntimeVersion() -{ - return OracleVersion(static_cast(Check(OCI_GetOCIRuntimeVersion()))); -} - -inline unsigned int Environment::GetCompileMajorVersion() -{ - return OCI_VER_MAJ(Check(OCI_GetOCICompileVersion())); -} - -inline unsigned int Environment::GetCompileMinorVersion() -{ - return OCI_VER_MIN(Check(OCI_GetOCICompileVersion())); -} - -inline unsigned int Environment::GetCompileRevisionVersion() -{ - return OCI_VER_REV(Check(OCI_GetOCICompileVersion())); -} - -inline unsigned int Environment::GetRuntimeMajorVersion() -{ - return OCI_VER_MAJ(Check(OCI_GetOCIRuntimeVersion())); -} - -inline unsigned int Environment::GetRuntimeMinorVersion() -{ - return OCI_VER_MIN(Check(OCI_GetOCIRuntimeVersion())); -} - -inline unsigned int Environment::GetRuntimeRevisionVersion() -{ - return OCI_VER_REV(Check(OCI_GetOCIRuntimeVersion())); -} - -inline void Environment::EnableWarnings(bool value) -{ - OCI_EnableWarnings(static_cast(value)); -} - -inline bool Environment::SetFormat(FormatType formatType, const ostring& format) -{ - return Check(OCI_SetFormat(nullptr, formatType, format.c_str()) == TRUE); -} - -inline ostring Environment::GetFormat(FormatType formatType) -{ - return MakeString(Check(OCI_GetFormat(nullptr, formatType))); -} - -inline void Environment::StartDatabase(const ostring& db, const ostring& user, const ostring &pwd, Environment::StartFlags startFlags, - Environment::StartMode startMode, Environment::SessionFlags sessionFlags, const ostring& spfile) -{ - Check(OCI_DatabaseStartup(db.c_str(), user.c_str(), pwd.c_str(), sessionFlags.GetValues(), - startMode.GetValues(), startFlags.GetValues(), spfile.c_str() )); -} - -inline void Environment::ShutdownDatabase(const ostring& db, const ostring& user, const ostring &pwd, Environment::ShutdownFlags shutdownFlags, - Environment::ShutdownMode shutdownMode, Environment::SessionFlags sessionFlags) -{ - Check(OCI_DatabaseShutdown(db.c_str(), user.c_str(), pwd.c_str(), sessionFlags.GetValues(), - shutdownMode.GetValues(), shutdownFlags.GetValues() )); -} - -inline void Environment::ChangeUserPassword(const ostring& db, const ostring& user, const ostring& pwd, const ostring& newPwd) -{ - Check(OCI_SetUserPassword(db.c_str(), user.c_str(), pwd.c_str(), newPwd.c_str())); -} - -inline void Environment::SetHAHandler(HAHandlerProc handler) -{ - Check(OCI_SetHAHandler(static_cast(handler != nullptr ? Environment::HAHandler : nullptr))); - - SetUserCallback(GetEnvironmentHandle(), handler); -} - -inline void Environment::HAHandler(OCI_Connection *pConnection, unsigned int source, unsigned int event, OCI_Timestamp *pTimestamp) -{ - const HAHandlerProc handler = GetUserCallback(GetEnvironmentHandle()); - - if (handler) - { - Connection connection(pConnection, nullptr); - Timestamp timestamp(pTimestamp, connection.GetHandle()); - - handler(connection, - HAEventSource(static_cast(source)), - HAEventType (static_cast (event)), - timestamp); - } -} - -inline unsigned int Environment::TAFHandler(OCI_Connection *pConnection, unsigned int type, unsigned int event) -{ - unsigned int res = OCI_FOC_OK; - - const Connection::TAFHandlerProc handler = GetUserCallback(Check(pConnection)); - - if (handler) - { - Connection connection(pConnection, nullptr); - - res = handler(connection, - Connection::FailoverRequest( static_cast (type)), - Connection::FailoverEvent ( static_cast (event))); - } - - return res; -} - -inline void Environment::NotifyHandler(OCI_Event *pEvent) -{ - const Subscription::NotifyHandlerProc handler = GetUserCallback((Check(OCI_EventGetSubscription(pEvent)))); - - if (handler) - { - Event evt(pEvent); - handler(evt); - } -} - -inline void Environment::NotifyHandlerAQ(OCI_Dequeue *pDequeue) -{ - const Dequeue::NotifyAQHandlerProc handler = GetUserCallback(Check(pDequeue)); - - if (handler) - { - Dequeue dequeue(pDequeue); - handler(dequeue); - } -} - -template -T Environment::GetUserCallback(AnyPointer ptr) -{ - return reinterpret_cast(GetInstance()._callbacks.Get(ptr)); -} - -template -void Environment::SetUserCallback(AnyPointer ptr, T callback) -{ - if (callback) - { - GetInstance()._callbacks.Set(ptr, reinterpret_cast(callback)); - } - else - { - GetInstance()._callbacks.Remove(ptr); - } -} - -template -void Environment::SetSmartHandle(AnyPointer ptr, T handle) -{ - if (handle) - { - GetInstance()._handles.Set(ptr, handle); - } - else - { - GetInstance()._handles.Remove(ptr); - } -} - -template -T Environment::GetSmartHandle(AnyPointer ptr) -{ - return dynamic_cast(GetInstance()._handles.Get(ptr)); -} - -inline Handle * Environment::GetEnvironmentHandle() -{ - return GetInstance()._handle.GetHandle(); -} - -inline Environment& Environment::GetInstance() -{ - Environment* handle = static_cast(OCI_GetUserData(nullptr)); - if (handle != nullptr) - { - return *handle; - } - - static Environment environment; - - OCI_SetUserData(nullptr,&environment); - - return environment; -} - -inline Environment::Environment() : _charMaxSize(0), _initialized(false) -{ - -} - -inline void Environment::SelfInitialize(EnvironmentFlags mode, const ostring& libpath) -{ - _mode = mode; - - Check(OCI_Initialize(nullptr, libpath.c_str(), _mode.GetValues() | OCI_ENV_CONTEXT)); - - _initialized = true; - - _locker.SetAccessMode((_mode & Environment::Threaded) == Environment::Threaded); - - _callbacks.SetLocker(&_locker); - _handles.SetLocker(&_locker); - - _handle.Acquire(const_cast(Check(OCI_HandleGetEnvironment())), nullptr, nullptr, nullptr); - - _charMaxSize = ComputeCharMaxSize(GetCharset()); -} - -inline void Environment::SelfCleanup() -{ - _locker.SetAccessMode(false); - - _callbacks.SetLocker(nullptr); - _handles.SetLocker(nullptr); - - _handle.Release(); - - if (_initialized) - { - Check(OCI_Cleanup()); - } - - _initialized = false; -} - -/* --------------------------------------------------------------------------------------------- * - * Mutex - * --------------------------------------------------------------------------------------------- */ - -inline MutexHandle Mutex::Create() -{ - return Environment::GetInstance().Initialized() ? Check(OCI_MutexCreate()) : nullptr; -} - -inline void Mutex::Destroy(MutexHandle handle) -{ - Check(OCI_MutexFree(handle)); -} - -inline void Mutex::Acquire(MutexHandle handle) -{ - Check(OCI_MutexAcquire(handle)); -} - -inline void Mutex::Release(MutexHandle handle) -{ - Check(OCI_MutexRelease(handle)); -} - -/* --------------------------------------------------------------------------------------------- * - * Thread - * --------------------------------------------------------------------------------------------- */ - -inline ThreadHandle Thread::Create() -{ - return Check(OCI_ThreadCreate()); -} - -inline void Thread::Destroy(ThreadHandle handle) -{ - Check(OCI_ThreadFree(handle)); -} - -inline void Thread::Run(ThreadHandle handle, ThreadProc func, AnyPointer arg) -{ - Check(OCI_ThreadRun(handle, func, arg)); -} - -inline void Thread::Join(ThreadHandle handle) -{ - Check(OCI_ThreadJoin(handle)); -} - -inline ThreadId Thread::GetThreadId(ThreadHandle handle) -{ - return Check(OCI_HandleGetThreadID(handle)); -} - -/* --------------------------------------------------------------------------------------------- * - * ThreadKey - * --------------------------------------------------------------------------------------------- */ - -inline void ThreadKey::Create(const ostring& name, ThreadKeyFreeProc freeProc) -{ - Check(OCI_ThreadKeyCreate(name.c_str(), freeProc)); -} - -inline void ThreadKey::SetValue(const ostring& name, AnyPointer value) -{ - Check(OCI_ThreadKeySetValue(name.c_str(), value)); -} - -inline AnyPointer ThreadKey::GetValue(const ostring& name) -{ - return Check(OCI_ThreadKeyGetValue(name.c_str())); -} - -/* --------------------------------------------------------------------------------------------- * - * Pool - * --------------------------------------------------------------------------------------------- */ - -inline Pool::Pool() -{ - -} - -inline Pool::Pool(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, - unsigned int minSize, unsigned int maxSize, unsigned int increment, Environment::SessionFlags sessionFlags) -{ - Open(db, user, pwd, poolType, minSize, maxSize, increment, sessionFlags); -} - -inline void Pool::Open(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, - unsigned int minSize, unsigned int maxSize, unsigned int increment, Environment::SessionFlags sessionFlags) -{ - Release(); - - Acquire(Check(OCI_PoolCreate(db.c_str(), user.c_str(), pwd.c_str(), poolType, sessionFlags.GetValues(), - minSize, maxSize, increment)), reinterpret_cast(OCI_PoolFree), nullptr, Environment::GetEnvironmentHandle()); -} - -inline void Pool::Close() -{ - Release(); -} - -inline Connection Pool::GetConnection(const ostring& sessionTag) -{ - return Connection(Check( OCI_PoolGetConnection(*this, sessionTag.c_str())), GetHandle()); -} - -inline unsigned int Pool::GetTimeout() const -{ - return Check( OCI_PoolGetTimeout(*this)); -} - -inline void Pool::SetTimeout(unsigned int value) -{ - Check( OCI_PoolSetTimeout(*this, value)); -} - -inline bool Pool::GetNoWait() const -{ - return (Check( OCI_PoolGetNoWait(*this)) == TRUE); -} - -inline void Pool::SetNoWait(bool value) -{ - Check( OCI_PoolSetNoWait(*this, value)); -} - -inline unsigned int Pool::GetBusyConnectionsCount() const -{ - return Check( OCI_PoolGetBusyCount(*this)); -} - -inline unsigned int Pool::GetOpenedConnectionsCount() const -{ - return Check( OCI_PoolGetOpenedCount(*this)); -} - -inline unsigned int Pool::GetMinSize() const -{ - return Check( OCI_PoolGetMin(*this)); -} - -inline unsigned int Pool::GetMaxSize() const -{ - return Check( OCI_PoolGetMax(*this)); -} - -inline unsigned int Pool::GetIncrement() const -{ - return Check( OCI_PoolGetIncrement(*this)); -} - -inline unsigned int Pool::GetStatementCacheSize() const -{ - return Check( OCI_PoolGetStatementCacheSize(*this)); -} - -inline void Pool::SetStatementCacheSize(unsigned int value) -{ - Check( OCI_PoolSetStatementCacheSize(*this, value)); -} - -/* --------------------------------------------------------------------------------------------- * - * Connection - * --------------------------------------------------------------------------------------------- */ - -inline Connection::Connection() -{ - -} - -inline Connection::Connection(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags) -{ - Open(db, user, pwd, sessionFlags); -} - -inline Connection::Connection(OCI_Connection *con, Handle *parent) -{ - Acquire(con, reinterpret_cast(parent ? OCI_ConnectionFree : nullptr), nullptr, parent); -} - -inline void Connection::Open(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags) -{ - Acquire(Check(OCI_ConnectionCreate(db.c_str(), user.c_str(), pwd.c_str(), sessionFlags.GetValues())), - reinterpret_cast(OCI_ConnectionFree), nullptr, Environment::GetEnvironmentHandle()); -} - -inline void Connection::Close() -{ - Release(); -} - -inline void Connection::Commit() -{ - Check(OCI_Commit(*this)); -} - -inline void Connection::Rollback() -{ - Check(OCI_Rollback(*this)); -} - -inline void Connection::Break() -{ - Check(OCI_Break(*this)); -} - -inline void Connection::SetAutoCommit(bool enabled) -{ - Check(OCI_SetAutoCommit(*this, enabled)); -} - -inline bool Connection::GetAutoCommit() const -{ - return (Check(OCI_GetAutoCommit(*this)) == TRUE); -} - -inline bool Connection::IsServerAlive() const -{ - return (Check(OCI_IsConnected(*this)) == TRUE); -} - -inline bool Connection::PingServer() const -{ - return( Check(OCI_Ping(*this)) == TRUE); -} - -inline ostring Connection::GetConnectionString() const -{ - return MakeString(Check(OCI_GetDatabase(*this))); -} - -inline ostring Connection::GetUserName() const -{ - return MakeString(Check(OCI_GetUserName(*this))); -} - -inline ostring Connection::GetPassword() const -{ - return MakeString(Check(OCI_GetPassword(*this))); -} - -inline OracleVersion Connection::GetVersion() const -{ - return OracleVersion(static_cast(Check(OCI_GetVersionConnection(*this)))); -} - -inline ostring Connection::GetServerVersion() const -{ - return MakeString(Check( OCI_GetVersionServer(*this))); -} - -inline unsigned int Connection::GetServerMajorVersion() const -{ - return Check(OCI_GetServerMajorVersion(*this)); -} - -inline unsigned int Connection::GetServerMinorVersion() const -{ - return Check(OCI_GetServerMinorVersion(*this)); -} - -inline unsigned int Connection::GetServerRevisionVersion() const -{ - return Check(OCI_GetServerRevisionVersion(*this)); -} - -inline void Connection::ChangePassword(const ostring& newPwd) -{ - Check(OCI_SetPassword(*this, newPwd.c_str())); -} - -inline ostring Connection::GetSessionTag() const -{ - return MakeString(Check(OCI_GetSessionTag(*this))); -} - -inline void Connection::SetSessionTag(const ostring& tag) -{ - Check(OCI_SetSessionTag(*this, tag.c_str())); -} - -inline Transaction Connection::GetTransaction() const -{ - return Transaction(Check(OCI_GetTransaction(*this))); -} - -inline void Connection::SetTransaction(const Transaction &transaction) -{ - Check(OCI_SetTransaction(*this, transaction)); -} - -inline bool Connection::SetFormat(FormatType formatType, const ostring& format) -{ - return Check(OCI_SetFormat(*this, formatType, format.c_str()) == TRUE); -} - -inline ostring Connection::GetFormat(FormatType formatType) -{ - return MakeString(Check(OCI_GetFormat(*this, formatType))); -} - -inline void Connection::EnableServerOutput(unsigned int bufsize, unsigned int arrsize, unsigned int lnsize) -{ - Check(OCI_ServerEnableOutput(*this, bufsize, arrsize, lnsize)); -} - -inline void Connection::DisableServerOutput() -{ - Check(OCI_ServerDisableOutput(*this)); -} - -inline bool Connection::GetServerOutput(ostring &line) const -{ - const otext * str = Check(OCI_ServerGetOutput(*this)); - - line = MakeString(str); - - return (str != nullptr); -} - -inline void Connection::GetServerOutput(std::vector &lines) const -{ - const otext * str = Check(OCI_ServerGetOutput(*this)); - - while (str) - { - lines.push_back(str); - str = Check(OCI_ServerGetOutput(*this)); - } -} - -inline void Connection::SetTrace(SessionTrace trace, const ostring& value) -{ - Check(OCI_SetTrace(*this, trace, value.c_str())); -} - -inline ostring Connection::GetTrace(SessionTrace trace) const -{ - return MakeString(Check(OCI_GetTrace(*this, trace))); -} - -inline ostring Connection::GetDatabase() const -{ - return MakeString(Check(OCI_GetDBName(*this))); -} - -inline ostring Connection::GetInstance() const -{ - return Check(OCI_GetInstanceName(*this)); -} - -inline ostring Connection::GetService() const -{ - return MakeString(Check(OCI_GetServiceName(*this))); -} - -inline ostring Connection::GetServer() const -{ - return Check(OCI_GetServerName(*this)); -} - -inline ostring Connection::GetDomain() const -{ - return MakeString(Check(OCI_GetDomainName(*this))); -} - -inline Timestamp Connection::GetInstanceStartTime() const -{ - return Timestamp(Check(OCI_GetInstanceStartTime(*this)), GetHandle()); -} - -inline unsigned int Connection::GetStatementCacheSize() const -{ - return Check(OCI_GetStatementCacheSize(*this)); -} - -inline void Connection::SetStatementCacheSize(unsigned int value) -{ - Check(OCI_SetStatementCacheSize(*this, value)); -} - -inline unsigned int Connection::GetDefaultLobPrefetchSize() const -{ - return Check(OCI_GetDefaultLobPrefetchSize(*this)); -} - -inline void Connection::SetDefaultLobPrefetchSize(unsigned int value) -{ - Check(OCI_SetDefaultLobPrefetchSize(*this, value)); -} - -inline unsigned int Connection::GetMaxCursors() const -{ - return Check(OCI_GetMaxCursors(*this)); -} - -inline bool Connection::IsTAFCapable() const -{ - return (Check(OCI_IsTAFCapable(*this)) == TRUE); -} - -inline void Connection::SetTAFHandler(TAFHandlerProc handler) -{ - Check(OCI_SetTAFHandler(*this, static_cast(handler != nullptr ? Environment::TAFHandler : nullptr))); - - Environment::SetUserCallback(static_cast(*this), handler); -} - -inline AnyPointer Connection::GetUserData() -{ - return Check(OCI_GetUserData(*this)); -} - -inline void Connection::SetUserData(AnyPointer value) -{ - Check(OCI_SetUserData(*this, value)); -} - -inline unsigned int Connection::GetTimeout(TimeoutType timeout) -{ - return Check(OCI_GetTimeout(*this, timeout)); -} - -inline void Connection::SetTimeout(TimeoutType timeout, unsigned int value) -{ - Check(OCI_SetTimeout(*this, timeout, value)); -} - -/* --------------------------------------------------------------------------------------------- * - * Transaction - * --------------------------------------------------------------------------------------------- */ - -inline Transaction::Transaction(const Connection &connection, unsigned int timeout, TransactionFlags flags, OCI_XID *pxid) -{ - Acquire(Check(OCI_TransactionCreate(connection, timeout, flags.GetValues(), pxid)), reinterpret_cast(OCI_TransactionFree), nullptr, nullptr); -} - -inline Transaction::Transaction(OCI_Transaction *trans) -{ - Acquire(trans, nullptr, nullptr, nullptr); -} - -inline void Transaction::Prepare() -{ - Check(OCI_TransactionPrepare(*this)); -} - -inline void Transaction::Start() -{ - Check(OCI_TransactionStart(*this)); -} - -inline void Transaction::Stop() -{ - Check(OCI_TransactionStop(*this)); -} - -inline void Transaction::Resume() -{ - Check(OCI_TransactionResume(*this)); -} - -inline void Transaction::Forget() -{ - Check(OCI_TransactionForget(*this)); -} - -inline Transaction::TransactionFlags Transaction::GetFlags() const -{ - return TransactionFlags(static_cast(Check(OCI_TransactionGetMode(*this)))); -} - -inline unsigned int Transaction::GetTimeout() const -{ - return Check(OCI_TransactionGetTimeout(*this)); -} - -/* --------------------------------------------------------------------------------------------- * -* Number -* --------------------------------------------------------------------------------------------- */ - -inline Number::Number(bool create) -{ - if (create) - { - Allocate(); - } -} - -inline Number::Number(OCI_Number *pNumber, Handle *parent) -{ - Acquire(pNumber, nullptr, nullptr, parent); -} - -inline Number::Number(const ostring& str, const ostring& format) -{ - Allocate(); - - FromString(str, format); -} - -inline Number::Number(const otext* str, const otext* format) -{ - Allocate(); - - FromString(str, format); -} - -inline void Number::Allocate() -{ - Acquire(Check(OCI_NumberCreate(nullptr)), reinterpret_cast(OCI_NumberFree), nullptr, nullptr); -} - -inline void Number::FromString(const ostring& str, const ostring& format) const -{ - Check(OCI_NumberFromText(*this, str.c_str(), format.empty() ? Environment::GetFormat(FormatNumeric).c_str() : format.c_str())); -} - -inline ostring Number::ToString(const ostring& format) const -{ - if (!IsNull()) - { - const size_t size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_NumberToText(*this, format.c_str(), static_cast(size), buffer)); - - return MakeString(static_cast(buffer)); - } - - return OCI_STRING_NULL; -} - -inline ostring Number::ToString() const -{ - return ToString(Environment::GetFormat(FormatNumeric)); -} - -inline Number Number::Clone() const -{ - Number result; - - result.Allocate(); - - Check(OCI_NumberAssign(result, *this)); - - return result; -} - -template -AnyPointer Number::GetNativeValue(const T& value) -{ - return reinterpret_cast(const_cast(&value)); -} - -template<> -inline AnyPointer Number::GetNativeValue(const Number& value) -{ - return (reinterpret_cast(Check(OCI_NumberGetContent(value)))); -} - -inline int Number::Compare(const Number& other) const -{ - return Check(OCI_NumberCompare(*this, other)); -} - -template -T Number::GetValue() const -{ - T value; - - Check(OCI_NumberGetValue(*this, NumericTypeResolver::Value, &value)); - - return value; -} - -template -Number& Number::SetValue(const T &value) -{ - if (IsNull()) - { - Allocate(); - } - - Check(OCI_NumberSetValue(*this, NumericTypeResolver::Value, GetNativeValue(value))); - - return *this; -} - -template -void Number::Add(const T &value) -{ - Check(OCI_NumberAdd(*this, NumericTypeResolver::Value, GetNativeValue(value))); -} - -template -void Number::Sub(const T &value) -{ - Check(OCI_NumberSub(*this, NumericTypeResolver::Value, GetNativeValue(value))); -} - -template -void Number::Multiply(const T &value) -{ - Check(OCI_NumberMultiply(*this, NumericTypeResolver::Value, GetNativeValue(value))); -} - -template -void Number::Divide(const T &value) -{ - Check(OCI_NumberDivide(*this, NumericTypeResolver::Value, GetNativeValue(value))); -} - -inline Number& Number::operator = (OCI_Number * &lhs) -{ - Acquire(lhs, reinterpret_cast(OCI_NumberFree), nullptr, nullptr); - return *this; -} - -template::Type::type*> -Number& Number::operator = (const T &lhs) -{ - SetValue(lhs); - return *this; -} - -template::Type::type*> -Number::operator T() const -{ - return GetValue(); -} - -template::Type::type*> -Number Number::operator + (const T &value) -{ - Number result = Clone(); - result.Add(value); - return result; -} - -template::Type::type*> -Number Number::operator - (const T &value) -{ - Number result = Clone(); - result.Sub(value); - return result; -} - -template::Type::type*> -Number Number::operator * (const T &value) -{ - Number result = Clone(); - result.Multiply(value); - return result; -} - -template::Type::type*> -Number Number::operator / (const T &value) -{ - Number result = Clone(); - result.Divide(value); - return result; -} - -template::Type::type*> -Number& Number::operator += (const T &value) -{ - Add(value); - return *this; -} - -template::Type::type*> -Number& Number::operator -= (const T &value) -{ - Sub(value); - return *this; -} - -template::Type::type*> -Number& Number::operator *= (const T &value) -{ - Multiply(value); - return *this; -} - -template::Type::type*> -Number& Number::operator /= (const T &value) -{ - Divide(value); - return *this; -} - -inline Number& Number::operator ++ () -{ - return *this += 1; -} - -inline Number& Number::operator -- () -{ - return *this += 1; -} - -inline Number Number::operator ++ (int) -{ - return *this + 1; -} - -inline Number Number::operator -- (int) -{ - return *this - 1; -} - -inline bool Number::operator == (const Number& other) const -{ - return Compare(other) == 0; -} - -inline bool Number::operator != (const Number& other) const -{ - return !(*this == other); -} - -inline bool Number::operator > (const Number& other) const -{ - return Compare(other) > 0; -} - -inline bool Number::operator < (const Number& other) const -{ - return Compare(other) < 0; -} - -inline bool Number::operator >= (const Number& other) const -{ - const int res = Compare(other); - - return res == 0 || res < 0; -} - -inline bool Number::operator <= (const Number& other) const -{ - const int res = Compare(other); - - return res == 0 || res > 0; -} - -/* --------------------------------------------------------------------------------------------- * - * Date - * --------------------------------------------------------------------------------------------- */ - -inline Date::Date(bool create) -{ - if (create) - { - Allocate(); - } -} - -inline Date::Date(const ostring& str, const ostring& format) -{ - Allocate(); - - FromString(str, format); -} - -inline Date::Date(const otext* str, const otext* format) -{ - Allocate(); - - FromString(str, format); -} - -inline Date::Date(OCI_Date *pDate, Handle *parent) -{ - Acquire(pDate, nullptr, nullptr, parent); -} - -inline void Date::Allocate() -{ - Acquire(Check(OCI_DateCreate(nullptr)), reinterpret_cast(OCI_DateFree), nullptr, nullptr); -} - -inline Date Date::SysDate() -{ - Date result; - - result.Allocate(); - - Check(OCI_DateSysDate(result)); - - return result; -} - -inline Date Date::Clone() const -{ - Date result; - - result.Allocate(); - - Check(OCI_DateAssign(result, *this)); - - return result; -} - -inline int Date::Compare(const Date& other) const -{ - return Check(OCI_DateCompare(*this, other)); -} - -inline bool Date::IsValid() const -{ - return (Check(OCI_DateCheck(*this)) == 0); -} - -inline int Date::GetYear() const -{ - int year = 0, month = 0, day = 0; - - GetDate(year, month, day); - - return year; -} - -inline void Date::SetYear(int value) -{ - int year = 0, month = 0, day = 0; - - GetDate(year, month, day); - SetDate(value, month, day); -} - -inline int Date::GetMonth() const -{ - int year = 0, month = 0, day = 0; - - GetDate(year, month, day); - - return month; -} - -inline void Date::SetMonth(int value) -{ - int year = 0, month = 0, day = 0; - - GetDate(year, month, day); - SetDate(year, value, day); -} - -inline int Date::GetDay() const -{ - int year = 0, month = 0, day = 0; - - GetDate(year, month, day); - - return day; -} - -inline void Date::SetDay(int value) -{ - int year = 0, month = 0, day = 0; - - GetDate(year, month, day); - SetDate(year, month, value); -} - -inline int Date::GetHours() const -{ - int hour = 0, minutes = 0, seconds = 0; - - GetTime(hour, minutes, seconds); - - return hour; -} - -inline void Date::SetHours(int value) -{ - int hour = 0, minutes = 0, seconds = 0; - - GetTime(hour, minutes, seconds); - SetTime(value, minutes, seconds); -} - -inline int Date::GetMinutes() const -{ - int hour = 0, minutes = 0, seconds = 0; - - GetTime(hour, minutes, seconds); - - return minutes; -} - -inline void Date::SetMinutes(int value) -{ - int hour = 0, minutes = 0, seconds = 0; - - GetTime(hour, minutes, seconds); - SetTime(hour, value, seconds); -} - -inline int Date::GetSeconds() const -{ - int hour = 0, minutes = 0, seconds = 0; - - GetTime(hour, minutes, seconds); - - return seconds; -} - -inline void Date::SetSeconds(int value) -{ - int hour = 0, minutes = 0, seconds = 0; - - GetTime(hour, minutes, seconds); - SetTime(hour, minutes, value); -} - -inline int Date::DaysBetween(const Date& other) const -{ - return Check(OCI_DateDaysBetween(*this, other)); -} - -inline void Date::SetDate(int year, int month, int day) -{ - Check(OCI_DateSetDate(*this, year, month, day)); -} - -inline void Date::SetTime(int hour, int min, int sec) -{ - Check(OCI_DateSetTime(*this, hour, min , sec)); -} - -inline void Date::SetDateTime(int year, int month, int day, int hour, int min, int sec) -{ - Check(OCI_DateSetDateTime(*this, year, month, day, hour, min , sec)); -} - -inline void Date::GetDate(int &year, int &month, int &day) const -{ - Check(OCI_DateGetDate(*this, &year, &month, &day)); -} - -inline void Date::GetTime(int &hour, int &min, int &sec) const -{ - Check(OCI_DateGetTime(*this, &hour, &min , &sec)); -} - -inline void Date::GetDateTime(int &year, int &month, int &day, int &hour, int &min, int &sec) const -{ - Check(OCI_DateGetDateTime(*this, &year, &month, &day, &hour, &min , &sec)); -} - -inline void Date::AddDays(int days) -{ - Check(OCI_DateAddDays(*this, days)); -} - -inline void Date::AddMonths(int months) -{ - OCI_DateAddMonths(*this, months); -} - -inline Date Date::NextDay(const ostring& day) const -{ - Date result = Clone(); - - Check(OCI_DateNextDay(result, day.c_str())); - - return result; -} - -inline Date Date::LastDay() const -{ - Date result = Clone(); - - Check(OCI_DateLastDay(result)); - - return result; -} - -inline void Date::ChangeTimeZone(const ostring& tzSrc, const ostring& tzDst) -{ - Check(OCI_DateZoneToZone(*this, tzSrc.c_str(), tzDst.c_str())); -} - -inline void Date::FromString(const ostring& str, const ostring& format) -{ - Check(OCI_DateFromText(*this, str.c_str(), format.empty() ? Environment::GetFormat(FormatDate).c_str() : format.c_str())); -} - -inline ostring Date::ToString(const ostring& format) const -{ - if (!IsNull()) - { - const size_t size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_DateToText(*this, format.c_str(), static_cast(size), buffer)); - - return MakeString(static_cast(buffer)); - } - - return OCI_STRING_NULL; -} - -inline ostring Date::ToString() const -{ - return ToString(Environment::GetFormat(FormatDate)); -} - -inline Date& Date::operator ++ () -{ - return *this += 1; -} - -inline Date Date::operator ++ (int) -{ - Date result = Clone(); - - *this += 1; - - return result; -} - -inline Date& Date::operator -- () -{ - return *this -= 1; -} - -inline Date Date::operator -- (int) -{ - Date result = Clone(); - - *this -= 1; - - return result; -} - -inline Date Date::operator + (int value) const -{ - Date result = Clone(); - return result += value; -} - -inline Date Date::operator - (int value) const -{ - Date result = Clone(); - return result -= value; -} - -inline Date& Date::operator += (int value) -{ - AddDays(value); - return *this; -} - -inline Date& Date::operator -= (int value) -{ - AddDays(-value); - return *this; -} - -inline bool Date::operator == (const Date& other) const -{ - return Compare(other) == 0; -} - -inline bool Date::operator != (const Date& other) const -{ - return !(*this == other); -} - -inline bool Date::operator > (const Date& other) const -{ - return Compare(other) > 0; -} - -inline bool Date::operator < (const Date& other) const -{ - return Compare(other) < 0; -} - -inline bool Date::operator >= (const Date& other) const -{ - const int res = Compare(other); - - return res == 0 || res > 0; -} - -inline bool Date::operator <= (const Date& other) const -{ - const int res = Compare(other); - - return res == 0 || res < 0; -} - -/* --------------------------------------------------------------------------------------------- * - * Interval - * --------------------------------------------------------------------------------------------- */ - -inline Interval::Interval() -{ -} - -inline Interval::Interval(IntervalType type) -{ - Acquire(Check(OCI_IntervalCreate(nullptr, type)), reinterpret_cast(OCI_IntervalFree), nullptr, nullptr); -} - -inline Interval::Interval(IntervalType type, const ostring& data) -{ - Acquire(Check(OCI_IntervalCreate(nullptr, type)), reinterpret_cast(OCI_IntervalFree), nullptr, nullptr); - - FromString(data); -} - -inline Interval::Interval(OCI_Interval *pInterval, Handle *parent) -{ - Acquire(pInterval, nullptr, nullptr, parent); -} - -inline Interval Interval::Clone() const -{ - Interval result(GetType()); - - Check(OCI_IntervalAssign(result, *this)); - - return result; -} - -inline int Interval::Compare(const Interval& other) const -{ - return Check(OCI_IntervalCompare(*this, other)); -} - -inline Interval::IntervalType Interval::GetType() const -{ - return IntervalType(static_cast(Check(OCI_IntervalGetType(*this)))); -} - -inline bool Interval::IsValid() const -{ - return (Check(OCI_IntervalCheck(*this)) == 0); -} - -inline int Interval::GetYear() const -{ - int year = 0, month = 0; - - GetYearMonth(year, month); - - return year; -} - -inline void Interval::SetYear(int value) -{ - int year = 0, month = 0; - - GetYearMonth(year, month); - SetYearMonth(value, month); -} - -inline int Interval::GetMonth() const -{ - int year = 0, month = 0; - - GetYearMonth(year, month); - - return month; -} - -inline void Interval::SetMonth(int value) -{ - int year = 0, month = 0; - - GetYearMonth(year, month); - SetYearMonth(year, value); -} - -inline int Interval::GetDay() const -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - - return day; -} - -inline void Interval::SetDay(int value) -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - SetDaySecond(value, hour, minutes, seconds, milliseconds); -} - -inline int Interval::GetHours() const -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - - return hour; -} - -inline void Interval::SetHours(int value) -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - SetDaySecond(day, value, minutes, seconds, milliseconds); -} - -inline int Interval::GetMinutes() const -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - - return minutes; -} - -inline void Interval::SetMinutes(int value) -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - SetDaySecond(day, hour, value, seconds, milliseconds); -} - -inline int Interval::GetSeconds() const -{ - int day, hour, minutes, seconds, milliseconds; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - - return seconds; -} - -inline void Interval::SetSeconds(int value) -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - SetDaySecond(day, hour, minutes, value, milliseconds); -} - -inline int Interval::GetMilliSeconds() const -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - - return milliseconds; -} - -inline void Interval::SetMilliSeconds(int value) -{ - int day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDaySecond(day, hour, minutes, seconds, milliseconds); - SetDaySecond(day, hour, minutes, seconds, value); -} - -inline void Interval::GetDaySecond(int &day, int &hour, int &min, int &sec, int &fsec) const -{ - Check(OCI_IntervalGetDaySecond(*this, &day, &hour, &min, &sec, &fsec)); -} - -inline void Interval::SetDaySecond(int day, int hour, int min, int sec, int fsec) -{ - Check(OCI_IntervalSetDaySecond(*this, day, hour, min, sec, fsec)); -} - -inline void Interval::GetYearMonth(int &year, int &month) const -{ - Check(OCI_IntervalGetYearMonth(*this, &year, &month)); -} -inline void Interval::SetYearMonth(int year, int month) -{ - Check(OCI_IntervalSetYearMonth(*this, year, month)); -} - -inline void Interval::UpdateTimeZone(const ostring& timeZone) -{ - Check(OCI_IntervalFromTimeZone(*this, timeZone.c_str())); -} - -inline void Interval::FromString(const ostring& data) -{ - Check(OCI_IntervalFromText(*this, data.c_str())); -} - -inline ostring Interval::ToString(int leadingPrecision, int fractionPrecision) const -{ - if (!IsNull()) - { - const size_t size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_IntervalToText(*this, leadingPrecision, fractionPrecision, static_cast(size), buffer)); - - return MakeString(static_cast(buffer)); - } - - return OCI_STRING_NULL; -} - -inline ostring Interval::ToString() const -{ - return ToString(OCI_STRING_DEFAULT_PREC, OCI_STRING_DEFAULT_PREC); -} - -inline Interval Interval::operator + (const Interval& other) const -{ - Interval result = Clone(); - return result += other; -} - -inline Interval Interval::operator - (const Interval& other) const -{ - Interval result = Clone(); - return result -= other; -} - -inline Interval& Interval::operator += (const Interval& other) -{ - Check(OCI_IntervalAdd(*this, other)); - return *this; -} - -inline Interval& Interval::operator -= (const Interval& other) -{ - Check(OCI_IntervalSubtract(*this, other)); - return *this; -} - -inline bool Interval::operator == (const Interval& other) const -{ - return Compare(other) == 0; -} - -inline bool Interval::operator != (const Interval& other) const -{ - return (!(*this == other)); -} - -inline bool Interval::operator > (const Interval& other) const -{ - return (Compare(other) > 0); -} - -inline bool Interval::operator < (const Interval& other) const -{ - return (Compare(other) < 0); -} - -inline bool Interval::operator >= (const Interval& other) const -{ - const int res = Compare(other); - - return (res == 0 || res < 0); -} - -inline bool Interval::operator <= (const Interval& other) const -{ - const int res = Compare(other); - - return (res == 0 || res > 0); -} - -/* --------------------------------------------------------------------------------------------- * - * Timestamp - * --------------------------------------------------------------------------------------------- */ - -inline Timestamp::Timestamp() -{ -} - -inline Timestamp::Timestamp(TimestampType type) -{ - Acquire(Check(OCI_TimestampCreate(nullptr, type)), reinterpret_cast(OCI_TimestampFree), nullptr, nullptr); -} - -inline Timestamp::Timestamp(TimestampType type, const ostring& data, const ostring& format) -{ - Acquire(Check(OCI_TimestampCreate(nullptr, type)), reinterpret_cast(OCI_TimestampFree), nullptr, nullptr); - FromString(data, format); -} - -inline Timestamp::Timestamp(OCI_Timestamp *pTimestamp, Handle *parent) -{ - Acquire(pTimestamp, nullptr, nullptr, parent); -} - -inline Timestamp Timestamp::Clone() const -{ - Timestamp result(GetType()); - - Check(OCI_TimestampAssign(result, *this)); - - return result; -} - -inline int Timestamp::Compare(const Timestamp& other) const -{ - return Check(OCI_TimestampCompare(*this, other)); -} - -inline Timestamp::TimestampType Timestamp::GetType() const -{ - return TimestampType(static_cast(Check(OCI_TimestampGetType(*this)))); -} - -inline void Timestamp::SetDateTime(int year, int month, int day, int hour, int min, int sec, int fsec, const ostring& timeZone) -{ - Check(OCI_TimestampConstruct(*this, year, month, day, hour, min,sec, fsec, timeZone.c_str())); -} - -inline void Timestamp::Convert(const Timestamp& other) -{ - Check(OCI_TimestampConvert(*this, other)); -} - -inline bool Timestamp::IsValid() const -{ - return (Check(OCI_TimestampCheck(*this)) == 0); -} - -inline int Timestamp::GetYear() const -{ - int year, month, day; - - GetDate(year, month, day); - - return year; -} - -inline void Timestamp::SetYear(int value) -{ - int year, month, day; - - GetDate(year, month, day); - SetDate(value, month, day); -} - -inline int Timestamp::GetMonth() const -{ - int year, month, day; - - GetDate(year, month, day); - - return month; -} - -inline void Timestamp::SetMonth(int value) -{ - int year, month, day; - - GetDate(year, month, day); - SetDate(year, value, day); -} - -inline int Timestamp::GetDay() const -{ - int year, month, day; - - GetDate(year, month, day); - - return day; -} - -inline void Timestamp::SetDay(int value) -{ - int year, month, day; - - GetDate(year, month, day); - SetDate(year, month, value); -} - -inline int Timestamp::GetHours() const -{ - int hour, minutes, seconds, milliseconds; - - GetTime(hour, minutes, seconds, milliseconds); - - return hour; -} - -inline void Timestamp::SetHours(int value) -{ - int hour, minutes, seconds, milliseconds; - - GetTime(hour, minutes, seconds, milliseconds); - SetTime(value, minutes, seconds, milliseconds); -} - -inline int Timestamp::GetMinutes() const -{ - int hour, minutes, seconds, milliseconds; - - GetTime(hour, minutes, seconds, milliseconds); - - return minutes; -} - -inline void Timestamp::SetMinutes(int value) -{ - int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetTime(hour, minutes, seconds, milliseconds); - SetTime(hour, value, seconds, milliseconds); -} - -inline int Timestamp::GetSeconds() const -{ - int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetTime(hour, minutes, seconds, milliseconds); - - return seconds; -} - -inline void Timestamp::SetSeconds(int value) -{ - int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetTime(hour, minutes, seconds, milliseconds); - SetTime(hour, minutes, value, milliseconds); -} - -inline int Timestamp::GetMilliSeconds() const -{ - int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetTime(hour, minutes, seconds, milliseconds); - - return milliseconds; -} - -inline void Timestamp::SetMilliSeconds(int value) -{ - int hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetTime(hour, minutes, seconds, milliseconds); - SetTime(hour, minutes, seconds, value); -} - -inline void Timestamp::GetDate(int &year, int &month, int &day) const -{ - Check(OCI_TimestampGetDate(*this, &year, &month, &day)); -} - -inline void Timestamp::GetTime(int &hour, int &min, int &sec, int &fsec) const -{ - Check(OCI_TimestampGetTime(*this, &hour, &min, &sec, &fsec)); -} - -inline void Timestamp::GetDateTime(int &year, int &month, int &day, int &hour, int &min, int &sec, int &fsec) const -{ - Check(OCI_TimestampGetDateTime(*this, &year, &month, &day, &hour, &min, &sec, &fsec)); -} - -inline void Timestamp::SetDate(int year, int month, int day) -{ - int tmpYear = 0, tmpMonth = 0, tempDay = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDateTime(tmpYear, tmpMonth, tempDay, hour, minutes, seconds, milliseconds); - SetDateTime(year, month, day, hour, minutes, seconds, milliseconds); -} - -inline void Timestamp::SetTime(int hour, int min, int sec, int fsec) -{ - int year = 0, month = 0, day = 0, tmpHour = 0, tmpMinutes = 0, tmpSeconds = 0, tmpMilliseconds = 0; - - GetDateTime(year, month, day, tmpHour, tmpMinutes, tmpSeconds, tmpMilliseconds); - SetDateTime(year, month, day, hour, min, sec, fsec); -} - -inline void Timestamp::SetTimeZone(const ostring& timeZone) -{ - if (GetType() == WithTimeZone) - { - int year = 0, month = 0, day = 0, hour = 0, minutes = 0, seconds = 0, milliseconds = 0; - - GetDateTime(year, month, day, hour, minutes, seconds, milliseconds); - SetDateTime(year, month, day, hour, minutes, seconds, milliseconds, timeZone); - } -} - -inline ostring Timestamp::GetTimeZone() const -{ - if (GetType() != NoTimeZone) - { - const size_t size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_TimestampGetTimeZoneName(*this, static_cast(size), buffer) == TRUE); - - return MakeString(static_cast(buffer)); - } - - return ostring(); -} - -inline void Timestamp::GetTimeZoneOffset(int &hour, int &min) const -{ - Check(OCI_TimestampGetTimeZoneOffset(*this, &hour, &min)); -} - -inline void Timestamp::Substract(const Timestamp &lsh, const Timestamp &rsh, Interval& result) -{ - Check(OCI_TimestampSubtract(lsh, rsh, result)); -} - -inline Timestamp Timestamp::SysTimestamp(TimestampType type) -{ - Timestamp result(type); - - Check(OCI_TimestampSysTimestamp(result)); - - return result; -} - -inline void Timestamp::FromString(const ostring& data, const ostring& format) -{ - Check(OCI_TimestampFromText(*this, data.c_str(), format.empty() ? Environment::GetFormat(FormatTimestamp).c_str() : format.c_str())); -} - -inline ostring Timestamp::ToString(const ostring& format, int precision = OCI_STRING_DEFAULT_PREC) const -{ - if (!IsNull()) - { - const size_t size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_TimestampToText(*this, format.c_str(), static_cast(size), buffer, precision)); - - return MakeString(static_cast(buffer)); - } - - return OCI_STRING_NULL; -} - -inline ostring Timestamp::ToString() const -{ - return ToString(Environment::GetFormat(FormatTimestamp), OCI_STRING_DEFAULT_PREC); -} - -inline Timestamp& Timestamp::operator ++ () -{ - return *this += 1; -} - -inline Timestamp Timestamp::operator ++ (int) -{ - Timestamp result = Clone(); - - *this += 1; - - return result; -} - -inline Timestamp& Timestamp::operator -- () -{ - return *this -= 1; -} - -inline Timestamp Timestamp::operator -- (int) -{ - Timestamp result = Clone(); - - *this -= 1; - - return result; -} - -inline Timestamp Timestamp::operator + (int value) const -{ - Timestamp result = Clone(); - Interval interval(Interval::DaySecond); - interval.SetDay(1); - return result += value; -} - -inline Timestamp Timestamp::operator - (int value) const -{ - Timestamp result = Clone(); - Interval interval(Interval::DaySecond); - interval.SetDay(1); - return result -= value; -} - -inline Interval Timestamp::operator - (const Timestamp& other) -{ - Interval interval(Interval::DaySecond); - Check(OCI_TimestampSubtract(*this, other, interval)); - return interval; -} - -inline Timestamp Timestamp::operator + (const Interval& other) const -{ - Timestamp result = Clone(); - return result += other; -} - -inline Timestamp Timestamp::operator - (const Interval& other) const -{ - Timestamp result = Clone(); - return result -= other; -} - -inline Timestamp& Timestamp::operator += (const Interval& other) -{ - Check(OCI_TimestampIntervalAdd(*this, other)); - return *this; -} - -inline Timestamp& Timestamp::operator -= (const Interval& other) -{ - Check(OCI_TimestampIntervalSub(*this, other)); - return *this; -} - -inline Timestamp& Timestamp::operator += (int value) -{ - Interval interval(Interval::DaySecond); - interval.SetDay(value); - return *this += interval; -} - -inline Timestamp& Timestamp::operator -= (int value) -{ - Interval interval(Interval::DaySecond); - interval.SetDay(value); - return *this -= interval; -} - -inline bool Timestamp::operator == (const Timestamp& other) const -{ - return Compare(other) == 0; -} - -inline bool Timestamp::operator != (const Timestamp& other) const -{ - return (!(*this == other)); -} - -inline bool Timestamp::operator > (const Timestamp& other) const -{ - return (Compare(other) > 0); -} - -inline bool Timestamp::operator < (const Timestamp& other) const -{ - return (Compare(other) < 0); -} - -inline bool Timestamp::operator >= (const Timestamp& other) const -{ - const int res = Compare(other); - - return (res == 0 || res < 0); -} - -inline bool Timestamp::operator <= (const Timestamp& other) const -{ - const int res = Compare(other); - - return (res == 0 || res > 0); -} - -/* --------------------------------------------------------------------------------------------- * - * Lob - * --------------------------------------------------------------------------------------------- */ - -template -inline Lob::Lob() -{ -} - -template -Lob::Lob(const Connection &connection) -{ - Acquire(Check(OCI_LobCreate(connection, U)), reinterpret_cast(OCI_LobFree), nullptr, connection.GetHandle()); -} - -template -Lob::Lob(OCI_Lob *pLob, Handle *parent) -{ - Acquire(pLob, nullptr, nullptr, parent); -} - -template<> -inline ostring Lob::Read(unsigned int length) -{ - ManagedBuffer buffer(static_cast(Environment::GetCharMaxSize() * (length + 1))); - - unsigned int charCount = length; - unsigned int byteCount = 0; - - if (Check(OCI_LobRead2(*this, static_cast(buffer), &charCount, &byteCount))) - { - length = byteCount / sizeof(otext); - } - - return MakeString(static_cast(buffer), static_cast(length)); -} - -template<> -inline ostring Lob::Read(unsigned int length) -{ - ManagedBuffer buffer(static_cast(Environment::GetCharMaxSize() * (length + 1))); - - unsigned int charCount = length; - unsigned int byteCount = 0; - - if (Check(OCI_LobRead2(*this, static_cast(buffer), &charCount, &byteCount))) - { - length = byteCount / sizeof(otext); - } - - return MakeString(static_cast(buffer), static_cast(length)); - -} - -template<> -inline Raw Lob::Read(unsigned int length) -{ - ManagedBuffer buffer(length + 1); - - length = Check(OCI_LobRead(*this, static_cast(buffer), length)); - - return MakeRaw(buffer, length); -} - -template -unsigned int Lob::Write(const T& content) -{ - if (content.empty()) - { - return 0; - } - - unsigned int res = 0; - unsigned int charCount = 0; - unsigned int byteCount = static_cast(content.size() * sizeof(typename T::value_type)); - const AnyPointer buffer = static_cast(const_cast(&content[0])); - - if (Check(OCI_LobWrite2(*this, buffer, &charCount, &byteCount))) - { - res = U == LobBinary ? byteCount : charCount; - } - - return res; -} - -template -void Lob::Append(const Lob& other) -{ - Check(OCI_LobAppendLob(*this, other)); -} - -template -unsigned int Lob::Append(const T& content) -{ - if (content.empty()) - { - return 0; - } - - const AnyPointer data = static_cast(const_cast(&content[0])); - - return Check(OCI_LobAppend(*this, data, static_cast(content.size()))); -} - -template -bool Lob::Seek(SeekMode seekMode, big_uint offset) -{ - return (Check(OCI_LobSeek(*this, offset, seekMode)) == TRUE); -} - -template -Lob Lob::Clone() const -{ - Lob result(GetConnection()); - - Check(OCI_LobAssign(result, *this)); - - return result; -} - -template -bool Lob::Equals(const Lob &other) const -{ - return (Check(OCI_LobIsEqual(*this, other)) == TRUE); -} - -template -LobType Lob::GetType() const -{ - return LobType(static_cast(Check(OCI_LobGetType(*this)))); -} - -template -big_uint Lob::GetOffset() const -{ - return Check(OCI_LobGetOffset(*this)); -} - -template -big_uint Lob::GetLength() const -{ - return Check(OCI_LobGetLength(*this)); -} - -template -big_uint Lob::GetMaxSize() const -{ - return Check(OCI_LobGetMaxSize(*this)); -} - -template -big_uint Lob::GetChunkSize() const -{ - return Check(OCI_LobGetChunkSize(*this)); -} - -template -Connection Lob::GetConnection() const -{ - return Connection(Check(OCI_LobGetConnection(*this)), nullptr); -} - -template -void Lob::Truncate(big_uint length) -{ - Check(OCI_LobTruncate(*this, length)); -} - -template -big_uint Lob::Erase(big_uint offset, big_uint length) -{ - return Check(OCI_LobErase(*this, offset, length)); -} - -template -void Lob::Copy(Lob &dest, big_uint offset, big_uint offsetDest, big_uint length) const -{ - Check(OCI_LobCopy(dest, *this, offsetDest, offset, length)); -} - -template -bool Lob::IsTemporary() const -{ - return (Check(OCI_LobIsTemporary(*this)) == TRUE); -} - -template -bool Lob::IsRemote() const -{ - return (Check(OCI_LobIsRemote(*this)) == TRUE); -} - -template -void Lob::Open(OpenMode mode) -{ - Check(OCI_LobOpen(*this, mode)); -} - -template -void Lob::Flush() -{ - Check(OCI_LobFlush(*this)); -} - -template -void Lob::Close() -{ - Check(OCI_LobClose(*this)); -} - -template -void Lob::EnableBuffering(bool value) -{ - Check(OCI_LobEnableBuffering(*this, value)); -} - -template -Lob& Lob::operator += (const Lob& other) -{ - Append(other); - return *this; -} - -template -bool Lob::operator == (const Lob& other) const -{ - return Equals(other); -} - -template -bool Lob::operator != (const Lob& other) const -{ - return !(*this == other); -} - -/* --------------------------------------------------------------------------------------------- * - * File - * --------------------------------------------------------------------------------------------- */ - -inline File::File() -{ -} - -inline File::File(const Connection &connection) -{ - Acquire(Check(OCI_FileCreate(connection, OCI_BFILE)), reinterpret_cast(OCI_FileFree), nullptr, connection.GetHandle()); -} - -inline File::File(const Connection &connection, const ostring& directory, const ostring& name) -{ - Acquire(Check(OCI_FileCreate(connection, OCI_BFILE)), reinterpret_cast(OCI_FileFree), nullptr, connection.GetHandle()); - - SetInfos(directory, name); -} - -inline File::File(OCI_File *pFile, Handle *parent) -{ - Acquire(pFile, nullptr, nullptr, parent); -} - -inline Raw File::Read(unsigned int size) -{ - ManagedBuffer buffer(static_cast(size + 1)); - - size = Check(OCI_FileRead(*this, static_cast(buffer), size)); - - return MakeRaw(buffer, size); -} - -inline bool File::Seek(SeekMode seekMode, big_uint offset) -{ - return (Check(OCI_FileSeek(*this, offset, seekMode)) == TRUE); -} - -inline File File::Clone() const -{ - File result(GetConnection()); - - Check(OCI_FileAssign(result, *this)); - - return result; -} - -inline bool File::Equals(const File &other) const -{ - return (Check(OCI_FileIsEqual(*this, other)) == TRUE); -} - -inline big_uint File::GetOffset() const -{ - return Check(OCI_FileGetOffset(*this)); -} - -inline big_uint File::GetLength() const -{ - return Check(OCI_FileGetSize(*this)); -} - -inline Connection File::GetConnection() const -{ - return Connection(Check(OCI_FileGetConnection(*this)), nullptr); -} - -inline bool File::Exists() const -{ - return (Check(OCI_FileExists(*this)) == TRUE); -} - -inline void File::SetInfos(const ostring& directory, const ostring& name) -{ - Check(OCI_FileSetName(*this, directory.c_str(), name.c_str())); -} - -inline ostring File::GetName() const -{ - return MakeString(Check(OCI_FileGetName(*this))); -} - -inline ostring File::GetDirectory() const -{ - return MakeString(Check(OCI_FileGetDirectory(*this))); -} - -inline void File::Open() -{ - Check(OCI_FileOpen(*this)); -} - -inline bool File::IsOpened() const -{ - return (Check(OCI_FileIsOpen(*this)) == TRUE); -} - -inline void File::Close() -{ - Check(OCI_FileClose(*this)); -} - -inline bool File::operator == (const File& other) const -{ - return Equals(other); -} - -inline bool File::operator != (const File& other) const -{ - return (!(*this == other)); -} - -/* --------------------------------------------------------------------------------------------- * - * TypeInfo - * --------------------------------------------------------------------------------------------- */ - -inline TypeInfo::TypeInfo(const Connection &connection, const ostring& name, TypeInfoType type) -{ - Acquire(Check(OCI_TypeInfoGet(connection, name.c_str(), type)), static_cast(nullptr), nullptr, connection.GetHandle()); -} - -inline TypeInfo::TypeInfo(OCI_TypeInfo *pTypeInfo) -{ - Acquire(pTypeInfo, nullptr, nullptr, nullptr); -} - -inline TypeInfo::TypeInfoType TypeInfo::GetType() const -{ - return TypeInfoType(static_cast(Check(OCI_TypeInfoGetType(*this)))); -} - -inline ostring TypeInfo::GetName() const -{ - return Check(OCI_TypeInfoGetName(*this)); -} - -inline Connection TypeInfo::GetConnection() const -{ - return Connection(Check(OCI_TypeInfoGetConnection(*this)), nullptr); -} - -inline unsigned int TypeInfo::GetColumnCount() const -{ - return Check(OCI_TypeInfoGetColumnCount(*this)); -} - -inline Column TypeInfo::GetColumn(unsigned int index) const -{ - return Column(Check(OCI_TypeInfoGetColumn(*this, index)), GetHandle()); -} - -inline boolean TypeInfo::IsFinalType() const -{ - return (Check(OCI_TypeInfoIsFinalType(*this)) == TRUE); -} - -inline TypeInfo TypeInfo::GetSuperType() const -{ - return TypeInfo(Check(OCI_TypeInfoGetSuperType(*this))); -} - -/* --------------------------------------------------------------------------------------------- * - * Object - * --------------------------------------------------------------------------------------------- */ - -inline Object::Object() -{ -} - -inline Object::Object(const TypeInfo &typeInfo) -{ - Connection connection = typeInfo.GetConnection(); - Acquire(Check(OCI_ObjectCreate(connection, typeInfo)), reinterpret_cast(OCI_ObjectFree), nullptr, connection.GetHandle()); -} - -inline Object::Object(OCI_Object *pObject, Handle *parent) -{ - Acquire(pObject, nullptr, nullptr, parent); -} - -inline Object Object::Clone() const -{ - Object result(GetTypeInfo()); - - Check(OCI_ObjectAssign(result, *this)); - - return result; -} - -inline bool Object::IsAttributeNull(const ostring& name) const -{ - return (Check(OCI_ObjectIsNull(*this, name.c_str())) == TRUE); -} - -inline void Object::SetAttributeNull(const ostring& name) -{ - Check(OCI_ObjectSetNull(*this, name.c_str())); -} - -inline TypeInfo Object::GetTypeInfo() const -{ - return TypeInfo(Check(OCI_ObjectGetTypeInfo(*this))); -} - -inline Reference Object::GetReference() const -{ - TypeInfo typeInfo = GetTypeInfo(); - Connection connection = typeInfo.GetConnection(); - - OCI_Ref *pRef = OCI_RefCreate(connection, typeInfo); - - Check(OCI_ObjectGetSelfRef(*this, pRef)); - - return Reference(pRef, GetHandle()); -} - -inline Object::ObjectType Object::GetType() const -{ - return ObjectType(static_cast(Check(OCI_ObjectGetType(*this)))); -} - -template<> -inline bool Object::Get(const ostring& name) const -{ - return (Check(OCI_ObjectGetBoolean(*this, name.c_str())) == TRUE); -} - -template<> -inline short Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetShort(*this, name.c_str())); -} - -template<> -inline unsigned short Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetUnsignedShort(*this, name.c_str())); -} - -template<> -inline int Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetInt(*this, name.c_str())); -} - -template<> -inline unsigned int Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetUnsignedInt(*this, name.c_str())); -} - -template<> -inline big_int Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetBigInt(*this, name.c_str())); -} - -template<> -inline big_uint Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetUnsignedBigInt(*this, name.c_str())); -} - -template<> -inline float Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetFloat(*this, name.c_str())); -} - -template<> -inline double Object::Get(const ostring& name) const -{ - return Check(OCI_ObjectGetDouble(*this, name.c_str())); -} - -template<> -inline Number Object::Get(const ostring& name) const -{ - return Number(Check(OCI_ObjectGetNumber(*this, name.c_str())), GetHandle()); -} - -template<> -inline ostring Object::Get(const ostring& name) const -{ - return MakeString(Check(OCI_ObjectGetString(*this,name.c_str()))); -} - -template<> -inline Date Object::Get(const ostring& name) const -{ - return Date(Check(OCI_ObjectGetDate(*this,name.c_str())), GetHandle()); -} - -template<> -inline Timestamp Object::Get(const ostring& name) const -{ - return Timestamp(Check(OCI_ObjectGetTimestamp(*this,name.c_str())), GetHandle()); -} - -template<> -inline Interval Object::Get(const ostring& name) const -{ - return Interval(Check(OCI_ObjectGetInterval(*this,name.c_str())), GetHandle()); -} - -template<> -inline Object Object::Get(const ostring& name) const -{ - return Object(Check(OCI_ObjectGetObject(*this,name.c_str())), GetHandle()); -} - -template<> -inline Reference Object::Get(const ostring& name) const -{ - return Reference(Check(OCI_ObjectGetRef(*this,name.c_str())), GetHandle()); -} - -template<> -inline Clob Object::Get(const ostring& name) const -{ - return Clob(Check(OCI_ObjectGetLob(*this,name.c_str())), GetHandle()); -} - -template<> -inline NClob Object::Get(const ostring& name) const -{ - return NClob(Check(OCI_ObjectGetLob(*this, name.c_str())), GetHandle()); -} - -template<> -inline Blob Object::Get(const ostring& name) const -{ - return Blob(Check(OCI_ObjectGetLob(*this,name.c_str())), GetHandle()); -} - -template<> -inline File Object::Get(const ostring& name) const -{ - return File(Check(OCI_ObjectGetFile(*this,name.c_str())), GetHandle()); -} - -template<> -inline Raw Object::Get(const ostring& name) const -{ - unsigned int size = Check(OCI_ObjectGetRawSize(*this, name.c_str())); - - ManagedBuffer buffer(static_cast(size + 1)); - - size = static_cast(Check(OCI_ObjectGetRaw(*this, name.c_str(), static_cast(buffer), size))); - - return MakeRaw(buffer, size); -} - -template -T Object::Get(const ostring& name) const -{ - return T(Check(OCI_ObjectGetColl(*this, name.c_str())), GetHandle()); -} - -template<> -inline void Object::Set(const ostring& name, const bool &value) -{ - Check(OCI_ObjectSetBoolean(*this, name.c_str(), static_cast(value))); -} - -template<> -inline void Object::Set(const ostring& name, const short &value) -{ - Check(OCI_ObjectSetShort(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const unsigned short &value) -{ - Check(OCI_ObjectSetUnsignedShort(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const int &value) -{ - Check(OCI_ObjectSetInt(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const unsigned int &value) -{ - Check(OCI_ObjectSetUnsignedInt(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const big_int &value) -{ - Check(OCI_ObjectSetBigInt(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const big_uint &value) -{ - Check(OCI_ObjectSetUnsignedBigInt(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const float &value) -{ - Check(OCI_ObjectSetFloat(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const double &value) -{ - Check(OCI_ObjectSetDouble(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Number &value) -{ - Check(OCI_ObjectSetNumber(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const ostring &value) -{ - Check(OCI_ObjectSetString(*this, name.c_str(), value.c_str())); -} - -template<> -inline void Object::Set(const ostring& name, const Date &value) -{ - Check(OCI_ObjectSetDate(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Timestamp &value) -{ - Check(OCI_ObjectSetTimestamp(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Interval &value) -{ - Check(OCI_ObjectSetInterval(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Object &value) -{ - Check(OCI_ObjectSetObject(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Reference &value) -{ - Check(OCI_ObjectSetRef(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Clob &value) -{ - Check(OCI_ObjectSetLob(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const NClob &value) -{ - Check(OCI_ObjectSetLob(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Blob &value) -{ - Check(OCI_ObjectSetLob(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const File &value) -{ - Check(OCI_ObjectSetFile(*this, name.c_str(), value)); -} - -template<> -inline void Object::Set(const ostring& name, const Raw &value) -{ - const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; - - Check(OCI_ObjectSetRaw(*this, name.c_str(), data, static_cast(value.size()))); - -} - -template -void Object::Set(const ostring& name, const T &value) -{ - Check(OCI_ObjectSetColl(*this, name.c_str(), value)); -} - -inline ostring Object::ToString() const -{ - if (!IsNull()) - { - unsigned int len = 0; - - Check(OCI_ObjectToText(*this, &len, nullptr)); - - ManagedBuffer buffer(static_cast(len + 1)); - - Check(OCI_ObjectToText(*this, &len, buffer)); - - return MakeString(static_cast(buffer), static_cast(len)); - } - - return OCI_STRING_NULL; -} - -/* --------------------------------------------------------------------------------------------- * - * Reference - * --------------------------------------------------------------------------------------------- */ - -inline Reference::Reference() -{ -} - -inline Reference::Reference(const TypeInfo &typeInfo) -{ - Connection connection = typeInfo.GetConnection(); - Acquire(Check(OCI_RefCreate(connection, typeInfo)), reinterpret_cast(OCI_RefFree), nullptr, connection.GetHandle()); -} - -inline Reference::Reference(OCI_Ref *pRef, Handle *parent) -{ - Acquire(pRef, nullptr, nullptr, parent); -} - -inline TypeInfo Reference::GetTypeInfo() const -{ - return TypeInfo(Check(OCI_RefGetTypeInfo(*this))); -} - -inline Object Reference::GetObject() const -{ - return Object(Check(OCI_RefGetObject(*this)), GetHandle()); -} - -inline Reference Reference::Clone() const -{ - Reference result(GetTypeInfo()); - - Check(OCI_RefAssign(result, *this)); - - return result; -} - -inline bool Reference::IsReferenceNull() const -{ - return (Check(OCI_RefIsNull(*this)) == TRUE); -} - -inline void Reference::SetReferenceNull() -{ - Check(OCI_RefSetNull(*this)); -} - -inline ostring Reference::ToString() const -{ - if (!IsNull()) - { - const unsigned int size = Check(OCI_RefGetHexSize(*this)); - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_RefToText(*this, size, buffer)); - - return MakeString(static_cast(buffer), static_cast(size)); - } - - return OCI_STRING_NULL; -} - -/* --------------------------------------------------------------------------------------------- * - * Collection - * --------------------------------------------------------------------------------------------- */ - -template -Collection::Collection() -{ -} - -template -Collection::Collection(const TypeInfo &typeInfo) -{ - Acquire(Check(OCI_CollCreate(typeInfo)), reinterpret_cast(OCI_CollFree), nullptr, typeInfo.GetConnection().GetHandle()); -} - -template -Collection::Collection(OCI_Coll *pColl, Handle *parent) -{ - Acquire(pColl, nullptr, nullptr, parent); -} - -template -Collection Collection::Clone() const -{ - Collection result(GetTypeInfo()); - - Check(OCI_CollAssign(result, *this)); - - return result; -} - -template -TypeInfo Collection::GetTypeInfo() const -{ - return TypeInfo(Check(OCI_CollGetTypeInfo(*this))); -} - -template -typename Collection::CollectionType Collection::GetType() const -{ - return CollectionType(Check(OCI_CollGetType(*this))); -} - -template -unsigned int Collection::GetMax() const -{ - return Check(OCI_CollGetMax(*this)); -} - -template -unsigned int Collection::GetSize() const - -{ - return Check(OCI_CollGetSize(*this)); -} - -template -unsigned int Collection::GetCount() const - -{ - return Check(OCI_CollGetCount(*this)); -} - -template -void Collection::Truncate(unsigned int size) -{ - Check(OCI_CollTrim(*this, size)); -} - -template -void Collection::Clear() -{ - Check(OCI_CollClear(*this)); -} - -template -bool Collection::IsElementNull(unsigned int index) const -{ - return (Check(OCI_ElemIsNull(Check(OCI_CollGetElem(*this, index)))) == TRUE); -} - -template -void Collection::SetElementNull(unsigned int index) -{ - Check(OCI_ElemSetNull(Check(OCI_CollGetElem(*this, index)))); -} - -template -bool Collection::Delete(unsigned int index) const -{ - return (Check(OCI_CollDeleteElem(*this, index)) == TRUE); -} - -template -typename Collection::iterator Collection::begin() -{ - return iterator(this, 1); -} - -template -typename Collection::const_iterator Collection::begin() const -{ - return const_iterator(const_cast(this), 1); -} - -template -typename Collection::iterator Collection::end() -{ - return iterator(const_cast(this), GetCount() + 1); -} - -template -typename Collection::const_iterator Collection::end() const -{ - return const_iterator(const_cast(this), GetCount() + 1); -} - -template -T Collection::Get(unsigned int index) const -{ - return GetElem(Check(OCI_CollGetElem(*this, index)), GetHandle()); -} - -template -void Collection::Set(unsigned int index, const T & value) -{ - OCI_Elem * elem = Check(OCI_CollGetElem(*this, index)); - - SetElem(elem, value); - - Check(OCI_CollSetElem(*this, index, elem)); -} - -template -void Collection::Append(const T &value) -{ - OCI_Elem * elem = Check(OCI_ElemCreate(OCI_CollGetTypeInfo(*this))); - - SetElem(elem, value); - - Check(OCI_CollAppend(*this, elem)); - Check(OCI_ElemFree(elem)); -} - -template<> -inline bool Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return (Check(OCI_ElemGetBoolean(elem)) == TRUE); -} - -template<> -inline short Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetShort(elem)); -} - -template<> -inline unsigned short Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetUnsignedShort(elem)); -} - -template<> -inline int Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetInt(elem)); -} - -template<> -inline unsigned int Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetUnsignedInt(elem)); -} - -template<> -inline big_int Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetBigInt(elem)); -} - -template<> -inline big_uint Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetUnsignedBigInt(elem)); -} - -template<> -inline float Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetFloat(elem)); -} - -template<> -inline double Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return Check(OCI_ElemGetDouble(elem)); -} - -template<> -inline Number Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Number(Check(OCI_ElemGetNumber(elem)), parent); -} - -template<> -inline ostring Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - return MakeString(Check(OCI_ElemGetString(elem))); -} - -template<> -inline Raw Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - ARG_NOT_USED(parent); - - unsigned int size = Check(OCI_ElemGetRawSize(elem)); - - ManagedBuffer buffer(static_cast(size + 1)); - - size = Check(OCI_ElemGetRaw(elem, static_cast(buffer), size)); - - return MakeRaw(buffer, size); -} - -template<> -inline Date Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Date(Check(OCI_ElemGetDate(elem)), parent); -} - -template<> -inline Timestamp Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Timestamp(Check(OCI_ElemGetTimestamp(elem)), parent); -} - -template<> -inline Interval Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Interval(Check(OCI_ElemGetInterval(elem)), parent); -} - -template<> -inline Object Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Object(Check(OCI_ElemGetObject(elem)), parent); -} - -template<> -inline Reference Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Reference(Check(OCI_ElemGetRef(elem)), parent); -} - -template<> -inline Clob Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Clob(Check(OCI_ElemGetLob(elem)), parent); -} - -template<> -inline NClob Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return NClob(Check(OCI_ElemGetLob(elem)), parent); -} -template<> -inline Blob Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return Blob(Check(OCI_ElemGetLob(elem)), parent); -} - -template<> -inline File Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return File(Check(OCI_ElemGetFile(elem)), parent); -} - -template - T Collection::GetElem(OCI_Elem *elem, Handle *parent) -{ - return T(Check(OCI_ElemGetColl(elem)), parent); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const bool &value) -{ - Check(OCI_ElemSetBoolean(elem, static_cast(value))); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const short &value) -{ - Check(OCI_ElemSetShort(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const unsigned short &value) -{ - Check(OCI_ElemSetUnsignedShort(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const int &value) -{ - Check(OCI_ElemSetInt(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const unsigned int &value) -{ - Check(OCI_ElemSetUnsignedInt(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const big_int &value) -{ - Check(OCI_ElemSetBigInt(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const big_uint &value) -{ - Check(OCI_ElemSetUnsignedBigInt(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const float &value) -{ - Check(OCI_ElemSetFloat(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const double &value) -{ - Check(OCI_ElemSetDouble(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Number &value) -{ - Check(OCI_ElemSetNumber(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const ostring& value) -{ - Check(OCI_ElemSetString(elem, value.c_str())); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Raw &value) -{ - const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; - - Check(OCI_ElemSetRaw(elem, data, static_cast(value.size()))); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Date &value) -{ - Check(OCI_ElemSetDate(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Timestamp &value) -{ - Check(OCI_ElemSetTimestamp(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Interval &value) -{ - Check(OCI_ElemSetInterval(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Object &value) -{ - Check(OCI_ElemSetObject(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Reference &value) -{ - Check(OCI_ElemSetRef(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Clob &value) -{ - Check(OCI_ElemSetLob(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const NClob &value) -{ - Check(OCI_ElemSetLob(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const Blob &value) -{ - Check(OCI_ElemSetLob(elem, value)); -} - -template<> -inline void Collection::SetElem(OCI_Elem *elem, const File &value) -{ - Check(OCI_ElemSetFile(elem, value)); -} - -template -void Collection::SetElem(OCI_Elem *elem, const T &value) -{ - Check(OCI_ElemSetColl(elem, value)); -} - -template -ostring Collection::ToString() const -{ - if (!IsNull()) - { - unsigned int len = 0; - - Check(OCI_CollToText(*this, &len, nullptr)); - - ManagedBuffer buffer(static_cast(len + 1)); - - Check(OCI_CollToText(*this, &len, buffer)); - - return MakeString(static_cast(buffer), static_cast(len)); - } - - return OCI_STRING_NULL; -} - -template -CollectionElement Collection::operator [] (unsigned int index) -{ - return CollectionElement(this, index); -} - -template -CollectionElement Collection::operator [](unsigned int index) const -{ - return CollectionElement(this, index); -} - -template -CollectionIterator::CollectionIterator() : _elem() -{ - -} - -template -CollectionIterator::CollectionIterator(CollectionType *collection, unsigned int pos) : _elem(collection, pos) -{ - -} - -template -CollectionIterator::CollectionIterator(const CollectionIterator& other) : _elem(other._elem) -{ - -} - -template -CollectionIterator& CollectionIterator::operator = (const CollectionIterator& other) -{ - if (this != &other) - { - _elem._pos = other._elem._pos; - _elem._coll = other._elem._coll; - } - - return *this; -} - -template -CollectionIterator& CollectionIterator::operator += (difference_type value) -{ - _elem._pos += static_cast(value); - return *this; -} - -template -CollectionIterator& CollectionIterator::operator -= (difference_type value) -{ - _elem._pos -= static_cast(value); - return *this; -} - -template -T& CollectionIterator::operator*() -{ - return _elem; -} - -template -T* CollectionIterator::operator->() -{ - return &_elem; -} - -template -CollectionIterator& CollectionIterator::operator--() -{ - --_elem._pos; - return *this; -} - -template -CollectionIterator& CollectionIterator::operator++() -{ - ++*(const_cast(&_elem._pos)); - return *this; -} - -template -CollectionIterator CollectionIterator::operator++(int) -{ - CollectionIterator res(_elem._coll, _elem._pos); - ++(*this); - return res; -} - -template -CollectionIterator CollectionIterator::operator--(int) -{ - CollectionIterator res(_elem); - --(*this); - return res; -} - -template -CollectionIterator CollectionIterator::operator + (difference_type value) -{ - return CollectionIterator(_elem._coll, _elem._pos + static_cast(value)); -} - -template -CollectionIterator CollectionIterator::operator - (difference_type value) -{ - return CollectionIterator(_elem._coll, _elem._pos - static_cast(value)); -} - -template -typename CollectionIterator::difference_type CollectionIterator::operator - (const CollectionIterator & other) -{ - return static_cast(_elem._pos - other._elem._pos); -} - -template -bool CollectionIterator::operator == (const CollectionIterator& other) -{ - return _elem._pos == other._elem._pos && (static_cast(*_elem._coll)) == (static_cast(*other._elem._coll)); -} - -template -bool CollectionIterator::operator != (const CollectionIterator& other) -{ - return !(*this == other); -} - -template -bool CollectionIterator::operator > (const CollectionIterator& other) -{ - return _elem._pos > other._elem._pos; -} - -template -bool CollectionIterator::operator < (const CollectionIterator& other) -{ - return _elem._pos < other._elem._pos; -} - -template -bool CollectionIterator::operator >= (const CollectionIterator& other) -{ - return _elem._pos >= other._elem._pos; -} - -template -bool CollectionIterator::operator <= (const CollectionIterator& other) -{ - return _elem._pos <= other._elem._pos; -} - -template -CollectionElement::CollectionElement() : _coll(nullptr), _pos(0) -{ - -} - -template -CollectionElement::CollectionElement(CollectionType *coll, unsigned int pos) : _coll(coll), _pos(pos) -{ - -} - -template -CollectionElement::operator T() const -{ - return _coll->Get(_pos); -} - -template -CollectionElement& CollectionElement::operator = (const ValueType& other) -{ - if (this != &other) - { - _coll->Set(_pos, other); - } - - return *this; -} - -template -CollectionElement& CollectionElement::operator = (const CollectionElement &other) -{ - if (this != &other) - { - _coll->Set(_pos, static_cast(other)); - } - - return *this; -} - -template -bool CollectionElement::IsNull() const -{ - return _coll->IsElementNull(_pos); -} - -template -void CollectionElement::SetNull() -{ - _coll->SetElementNull(_pos); -} - -/* --------------------------------------------------------------------------------------------- * - * Long - * --------------------------------------------------------------------------------------------- */ - -template -Long::Long() -{ -} - -template -Long::Long(const Statement &statement) -{ - Acquire(Check(OCI_LongCreate(statement, U)), reinterpret_cast(OCI_LongFree), nullptr, statement.GetHandle()); -} - -template -Long::Long(OCI_Long *pLong, Handle* parent) -{ - Acquire(pLong, nullptr, nullptr, parent); -} - -template -unsigned int Long::Write(const T& content) -{ - if (content.empty()) - { - return 0; - } - - return Check(OCI_LongWrite(*this, static_cast(const_cast(&content[0])), static_cast(content.size()))); -} - -template -unsigned int Long::GetLength() const -{ - return Check(OCI_LongGetSize(*this)); -} - -template<> -inline ostring Long::GetContent() const -{ - return MakeString(static_cast(Check(OCI_LongGetBuffer(*this)))); -} - -template<> -inline Raw Long::GetContent() const -{ - return MakeRaw(Check(OCI_LongGetBuffer(*this)), GetLength()); -} - -/* --------------------------------------------------------------------------------------------- * - * BindObject - * --------------------------------------------------------------------------------------------- */ - -inline BindObject::BindObject(const Statement &statement, const ostring& name, unsigned int mode) : _statement(statement), _name(name), _mode(mode) -{ -} - -inline BindObject::~BindObject() noexcept -{ -} - -inline ostring BindObject::GetName() const -{ - return _name; -} - -inline Statement BindObject::GetStatement() const -{ - return _statement; -} - -inline unsigned int BindObject::GetMode() const -{ - return _mode; -} - -/* --------------------------------------------------------------------------------------------- * - * BindArray - * --------------------------------------------------------------------------------------------- */ - -inline BindArray::BindArray(const Statement &statement, const ostring& name, unsigned int mode) : BindObject(statement, name, mode), _object(nullptr) -{ - -} - -template -void BindArray::SetVector(std::vector & vector, bool isPlSqlTable, unsigned int elemSize) -{ - _object = OnAllocate(new BindArrayObject(_statement, GetName(), vector, isPlSqlTable, GetMode(), elemSize)); -} - -inline BindArray::~BindArray() noexcept -{ - delete OnDeallocate(_object); -} - -template -typename BindResolver::OutputType * BindArray::GetData() const -{ - return static_cast::OutputType *>(*(dynamic_cast< BindArrayObject * > (_object))); -} - -inline void BindArray::SetInData() -{ - - if (GetMode() & OCI_BDM_IN || _object->IsHandleObject()) - { - _object->SetInData(); - } -} - -inline void BindArray::SetOutData() -{ - if (GetMode() & OCI_BDM_OUT) - { - _object->SetOutData(); - } -} - -inline unsigned int BindArray::GetSize() const -{ - return _object ? _object->GetSize() : _statement.GetBindArraySize(); -} - -inline unsigned int BindArray::GetSizeForBindCall() const -{ - return _object ? _object->GetSizeForBindCall() : 0; -} - -template -BindArray::BindArrayObject::BindArrayObject(const Statement &statement, const ostring &name, ObjectVector &vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize) - : _statement(statement), _name(name), _vector(vector), _data(nullptr), _isPlSqlTable(isPlSqlTable), _mode(mode), _elemCount(BindArrayObject::GetSize()), _elemSize(elemSize) -{ - AllocData(); -} - -template -BindArray::BindArrayObject::~BindArrayObject() noexcept -{ - FreeData(); -} - -template -void BindArray::BindArrayObject::AllocData() -{ - _data = OnAllocate(new NativeType[_elemCount], _elemCount); - - memset(_data, 0, sizeof(NativeType) * _elemCount); -} - -template<> -inline void BindArray::BindArrayObject::AllocData() -{ - const size_t count = _elemSize * _elemCount; - - _data = OnAllocate(new otext[count], count); - - memset(_data, 0, count * sizeof(otext)); -} - -template<> -inline void BindArray::BindArrayObject ::AllocData() -{ - const size_t count = _elemSize * _elemCount; - - _data = OnAllocate(new unsigned char[count], count); - - memset(_data, 0, count * sizeof(unsigned char)); -} - -template -void BindArray::BindArrayObject::FreeData() const -{ - delete [] OnDeallocate(_data); -} - -template -void BindArray::BindArrayObject::SetInData() -{ - typename ObjectVector::iterator it, it_end; - - unsigned int index = 0; - const unsigned int currElemCount = GetSize(); - - for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) - { - _data[index] = static_cast(*it); - } -} - -template<> -inline void BindArray::BindArrayObject::SetInData() -{ - std::vector::iterator it, it_end; - - unsigned int index = 0; - const unsigned int currElemCount = GetSize(); - - for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) - { - const ostring & value = *it; - - memcpy( _data + (_elemSize * index), value.c_str(), (value.size() + 1) * sizeof(otext)); - } -} - -template<> -inline void BindArray::BindArrayObject::SetInData() -{ - std::vector::iterator it, it_end; - - unsigned int index = 0; - const unsigned int currElemCount = GetSize(); - - for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) - { - Raw & value = *it; - - if (!value.empty()) - { - memcpy(_data + (_elemSize * index), &value[0], value.size()); - } - - OCI_BindSetDataSizeAtPos(OCI_GetBind2(_statement, GetName().c_str()), index + 1, static_cast(value.size())); - } -} - -template -void BindArray::BindArrayObject::SetOutData() -{ - typename ObjectVector::iterator it, it_end; - - unsigned int index = 0; - const unsigned int currElemCount = GetSize(); - - for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) - { - *it = static_cast(_data[index]); - } -} - -template<> -inline void BindArray::BindArrayObject::SetOutData() -{ - std::vector::iterator it, it_end; - - OCI_Bind *pBind = Check(OCI_GetBind2(_statement, GetName().c_str())); - - unsigned int index = 0; - const unsigned int currElemCount = GetSize(); - - for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) - { - otext *currData = _data + (_elemSize * sizeof(otext) * index); - - (*it).assign(currData, currData + Check(OCI_BindGetDataSizeAtPos(pBind, index + 1))); - } -} - -template<> -inline void BindArray::BindArrayObject::SetOutData() -{ - std::vector::iterator it, it_end; - - OCI_Bind *pBind = Check(OCI_GetBind2(_statement, GetName().c_str())); - - unsigned int index = 0; - const unsigned int currElemCount = GetSize(); - - for (it = _vector.begin(), it_end = _vector.end(); it != it_end && index < _elemCount && index < currElemCount; ++it, ++index) - { - unsigned char *currData = _data + (_elemSize * index); - - (*it).assign(currData, currData + Check(OCI_BindGetDataSizeAtPos(pBind, index + 1))); - } -} - -template -ostring BindArray::BindArrayObject::GetName() const -{ - return _name; -} - -template -bool BindArray::BindArrayObject::IsHandleObject() const -{ - return BindResolver::IsHandle; -} - -template -unsigned int BindArray::BindArrayObject::GetSize() const -{ - return _isPlSqlTable ? static_cast(_vector.size()) : _statement.GetBindArraySize(); -} - -template -unsigned int BindArray::BindArrayObject::GetSizeForBindCall() const -{ - return _isPlSqlTable ? static_cast(_vector.size()) : 0; -} - -template -BindArray::BindArrayObject::operator ObjectVector & () const -{ - return _vector; -} - -template -BindArray::BindArrayObject::operator NativeType * () const -{ - return _data; -} - -/* --------------------------------------------------------------------------------------------- * - * BindObjectAdaptor - * --------------------------------------------------------------------------------------------- */ - -template -void BindObjectAdaptor::SetInData() -{ - if (GetMode() & OCI_BDM_IN) - { - size_t size = _object.size(); - - if (size > _size) - { - size = _size; - } - - if (size > 0) - { - memcpy(_data, &_object[0], size * sizeof(NativeType)); - } - - _data[size] = 0; - } -} - -template -void BindObjectAdaptor::SetOutData() -{ - if (GetMode() & OCI_BDM_OUT) - { - size_t size = Check(OCI_BindGetDataSize(Check(OCI_GetBind2(_statement, _name.c_str())))); - - _object.assign(_data, _data + size); - } -} - -template -BindObjectAdaptor::BindObjectAdaptor(const Statement &statement, const ostring& name, unsigned int mode, ObjectType &object, unsigned int size) : - BindObject(statement, name, mode), - _object(object), - _data(OnAllocate(new NativeType[size+1], size+1)), - _size(size) -{ - memset(_data, 0, (_size+1) * sizeof(NativeType)); -} - -template -BindObjectAdaptor::~BindObjectAdaptor() noexcept -{ - delete OnDeallocate(_data); -} - -template -BindObjectAdaptor::operator NativeType *() const -{ - return _data; -} - -/* --------------------------------------------------------------------------------------------- * - * BindTypeAdaptor - * --------------------------------------------------------------------------------------------- */ - -template -void BindTypeAdaptor::SetInData() -{ - if (GetMode() & OCI_BDM_IN) - { - *_data = static_cast(_object); - } -} - -template -void BindTypeAdaptor::SetOutData() -{ - if (GetMode() & OCI_BDM_OUT) - { - _object = static_cast(*_data); - } -} - -template -BindTypeAdaptor::BindTypeAdaptor(const Statement &statement, const ostring& name, unsigned int mode, ObjectType &object) : -BindObject(statement, name, mode), -_object(object), -_data(OnAllocate(new NativeType)) -{ - -} - -template -BindTypeAdaptor::~BindTypeAdaptor() noexcept -{ - delete OnDeallocate(_data); -} - -template -BindTypeAdaptor::operator NativeType *() const -{ - return _data; -} - -template<> -inline void BindTypeAdaptor::SetInData() -{ - if (GetMode() & OCI_BDM_IN) - { - *_data = (_object == true); - } -} - -template<> -inline void BindTypeAdaptor::SetOutData() -{ - if (GetMode() & OCI_BDM_OUT) - { - _object = (*_data == TRUE); - } -} - -/* --------------------------------------------------------------------------------------------- * - * BindsHolder - * --------------------------------------------------------------------------------------------- */ - -inline BindsHolder::BindsHolder(const Statement &statement) : _statement(statement) -{ - -} - -inline BindsHolder::~BindsHolder() noexcept -{ - Clear(); -} - -inline void BindsHolder::Clear() -{ - std::vector::iterator it, it_end; - - for(it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) - { - delete OnDeallocate(*it); - } - - _bindObjects.clear(); -} - -inline void BindsHolder::AddBindObject(BindObject *bindObject) -{ - if (Check(OCI_IsRebindingAllowed(_statement))) - { - std::vector::iterator it, it_end; - - for(it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) - { - BindObject *previousBindObject = *it; - if (previousBindObject->GetName() == bindObject->GetName()) - { - _bindObjects.erase(it); - delete OnDeallocate(previousBindObject); - break; - } - } - } - - _bindObjects.push_back(bindObject); -} - -inline void BindsHolder::SetOutData() -{ - std::vector::iterator it, it_end; - - for(it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) - { - (*it)->SetOutData(); - } -} - -inline void BindsHolder::SetInData() -{ - std::vector::iterator it, it_end; - - for(it = _bindObjects.begin(), it_end = _bindObjects.end(); it != it_end; ++it) - { - (*it)->SetInData(); - } -} - -/* --------------------------------------------------------------------------------------------- * - * Bind - * --------------------------------------------------------------------------------------------- */ - -inline BindInfo::BindInfo(OCI_Bind *pBind, Handle *parent) -{ - Acquire(pBind, nullptr, nullptr, parent); -} - -inline ostring BindInfo::GetName() const -{ - return MakeString(Check(OCI_BindGetName(*this))); -} - -inline DataType BindInfo::GetType() const -{ - return DataType(static_cast(Check(OCI_BindGetType(*this)))); -} - -inline unsigned int BindInfo::GetSubType() const -{ - return Check(OCI_BindGetSubtype(*this)); -} - -inline unsigned int BindInfo::GetDataCount() const -{ - return Check(OCI_BindGetDataCount(*this)); -} - -inline Statement BindInfo::GetStatement() const -{ - return Statement(Check(OCI_BindGetStatement(*this))); -} - -inline void BindInfo::SetDataNull(bool value, unsigned int index) -{ - if (value) - { - Check(OCI_BindSetNullAtPos(*this, index)); - } - else - { - Check(OCI_BindSetNotNullAtPos(*this, index)); - } -} - -inline bool BindInfo::IsDataNull(unsigned int index) const -{ - return (Check(OCI_BindIsNullAtPos(*this, index)) == TRUE); -} - -inline void BindInfo::SetCharsetForm(CharsetForm value) -{ - Check(OCI_BindSetCharsetForm(*this, value)); -} - -inline BindInfo::BindDirection BindInfo::GetDirection() const -{ - return BindDirection(static_cast(Check(OCI_BindGetDirection(*this)))); -} - -/* --------------------------------------------------------------------------------------------- * - * Statement - * --------------------------------------------------------------------------------------------- */ - -inline Statement::Statement() -{ -} - -inline Statement::Statement(const Connection &connection) -{ - Acquire(Check(OCI_StatementCreate(connection)), reinterpret_cast(OCI_StatementFree), OnFreeSmartHandle, connection.GetHandle()); -} - -inline Statement::Statement(OCI_Statement *stmt, Handle *parent) -{ - Acquire(stmt, reinterpret_cast(parent ? OCI_StatementFree : nullptr), OnFreeSmartHandle, parent); -} - -inline Connection Statement::GetConnection() const -{ - return Connection(Check(OCI_StatementGetConnection(*this)), nullptr); -} - -inline void Statement::Describe(const ostring& sql) -{ - ClearBinds(); - ReleaseResultsets(); - Check(OCI_Describe(*this, sql.c_str())); -} - -inline void Statement::Parse(const ostring& sql) -{ - ClearBinds(); - ReleaseResultsets(); - Check(OCI_Parse(*this, sql.c_str())); -} - -inline void Statement::Prepare(const ostring& sql) -{ - ClearBinds(); - ReleaseResultsets(); - Check(OCI_Prepare(*this, sql.c_str())); -} - -inline void Statement::ExecutePrepared() -{ - ReleaseResultsets(); - SetInData(); - Check(OCI_Execute(*this)); - SetOutData(); -} - -template -unsigned int Statement::ExecutePrepared(T callback) -{ - ExecutePrepared(); - - return Fetch(callback); -} - -template -unsigned int Statement::ExecutePrepared(T callback, U adapter) -{ - ExecutePrepared(); - - return Fetch(callback, adapter); -} - -inline void Statement::Execute(const ostring& sql) -{ - ClearBinds(); - ReleaseResultsets(); - Check(OCI_ExecuteStmt(*this, sql.c_str())); -} - -template -unsigned int Statement::Execute(const ostring& sql, T callback) -{ - Execute(sql); - - return Fetch(callback); -} - -template -unsigned int Statement::Execute(const ostring& sql, T callback, U adapter) -{ - Execute(sql); - - return Fetch(callback, adapter); -} - -template -unsigned int Statement::Fetch(T callback) -{ - unsigned int res = 0; - - Resultset rs = GetResultset(); - - while (rs) - { - res += rs.ForEach(callback); - rs = GetNextResultset(); - } - - return res; -} - -template -unsigned int Statement::Fetch(T callback, U adapter) -{ - unsigned int res = 0; - - Resultset rs = GetResultset(); - - while (rs) - { - res += rs.ForEach(callback, adapter); - rs = GetNextResultset(); - } - - return res; -} - -inline unsigned int Statement::GetAffectedRows() const -{ - return Check(OCI_GetAffectedRows(*this)); -} - -inline ostring Statement::GetSql() const -{ - return MakeString(Check(OCI_GetSql(*this))); -} - -inline ostring Statement::GetSqlIdentifier() const -{ - return MakeString(Check(OCI_GetSqlIdentifier(*this))); -} - -inline Resultset Statement::GetResultset() -{ - return Resultset(Check(OCI_GetResultset(*this)), GetHandle()); -} - -inline Resultset Statement::GetNextResultset() -{ - return Resultset(Check(OCI_GetNextResultset(*this)), GetHandle()); -} - -inline void Statement::SetBindArraySize(unsigned int size) -{ - Check(OCI_BindArraySetSize(*this, size)); -} - -inline unsigned int Statement::GetBindArraySize() const -{ - return Check(OCI_BindArrayGetSize(*this)); -} - -inline void Statement::AllowRebinding(bool value) -{ - Check(OCI_AllowRebinding(*this, value)); -} - -inline bool Statement::IsRebindingAllowed() const -{ - return (Check(OCI_IsRebindingAllowed(*this)) == TRUE); -} - -inline unsigned int Statement::GetBindIndex(const ostring& name) const -{ - return Check(OCI_GetBindIndex(*this, name.c_str())); -} - -inline unsigned int Statement::GetBindCount() const -{ - return Check(OCI_GetBindCount(*this)); -} - -inline BindInfo Statement::GetBind(unsigned int index) const -{ - return BindInfo(Check(OCI_GetBind(*this, index)), GetHandle()); -} - -inline BindInfo Statement::GetBind(const ostring& name) const -{ - return BindInfo(Check(OCI_GetBind2(*this, name.c_str())), GetHandle()); -} - -template -void Statement::Bind1(M &method, const ostring& name, T& value, BindInfo::BindDirection mode) -{ - Check(method(*this, name.c_str(), &value)); - SetLastBindMode(mode); -} - -template -void Statement::Bind2(M &method, const ostring& name, T& value, BindInfo::BindDirection mode) -{ - Check(method(*this, name.c_str(), static_cast::OutputType>(value))); - SetLastBindMode(mode); -} - -template -void Statement::BindVector1(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); - bnd->SetVector(values, type == BindInfo::AsPlSqlTable, sizeof(typename BindResolver::OutputType)); - - const boolean res = method(*this, name.c_str(), bnd->GetData(), bnd->GetSizeForBindCall()); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template -void Statement::BindVector2(M &method, const ostring& name, std::vector &values, BindInfo::BindDirection mode, U subType, BindInfo::VectorType type) -{ - BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); - bnd->SetVector(values, type == BindInfo::AsPlSqlTable, sizeof(typename BindResolver::OutputType)); - - const boolean res = method(*this, name.c_str(), bnd->GetData(), subType, bnd->GetSizeForBindCall()); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template<> -inline void Statement::Bind(const ostring& name, bool &value, BindInfo::BindDirection mode) -{ - BindTypeAdaptor * bnd = OnAllocate(new BindTypeAdaptor(*this, name, mode, value)); - - const boolean res = OCI_BindBoolean(*this, name.c_str(), static_cast(*bnd)); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template<> -inline void Statement::Bind(const ostring& name, short &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindShort, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, unsigned short &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindUnsignedShort, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, int &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindInt, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, unsigned int &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindUnsignedInt, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, big_int &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindBigInt, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, big_uint &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindUnsignedBigInt, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, float &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindFloat, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, double &value, BindInfo::BindDirection mode) -{ - Bind1(OCI_BindDouble, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Number &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindNumber, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Date &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindDate, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Timestamp &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindTimestamp, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Interval &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindInterval, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Clob &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindLob, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, NClob &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindLob, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Blob &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindLob, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, File &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindFile, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Object &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindObject, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Reference &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindRef, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Statement &value, BindInfo::BindDirection mode) -{ - Bind2(OCI_BindStatement, name, value, mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Clong &value, unsigned int maxSize, BindInfo::BindDirection mode) -{ - Check(OCI_BindLong(*this, name.c_str(), value, maxSize)); - SetLastBindMode(mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Clong &value, int maxSize, BindInfo::BindDirection mode) -{ - Bind(name, value, static_cast(maxSize), mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Blong &value, unsigned int maxSize, BindInfo::BindDirection mode) -{ - Check(OCI_BindLong(*this, name.c_str(), value, maxSize)); - SetLastBindMode(mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Blong &value, int maxSize, BindInfo::BindDirection mode) -{ - Bind(name, value, static_cast(maxSize), mode); -} - -template<> -inline void Statement::Bind(const ostring& name, ostring &value, unsigned int maxSize, BindInfo::BindDirection mode) -{ - if (maxSize == 0) - { - maxSize = static_cast(value.size()); - } - - value.reserve(maxSize); - - BindObjectAdaptor * bnd = OnAllocate(new BindObjectAdaptor(*this, name, mode, value, maxSize + 1)); - - const boolean res = OCI_BindString(*this, name.c_str(), static_cast(*bnd), maxSize); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template<> -inline void Statement::Bind(const ostring& name, ostring &value, int maxSize, BindInfo::BindDirection mode) -{ - Bind(name, value, static_cast(maxSize), mode); -} - -template<> -inline void Statement::Bind(const ostring& name, Raw &value, unsigned int maxSize, BindInfo::BindDirection mode) -{ - if (maxSize == 0) - { - maxSize = static_cast(value.size()); - } - - value.reserve(maxSize); - - BindObjectAdaptor * bnd = OnAllocate(new BindObjectAdaptor(*this, name, mode, value, maxSize)); - - const boolean res = OCI_BindRaw(*this, name.c_str(), static_cast(*bnd), maxSize); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template<> -inline void Statement::Bind(const ostring& name, Raw &value, int maxSize, BindInfo::BindDirection mode) -{ - Bind(name, value, static_cast(maxSize), mode); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfShorts, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfUnsignedShorts, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfInts, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfUnsignedInts, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfBigInts, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfUnsignedBigInts, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfFloats, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfDoubles, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfDates, name, values, mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector1(OCI_BindArrayOfNumbers, name, values, mode, type); -} - -template -void Statement::Bind(const ostring& name, Collection &value, BindInfo::BindDirection mode) -{ - Check(OCI_BindColl(*this, name.c_str(), value)); - SetLastBindMode(mode); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, Timestamp::TimestampTypeValues subType, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfTimestamps, name, values, mode, subType, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, Timestamp::TimestampType subType, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - Bind(name, values, subType.GetValue(), mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, Interval::IntervalTypeValues subType, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfIntervals, name, values, mode, subType, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, Interval::IntervalType subType, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - Bind(name, values, subType.GetValue(), mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast(OCI_CLOB), type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast(OCI_NCLOB), type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfLobs, name, values, mode, static_cast(OCI_BLOB), type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfFiles, name, values, mode, static_cast(OCI_BFILE), type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfObjects, name, values, mode, static_cast(typeInfo), type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfRefs, name, values, mode, static_cast(typeInfo), type); -} - -template -void Statement::Bind(const ostring& name, std::vector > &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfColls, name, values, mode, static_cast(typeInfo), type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); - bnd->SetVector(values, type == BindInfo::AsPlSqlTable, maxSize+1); - - const boolean res = OCI_BindArrayOfStrings(*this, name.c_str(), bnd->GetData(), maxSize, bnd->GetSizeForBindCall()); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - Bind(name, values, static_cast(maxSize), mode, type); -} - -template<> -inline void Statement::Bind(const ostring& name, std::vector &values, unsigned int maxSize, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindArray * bnd = OnAllocate(new BindArray(*this, name, mode)); - bnd->SetVector(values, type == BindInfo::AsPlSqlTable, maxSize); - - const boolean res = OCI_BindArrayOfRaws(*this, name.c_str(), bnd->GetData(), maxSize, bnd->GetSizeForBindCall()); - - if (res) - { - BindsHolder *bindsHolder = GetBindsHolder(true); - bindsHolder->AddBindObject(bnd); - SetLastBindMode(mode); - } - else - { - delete OnDeallocate(bnd); - } - - Check(res); -} - -template -void Statement::Bind(const ostring& name, std::vector &values, TypeInfo &typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type) -{ - BindVector2(OCI_BindArrayOfColls, name, values, mode, static_cast(typeInfo), GetArraysize(type, values)); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterUnsignedShort(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterShort(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterUnsignedInt(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterInt(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterUnsignedBigInt(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterBigInt(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterFloat(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterDouble(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterNumber(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterDate(*this, name.c_str())); -} - -template<> -inline void Statement::Register(const ostring& name, Timestamp::TimestampTypeValues type) -{ - Check(OCI_RegisterTimestamp(*this, name.c_str(), type)); -} - -template<> -inline void Statement::Register(const ostring& name, Timestamp::TimestampType type) -{ - Register(name, type.GetValue()); -} - -template<> -inline void Statement::Register(const ostring& name, Interval::IntervalTypeValues type) -{ - Check(OCI_RegisterInterval(*this, name.c_str(), type)); -} - -template<> -inline void Statement::Register(const ostring& name, Interval::IntervalType type) -{ - Register(name, type.GetValue()); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterLob(*this, name.c_str(), OCI_CLOB)); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterLob(*this, name.c_str(), OCI_NCLOB)); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterLob(*this, name.c_str(), OCI_BLOB)); -} - -template<> -inline void Statement::Register(const ostring& name) -{ - Check(OCI_RegisterFile(*this, name.c_str(), OCI_BFILE)); -} - -template<> -inline void Statement::Register(const ostring& name, TypeInfo& typeInfo) -{ - Check(OCI_RegisterObject(*this, name.c_str(), typeInfo)); -} - -template<> -inline void Statement::Register(const ostring& name, TypeInfo& typeInfo) -{ - Check(OCI_RegisterRef(*this, name.c_str(), typeInfo)); -} - -template<> -inline void Statement::Register(const ostring& name, unsigned int len) -{ - Check(OCI_RegisterString(*this, name.c_str(), len)); -} - -template<> -inline void Statement::Register(const ostring& name, int len) -{ - Register(name, static_cast(len)); -} - -template<> -inline void Statement::Register(const ostring& name, unsigned int len) -{ - Check(OCI_RegisterRaw(*this, name.c_str(), len)); -} - -template<> -inline void Statement::Register(const ostring& name, int len) -{ - Register(name, static_cast(len)); -} - -inline Statement::StatementType Statement::GetStatementType() const -{ - return StatementType(static_cast(Check(OCI_GetStatementType(*this)))); -} - -inline unsigned int Statement::GetSqlErrorPos() const -{ - return Check(OCI_GetSqlErrorPos(*this)); -} - -inline void Statement::SetFetchMode(FetchMode value) -{ - Check(OCI_SetFetchMode(*this, value)); -} - -inline Statement::FetchMode Statement::GetFetchMode() const -{ - return FetchMode(static_cast(Check(OCI_GetFetchMode(*this)))); -} - -inline void Statement::SetBindMode(BindMode value) -{ - Check(OCI_SetBindMode(*this, value)); -} - -inline Statement::BindMode Statement::GetBindMode() const -{ - return BindMode(static_cast(Check(OCI_GetBindMode(*this)))); -} - -inline void Statement::SetFetchSize(unsigned int value) -{ - Check(OCI_SetFetchSize(*this, value)); -} - -inline unsigned int Statement::GetFetchSize() const -{ - return Check(OCI_GetFetchSize(*this)); -} - -inline void Statement::SetPrefetchSize(unsigned int value) -{ - Check(OCI_SetPrefetchSize(*this, value)); -} - -inline unsigned int Statement::GetPrefetchSize() const -{ - return Check(OCI_GetPrefetchSize(*this)); -} - -inline void Statement::SetPrefetchMemory(unsigned int value) -{ - Check(OCI_SetPrefetchMemory(*this, value)); -} - -inline unsigned int Statement::GetPrefetchMemory() const -{ - return Check(OCI_GetPrefetchMemory(*this)); -} - -inline void Statement::SetLongMaxSize(unsigned int value) -{ - Check(OCI_SetLongMaxSize(*this, value)); -} - -inline unsigned int Statement::GetLongMaxSize() const -{ - return Check(OCI_GetLongMaxSize(*this)); -} - -inline void Statement::SetLongMode(LongMode value) -{ - Check(OCI_SetLongMode(*this, value)); -} - -inline Statement::LongMode Statement::GetLongMode() const -{ - return LongMode(static_cast(Check(OCI_GetLongMode(*this)))); -} - -inline unsigned int Statement::GetSQLCommand() const -{ - return Check(OCI_GetSQLCommand(*this)); -} - -inline ostring Statement::GetSQLVerb() const -{ - return MakeString(Check(OCI_GetSQLVerb(*this))); -} - -inline void Statement::GetBatchErrors(std::vector &exceptions) -{ - exceptions.clear(); - - OCI_Error *err = Check(OCI_GetBatchError(*this)); - - while (err) - { - exceptions.push_back(Exception(err)); - - err = Check(OCI_GetBatchError(*this)); - } -} - -inline void Statement::ClearBinds() const -{ - BindsHolder *bindsHolder = GetBindsHolder(false); - - if (bindsHolder) - { - bindsHolder->Clear(); - } -} - -inline void Statement::SetOutData() const -{ - BindsHolder *bindsHolder = GetBindsHolder(false); - - if (bindsHolder) - { - bindsHolder->SetOutData(); - } -} - -inline void Statement::SetInData() const -{ - BindsHolder *bindsHolder = GetBindsHolder(false); - - if (bindsHolder) - { - bindsHolder->SetInData(); - } -} - -inline void Statement::ReleaseResultsets() const -{ - if (_smartHandle) - { - Handle *handle = nullptr; - - while (_smartHandle->GetChildren().FindIf(IsResultsetHandle, handle)) - { - if (handle) - { - handle->DetachFromHolders(); - - delete OnDeallocate(handle); - - handle = nullptr; - } - } - } -} - -inline bool Statement::IsResultsetHandle(Handle *handle) -{ - Resultset::SmartHandle *smartHandle = dynamic_cast(handle); - - return smartHandle != nullptr; -} - -inline void Statement::OnFreeSmartHandle(SmartHandle *smartHandle) -{ - if (smartHandle) - { - BindsHolder *bindsHolder = static_cast(smartHandle->GetExtraInfos()); - - smartHandle->SetExtraInfos(nullptr); - - delete OnDeallocate(bindsHolder); - } -} - -inline void Statement::SetLastBindMode(BindInfo::BindDirection mode) -{ - Check(OCI_BindSetDirection(Check(OCI_GetBind(*this, Check(OCI_GetBindCount(*this)))), mode)); -} - -inline BindsHolder * Statement::GetBindsHolder(bool create) const -{ - BindsHolder * bindsHolder = static_cast(_smartHandle->GetExtraInfos()); - - if (bindsHolder == nullptr && create) - { - bindsHolder = OnAllocate(new BindsHolder(*this)); - _smartHandle->SetExtraInfos(bindsHolder); - } - - return bindsHolder; -} - -/* --------------------------------------------------------------------------------------------- * - * Resultset - * --------------------------------------------------------------------------------------------- */ - -inline Resultset::Resultset(OCI_Resultset *resultset, Handle *parent) -{ - Acquire(resultset, nullptr, nullptr, parent); -} - -inline bool Resultset::Next() -{ - return (Check(OCI_FetchNext(*this)) == TRUE); -} - -inline bool Resultset::Prev() -{ - return (Check(OCI_FetchPrev(*this)) == TRUE); -} - -inline bool Resultset::First() -{ - return (Check(OCI_FetchFirst(*this)) == TRUE); -} - -inline bool Resultset::Last() -{ - return (Check(OCI_FetchLast(*this)) == TRUE); -} - -inline bool Resultset::Seek(SeekMode mode, int offset) -{ - return (Check(OCI_FetchSeek(*this, mode, offset)) == TRUE); -} - -inline unsigned int Resultset::GetCount() const -{ - return Check(OCI_GetRowCount(*this)); -} - -inline unsigned int Resultset::GetCurrentRow() const -{ - return Check(OCI_GetCurrentRow(*this)); -} - -inline unsigned int Resultset::GetColumnIndex(const ostring& name) const -{ - return Check(OCI_GetColumnIndex(*this, name.c_str())); -} - -inline unsigned int Resultset::GetColumnCount() const -{ - return Check(OCI_GetColumnCount(*this)); -} - -inline Column Resultset::GetColumn(unsigned int index) const -{ - return Column(Check(OCI_GetColumn(*this, index)), GetHandle()); -} - -inline Column Resultset::GetColumn(const ostring& name) const -{ - return Column(Check(OCI_GetColumn2(*this, name.c_str())), GetHandle()); -} - -inline bool Resultset::IsColumnNull(unsigned int index) const -{ - return (Check(OCI_IsNull(*this, index)) == TRUE); -} - -inline bool Resultset::IsColumnNull(const ostring& name) const -{ - return (Check(OCI_IsNull2(*this, name.c_str())) == TRUE); -} - -inline Statement Resultset::GetStatement() const -{ - return Statement( Check(OCI_ResultsetGetStatement(*this)), nullptr); -} - -inline bool Resultset::operator ++ (int) -{ - return Next(); -} - -inline bool Resultset::operator -- (int) -{ - return Prev(); -} - -inline bool Resultset::operator += (int offset) -{ - return Seek(SeekRelative, offset); -} - -inline bool Resultset::operator -= (int offset) -{ - return Seek(SeekRelative, -offset); -} - -template -void Resultset::Get(unsigned int index, T& value) const -{ - value = Get(index); -} - -template -void Resultset::Get(const ostring &name, T& value) const -{ - value = Get(name); -} - -template -bool Resultset::Get(T& value, TAdapter adapter) const -{ - return adapter(static_cast(*this), value); -} - -template -unsigned int Resultset::ForEach(TCallback callback) -{ - while (Next()) - { - if (!callback(static_cast(*this))) - { - break; - } - } - - return GetCurrentRow(); -} - -template -unsigned int Resultset::ForEach(T callback, U adapter) -{ - while (Next()) - { - if (!callback(adapter(static_cast(*this)))) - { - break; - } - } - - return GetCurrentRow(); -} - -template<> -inline short Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetShort(*this, index)); -} - -template<> -inline short Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetShort2(*this, name.c_str())); -} - -template<> -inline unsigned short Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetUnsignedShort(*this, index)); -} - -template<> -inline unsigned short Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetUnsignedShort2(*this, name.c_str())); -} - -template<> -inline int Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetInt(*this, index)); -} - -template<> -inline int Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetInt2(*this, name.c_str())); -} - -template<> -inline unsigned int Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetUnsignedInt(*this, index)); -} - -template<> -inline unsigned int Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetUnsignedInt2(*this, name.c_str())); -} - -template<> -inline big_int Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetBigInt(*this, index)); -} - -template<> -inline big_int Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetBigInt2(*this, name.c_str())); -} - -template<> -inline big_uint Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetUnsignedBigInt(*this, index)); -} - -template<> -inline big_uint Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetUnsignedBigInt2(*this, name.c_str())); -} - -template<> -inline float Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetFloat(*this, index)); -} - -template<> -inline float Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetFloat2(*this, name.c_str())); -} - -template<> -inline double Resultset::Get(unsigned int index) const -{ - return Check(OCI_GetDouble(*this, index)); -} - -template<> -inline double Resultset::Get(const ostring& name) const -{ - return Check(OCI_GetDouble2(*this, name.c_str())); -} - -template<> -inline Number Resultset::Get(unsigned int index) const -{ - return Number(Check(OCI_GetNumber(*this, index)), GetHandle()); -} - -template<> -inline Number Resultset::Get(const ostring& name) const -{ - return Number(Check(OCI_GetNumber2(*this, name.c_str())), GetHandle()); -} - -template<> -inline ostring Resultset::Get(unsigned int index) const -{ - return MakeString(Check(OCI_GetString(*this, index))); -} - -template<> -inline ostring Resultset::Get(const ostring& name) const -{ - return MakeString(Check(OCI_GetString2(*this,name.c_str()))); -} - -template<> -inline Raw Resultset::Get(unsigned int index) const -{ - unsigned int size = Check(OCI_GetDataLength(*this,index)); - - ManagedBuffer buffer(static_cast(size + 1)); - - size = Check(OCI_GetRaw(*this, index, static_cast(buffer), size)); - - return MakeRaw(buffer, size); -} - -template<> -inline Raw Resultset::Get(const ostring& name) const -{ - unsigned int size = Check(OCI_GetDataLength(*this, Check(OCI_GetColumnIndex(*this, name.c_str())))); - - ManagedBuffer buffer(static_cast(size + 1)); - - size = Check(OCI_GetRaw2(*this, name.c_str(), static_cast(buffer), size)); - - return MakeRaw(buffer, size); -} - -template<> -inline Date Resultset::Get(unsigned int index) const -{ - return Date(Check(OCI_GetDate(*this, index)), GetHandle()); -} - -template<> -inline Date Resultset::Get(const ostring& name) const -{ - return Date(Check(OCI_GetDate2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Timestamp Resultset::Get(unsigned int index) const -{ - return Timestamp(Check(OCI_GetTimestamp(*this, index)), GetHandle()); -} - -template<> -inline Timestamp Resultset::Get(const ostring& name) const -{ - return Timestamp(Check(OCI_GetTimestamp2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Interval Resultset::Get(unsigned int index) const -{ - return Interval(Check(OCI_GetInterval(*this, index)), GetHandle()); -} - -template<> -inline Interval Resultset::Get(const ostring& name) const -{ - return Interval(Check(OCI_GetInterval2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Object Resultset::Get(unsigned int index) const -{ - return Object(Check(OCI_GetObject(*this, index)), GetHandle()); -} - -template<> -inline Object Resultset::Get(const ostring& name) const -{ - return Object(Check(OCI_GetObject2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Reference Resultset::Get(unsigned int index) const -{ - return Reference(Check(OCI_GetRef(*this, index)), GetHandle()); -} - -template<> -inline Reference Resultset::Get(const ostring& name) const -{ - return Reference(Check(OCI_GetRef2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Statement Resultset::Get(unsigned int index) const -{ - return Statement(Check(OCI_GetStatement(*this, index)), GetHandle()); -} - -template<> -inline Statement Resultset::Get(const ostring& name) const -{ - return Statement(Check(OCI_GetStatement2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Clob Resultset::Get(unsigned int index) const -{ - return Clob(Check(OCI_GetLob(*this, index)), GetHandle()); -} - -template<> -inline Clob Resultset::Get(const ostring& name) const -{ - return Clob(Check(OCI_GetLob2(*this,name.c_str())), GetHandle()); -} - -template<> -inline NClob Resultset::Get(unsigned int index) const -{ - return NClob(Check(OCI_GetLob(*this, index)), GetHandle()); -} - -template<> -inline NClob Resultset::Get(const ostring& name) const -{ - return NClob(Check(OCI_GetLob2(*this, name.c_str())), GetHandle()); -} - -template<> -inline Blob Resultset::Get(unsigned int index) const -{ - return Blob(Check(OCI_GetLob(*this, index)), GetHandle()); -} - -template<> -inline Blob Resultset::Get(const ostring& name) const -{ - return Blob(Check(OCI_GetLob2(*this,name.c_str())), GetHandle()); -} - -template<> -inline File Resultset::Get(unsigned int index) const -{ - return File(Check(OCI_GetFile(*this, index)), GetHandle()); -} - -template<> -inline File Resultset::Get(const ostring& name) const -{ - return File(Check(OCI_GetFile2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Clong Resultset::Get(unsigned int index) const -{ - return Clong(Check(OCI_GetLong(*this, index)), GetHandle()); -} - -template<> -inline Clong Resultset::Get(const ostring& name) const -{ - return Clong(Check(OCI_GetLong2(*this,name.c_str())), GetHandle()); -} - -template<> -inline Blong Resultset::Get(unsigned int index) const -{ - return Blong(Check(OCI_GetLong(*this, index)), GetHandle()); -} - -template<> -inline Blong Resultset::Get(const ostring& name) const -{ - return Blong(Check(OCI_GetLong2(*this,name.c_str())), GetHandle()); -} - -template -T Resultset::Get(unsigned int index) const -{ - return T(Check(OCI_GetColl(*this, index)), GetHandle()); -} - -template -T Resultset::Get(const ostring& name) const -{ - return T(Check(OCI_GetColl2(*this, name.c_str())), GetHandle()); -} - -/* --------------------------------------------------------------------------------------------- * - * Column - * --------------------------------------------------------------------------------------------- */ - -inline Column::Column(OCI_Column *pColumn, Handle *parent) -{ - Acquire(pColumn, nullptr, nullptr, parent); -} - -inline ostring Column::GetName() const -{ - return MakeString(Check(OCI_ColumnGetName(*this))); -} - -inline ostring Column::GetSQLType() const -{ - return MakeString(Check(OCI_ColumnGetSQLType(*this))); -} - -inline ostring Column::GetFullSQLType() const -{ - const unsigned int size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_ColumnGetFullSQLType(*this, buffer, size)); - - return MakeString(static_cast(buffer)); -} - -inline DataType Column::GetType() const -{ - return DataType(static_cast(Check(OCI_ColumnGetType(*this)))); -} - -inline unsigned int Column::GetSubType() const -{ - return Check(OCI_ColumnGetSubType(*this)); -} - -inline CharsetForm Column::GetCharsetForm() const -{ - return CharsetForm(static_cast(Check(OCI_ColumnGetCharsetForm(*this)))); -} - -inline CollationID Column::GetCollationID() const -{ - return CollationID(static_cast(Check(OCI_ColumnGetCollationID(*this)))); -} - -inline unsigned int Column::GetSize() const -{ - return Check(OCI_ColumnGetSize(*this)); -} - -inline int Column::GetScale() const -{ - return Check(OCI_ColumnGetScale(*this)); -} - -inline int Column::GetPrecision() const -{ - return Check(OCI_ColumnGetPrecision(*this)); -} - -inline int Column::GetFractionalPrecision() const -{ - return Check(OCI_ColumnGetFractionalPrecision(*this)); -} - -inline int Column::GetLeadingPrecision() const -{ - return Check(OCI_ColumnGetLeadingPrecision(*this)); -} - -inline Column::PropertyFlags Column::GetPropertyFlags() const -{ - return PropertyFlags(static_cast(Check(OCI_ColumnGetPropertyFlags(*this)))); -} - -inline bool Column::IsNullable() const -{ - return (Check(OCI_ColumnGetNullable(*this)) == TRUE); -} - -inline bool Column::IsCharSemanticUsed() const -{ - return (Check(OCI_ColumnGetCharUsed(*this)) == TRUE); -} - -inline TypeInfo Column::GetTypeInfo() const -{ - return TypeInfo(Check(OCI_ColumnGetTypeInfo(*this))); -} - -/* --------------------------------------------------------------------------------------------- * - * Subscription - * --------------------------------------------------------------------------------------------- */ - -inline Subscription::Subscription() -{ - -} - -inline Subscription::Subscription(OCI_Subscription *pSubcription) -{ - Acquire(pSubcription, nullptr, nullptr, nullptr); -} - -inline void Subscription::Register(const Connection &connection, const ostring& name, ChangeTypes changeTypes, NotifyHandlerProc handler, unsigned int port, unsigned int timeout) -{ - Acquire(Check(OCI_SubscriptionRegister(connection, name.c_str(), changeTypes.GetValues(), - static_cast (handler != nullptr ? Environment::NotifyHandler : nullptr), port, timeout)), - reinterpret_cast(OCI_SubscriptionUnregister), nullptr, nullptr); - - Environment::SetUserCallback(static_cast(*this), handler); -} - -inline void Subscription::Unregister() -{ - Environment::SetUserCallback(static_cast(*this), nullptr); - - Release(); -} - -inline void Subscription::Watch(const ostring& sql) -{ - Statement st(GetConnection()); - - st.Execute(sql); - - Check(OCI_SubscriptionAddStatement(*this, st)); -} - -inline ostring Subscription::GetName() const -{ - return MakeString(Check(OCI_SubscriptionGetName(*this))); -} - -inline unsigned int Subscription::GetTimeout() const -{ - return Check(OCI_SubscriptionGetTimeout(*this)); -} - -inline unsigned int Subscription::GetPort() const -{ - return Check(OCI_SubscriptionGetPort(*this)); -} - -inline Connection Subscription::GetConnection() const -{ - return Connection(Check(OCI_SubscriptionGetConnection(*this)), nullptr); -} - -/* --------------------------------------------------------------------------------------------- * - * Event - * --------------------------------------------------------------------------------------------- */ - -inline Event::Event(OCI_Event *pEvent) -{ - Acquire(pEvent, nullptr, nullptr, nullptr); -} - -inline Event::EventType Event::GetType() const -{ - return EventType(static_cast(Check(OCI_EventGetType(*this)))); -} - -inline Event::ObjectEvent Event::GetObjectEvent() const -{ - return ObjectEvent(static_cast(Check(OCI_EventGetOperation(*this)))); -} - -inline ostring Event::GetDatabaseName() const -{ - return MakeString(Check(OCI_EventGetDatabase(*this))); -} - -inline ostring Event::GetObjectName() const -{ - return MakeString(Check(OCI_EventGetObject(*this))); -} - -inline ostring Event::GetRowID() const -{ - return MakeString(Check(OCI_EventGetRowid(*this))); -} - -inline Subscription Event::GetSubscription() const -{ - return Subscription(Check(OCI_EventGetSubscription(*this))); -} - -/* --------------------------------------------------------------------------------------------- * - * Agent - * --------------------------------------------------------------------------------------------- */ - -inline Agent::Agent(const Connection &connection, const ostring& name, const ostring& address) -{ - Acquire(Check(OCI_AgentCreate(connection, name.c_str(), address.c_str())), reinterpret_cast(OCI_AgentFree), nullptr, nullptr); -} - -inline Agent::Agent(OCI_Agent *pAgent, Handle *parent) -{ - Acquire(pAgent, nullptr, nullptr, parent); -} - -inline ostring Agent::GetName() const -{ - return MakeString(Check(OCI_AgentGetName(*this))); -} - -inline void Agent::SetName(const ostring& value) -{ - Check(OCI_AgentSetName(*this, value.c_str())); -} - -inline ostring Agent::GetAddress() const -{ - return MakeString(Check(OCI_AgentGetAddress(*this))); -} - -inline void Agent::SetAddress(const ostring& value) -{ - Check(OCI_AgentSetAddress(*this, value.c_str())); -} - -/* --------------------------------------------------------------------------------------------- * - * Message - * --------------------------------------------------------------------------------------------- */ - -inline Message::Message(const TypeInfo &typeInfo) -{ - Acquire(Check(OCI_MsgCreate(typeInfo)), reinterpret_cast(OCI_MsgFree), nullptr, nullptr); -} - -inline Message::Message(OCI_Msg *pMessage, Handle *parent) -{ - Acquire(pMessage, nullptr, nullptr, parent); -} - -inline void Message::Reset() -{ - Check(OCI_MsgReset(*this)); -} - -template<> -inline Object Message::GetPayload() -{ - return Object(Check(OCI_MsgGetObject(*this)), nullptr); -} - -template<> -inline void Message::SetPayload(const Object &value) -{ - Check(OCI_MsgSetObject(*this, value)); -} - -template<> -inline Raw Message::GetPayload() -{ - unsigned int size = 0; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_MsgGetRaw(*this, static_cast(buffer), &size)); - - return MakeRaw(buffer, size); -} - -template<> -inline void Message::SetPayload(const Raw &value) -{ - const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; - - Check(OCI_MsgSetRaw(*this, data, static_cast(value.size()))); -} - -inline Date Message::GetEnqueueTime() const -{ - return Date(Check(OCI_MsgGetEnqueueTime(*this)), nullptr); -} - -inline int Message::GetAttemptCount() const -{ - return Check(OCI_MsgGetAttemptCount(*this)); -} - -inline Message::MessageState Message::GetState() const -{ - return MessageState(static_cast(Check(OCI_MsgGetState(*this)))); -} - -inline Raw Message::GetID() const -{ - unsigned int size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_MsgGetID(*this, static_cast(buffer), &size)); - - return MakeRaw(buffer, size); -} - -inline int Message::GetExpiration() const -{ - return Check(OCI_MsgGetExpiration(*this)); -} - -inline void Message::SetExpiration(int value) -{ - Check(OCI_MsgSetExpiration(*this, value)); -} - -inline int Message::GetEnqueueDelay() const -{ - return Check(OCI_MsgGetEnqueueDelay(*this)); -} - -inline void Message::SetEnqueueDelay(int value) -{ - Check(OCI_MsgSetEnqueueDelay(*this, value)); -} - -inline int Message::GetPriority() const -{ - return Check(OCI_MsgGetPriority(*this)); -} - -inline void Message::SetPriority(int value) -{ - Check(OCI_MsgSetPriority(*this, value)); -} - -inline Raw Message::GetOriginalID() const -{ - unsigned int size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_MsgGetOriginalID(*this, static_cast(buffer), &size)); - - return MakeRaw(buffer, size); -} - -inline void Message::SetOriginalID(const Raw &value) -{ - const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; - - Check(OCI_MsgSetOriginalID(*this, data, static_cast(value.size()))); -} - -inline ostring Message::GetCorrelation() const -{ - return MakeString(Check(OCI_MsgGetCorrelation(*this))); -} - -inline void Message::SetCorrelation(const ostring& value) -{ - Check(OCI_MsgSetCorrelation(*this, value.c_str())); -} - -inline ostring Message::GetExceptionQueue() const -{ - return MakeString(Check(OCI_MsgGetExceptionQueue(*this))); -} - -inline void Message::SetExceptionQueue(const ostring& value) -{ - Check(OCI_MsgSetExceptionQueue(*this, value.c_str())); -} - -inline Agent Message::GetSender() const -{ - return Agent(Check(OCI_MsgGetSender(*this)), nullptr); -} - -inline void Message::SetSender(const Agent &agent) -{ - Check(OCI_MsgSetSender(*this, agent)); -} - -inline void Message::SetConsumers(std::vector &agents) -{ - const size_t size = agents.size(); - ManagedBuffer buffer(size); - - OCI_Agent ** pAgents = static_cast(buffer); - - for (size_t i = 0; i < size; ++i) - { - pAgents[i] = static_cast(agents[i]); - } - - Check(OCI_MsgSetConsumers(*this, pAgents, static_cast(size))); -} - -/* --------------------------------------------------------------------------------------------- * - * Enqueue - * --------------------------------------------------------------------------------------------- */ - -inline Enqueue::Enqueue(const TypeInfo &typeInfo, const ostring& queueName) -{ - Acquire(Check(OCI_EnqueueCreate(typeInfo, queueName.c_str())), reinterpret_cast(OCI_EnqueueFree), nullptr, nullptr); -} - -inline void Enqueue::Put(const Message &message) -{ - Check(OCI_EnqueuePut(*this, message)); -} - -inline Enqueue::EnqueueVisibility Enqueue::GetVisibility() const -{ - return EnqueueVisibility(static_cast(Check(OCI_EnqueueGetVisibility(*this)))); -} - -inline void Enqueue::SetVisibility(EnqueueVisibility value) -{ - Check(OCI_EnqueueSetVisibility(*this, value)); -} - -inline Enqueue::EnqueueMode Enqueue::GetMode() const -{ - return EnqueueMode(static_cast(Check(OCI_EnqueueGetSequenceDeviation(*this)))); -} - -inline void Enqueue::SetMode(EnqueueMode value) -{ - Check(OCI_EnqueueSetSequenceDeviation(*this, value)); -} - -inline Raw Enqueue::GetRelativeMsgID() const -{ - unsigned int size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(static_cast(size + 1)); - - Check(OCI_EnqueueGetRelativeMsgID(*this, static_cast(buffer), &size)); - - return MakeRaw(buffer, size); -} - -inline void Enqueue::SetRelativeMsgID(const Raw &value) -{ - const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; - - Check(OCI_EnqueueSetRelativeMsgID(*this, data, static_cast(value.size()))); -} - -/* --------------------------------------------------------------------------------------------- * - * Dequeue - * --------------------------------------------------------------------------------------------- */ - -inline Dequeue::Dequeue(const TypeInfo &typeInfo, const ostring& queueName) -{ - Acquire(Check(OCI_DequeueCreate(typeInfo, queueName.c_str())), reinterpret_cast(OCI_DequeueFree), nullptr, nullptr); -} - -inline Dequeue::Dequeue(OCI_Dequeue *pDequeue) -{ - Acquire(pDequeue, nullptr, nullptr, nullptr); -} - -inline Message Dequeue::Get() -{ - return Message(Check(OCI_DequeueGet(*this)), nullptr); -} - -inline Agent Dequeue::Listen(int timeout) -{ - return Agent(Check(OCI_DequeueListen(*this, timeout)), nullptr); -} - -inline ostring Dequeue::GetConsumer() const -{ - return MakeString(Check(OCI_DequeueGetConsumer(*this))); -} - -inline void Dequeue::SetConsumer(const ostring& value) -{ - Check(OCI_DequeueSetConsumer(*this, value.c_str())); -} - -inline ostring Dequeue::GetCorrelation() const -{ - return MakeString(Check(OCI_DequeueGetCorrelation(*this))); -} - -inline void Dequeue::SetCorrelation(const ostring& value) -{ - Check(OCI_DequeueSetCorrelation(*this, value.c_str())); -} - -inline Raw Dequeue::GetRelativeMsgID() const -{ - unsigned int size = OCI_SIZE_BUFFER; - - ManagedBuffer buffer(size + 1); - - Check(OCI_DequeueGetRelativeMsgID(*this, static_cast(buffer), &size)); - - return MakeRaw(buffer, size); -} - -inline void Dequeue::SetRelativeMsgID(const Raw &value) -{ - const AnyPointer data = value.empty() ? nullptr : static_cast(const_cast(&value[0])) ; - - Check(OCI_DequeueSetRelativeMsgID(*this, data, static_cast(value.size()))); -} - -inline Dequeue::DequeueVisibility Dequeue::GetVisibility() const -{ - return DequeueVisibility(static_cast(Check(OCI_DequeueGetVisibility(*this)))); -} - -inline void Dequeue::SetVisibility(DequeueVisibility value) -{ - Check(OCI_DequeueSetVisibility(*this, value)); -} - -inline Dequeue::DequeueMode Dequeue::GetMode() const -{ - return DequeueMode(static_cast(Check(OCI_DequeueGetMode(*this)))); -} - -inline void Dequeue::SetMode(DequeueMode value) -{ - Check(OCI_DequeueSetMode(*this, value)); -} - -inline Dequeue::NavigationMode Dequeue::GetNavigation() const -{ - return NavigationMode(static_cast(Check(OCI_DequeueGetNavigation(*this)))); -} - -inline void Dequeue::SetNavigation(NavigationMode value) -{ - Check(OCI_DequeueSetNavigation(*this, value)); -} - -inline int Dequeue::GetWaitTime() const -{ - return Check(OCI_DequeueGetWaitTime(*this)); -} - -inline void Dequeue::SetWaitTime(int value) -{ - Check(OCI_DequeueSetWaitTime(*this, value)); -} - -inline void Dequeue::SetAgents(std::vector &agents) -{ - const size_t size = agents.size(); - ManagedBuffer buffer(size); - - OCI_Agent ** pAgents = static_cast(buffer); - - for (size_t i = 0; i < size; ++i) - { - pAgents[i] = static_cast(agents[i]); - } - - Check(OCI_DequeueSetAgentList(*this, pAgents, static_cast(size))); -} - -inline void Dequeue::Subscribe(unsigned int port, unsigned int timeout, NotifyAQHandlerProc handler) -{ - Check(OCI_DequeueSubscribe(*this, port, timeout, static_cast(handler != nullptr ? Environment::NotifyHandlerAQ : nullptr))); - - Environment::SetUserCallback(static_cast(*this), handler); -} - -inline void Dequeue::Unsubscribe() -{ - Check(OCI_DequeueUnsubscribe(*this)); -} - -/* --------------------------------------------------------------------------------------------- * - * DirectPath - * --------------------------------------------------------------------------------------------- */ - -inline DirectPath::DirectPath(const TypeInfo &typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring& partition) -{ - Acquire(Check(OCI_DirPathCreate(typeInfo, partition.c_str(), nbCols, nbRows)), reinterpret_cast(OCI_DirPathFree), nullptr, nullptr); -} - -inline void DirectPath::SetColumn(unsigned int colIndex, const ostring& name, unsigned int maxSize, const ostring& format) -{ - Check(OCI_DirPathSetColumn(*this, colIndex, name.c_str(), maxSize, format.c_str())); -} - -template -inline void DirectPath::SetEntry(unsigned int rowIndex, unsigned int colIndex, const T &value, bool complete) -{ - Check(OCI_DirPathSetEntry(*this, rowIndex, colIndex, static_cast(const_cast(value.c_str())), static_cast(value.size()), complete)); -} - -inline void DirectPath::Reset() -{ - Check(OCI_DirPathReset(*this)); -} - -inline void DirectPath::Prepare() -{ - Check(OCI_DirPathPrepare(*this)); -} - -inline DirectPath::Result DirectPath::Convert() -{ - return Result(static_cast(Check(OCI_DirPathConvert(*this)))); -} - -inline DirectPath::Result DirectPath::Load() -{ - return Result(static_cast(Check(OCI_DirPathLoad(*this)))); -} - -inline void DirectPath::Finish() -{ - Check(OCI_DirPathFinish(*this)); -} - -inline void DirectPath::Abort() -{ - Check(OCI_DirPathAbort(*this)); -} - -inline void DirectPath::Save() -{ - Check(OCI_DirPathSave(*this)); -} - -inline void DirectPath::FlushRow() -{ - Check(OCI_DirPathFlushRow(*this)); -} - -inline void DirectPath::SetCurrentRows(unsigned int value) -{ - Check(OCI_DirPathSetCurrentRows(*this, value)); -} - -inline unsigned int DirectPath::GetCurrentRows() const -{ - return Check(OCI_DirPathGetCurrentRows(*this)); -} - -inline unsigned int DirectPath::GetMaxRows() const -{ - return Check(OCI_DirPathGetMaxRows(*this)); -} - -inline unsigned int DirectPath::GetRowCount() const -{ - return Check(OCI_DirPathGetRowCount(*this)); -} - -inline unsigned int DirectPath::GetAffectedRows() const -{ - return Check(OCI_DirPathGetAffectedRows(*this)); -} - -inline void DirectPath::SetDateFormat(const ostring& format) -{ - Check(OCI_DirPathSetDateFormat(*this, format.c_str())); -} - -inline void DirectPath::SetParallel(bool value) -{ - Check(OCI_DirPathSetParallel(*this, value)); -} - -inline void DirectPath::SetNoLog(bool value) -{ - Check(OCI_DirPathSetNoLog(*this, value)); -} - -inline void DirectPath::SetCacheSize(unsigned int value) -{ - Check(OCI_DirPathSetCacheSize(*this, value)); -} - -inline void DirectPath::SetBufferSize(unsigned int value) -{ - Check(OCI_DirPathSetBufferSize(*this, value)); -} - -inline void DirectPath::SetConversionMode(ConversionMode value) -{ - Check(OCI_DirPathSetConvertMode(*this, value)); -} - -inline unsigned int DirectPath::GetErrorColumn() -{ - return Check(OCI_DirPathGetErrorColumn(*this)); -} - -inline unsigned int DirectPath::GetErrorRow() -{ - return Check(OCI_DirPathGetErrorRow(*this)); -} - -/* --------------------------------------------------------------------------------------------- * - * Queue - * --------------------------------------------------------------------------------------------- */ - -inline void Queue::Create(const Connection &connection, const ostring& queue, const ostring& table, QueueType queueType, unsigned int maxRetries, - unsigned int retryDelay, unsigned int retentionTime, bool dependencyTracking, const ostring& comment) -{ - Check(OCI_QueueCreate(connection, queue.c_str(), table.c_str(), queueType, maxRetries, retryDelay, retentionTime, dependencyTracking, comment.c_str())); -} - -inline void Queue::Alter(const Connection &connection, const ostring& queue, unsigned int maxRetries, unsigned int retryDelay, unsigned int retentionTime, const ostring& comment) -{ - Check(OCI_QueueAlter(connection, queue.c_str(), maxRetries, retryDelay, retentionTime, comment.c_str())); -} - -inline void Queue::Drop(const Connection &connection, const ostring& queue) -{ - Check(OCI_QueueDrop(connection, queue.c_str())); -} - -inline void Queue::Start(const Connection &connection, const ostring& queue, bool enableEnqueue, bool enableDequeue) -{ - Check(OCI_QueueStart(connection, queue.c_str(), enableEnqueue, enableDequeue)); -} - -inline void Queue::Stop(const Connection &connection, const ostring& queue, bool stopEnqueue, bool stopDequeue, bool wait) -{ - Check(OCI_QueueStop(connection, queue.c_str(), stopEnqueue, stopDequeue, wait)); -} - -/* --------------------------------------------------------------------------------------------- * - * QueueTable - * --------------------------------------------------------------------------------------------- */ - -inline void QueueTable::Create(const Connection &connection, const ostring& table, const ostring& payloadType, bool multipleConsumers, const ostring& storageClause, const ostring& sortList, - GroupingMode groupingMode, const ostring& comment, unsigned int primaryInstance, unsigned int secondaryInstance, const ostring& compatible) - -{ - Check(OCI_QueueTableCreate(connection, table.c_str(), payloadType.c_str(), storageClause.c_str(), sortList.c_str(), multipleConsumers, - groupingMode, comment.c_str(), primaryInstance, secondaryInstance, compatible.c_str())); -} - -inline void QueueTable::Alter(const Connection &connection, const ostring& table, const ostring& comment, unsigned int primaryInstance, unsigned int secondaryInstance) -{ - Check(OCI_QueueTableAlter(connection, table.c_str(), comment.c_str(), primaryInstance, secondaryInstance)); -} - -inline void QueueTable::Drop(const Connection &connection, const ostring& table, bool force) -{ - Check(OCI_QueueTableDrop(connection, table.c_str(), force)); -} - -inline void QueueTable::Purge(const Connection &connection, const ostring& table, PurgeMode mode, const ostring& condition, bool block) -{ - Check(OCI_QueueTablePurge(connection, table.c_str(), condition.c_str(), block, static_cast(mode))); -} - -inline void QueueTable::Migrate(const Connection &connection, const ostring& table, const ostring& compatible) -{ - Check(OCI_QueueTableMigrate(connection, table.c_str(), compatible.c_str())); -} - -/** - * @} - */ - -} diff --git a/include/ocilibcpp/support.hpp b/include/ocilibcpp/support.hpp new file mode 100644 index 00000000..68923fcc --- /dev/null +++ b/include/ocilibcpp/support.hpp @@ -0,0 +1,201 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "ocilibcpp/core.hpp" + +namespace ocilib +{ + namespace support + { + /** + * @brief Internal usage. + * Allow resolving a native type used by C API from a C++ type in binding operations + */ + template struct BindResolver {}; + + + class BindObject + { + public: + + BindObject(const Statement& statement, const ostring& name, unsigned int mode); + + virtual ~BindObject() noexcept; + + ostring GetName() const; + + Statement GetStatement() const; + + unsigned int GetMode() const; + + virtual void SetInData() = 0; + virtual void SetOutData() = 0; + + protected: + + const Statement& _statement; + ostring _name; + unsigned int _mode; + }; + + class BindArray : public BindObject + { + public: + + BindArray(const Statement& statement, const ostring& name, unsigned int mode); + virtual ~BindArray() noexcept; + + template + void SetVector(std::vector& vector, bool isPlSqlTable, unsigned int elemSize); + + template + typename BindResolver::OutputType* GetData() const; + + void SetInData() override; + void SetOutData() override; + + unsigned int GetSize() const; + unsigned int GetSizeForBindCall() const; + + private: + + class AbstractBindArrayObject + { + public: + virtual ~AbstractBindArrayObject() {}; + virtual void SetInData() = 0; + virtual void SetOutData() = 0; + virtual ostring GetName() const = 0; + virtual bool IsHandleObject() const = 0; + virtual unsigned int GetSize() const = 0; + virtual unsigned int GetSizeForBindCall() const = 0; + }; + + template + class BindArrayObject : public AbstractBindArrayObject + { + public: + + typedef T ObjectType; + typedef std::vector ObjectVector; + typedef typename BindResolver::OutputType NativeType; + + BindArrayObject(const Statement& statement, const ostring& name, ObjectVector& vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize); + virtual ~BindArrayObject() noexcept; + void SetInData() override; + void SetOutData() override; + ostring GetName()const override; + bool IsHandleObject() const override; + unsigned int GetSize() const override; + unsigned int GetSizeForBindCall() const override; + + operator ObjectVector& () const; + operator NativeType* () const; + + private: + + void AllocData(); + void FreeData() const; + + const Statement& _statement; + ostring _name; + ObjectVector& _vector; + NativeType* _data; + bool _isPlSqlTable; + unsigned int _mode; + unsigned int _elemCount; + unsigned int _elemSize; + }; + + AbstractBindArrayObject* _object; + }; + + template + class BindObjectAdaptor : public BindObject + { + friend class Statement; + + public: + + typedef T ObjectType; + typedef typename BindResolver::OutputType NativeType; + + operator NativeType* () const; + + void SetInData() override; + void SetOutData() override; + + BindObjectAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object, unsigned int size); + virtual ~BindObjectAdaptor() noexcept; + + private: + + ObjectType& _object; + NativeType* _data; + unsigned int _size; + }; + + template + class BindTypeAdaptor : public BindObject + { + friend class Statement; + + public: + + typedef T ObjectType; + typedef typename BindResolver::OutputType NativeType; + + operator NativeType* () const; + + void SetInData() override; + void SetOutData() override; + + BindTypeAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object); + virtual ~BindTypeAdaptor() noexcept; + + private: + + ObjectType& _object; + NativeType* _data; + }; + + class BindsHolder + { + public: + + BindsHolder(const Statement& statement); + ~BindsHolder() noexcept; + + void Clear(); + + void AddBindObject(BindObject* bindObject); + + void SetOutData(); + void SetInData(); + + private: + + std::vector _bindObjects; + const Statement& _statement; + }; + } +} diff --git a/include/ocilibcpp/types.hpp b/include/ocilibcpp/types.hpp new file mode 100644 index 00000000..0ed3293a --- /dev/null +++ b/include/ocilibcpp/types.hpp @@ -0,0 +1,9042 @@ +/* + * OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI) + * + * Website: http://www.ocilib.net + * + * Copyright (c) 2007-2020 Vincent ROGIER + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "ocilibcpp/core.hpp" +#include "ocilibcpp/support.hpp" + +namespace ocilib +{ + + /** + * @brief + * Oracle Version enumerated values + * + */ + enum OracleVersionValues + { + Oracle80 = OCI_8_0, + Oracle8i = OCI_8_1, + Oracle9iR1 = OCI_9_0, + Oracle9iR2 = OCI_9_2, + Oracle10gR1 = OCI_10_1, + Oracle10gR2 = OCI_10_2, + Oracle11gR1 = OCI_11_1, + Oracle11gR2 = OCI_11_2, + Oracle12cR1 = OCI_12_1, + Oracle12cR2 = OCI_12_2, + Oracle18cR1 = OCI_18_1, + Oracle18cR2 = OCI_18_2, + Oracle18cR3 = OCI_18_3, + Oracle18cR4 = OCI_18_4 + }; + + /** + * @brief + * Oracle Version + * + * Possible values are DataTypeValues + * + */ + typedef core::Enum OracleVersion; + + /** + * @brief + * Data type enumerated values + * + */ + enum DataTypeValues + { + /** NUMERIC */ + TypeNumeric = OCI_CDT_NUMERIC, + /** DATE */ + TypeDate = OCI_CDT_DATETIME, + /** TEXT */ + TypeString = OCI_CDT_TEXT, + /** LONG / LONG RAW */ + TypeLong = OCI_CDT_LONG, + /** SQL CURSOR */ + TypeStatement = OCI_CDT_CURSOR, + /** CLOB or BLOB */ + TypeLob = OCI_CDT_LOB, + /** FILE */ + TypeFile = OCI_CDT_FILE, + /** TIMESTAMP */ + TypeTimestamp = OCI_CDT_TIMESTAMP, + /** INTERVAL */ + TypeInterval = OCI_CDT_INTERVAL, + /** RAW */ + TypeRaw = OCI_CDT_RAW, + /** Object type */ + TypeObject = OCI_CDT_OBJECT, + /** Collection */ + TypeCollection = OCI_CDT_COLLECTION, + /** Object REF */ + TypeReference = OCI_CDT_REF, + /** PL/SQL boolean */ + TypeBoolean = OCI_CDT_BOOLEAN + }; + + /** + * @brief + * Column data type + * + * Possible values are DataTypeValues + * + */ + typedef core::Enum DataType; + + /** + * @brief + * Numeric type enumerated values + * + */ + enum NumericTypeValues + { + /** Signed short */ + NumericShort = OCI_NUM_SHORT, + /** Signed Integer */ + NumericInt = OCI_NUM_INT, + /** Signed Big Integer (Integer or Long Integer depending on the compiler )*/ + NumericBigInt = OCI_NUM_BIGINT, + /** Unsigned short */ + NumericUnsignedShort = OCI_NUM_USHORT, + /** Unsigned Integer */ + NumericUnsignedInt = OCI_NUM_UINT, + /** Unsigned Big Integer (Integer or Long Integer depending on the compiler )*/ + NumericUnsignedBigInt = OCI_NUM_BIGUINT, + /** Double */ + NumericDouble = OCI_NUM_DOUBLE, + /** Float */ + NumericFloat = OCI_NUM_FLOAT, + /** Number */ + NumericNumber = OCI_NUM_NUMBER + }; + + /** + * @brief + * Numeric data type + * + * Possible values are NumericTypeValues + * + */ + typedef core::Enum NumericType; + + /** + * @brief + * Charset form enumerated values + * + */ + enum CharsetFormValues + { + /** Database character set will be converted to the server national character set */ + CharsetFormDefault = OCI_CSF_DEFAULT, + /** Client national character set will be converted to the server national character set */ + CharsetFormNational = OCI_CSF_NATIONAL + }; + + /** + * @brief + * Type of charsetForm + * + * Possible values are CharsetFormValues + * + */ + typedef core::Enum CharsetForm; + + /** + * @brief + * Collation ID enumerated values + * + */ + enum CollationIDValues + { + /** None */ + CollationIDNone = OCI_CCI_NONE, + /** Compare */ + CollationIDNlsComp = OCI_CCI_NLS_COMP, + /** Sort */ + CollationIDNlsSort = OCI_CCI_NLS_SORT, + /** Sort CI */ + CollationIDNlsSortCI = OCI_CCI_NLS_SORT_CI, + /** Sort AI */ + CollationIDNlsSortAI = OCI_CCI_NLS_SORT_AI, + /** Sort CS */ + CollationIDNlsSortCS = OCI_CCI_NLS_SORT_CS, + /** Sort VAR 1 */ + CollationIDNlsSortVar1 = OCI_CCI_NLS_SORT_VAR1, + /** Sort VAR 1 CI */ + CollationIDNlsSortVar1CI = OCI_CCI_NLS_SORT_VAR1_CI, + /** Sort VAR 1 AI */ + CollationIDNlsSortVar1AI = OCI_CCI_NLS_SORT_VAR1_AI, + /** Sort VAR 1 CS */ + CollationIDNlsSortVar1CS = OCI_CCI_NLS_SORT_VAR1_CS, + /** Binary */ + CollationIDBinary = OCI_CCI_BINARY, + /** Binary CI */ + CollationIDBinaryCI = OCI_CCI_BINARY_CI, + /** Binary AI */ + CollationIDBinaryAI = OCI_CCI_BINARY_AI + }; + + /** + * @brief + * Type of Collation ID + * + * Possible values are CollationIDValues + * + */ + typedef core::Enum CollationID; + + + /** + * @brief + * Seek Modes enumerated values + * + */ + enum SeekModeValues + { + /** Set the current position within the stream to the given position */ + SeekSet = OCI_SEEK_SET, + /** Set the current position within the stream begin position */ + SeekEnd = OCI_SEEK_END, + /** Set the current position within the stream to the given value offset from the current position */ + SeekOffset = OCI_SEEK_CUR + }; + + /** + * @brief + * Seek Modes + * + * Possible values are SeekModeValues + * + */ + typedef core::Enum SeekMode; + + /** + * @brief + * Open Modes enumerated values + * + */ + enum OpenModeValues + { + /** Stream is opened for read access */ + ReadOnly = OCI_LOB_READONLY, + /** Stream is opened for read / write access */ + ReadWrite = OCI_LOB_READWRITE + }; + + /** + * @brief + * Open Modes + * + * Possible values are OpenModeValues + * + */ + typedef core::Enum OpenMode; + + /** + * @brief + * Lob types enumerated values + * + */ + enum LobTypeValues + { + /** */ + LobBinary = OCI_BLOB, + /** */ + LobCharacter = OCI_CLOB, + /** */ + LobNationalCharacter = OCI_NCLOB + }; + + /** + * @brief + * Type of Lob + * + * Possible values are LobTypeValues + * + */ + typedef core::Enum LobType; + + /** + * @brief + * Long types enumerated values + * + */ + enum LongTypeValues + { + /** */ + LongBinary = OCI_BLONG, + /** */ + LongCharacter = OCI_CLONG + }; + + /** + * @brief + * Type of Long + * + * Possible values are LongTypeValues + * + */ + typedef core::Enum LongType; + + /** + * @brief + * Format type enumerated values + * + */ + enum FormatTypeValues + { + /** Date */ + FormatDate = OCI_FMT_DATE, + /** Timestamp */ + FormatTimestamp = OCI_FMT_TIMESTAMP, + /** All numeric types */ + FormatNumeric = OCI_FMT_NUMERIC, + /** BinaryDouble */ + FormatBinaryDouble = OCI_FMT_BINARY_DOUBLE, + /** Binary Float */ + FormatBinaryFloat = OCI_FMT_BINARY_FLOAT + }; + + /** + * @brief + * Format type + * + * Possible values are FormatTypeValues + * + */ + typedef core::Enum FormatType; + + /** + * + * @brief + * Exception class handling all OCILIB errors + * + * This class wraps the OCILIB object handle OCI_Error and its related methods + * + */ + class Exception : public std::exception + { + template + friend T core::Check(T result); + friend class Statement; + + public: + + /** + * @brief + * Exception type enumerated values + * + */ + enum ExceptionTypeValues + { + /** Exception caused by an Oracle error */ + OracleError = OCI_ERR_ORACLE, + /** Exception caused by an Ocilib error */ + OcilibError = OCI_ERR_OCILIB, + /** Exception caused by an Oracle Warning */ + OracleWarning = OCI_ERR_WARNING + }; + + /** + * @brief + * Type of Exception + * + * Possible values are Exception::ExceptionTypeValues + * + */ + typedef core::Enum ExceptionType; + + /** + * @brief + * Retrieve the error message + * + */ + ostring GetMessage() const; + + /** + * + * @brief + * Return the Exception type + * + */ + ExceptionType GetType() const; + + /** + * @brief + * Return the Oracle error code + * + */ + int GetOracleErrorCode() const; + + /** + * @brief + * Return the OCILIB error code + * + */ + int GetInternalErrorCode() const; + + /** + * @brief + * Return the statement within the error occurred + * + */ + Statement GetStatement() const; + + /** + * @brief + * Return the connection within the error occurred + * + */ + Connection GetConnection() const; + + /** + * @brief + * Return the row index which caused an error during statement execution + * + * @warning + * Row index start at 1. + * + * @return + * - 0 if the error is not related to array DML + * - otherwise the index of the given row which caused the error + * + */ + unsigned int GetRow() const; + + /** + * @brief + * Override the std::exception::what() method + * + * @return + * - The same content as GetMessage() but as using const char * type + * + */ + const char* what() const noexcept override; + + Exception(const Exception& other) noexcept; + + Exception& operator = (const Exception& other) noexcept; + + /** + * @brief + * Virtual destructor required for deriving from std::exception + * + */ + virtual ~Exception() noexcept; + + private: + + Exception() noexcept; + Exception(OCI_Error* err) noexcept; + + void SetWhat(const otext* value) noexcept; + + otext* _what; + OCI_Statement* _pStatement; + OCI_Connection* _pConnnection; + unsigned int _row; + ExceptionType _type; + int _errLib; + int _errOracle; + }; + + /** + * @brief + * Static class in charge of library initialization / cleanup + * + */ + class Environment + { + friend class Mutex; + friend class Connection; + friend class Pool; + friend class Subscription; + friend class Dequeue; + template + friend class core::HandleHolder; + + public: + + /** + * @brief + * HA Event sources enumerated values + * + */ + enum HAEventSourceValues + { + /** The event has been generated by an Oracle instance */ + SourceInstance = OCI_HES_INSTANCE, + /** The event has been generated by an Oracle database */ + SourceDatabase = OCI_HES_DATABASE, + /** The event has been generated by an Oracle Node */ + SourceNode = OCI_HES_NODE, + /** The event has been generated by an Oracle service */ + SourceService = OCI_HES_SERVICE, + /** The event has been generated by an Oracle service member */ + SourceServiceMember = OCI_HES_SERVICE_MEMBER, + /** The event has been generated by an Oracle ASM instance */ + SourceASMInstance = OCI_HES_ASM_INSTANCE, + /** The event has been generated at service pre connecting stage */ + SourcePreConnect = OCI_HES_PRECONNECT + }; + + /** + * @brief + * Source of HA events + * + * Possible values are Environment::HAEventSourceValues + * + */ + typedef core::Enum HAEventSource; + + /** + * @brief + * HA Event types enumerated values + * + */ + enum HAEventTypeValues + { + /** The source of the event is down */ + EventDown = OCI_HET_DOWN, + /** The source of the event is up (not generated yet by Oracle) */ + EventUp = OCI_HET_UP + }; + + /** + * @brief + * Type of HA events + * + * Possible values are Environment::HAEventTypeValues + * + */ + typedef core::Enum HAEventType; + + /** + * @brief + * Environment Flags enumerated values + * + */ + enum EnvironmentFlagsValues + { + /** Default mode */ + Default = OCI_ENV_DEFAULT, + /** Enable support for multi-threading */ + Threaded = OCI_ENV_THREADED, + /** Enable support for events related to subscriptions, HA and AQ notifications */ + Events = OCI_ENV_EVENTS + }; + + /** + * @brief + * Environment Flags + * + * Possible values are Environment::EnvironmentFlagsValues + * + */ + typedef core::Flags EnvironmentFlags; + + /** + * @brief + * OCI libraries import mode enumerated values + * + */ + enum ImportModeValues + { + /** OCI libraries are linked at compile time */ + ImportLinkage = OCI_IMPORT_MODE_LINKAGE, + /** OCI libraries are dynamically loaded at runtime */ + ImportRuntime = OCI_IMPORT_MODE_RUNTIME + }; + + /** + * @brief + * OCI libraries import mode + * + * Possible values are Environment::ImportMode + * + */ + typedef core::Enum ImportMode; + + /** + * @brief + * Charset mode enumerated values + * + */ + enum CharsetModeValues + { + /** Environment is ANSI string or UTF8 string */ + CharsetAnsi = OCI_CHAR_ANSI, + /** Environment is UNICODE using wide character string */ + CharsetWide = OCI_CHAR_WIDE + }; + + /** + * @brief + * Environment charset mode + * + * Possible values are Environment::CharsetModeValues + * + */ + typedef core::Enum CharsetMode; + + /** + * @brief + * Session flags enumerated values + * + */ + enum SessionFlagsValues + { + /** Default session mode */ + SessionDefault = OCI_SESSION_DEFAULT, + /** Requested session will be created through the XA interface */ + SessionXa = OCI_SESSION_XA, + /** the user is authenticated for SYSDBA access. */ + SessionSysDba = OCI_SESSION_SYSDBA, + /** the user is authenticated for SYSOPER access */ + SessionSysOper = OCI_SESSION_SYSOPER, + /** the user is authenticated for SYSASM access */ + SessionSysAsm = OCI_SESSION_SYSASM, + /** the user is authenticated for SYSBKP access */ + SessionSysBkp = OCI_SESSION_SYSBKP, + /** the user is authenticated for SYSDGD access */ + SessionSysDgD = OCI_SESSION_SYSDGD, + /** the user is authenticated for SYSKMT access */ + SessionSysKmt = OCI_SESSION_SYSKMT, + /** the user is authenticated for SYSRAC access */ + SessionSysRac = OCI_SESSION_SYSRAC, + /** the user is authenticated for PRELIM_AUTH access */ + SessionPreAuth = OCI_SESSION_PRELIM_AUTH + }; + + /** + * @brief + * Sessions flags + * + * Possible values are Environment::SessionFlagsValues + * + */ + typedef core::Flags SessionFlags; + + /** + * @brief + * Oracle instance start modes enumerated values + * + */ + enum StartModeValues + { + /** Start the instance without mounting and opening it */ + StartOnly = OCI_DB_SPM_START, + /** Mount (only) the instance */ + StartMount = OCI_DB_SPM_MOUNT, + /** Open (only) the instance */ + StartOpen = OCI_DB_SPM_OPEN, + /** Start, mount and open the instance */ + StartFull = OCI_DB_SPM_FULL + }; + + /** + * @brief + * Oracle instance start modes + * + * Possible values are Environment::StartModeValues + * + */ + typedef core::Flags StartMode; + + /** + * @brief + * Oracle instance start flags enumerated values + * + */ + enum StartFlagsValues + { + /** Default start flags */ + StartDefault = OCI_DB_SPF_DEFAULT, + /** Shuts down a running instance (if needed) using ABORT command and starts a new instance */ + StartForce = OCI_DB_SPF_FORCE, + /** Allows database access only to users with both CREATE SESSION and RESTRICTED SESSION privileges */ + StartRestrict = OCI_DB_SPF_RESTRICT + }; + + /** + * @brief + * Oracle instance start flags + * + * Possible values are Environment::StartFlagsValues + * + */ + typedef core::Flags StartFlags; + + /** + * @brief + * Oracle instance shutdown modes enumerated values + * + */ + enum ShutdownModeValues + { + /** Shutdown the instance */ + ShutdownOnly = OCI_DB_SDM_SHUTDOWN, + /** Close (only) the instance */ + ShutdownClose = OCI_DB_SDM_CLOSE, + /** Dismount (only) the instance */ + ShutdownDismount = OCI_DB_SDM_DISMOUNT, + /** Shutdown, close and dismount the instance */ + ShutdownFull = OCI_DB_SDM_FULL + }; + + /** + * @brief + * Oracle instance shutdown modes + * + * Possible values are Environment::ShutdownModeValues + * + */ + typedef core::Flags ShutdownMode; + + /** + * @brief + * Oracle instance shutdown flags enumerated values + * + */ + enum ShutdownFlagsValues + { + /** - Further connects are prohibited. + * - Waits for users to disconnect from the database */ + ShutdowntDefault = OCI_DB_SDF_DEFAULT, + /** - Further connects are prohibited + * - No new transactions are allowed. */ + ShutdowTrans = OCI_DB_SDF_TRANS, + /** - Further connects are prohibited + * - No new transactions are allowed. + * - Waits for active transactions to complete */ + ShutdownTransLocal = OCI_DB_SDF_TRANS_LOCAL, + /** - Does not wait for current calls to complete or users to disconnect from the database. + * - All uncommitted transactions are terminated and rolled back */ + ShutdownImmediate = OCI_DB_SDF_IMMEDIATE, + /** - Does not wait for current calls to complete or users to disconnect from the database. + * - All uncommitted transactions are terminated and are not rolled back. + * - This is the fastest possible way to shut down the database, but the next + * database startup may require instance recovery. + * - Therefore, this option should be used only in unusual circumstances */ + ShutdownAbort = OCI_DB_SDF_ABORT + }; + + /** + * @brief + * Oracle instance shutdown flags + * + * Possible values are Environment::ShutdownFlagsValues + * + */ + typedef core::Flags ShutdownFlags; + + /** + * @brief + * Allocated Bytes enumerated values + * + */ + enum AllocatedBytesValues + { + /** Allocated bytes by Oracle Client*/ + OracleClientBytes = OCI_MEM_ORACLE, + /** Allocated bytes by OCILIB */ + OcilibBytes = OCI_MEM_OCILIB, + /** All Allocated bytes */ + AllBytes = OCI_MEM_ALL + }; + + /** + * @brief + * Allocated Bytes + * + * Possible values are Environment::AllocatedBytesValues + * + */ + typedef core::Flags AllocatedBytesFlags; + + /** + * @typedef HAHandlerProc + * + * @brief + * User callback for HA event notifications + * + */ + typedef void(*HAHandlerProc) (Connection& con, HAEventSource eventSource, HAEventType eventType, Timestamp& time); + + /** + * @brief + * Initialize the OCILIB environment + * + * @param mode - Environment mode + * @param libpath - Oracle shared library path (optional) + * + * @note + * This function must be called before any other OCILIB library function. + * + * @warning + * - It should be called ONCE per application + * - It is not thread safe + * + * @note + * - The parameter 'libpath' is only used if OCILIB has been built with the option OCI_IMPORT_RUNTIME + * - If the parameter 'lib_path' is NULL, the Oracle library is loaded from system environment variables + * + */ + static void Initialize(EnvironmentFlags mode = Environment::Default, const ostring& libpath = OTEXT("")); + + /** + * @brief + * Clean up all resources allocated by the environment + * + * @note + * This function must be the last OCILIB library function call. + * - It deallocates objects not explicitly freed by the program (connections, statements, ...) + * - It unloads the Oracle shared library if it has been dynamically loaded + * + * @warning + * - It should be called ONCE per application + * - It is not thread safe + * + */ + static void Cleanup(); + + /** + * @brief + * Return the Environment mode flags + * + * @note + * It returns the value of the parameter 'mode' passed to Initialize() + * + */ + static Environment::EnvironmentFlags GetMode(); + + /** + * @brief + * Return the Oracle shared library import mode + * + */ + static Environment::ImportMode GetImportMode(); + + /** + * @brief + * Return the OCILIB charset type + * + */ + static Environment::CharsetMode GetCharset(); + + /** + * @brief + * Return maximum size for a character + * + * @note + * When Charset is Environment::CharsetAnsi and NLS_LANG is UTF8 based, return value is 4 + * Otherwise, it is sizeof(ostring::value_type) + * + */ + static unsigned int GetCharMaxSize(); + + /** + * @brief + * Return the current number of bytes allocated internally in the library + * + * @param type : type of memory to request + * + */ + static big_uint GetAllocatedBytes(AllocatedBytesFlags type); + + /** + * @brief + * Return true if the environment has been successfully initialized + * + */ + static bool Initialized(); + + /** + * @brief + * Return the version of OCI used for compiling OCILIB + * + * @note + * - with linkage build option, the version is determined from the oci.h header through different ways + * - with runtime loading build option, the version is set to the highest version + * of OCI needed by OCILIB, not necessarily the real OCI version + * + */ + static OracleVersion GetCompileVersion(); + + /** + * @brief + * Return the major version number of OCI used for compiling OCILIB + * + */ + static unsigned int GetCompileMajorVersion(); + + /** + * @brief + * Return the minor version number of OCI used for compiling OCILIB + * + */ + static unsigned int GetCompileMinorVersion(); + + /** + * @brief + * Return the revision version number of OCI used for compiling OCILIB + * + */ + static unsigned int GetCompileRevisionVersion(); + + /** + * @brief + * Return the version of OCI used at runtime + * + * @note + * - with linkage build option, the version is determined from the oci.h header through different ways + * - with runtime loading build option, the version determined from the symbols dynamically loaded. + * + */ + static OracleVersion GetRuntimeVersion(); + + /** + * @brief + * Return the major version number of OCI used at runtime + * + */ + static unsigned int GetRuntimeMajorVersion(); + + /** + * @brief + * Return the minor version number of OCI used at runtime + * + */ + static unsigned int GetRuntimeMinorVersion(); + + /** + * @brief + * Return the revision version number of OCI used at runtime + * + */ + static unsigned int GetRuntimeRevisionVersion(); + + /** + * @brief + * Enable or disable Oracle warning notifications + * + * @param value - enable/disable warnings + * + * @note + * Default value is false + * + */ + static void EnableWarnings(bool value); + + /** + * @brief + * Set the format string for implicit string conversions of the given type + * + * @param formatType - Type of format + * @param format - Format string + * + * Formats can set at 2 levels: + * - Environment level + * - Connection level + * + * When the library needs to perform a string conversion, it search for a valid format using the + * following order: + * - Connection format + * - Library format + * - Default format + * + * @note + * Default format values are : + * - OCI_FMT_DATE : constant OCI_STRING_FORMAT_DATE + * - OCI_FMT_TIMESTAMP : constant OCI_STRING_FORMAT_TIMESTAMP + * - OCI_FMT_NUMERIC : constant OCI_STRING_FORMAT_NUMERIC + * - OCI_FMT_BINARY_DOUBLE : constant OCI_STRING_FORMAT_BINARY_DOUBLE + * - OCI_FMT_BINARY FLOAT : constant OCI_STRING_FORMAT_BINARY_FLOAT + * + * @note + * Conversions are performed by Oracle built-in functions whenever possible. + * For DATE, TIMESTAMP and numeric types, see documentation of Oracle SQL to_char() function for more details + * For BINARY_DOUBLE and BINARY_FLOAT, refer to the C Standard Library printf() family documentation + * + */ + static bool SetFormat(FormatType formatType, const ostring& format); + + /** + * @brief + * Return the format string for implicit string conversions of the given type + * + * @param formatType - Type of format + * + * @note + * See SetFormat() for possible values + * + */ + static ostring GetFormat(FormatType formatType); + + /** + * @brief + * Start a database instance + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param startFlags - Start flags + * @param startMode - Start mode + * @param sessionFlags - Session Flags + * @param spfile - Client-side spfile to start up the database (optional) + * + * @note + * The only valid modes for sessionFlags are SessionSysDba and SessionSysOper. + * + * @note + * Start modes and flags parameters values can be combined. + * + * @note + * External credentials are supported by supplying a empty strings for the 'user' and 'pwd' parameters + * If the parameter 'db' is empty then a connection to the default local DB is done. + * + * @note + * If the client side spfile is not provided, the database is started with its server-side spfile. + * + */ + static void StartDatabase(const ostring& db, const ostring& user, const ostring& pwd, + Environment::StartFlags startFlags, + Environment::StartMode startMode, + Environment::SessionFlags sessionFlags = SessionSysDba, + const ostring& spfile = OTEXT("")); + + /** + * @brief + * Shutdown a database instance + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param shutdownFlags - Shutdown flags + * @param shutdownMode - Shutdown mode + * @param sessionFlags - Session flags + * + * @note + * The only valid modes for sessionFlags are SessionSysDba and SessionSysOper. + * + * @note + * Shutdown modes values can be combined. + * + * @note + * Shutdown flag values are exclusive. + * + * @note + * External credentials are supported by supplying a empty strings for the 'user' and 'pwd' parameters + * If the param 'db' is empty then a connection to the default local DB is done. + * + */ + static void ShutdownDatabase(const ostring& db, const ostring& user, const ostring& pwd, + Environment::ShutdownFlags shutdownFlags, + Environment::ShutdownMode shutdownMode, + Environment::SessionFlags sessionFlags = SessionSysDba); + + /** + * @brief + * Change the password of the given user on the given database + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param newPwd - Oracle User New password + * + */ + static void ChangeUserPassword(const ostring& db, const ostring& user, const ostring& pwd, const ostring& newPwd); + + /** + * @brief + * Set the High availability (HA) user handler + * + * @param handler - HA handler procedure + * + * @note + * See POCI_HA_HANDLER documentation for more details + * + * @note + * EnvMode::Events flag must be passed to Initialize() to be able to use HA events + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + static void SetHAHandler(HAHandlerProc handler); + + private: + + class EnvironmentHandle : core::HandleHolder + { + friend class Environment; + }; + + static void HAHandler(OCI_Connection* pConnection, unsigned int source, unsigned int event, OCI_Timestamp* pTimestamp); + static unsigned int TAFHandler(OCI_Connection* pConnection, unsigned int type, unsigned int event); + static void NotifyHandler(OCI_Event* pEvent); + static void NotifyHandlerAQ(OCI_Dequeue* pDequeue); + + template + static T GetUserCallback(AnyPointer ptr); + + template + static void SetUserCallback(AnyPointer ptr, T callback); + + template + static void SetSmartHandle(AnyPointer ptr, T handle); + + template + static T GetSmartHandle(AnyPointer ptr); + + static core::Handle* GetEnvironmentHandle(); + + static Environment& GetInstance(); + + Environment(); + + void SelfInitialize(EnvironmentFlags mode, const ostring& libpath); + void SelfCleanup(); + + core::Locker _locker; + core::ConcurrentMap _handles; + core::ConcurrentMap _callbacks; + EnvironmentHandle _handle; + EnvironmentFlags _mode; + unsigned int _charMaxSize; + bool _initialized; + }; + + /** + * @brief + * static class allowing to manipulate threads + * + * This class wraps the OCILIB object handle OCI_Thread and its related methods + * + * @note + * See @ref OcilibCApiThreading for more details on Oracle multi-threading support + * + */ + class Thread + { + public: + + /** + * @typedef ThreadProc + * + * @brief Thread callback + * + */ + typedef POCI_THREAD ThreadProc; + + /** + * @brief + * Create a Thread + * + * @return + * Thread handle on success or NULL on failure + * + */ + static ThreadHandle Create(); + + /** + * @brief + * Destroy a thread + * + * @param handle - Thread handle + * + */ + static void Destroy(ThreadHandle handle); + + /** + * @brief + * Execute the given routine within the given thread + * + * @param handle - Thread handle + * @param func - routine to execute + * @param arg - parameter to pass to the routine + * + */ + static void Run(ThreadHandle handle, ThreadProc func, AnyPointer arg); + + /** + * @brief + * Join the given thread + * + * @param handle - Thread handle + * + * @note + * This function waits for the given thread to finish + * + */ + static void Join(ThreadHandle handle); + + /** + * @brief + * Return the system Thread ID of the given thread handle + * + * @param handle - Thread handle + * + */ + static ThreadId GetThreadId(ThreadHandle handle); + }; + + /** + * @brief + * Static class allowing managing mutexes + * + * This class wraps the OCILIB object handle OCI_Mutex and its related methods + * + * See @ref OcilibCApiThreading for more details on Oracle multi-threading support + * + */ + class Mutex + { + public: + + /** + * @brief + * Create a Mutex handle + * + * @return + * Mutex handle on success or NULL on failure + * + */ + static MutexHandle Create(); + + /** + * @brief + * Destroy a mutex handle + * + * @param handle - Mutex handle + * + */ + static void Destroy(MutexHandle handle); + + /** + * @brief + * Acquire a mutex lock + * + * @param handle - Mutex handle + * + */ + static void Acquire(MutexHandle handle); + + /** + * @brief + * Release a mutex lock + * + * @param handle - Mutex handle + * + */ + static void Release(MutexHandle handle); + }; + + /** + * @brief + * Static class allowing to set/get thread local storage (TLS) values for a given unique key + * + * This class wraps the OCILIB object handle OCI_ThreadKey and its related methods + * + * @note + * See @ref OcilibCApiThreading for more details on Oracle multi-threading support + * + */ + class ThreadKey + { + public: + + /** + * @typedef ThreadKeyFreeProc + * + * @brief Thread Key callback for freeing resources + * + */ + typedef POCI_THREADKEYDEST ThreadKeyFreeProc; + + /** + * @brief + * Create a thread key object + * + * @param name - Thread key name + * @param freeProc - Thread key value destructor function + * + * @note + * Parameter freeProc is optional. It's called when the thread terminates to allow + * the program to deal with the thread specific value of the key + * + */ + static void Create(const ostring& name, ThreadKeyFreeProc freeProc = nullptr); + + /** + * @brief + * Set a thread key value + * + * @param name - Thread key name + * @param value - user value to set + * + */ + static void SetValue(const ostring& name, AnyPointer value); + + /** + * @brief + * Get a thread key value + * + * @param name - Thread key name + * + * @return + * Thread key value on success otherwise FALSE + * + */ + static AnyPointer GetValue(const ostring& name); + }; + + /** + * @brief + * A connection or session Pool. + * + * This class wraps the OCILIB object handle OCI_Pool and its related methods + * + */ + class Pool : public core::HandleHolder + { + public: + + /** + * @brief + * Pool type enumerated values + * + */ + enum PoolTypeValues + { + /** Pool of Connections */ + ConnectionPool = OCI_POOL_CONNECTION, + /** Pool of stateless sessions */ + SessionPool = OCI_POOL_SESSION + }; + + /** + * @brief + * Type of Pool + * + * Possible values are Pool::PoolTypeValues + * + */ + typedef core::Enum PoolType; + + /** + * @brief + * Default constructor + * + */ + Pool(); + + /** + * @brief + * Constructor that creates an underlying pool with the given information + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param poolType - Type of pool + * @param sessionFlags - session Flags + * @param minSize - minimum number of connections/sessions that can be opened. + * @param maxSize - maximum number of connections/sessions that can be opened. + * @param increment - next increment for connections/sessions to be opened + * + * @note + * it calls Open() with the given parameters + * + */ + Pool(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, + unsigned int minSize, unsigned int maxSize, unsigned int increment = 1, + Environment::SessionFlags sessionFlags = Environment::SessionDefault); + + /** + * @brief + * Create an Oracle pool of connections or sessions + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param poolType - Type of pool + * @param sessionFlags - session Flags + * @param minSize - minimum number of connections/sessions that can be opened. + * @param maxSize - maximum number of connections/sessions that can be opened. + * @param increment - next increment for connections/sessions to be opened + * + * @note + * External credentials are supported by supplying an empty string for the 'user' and 'pwd' parameters + * If the param 'db' is empty then a connection to the default local DB is done + * + */ + void Open(const ostring& db, const ostring& user, const ostring& pwd, Pool::PoolType poolType, + unsigned int minSize, unsigned int maxSize, unsigned int increment = 1, + Environment::SessionFlags sessionFlags = Environment::SessionDefault); + + /** + * @brief + * Destroy the current Oracle pool of connections or sessions + * + */ + void Close(); + + /** + * @brief + * Get a connection from the pool + * + * @param sessionTag - Session user tag string + * + * @par Session tagging + * + * Session pools have a nice feature called 'session tagging' + * It's possible to tag a session with a string identifier + * when the session is returned to the pool, it keeps its tags. + * When requesting a connection from the session pool, it's + * possible to request a session that has the given 'tag' parameter + * If one exists, it is returned. If not and if an untagged session + * is available, it is then returned. So check the connection tag + * property with OCI_GetSessionTag() to find out if the returned + * connection is tagged or not. + * + * This features is described in the OCI developer guide as the following : + * + * "The tags provide a way for users to customize sessions in the pool. + * A client may get a default or untagged session from a pool, set certain + * attributes on the session (such as NLS settings), and return the session + * to the pool, labeling it with an appropriate tag. + * The user may request a session with the same tags in order to have a + * session with the same attributes" + * + */ + Connection GetConnection(const ostring& sessionTag = OTEXT("")); + + /** + * @brief + * Get the idle timeout for connections/sessions in the pool + * + * @note + * Connections/sessions idled for more than this time value (in seconds) are terminated + * + * @note + * Timeout is not available for internal pooling implementation (client < 9i) + * + */ + unsigned int GetTimeout() const; + + /** + * @brief + * Set the connections/sessions idle timeout + * + * @param value - Timeout value + * + * @note + * connections/sessions idle for more than this time value (in seconds) are terminated + * + * @note + * This call has no effect if pooling is internally implemented (client < 9i) + * + */ + void SetTimeout(unsigned int value); + + /** + * @brief + * Get the waiting mode used when no more connections/sessions are available from the pool + * + * @return + * - true to wait for an available object if the pool is saturated + * - false to not wait for an available object + * + */ + bool GetNoWait() const; + + /** + * @brief + * Set the waiting mode used when no more connections/sessions are available from the pool + * + * @param value - wait for object + * + * @note + * For parameter value, pass : + * - true to wait for an available object if the pool is saturated + * - false to not wait for an available object + * + */ + void SetNoWait(bool value); + + /** + * @brief + * Return the current number of busy connections/sessions + * + */ + unsigned int GetBusyConnectionsCount() const; + + /** + * @brief + * Return the current number of opened connections/sessions + * + */ + unsigned int GetOpenedConnectionsCount() const; + + /** + * @brief + * Return the minimum number of connections/sessions that can be opened to the database + * + */ + unsigned int GetMinSize() const; + + /** + * @brief + * Return the maximum number of connections/sessions that can be opened to the database + * + */ + unsigned int GetMaxSize() const; + + /** + * @brief + * Return the increment for connections/sessions to be opened to the database when the pool is not full + * + */ + unsigned int GetIncrement() const; + + /** + * @brief + * Return the maximum number of statements to keep in the pool's statement cache + * + * @note + * Default value is 20 (value from Oracle Documentation) + * + */ + unsigned int GetStatementCacheSize() const; + + /** + * @brief + * Set the maximum number of statements to keep in the pool's statement cache + * + * @param value - maximum number of statements in the cache + * + */ + void SetStatementCacheSize(unsigned int value); + }; + + /** + * @brief + * A connection or session with a specific database. + * + * This class wraps the OCILIB object handle OCI_Connection and its related methods + * + */ + class Connection : public core::HandleHolder + { + friend class Environment; + friend class Exception; + friend class Statement; + friend class File; + friend class Timestamp; + friend class Pool; + friend class Object; + friend class TypeInfo; + friend class Reference; + friend class Resultset; + friend class Subscription; + + template + friend class Lob; + template + friend class Collection; + public: + + /** + * @brief + * Timeout enumerated values + * + */ + enum TimeoutTypeValues + { + /** + * - Time to wait for send operations completion to the database server + * - Requires Oracle 12cR1 client + */ + TimeoutSend = OCI_NTO_SEND, + /** + * - Time to wait for read operations completion from the database server + * - Requires Oracle 12cR1 client + */ + TimeoutReceive = OCI_NTO_RECEIVE, + /** + * - Time to wait for a database round-trip to complete ( Client processing is not taken into account) + * - Requires Oracle 18c client + */ + TimeoutCall = OCI_NTO_CALL + }; + + /** + * @brief + * Timeout Types + * + * Possible values are Connection::TimeoutValues + * + */ + typedef core::Enum TimeoutType; + + /** + * @brief + * Failover request enumerated values + * + */ + enum FailoverRequestValues + { + /** User has requested only session failover */ + FailoverRequestSession = OCI_FOT_SESSION, + /** User has requested select failover as well */ + FailoverRequestSelect = OCI_FOT_SELECT + }; + + /** + * @brief + * Failover requests + * + * Possible values are Connection::FailoverRequestValues + * + */ + typedef core::Enum FailoverRequest; + + /** + * @brief + * Failover events enumerated values + * + */ + enum FailoverEventValues + { + /** Successful completion of failover */ + FailoverEventEnd = OCI_FOE_END, + /** Failover was unsuccessful. Retrying is not allowed */ + FailoverEventAbort = OCI_FOE_ABORT, + /** Multiple authentication and failover has occurred after the original authentication. User has been re authenticated */ + FailoverEventReauthentificate = OCI_FOE_REAUTH, + /** Failover has detected a lost connection and failover is starting */ + FailoverEventBegin = OCI_FOE_BEGIN, + /** Failover was unsuccessful. Retrying is allowed */ + FailoverEventError = OCI_FOE_ERROR + }; + + /** + * @brief + * Failover events + * + * Possible values are Connection::FailoverEventValues + * + */ + typedef core::Enum FailoverEvent; + + /** + * @brief + * Failover callback results enumerated values + * + */ + enum FailoverResultValues + { + /** Default acknowledgment of a failover event */ + FailoverOk = OCI_FOC_OK, + /** Triggers a new failover attempt */ + FailoverRetry = OCI_FOC_RETRY + }; + + /** + * @brief + * Failover callback results + * + * Possible values are Connection::FailoverResultValues + * + */ + typedef core::Enum FailoverResult; + + /** + * @brief + * Session trace enumerated values + * + */ + enum SessionTraceValues + { + /** Specifies the user defined identifier in the session. It's recorded in the column CLIENT_IDENTIFIER of the system view V$SESSION */ + TraceIdentity = OCI_TRC_IDENTITY, + /** Name of the current module in the client application. It's recorded in the column MODULE of the system view V$SESSION */ + TraceModule = OCI_TRC_MODULE, + /** Name of the current action within the current module. It's recorded in the column ACTION of the system view V$SESSION */ + TraceAction = OCI_TRC_ACTION, + /** Client application additional information. It's recorded in the column CLIENT_INFO of the system view V$SESSION */ + TraceDetail = OCI_TRC_DETAIL + }; + + /** + * @brief + * Session traces + * + * Possible values are Connection::SessionTraceValues + * + */ + typedef core::Enum SessionTrace; + + /** + * @typedef TAFHandlerProc + * + * @brief + * User callback for TAF event notifications + * + */ + typedef FailoverResult(*TAFHandlerProc) (Connection& con, FailoverRequest failoverRequest, FailoverEvent failoverEvent); + + /** + * @brief + * Default constructor + * + */ + Connection(); + + /** + * @brief + * Constructor that creates an opens an underlying DB connection with the given information + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param sessionFlags - Session Flags + * + * @note + * it calls Open() with the given parameters + * + */ + Connection(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags = Environment::SessionDefault); + + /** + * @brief + * Create a physical connection to an Oracle database server + * + * @param db - Oracle Service Name + * @param user - Oracle User name + * @param pwd - Oracle User password + * @param sessionFlags - Session Flags + * * + * @note + * External credentials are supported by supplying an empty string for the 'user' and 'pwd' parameters + * If the param 'db' is empty then a connection to the default local DB is done + * + * @par Oracle XA support + * OCILIB supports Oracle XA connectivity. In order to get a connection using + * the XA interface : + * - For parameter 'db' : pass the value of the 'DB' parameter of the given + * XA connection string passed to the Transaction Processing Monitor (TPM) + * - Pass empty strings for 'user' and 'pwd' parameters + * - Use SessionFlags::SessionXa for parameter 'sessionFlags' + * + * @par Oracle XA Connection String + * + * The XA connection string used in a transaction monitor to connect to Oracle must + * be compatible with OCILIB : + * - the XA parameter 'Objects' MUST be set to 'true' + * - If EnvMode::Threaded is passed to Environment::Initialize(), the XA parameter 'Threads' must + * be set to 'true', otherwise to 'false' + * - If EnvMode::Events is passed to Environment::Initialize(), the XA parameter 'Events' must + * be set to 'true', otherwise to 'false' + * - As Oracle does not support Unicode UTF16 character set through the XA interface, + * Only OCI_CHARSET_ANSI builds of OCILIB can be used + * - You still can use UTF8 if the NLS_LANG environment variable is set with a valid + * UTF8 NLS value + * - DO NOT USE UNICODE OCILIB builds with XA connections + * + * @note + * On success, a local transaction is automatically created and started ONLY for regular + * standalone connections and connections retrieved from connection pools. + * No transaction is created for a XA connection or q connection retrieved from session pools. + * + */ + void Open(const ostring& db, const ostring& user, const ostring& pwd, Environment::SessionFlags sessionFlags = Environment::SessionDefault); + + /** + * @brief + * Close the physical connection to the DB server + * + */ + void Close(); + + /** + * @brief + * Commit current pending changes + * + */ + void Commit(); + + /** + * @brief + * Cancel current pending changes + * + */ + void Rollback(); + + /** + * @brief + * Perform an immediate abort of any currently Oracle OCI call on the given connection + * + * @note + * The current call will abort and will raise an exception + * + */ + void Break(); + + /** + * @brief + * Enable or disable auto commit mode (implicit commits after every SQL execution) + * + * @param enabled - auto commit new status + * + */ + void SetAutoCommit(bool enabled); + + /** + * @brief + * Indicates if auto commit is currently activated + * + */ + bool GetAutoCommit() const; + + /** + * @brief + * Indicate if the connection is still connected to the server + * + * @note + * the returned value is not real-time and is based on client library last heart beat status + * + */ + bool IsServerAlive() const; + + /** + * @brief + * Performs a round trip call to the server to confirm that the connection to the server is still valid. + * + * @warning + * This call is supported from Oracle 10g. + * + */ + bool PingServer() const; + + /** + * @brief + * Return the name of the connected database/service name + * + * @note + * The returned value is the value of the 'db' parameter of the Open() method + * + */ + ostring GetConnectionString() const; + + /** + * @brief + * Return the current logged user name + * + * @note + * The returned value is the value of the 'user' parameter of the Open() method + * + */ + ostring GetUserName() const; + + /** + * @brief + * Return the current logged user password + * + * @note + * The returned value is the value of the 'pwd' parameter of the Open() method + * + */ + ostring GetPassword() const; + + /** + * @brief + * Return the connected database server string version + * + * @note + * The returned value is the server version banner displayed by SQL*PLUS when connected to a DB server + * + */ + ostring GetServerVersion() const; + + /** + * @brief + * Return the Oracle version supported by the connection + * + * @note + * The supported version is the lower version between client and server: + * + */ + OracleVersion GetVersion() const; + + /** + * @brief + * Return the major version number of the connected database server + * + */ + unsigned int GetServerMajorVersion() const; + + /** + * @brief + * Return the minor version number of the connected database server + * + */ + unsigned int GetServerMinorVersion() const; + + /** + * @brief + * Return the revision version number of the connected database server + * + */ + unsigned int GetServerRevisionVersion() const; + + /** + * @brief + * Change the password of the logged user + * + * @param newPwd - New password + * + */ + void ChangePassword(const ostring& newPwd); + + /** + * @brief + * Return the tag associated with the given connection + * + */ + ostring GetSessionTag() const; + + /** + * @brief + * Associate a tag to the given connection/session + * + * @param tag - user tag string + * + * @note + * Use this call only for connections retrieved from a session pool + * See Pool::GetConnection() for more details + * + * @note + * To untag a session, call SetSessionTag() with an empty 'tag' parameter + * + */ + void SetSessionTag(const ostring& tag); + + /** + * @brief + * Return the current transaction of the connection + * + */ + Transaction GetTransaction() const; + + /** + * @brief + * Set a transaction to a connection + * + * @param transaction - Transaction to assign + * + * @note + * The current transaction (if any) is automatically stopped but the newly assigned is not started or resumed + * + * @warning + * Do not set a transaction to a XA connection or a connection retrieved from a session pool + * + */ + void SetTransaction(const Transaction& transaction); + + /** + * @brief + * Set the format string for implicit string conversions of the given type + * + * @param formatType - Type of format + * @param format - Format string + * + * Formats can set at 2 levels: + * - Environment level + * - Connection level + * + * When the library needs to perform a string conversion, it search for a valid format using the + * following order: + * - Connection format + * - Environment format + * - Default format + * + * @note + * Default format values are : + * - OCI_FMT_DATE : constant OCI_STRING_FORMAT_DATE + * - OCI_FMT_TIMESTAMP : constant OCI_STRING_FORMAT_TIMESTAMP + * - OCI_FMT_NUMERIC : constant OCI_STRING_FORMAT_NUMERIC + * - OCI_FMT_BINARY_DOUBLE : constant OCI_STRING_FORMAT_BINARY_DOUBLE + * - OCI_FMT_BINARY FLOAT : constant OCI_STRING_FORMAT_BINARY_FLOAT + * + * @note + * Conversions are performed by Oracle built-in functions whenever possible. + * For DATE, TIMESTAMP and numeric types, see documentation of Oracle SQL to_char() function for more details + * For BINARY_DOUBLE and BINARY_FLOAT, refer to the C Standard Library printf() family documentation + * + */ + bool SetFormat(FormatType formatType, const ostring& format); + + /** + * @brief + * Return the format string for implicit string conversions of the given type + * + * @param formatType - Type of format + * + * @note + * See SetFormat() for possible values + * + */ + ostring GetFormat(FormatType formatType); + + /** + * @brief + * Enable the server output + * + * @param bufsize - server buffer max size (server side) + * @param arrsize - number of lines to retrieve per server round-trip + * @param lnsize - maximum size of one line + * + * @note + * This call is equivalent to the command 'set serveroutput on' in SQL*PLUS + * + * @note + * - 'bufsize' minimum value is 2000, maximum 1000000 with Oracle < 10.2g and can be unlimited above + * - 'lnsize' maximum value is 255 with Oracle < 10g R2 and 32767 above + * + * @warning + * If EnableServerOutput() is not called, GetServerOutput() will return false + * + */ + void EnableServerOutput(unsigned int bufsize, unsigned int arrsize, unsigned int lnsize); + + /** + * @brief + * Disable the server output + * + * @note + * After this call, GetServerOutput() will return false. + * + */ + void DisableServerOutput(); + + /** + * @brief + * Retrieve one line of the server buffer + * + * @return + * true if a line has been retrieved otherwise false (server buffer is empty or all lines have been retrieved) + * + */ + bool GetServerOutput(ostring& line) const; + + /** + * @brief + * Retrieve all remaining lines of the server buffer + * + */ + void GetServerOutput(std::vector& lines) const; + + /** + * @brief + * Set tracing information for the session + * + * @param trace - trace type + * @param value - trace content + * + * Store current trace information to the given connection handle. + * These information: + * + * - is stored in the system view V$SESSION + * - can be retrieved from the connection property of an OCI_Error handle + * + * system view V$SESSION + * + * @warning + * The system view V$SESSION is updated on Oracle versions >= 10g + * + * @warning + * Oracle limits the size of these traces content and thus OCILIB will truncate + * the given values if needed : + * + * - TraceIdentity : 64 bytes + * - TraceModule : 48 bytes + * - TraceAction : 32 bytes + * - TraceDetail : 64 bytes + * + */ + void SetTrace(SessionTrace trace, const ostring& value); + + /** + * @brief + * Get the current trace for the trace type from the given connection. + * + * @param trace - trace type + * + * @note + * See SetTrace() for more details. + * + */ + ostring GetTrace(SessionTrace trace) const; + + /** + * @brief + * Return the Oracle server database name of the connected database/service name + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + ostring GetDatabase() const; + + /** + * @brief + * Return the Oracle server Instance name of the connected database/service name + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + ostring GetInstance() const; + + /** + * @brief + * Return the Oracle server Service name of the connected database/service name + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + ostring GetService() const; + + /** + * @brief + * Return the Oracle server Hos name of the connected database/service name + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + ostring GetServer() const; + + /** + * @brief + * Return the Oracle server Domain name of the connected database/service name + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + ostring GetDomain() const; + + /** + * @brief + * Return the date and time (Timestamp) server instance start of the + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + Timestamp GetInstanceStartTime() const; + + /** + * @brief + * Return the maximum number of statements to keep in the statement cache + * + * @note + * Default value is 20 (value from Oracle Documentation) + * + * @warning + * Requires Oracle Client 9.2 or above + * + */ + unsigned int GetStatementCacheSize() const; + + /** + * @brief + * Set the maximum number of statements to keep in the statement cache + * + * @param value - maximum number of statements in the cache + * + * @warning + * Requires Oracle Client 9.2 or above + * + */ + void SetStatementCacheSize(unsigned int value); + + /** + * @brief + * Return the default LOB prefetch buffer size for the connection + * + * @warning + * Requires Oracle Client AND Server 11gR1 or above + * + * @note + * Prefetch size is: + * - number of bytes for BLOBs (Blob) and BFILEs (File) + * - number of characters for CLOBs (Clob / NClob). + * + * @note + * Default is 0 (pre-fetching disabled) + * + */ + unsigned int GetDefaultLobPrefetchSize() const; + + /** + * @brief + * Enable or disable pre-fetching for all LOBs fetched in the connection + * + * @param value - default prefetch buffer size + * + * @note + * If parameter 'value': + * - is == 0, it disables pre-fetching for all LOBs fetched in the connection. + * - is > 0, it enables pre-fetching for all LOBs fetched in the connection + * and the given buffer size is used for pre-fetching LOBs + * + * @note + * LOBs pre-fetching is disabled by default + * + * @warning + * Requires Oracle Client AND Server 11gR1 or above. + * + * @note + * Prefetch size is: + * - number of bytes for BLOBs (Blob) and BFILEs (File) + * - number of characters for CLOBs (Clob / NClob). + * + */ + void SetDefaultLobPrefetchSize(unsigned int value); + + /** + * @brief + * Return the maximum number of SQL statements that can be opened in one session + * + * @warning + * Requires Oracle Client AND Server 12cR1 or above + * + * @note + * the returned value is the same as the db parameter 'open_cursors' from server's parameter file + * + * @note + * Return 0 if the client and server version are < 12cR1 + * + */ + unsigned int GetMaxCursors() const; + + /** + * @brief + * Verify if the connection support TAF events + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + bool IsTAFCapable() const; + + /** + * @brief + * Set the Transparent Application Failover (TAF) user handler + * + * @param handler - TAF handler procedure + * + * @note + * See TAFHandlerProc documentation for more details + * + * @warning + * This call is supported from Oracle 10gR2. + * + */ + void SetTAFHandler(TAFHandlerProc handler); + + /** + * @brief + * Return the pointer to user data previously associated with the connection + * + */ + AnyPointer GetUserData(); + + /** + * @brief + * Associate a pointer to user data to the given connection + * + * @param value - User data pointer + * + */ + void SetUserData(AnyPointer value); + + /** + * @brief + * Returns the requested timeout value for OCI calls that require server round-trips to the given database + * + * @param timeout - Type of timeout + * + * @note: + * See Connection::SetTimeout() for more information + * + * @return + * The given timeout value if supported, otherwise 0 + * + */ + unsigned int GetTimeout(TimeoutType timeout); + + /** + * @brief + * Set a given timeout for OCI calls that require server round-trips to the given database + * + * @param timeout - Type of timeout to set + * @param value - Timeout in milliseconds + * + * OCI client raises an timeout type related error when a given timeout is reached. + * + * @note + * To disable a given timeout, pass the value 0 + * + * @warning + * OCI client is using the following precedence rules when applying timeouts: + * - 1 - Timeout set using TimeoutCall (all other timeouts are discarded) + * - 2 - Timeouts set using TimeoutSend and/or TimeoutReceive + * - 3 - Timeouts set in sqlnet.ora file + * + * Here is a summary: + * + * FLAG | Min. Version | OCI Error raised | OCI Error description | sqlnet.ora equivalent | + * --------------- | ------------ | ---------------- | ------------------------------ | --------------------- | + * TimeoutSend | OCI_12_1 | ORA-12608 | TNS: Send timeout occurred | SQLNET.SEND_TIMEOUT | + * TimeoutReceive | OCI_12_1 | ORA-12609 | TNS: Receive timeout occurred | SQLNET.RECV_TIMEOUT | + * TimeoutCall | OCI_18_1 | ORA-03136 | inbound connection timed out | --- | + * + */ + void SetTimeout(TimeoutType timeout, unsigned int value); + + private: + + Connection(OCI_Connection* con, core::Handle* parent); + }; + + /** + * @brief + * Oracle Transaction object + * + * This class wraps the OCILIB object handle OCI_Transaction and its related methods + * + */ + class Transaction : public core::HandleHolder + { + friend class Connection; + + public: + + /** + * @brief + * Transaction flags enumerated values + * + */ + enum TransactionFlagsValues + { + Unknown = OCI_UNKNOWN, + /** (Global) Specifies tightly coupled and migratable branch */ + New = OCI_TRS_NEW, + /** (Global) Specifies a tightly coupled branch */ + Tight = OCI_TRS_TIGHT, + /** (Global) Specifies a loosely coupled branch */ + Loose = OCI_TRS_LOOSE, + /** (Global and local) start a read-only transaction */ + ReadOnly = OCI_TRS_READONLY, + /** (Global and local) start a read-write transaction */ + ReadWrite = OCI_TRS_READWRITE, + /** (Global and local) start a serializable transaction */ + Serializable = OCI_TRS_SERIALIZABLE + }; + + /** + * @brief + * Transaction flags + * + * Possible values are Transaction::TransactionFlagsValues + * + */ + typedef core::Flags TransactionFlags; + + /** + * @brief + * Create a new global transaction or a serializable/read-only local transaction + * + * @param connection - Connection + * @param timeout - Time that a transaction stays inactive after being stopped + * @param flags - Transaction flags + * @param pxid - pointer to a global transaction identifier structure + * + * @note + * For local transaction, don't use the 'pxid' parameter + * + */ + Transaction(const Connection& connection, unsigned int timeout, TransactionFlags flags, OCI_XID* pxid = nullptr); + + /** + * @brief + * Prepare a global transaction validation + * + */ + void Prepare(); + + /** + * @brief + * Start global transaction + * + */ + void Start(); + + /** + * @brief + * Stop current global transaction + * + */ + void Stop(); + + /** + * @brief + * Resume a stopped global transaction + * + */ + void Resume(); + + /** + * @brief + * Cancel the prepared global transaction validation + * + */ + void Forget(); + + /** + * @brief + * Return the transaction mode. + * + * @note: + * see Transaction() for possible values + * + */ + TransactionFlags GetFlags() const; + + /** + * @brief + * Return the transaction Timeout + * + */ + unsigned int GetTimeout() const; + + private: + + Transaction(OCI_Transaction* trans); + }; + + /** + * @brief + * Object identifying the SQL data type NUMBER. + * + * This class wraps the OCILIB object handle OCI_Number and its related methods + * + * NUMBERs can be handled using native scalar types + * This class is optional and exposes some special NUMBER properties + * + */ + class Number : public core::HandleHolder, public core::Streamable + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class Collection; + + public: + + /** + * @brief + * Create an empty null number object + * + * @param create - Indicates if a Oracle Number object must be must be created + * + */ + Number(bool create = false); + + /** + * @brief + * Create a Number object with the value provided by the input Number string + * + * @param str - String Number + * @param format - format of the Number provided in parameter 'data' + * + * @note + * For Number formats, refer to the Oracle SQL documentation + * + * @note + * Default connection Number format is computed from Environment::GetFormat() + * + */ + Number(const otext* str, const otext* format = OTEXT("")); + + /** + * @brief + * Create a Number object with the value provided by the input Number string + * + * @param str - String Number + * @param format - format of the Number provided in parameter 'data' + * + * @note + * ForNumber formats, refer to the Oracle SQL documentation + * + * @note + * Default connection Number format is computed from Environment::GetFormat() + * + */ + Number(const ostring& str, const ostring& format = OTEXT("")); + + /** + * @brief + * Assign to the number object the value provided by the input number time string + * + * @param str - String number time + * @param format - format of the number time provided in parameter 'data' + * + * @note + * For number formats, refer to the Oracle SQL documentation + * + * @note + * Default connection number format is computed from Environment::GetFormat() + * + */ + void FromString(const ostring& str, const ostring& format = OTEXT("")) const; + + /** + * @brief + * Convert the number value to a string using the given format + * + * @param format - number time format to use + * + * @note + * For number formats, refer to the Oracle SQL documentation + * + */ + ostring ToString(const ostring& format) const; + + /** + * @brief + * Convert the number value to a string using default format OCI_STRING_FORMAT_NUMERIC + * + * @note + * For number formats, refer to the Oracle SQL documentation + * + */ + ostring ToString() const override; + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Number Clone() const; + + Number& operator ++ (); + Number& operator -- (); + Number operator ++ (int); + Number operator -- (int); + + bool operator == (const Number& other) const; + bool operator != (const Number& other) const; + bool operator > (const Number& other) const; + bool operator < (const Number& other) const; + bool operator >= (const Number& other) const; + bool operator <= (const Number& other) const; + + template::Type::type* = nullptr> + Number& operator = (const T& lhs); + + template::Type::type* = nullptr> + operator T() const; + + template::Type::type* = nullptr> + Number operator - (const T& value); + + template::Type::type* = nullptr> + Number operator + (const T& value); + + template::Type::type* = nullptr> + Number operator * (const T& value); + + template::Type::type* = nullptr> + Number operator / (const T& value); + + template::Type::type* = nullptr> + Number& operator += (const T& value); + + template::Type::type* = nullptr> + Number& operator -= (const T& value); + + template::Type::type* = nullptr> + Number& operator *= (const T& value); + + template::Type::type* = nullptr> + Number& operator /= (const T& value); + + private: + + template + static AnyPointer GetNativeValue(const T& value); + + Number(OCI_Number* pNumber, core::Handle* parent = nullptr); + + void Allocate(); + + int Compare(const Number& other) const; + + template + inline T GetValue() const; + + template + Number& SetValue(const T& value); + + template + void Add(const T& value); + + template + void Sub(const T& value); + + template + void Multiply(const T& value); + + template + void Divide(const T& value); + + Number& operator = (OCI_Number*& lhs); + }; + + /** + * @brief + * Object identifying the SQL data type DATE. + * + * This class wraps the OCILIB object handle OCI_Date and its related methods + * + */ + class Date : public core::HandleHolder, public core::Streamable + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class Collection; + friend class Message; + + public: + + /** + * @brief + * Return the current system date time + * + */ + static Date SysDate(); + + /** + * @brief + * Create an empty null Date object + * + * @param create - Indicates if a Oracle Date object must be must be created + * + */ + Date(bool create = false); + + /** + * @brief + * Create a date object with the value provided by the input date time string + * + * @param str - String date time + * @param format - format of the date time provided in parameter 'data' + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + * @note + * Default connection date format is computed from Environment::GetFormat() + * + */ + Date(const otext* str, const otext* format = OTEXT("")); + + /** + * @brief + * Create a date object with the value provided by the input date time string + * + * @param str - String date time + * @param format - format of the date time provided in parameter 'data' + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + * @note + * Default connection date format is computed from Environment::GetFormat() + * + */ + + Date(const ostring& str, const ostring& format = OTEXT("")); + + /** + * @brief + * Check if the given date is valid + * + */ + bool IsValid() const; + + /** + * @brief + * Return the date year value + * + */ + int GetYear() const; + + /** + * @brief + * Set the date year value + * + */ + void SetYear(int value); + + /** + * @brief + * Return the date month value + * + */ + int GetMonth() const; + + /** + * @brief + * Set the date month value + * + */ + void SetMonth(int value); + + /** + * @brief + * Return the date day value + * + */ + int GetDay() const; + + /** + * @brief + * Set the date day value + * + */ + void SetDay(int value); + + /** + * @brief + * Return the date hours value + * + */ + int GetHours() const; + + /** + * @brief + * Set the date hours value + * + */ + void SetHours(int value); + + /** + * @brief + * Return the date minutes value + * + */ + int GetMinutes() const; + + /** + * @brief + * Set the date minutes value + * + */ + void SetMinutes(int value); + + /** + * @brief + * Return the date seconds value + * + */ + int GetSeconds() const; + + /** + * @brief + * Set the date seconds value + * + */ + void SetSeconds(int value); + + /** + * @brief + * Return the number of days with the given date + * + * @param other - date to compare + * + */ + int DaysBetween(const Date& other) const; + + /** + * @brief + * Set the date part + * + * @param year - Year value + * @param month - Month value + * @param day - Day value + * + */ + void SetDate(int year, int month, int day); + + /** + * @brief + * Set the time part + * + * @param hour - Hour value + * @param min - Minute value + * @param sec - Second value + * + */ + void SetTime(int hour, int min, int sec); + + /** + * @brief + * Set the date and time part + * + * @param year - Year value + * @param month - Month value + * @param day - Day value + * @param hour - Hour value + * @param min - Minute value + * @param sec - Second value + * + */ + void SetDateTime(int year, int month, int day, int hour, int min, int sec); + + /** + * @brief + * Extract the date parts + * + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * + */ + void GetDate(int& year, int& month, int& day) const; + + /** + * @brief + * Extract time parts + * + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * + */ + void GetTime(int& hour, int& min, int& sec) const; + + /** + * @brief + * Extract the date and time parts + * + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * + */ + void GetDateTime(int& year, int& month, int& day, int& hour, int& min, int& sec) const; + + /** + * @brief + * Add or subtract days + * + * @param days - Number of days to add/remove + * + */ + void AddDays(int days); + + /** + * @brief + * Add or subtract months + * + * @param months - Number of months to add/remove + * + */ + void AddMonths(int months); + + /** + * @brief + * Return the date of next day of the week, after the current date object + * + * @param day - Day of the week + * + */ + Date NextDay(const ostring& day) const; + + /** + * @brief + * Return the last day of month from the current date object + * + */ + Date LastDay() const; + + /** + * @brief + * Convert the date from one zone to another zone + * + * @param tzSrc - Source zone + * @param tzDst - Destination zone + * + */ + void ChangeTimeZone(const ostring& tzSrc, const ostring& tzDst); + + /** + * @brief + * Assign to the date object the value provided by the input date time string + * + * @param str - String date time + * @param format - format of the date time provided in parameter 'data' + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + * @note + * Default connection date format is computed from Environment::GetFormat() + * + */ + void FromString(const ostring& str, const ostring& format = OTEXT("")); + + /** + * @brief + * Convert the date value to a string using the given format + * + * @param format - date time format to use + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + */ + ostring ToString(const ostring& format) const; + + /** + * @brief + * Convert the date value to a string using default format OCI_STRING_FORMAT_DATE + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + */ + ostring ToString() const override; + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Date Clone() const; + + /** + * @brief + * Increment the date by 1 day + * + */ + Date& operator ++ (); + + /** + * @brief + * Increment the date by 1 day + * + */ + Date operator ++ (int); + + /** + * @brief + * Decrement the date by 1 day + * + */ + Date& operator -- (); + + /** + * @brief + * Decrement the date by 1 day + * + */ + Date operator -- (int); + + /** + * @brief + * Return a new date holding the current date value incremented by the given number of days + * + */ + Date operator + (int value) const; + + /** + * @brief + * Return a new date holding the current date value decremented by the given number of days + * + */ + Date operator - (int value) const; + + /** + * @brief + * Increment the date by the given number of days + * + */ + Date& operator += (int value); + + /** + * @brief + * Decrement the date by the given number of days + * + */ + Date& operator -= (int value); + + /** + * @brief + * Indicates if the current date value is equal to the given date value + * + */ + bool operator == (const Date& other) const; + + /** + * @brief + * Indicates if the current date value is not equal the given date value + * + */ + bool operator != (const Date& other) const; + + /** + * @brief + * Indicates if the current date value is superior to the given date value + * + */ + bool operator > (const Date& other) const; + + /** + * @brief + * Indicates if the current date value is inferior to the given date value + * + */ + bool operator < (const Date& other) const; + + /** + * @brief + * Indicates if the current date value is superior or equal to the given date value + * + */ + bool operator >= (const Date& other) const; + + /** + * @brief + * Indicates if the current date value is inferior or equal to the given date value + * + */ + bool operator <= (const Date& other) const; + + private: + + int Compare(const Date& other) const; + + Date(OCI_Date* pDate, core::Handle* parent = nullptr); + + void Allocate(); + }; + + /** + * @brief + * Object identifying the SQL data type INTERVAL. + * + * This class wraps the OCILIB object handle OCI_Interval and its related methods + * + */ + class Interval : public core::HandleHolder, public core::Streamable + { + friend class Environment; + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class Collection; + + public: + + /** + * @brief + * Interval types enumerated values + * + */ + enum IntervalTypeValues + { + /** Interval unit range is months -> years */ + YearMonth = OCI_INTERVAL_YM, + /** Interval unit range is seconds -> days */ + DaySecond = OCI_INTERVAL_DS + }; + + /** + * @brief + * Interval types + * + * Possible values are Interval::IntervalTypeValues + * + */ + typedef core::Enum IntervalType; + + /** + * @brief + * Create an empty null Interval instance + * + */ + Interval(); + + /** + * @brief + * Create a new instance of the given type + * + * @param type - Interval type to create + * + */ + Interval(IntervalType type); + + /** + * @brief + * Create an interval object with the value provided by the input interval string + * + * @param type - Interval type to create + * @param data - String interval + * + * @note + * For interval format, refer to the Oracle SQL documentation + * + */ + Interval(IntervalType type, const ostring& data); + + /** + * @brief + * Return the type of the given interval object + * + */ + IntervalType GetType() const; + + /** + * @brief + * Check if the given interval is valid + * + */ + bool IsValid() const; + + /** + * @brief + * Return the interval year value + * + * @warning + * this call is only permitted if the current interval type is Interval::YearMonth + * + */ + int GetYear() const; + + /** + * @brief + * Set the interval year value + * + * @warning + * this call is only permitted if the current interval type is Interval::YearMonth + * + */ + void SetYear(int value); + + /** + * @brief + * Return the interval month value + * + * @warning + * this call is only permitted if the current interval type is Interval::YearMonth + * + */ + int GetMonth() const; + + /** + * @brief + * Set the interval month value + * + * @warning + * this call is only permitted if the current interval type is Interval::YearMonth + * + */ + void SetMonth(int value); + + /** + * @brief + * Return the interval day value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + int GetDay() const; + + /** + * @brief + * Set the interval day value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + void SetDay(int value); + + /** + * @brief + * Return the interval hours value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + int GetHours() const; + + /** + * @brief + * Set the interval hours value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + void SetHours(int value); + + /** + * @brief + * Return the interval minutes value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + int GetMinutes() const; + + /** + * @brief + * Set the interval minutes value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + void SetMinutes(int value); + + /** + * @brief + * Return the interval seconds value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + int GetSeconds() const; + + /** + * @brief + * Set the interval seconds value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + void SetSeconds(int value); + + /** + * @brief + * Return the interval seconds value + * + */ + int GetMilliSeconds() const; + + /** + * @brief + * Set the interval milliseconds value + * + */ + void SetMilliSeconds(int value); + + /** + * @brief + * Extract the date / second parts from the interval value + * + * @param day - Place holder for Day value + * @param hour - Place holder for Hour value + * @param min - Place holder for Minutes value + * @param sec - Place holder for Seconds value + * @param fsec - Place holder for Milliseconds value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + void GetDaySecond(int& day, int& hour, int& min, int& sec, int& fsec) const; + + /** + * @brief + * Set the Day / Second parts + * + * @param day - Day value + * @param hour - Hour value + * @param min - Minutes value + * @param sec - Seconds value + * @param fsec - Milliseconds value + * + * @warning + * this call is only permitted if the current interval type is Interval::DaySecond + * + */ + void SetDaySecond(int day, int hour, int min, int sec, int fsec); + + /** + * @brief + * Extract the year / month parts from the interval value + * + * @param year - Place holder for year value + * @param month - Place holder for month value + * + * @warning + * this call is only permitted if the current interval type is Interval::YearMonth + * + */ + void GetYearMonth(int& year, int& month) const; + + /** + * @brief + * Set the Year / Month parts + * + * @param year - Year value + * @param month - Month value + * + * @warning + * this call is only permitted if the current interval type is Interval::YearMonth + * + */ + void SetYearMonth(int year, int month); + + /** + * @brief + * Update the interval value with the given time zone + * + * @param timeZone - Time zone name + * + */ + void UpdateTimeZone(const ostring& timeZone); + + /** + * @brief + * Assign to the interval object the value provided by the input interval string + * + * @param data - String interval + * + * @note + * For interval format, refer to the Oracle SQL documentation + * + */ + void FromString(const ostring& data); + + /** + * @brief + * Convert the interval value to a string using the given precisions + * + * @param leadingPrecision - leading precision + * @param fractionPrecision - fraction precision + * + */ + ostring ToString(int leadingPrecision, int fractionPrecision) const; + + /** + * @brief + * Convert the interval value to a string using the default precisions of 10 + * + */ + ostring ToString() const override; + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Interval Clone() const; + + /** + * @brief + * Return a new Interval holding the sum of the current Interval value and the given Interval value + * + */ + Interval operator + (const Interval& other) const; + + /** + * @brief + * Return a new Interval holding the difference of the current Interval value and the given Interval value + * + */ + Interval operator - (const Interval& other) const; + + /** + * @brief + * Increment the current Value with the given Interval value + * + */ + Interval& operator += (const Interval& other); + + /** + * @brief + * Decrement the current Value with the given Interval value + * + */ + Interval& operator -= (const Interval& other); + + /** + * @brief + * Indicates if the current Interval value is equal to the given Interval value + * + */ + bool operator == (const Interval& other) const; + + /** + * @brief + * Indicates if the current Interval value is not equal the given Interval value + * + */ + bool operator != (const Interval& other) const; + + /** + * @brief + * Indicates if the current Interval value is superior to the given Interval value + * + */ + bool operator > (const Interval& other) const; + + /** + * @brief + * Indicates if the current Interval value is inferior to the given Interval value + * + */ + bool operator < (const Interval& other) const; + + /** + * @brief + * Indicates if the current Interval value is superior or equal to the given Interval value + * + */ + bool operator >= (const Interval& other) const; + + /** + * @brief + * Indicates if the current Interval value is inferior or equal to the given Interval value + * + */ + bool operator <= (const Interval& other) const; + + private: + + int Compare(const Interval& other) const; + + Interval(OCI_Interval* pInterval, core::Handle* parent = nullptr); + }; + + /** + * + * @brief + * Object identifying the SQL data type TIMESTAMP. + * + * This class wraps the OCILIB object handle OCI_Timestamp and its related methods + * + */ + class Timestamp : public core::HandleHolder, public core::Streamable + { + friend class Environment; + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + friend class Connection; + template + friend class Collection; + + public: + + /** + * @brief + * Interval types enumerated values + * + */ + enum TimestampTypeValues + { + /** Timestamp does not contains any time zone information */ + NoTimeZone = OCI_TIMESTAMP, + /** Timestamp contains a given time zone */ + WithTimeZone = OCI_TIMESTAMP_TZ, + /** Timestamp contains the user's local session time zone */ + WithLocalTimeZone = OCI_TIMESTAMP_LTZ + }; + + /** + * @brief + * Type of timestamp + * + * Possible values are Timestamp::TimestampTypeValues + * + */ + typedef core::Enum TimestampType; + + /** + * @brief + * return the current system timestamp + * + * @param type - Timestamp type to create + * + */ + static Timestamp SysTimestamp(TimestampType type = NoTimeZone); + + /** + * @brief + * Create an empty null timestamp instance + * + */ + Timestamp(); + + /** + * @brief + * Create a new instance of the given type + * + * @param type - Timestamp type to create + * + */ + Timestamp(TimestampType type); + + /** + * @brief + * Creates a timestamp object with the value provided by the input date time string + * + * @param type - Timestamp type to create + * @param data - String date time + * @param format - format of the date time provided in parameter 'data' + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + */ + Timestamp(TimestampType type, const ostring& data, const ostring& format = OTEXT("")); + + /** + * @brief + * Return the type of the given timestamp object + * + */ + TimestampType GetType() const; + + /** + * @brief + * Convert the current timestamp to the type of the given timestamp. + * + * @param other - Timestamp to use for the type conversion + * + */ + void Convert(const Timestamp& other); + + /** + * @brief + * Check if the given timestamp is valid + * + */ + bool IsValid() const; + + /** + * @brief + * Return the timestamp year value + * + */ + int GetYear() const; + + /** + * @brief + * Set the timestamp year value + * + */ + void SetYear(int value); + + /** + * @brief + * Return the timestamp month value + * + */ + int GetMonth() const; + + /** + * @brief + * Set the timestamp month value + * + */ + void SetMonth(int value); + + /** + * @brief + * Return the timestamp day value + * + */ + int GetDay() const; + + /** + * @brief + * Set the timestamp day value + * + */ + void SetDay(int value); + + /** + * @brief + * Return the timestamp hours value + * + */ + int GetHours() const; + + /** + * @brief + * Set the timestamp hours value + * + */ + void SetHours(int value); + + /** + * @brief + * Return the timestamp minutes value + * + */ + int GetMinutes() const; + + /** + * @brief + * Set the timestamp minutes value + * + */ + void SetMinutes(int value); + + /** + * @brief + * Return the timestamp seconds value + * + */ + int GetSeconds() const; + + /** + * @brief + * Set the timestamp seconds value + * + */ + void SetSeconds(int value); + + /** + * @brief + * Return the timestamp seconds value + * + */ + int GetMilliSeconds() const; + + /** + * @brief + * Set the timestamp milliseconds value + * + */ + void SetMilliSeconds(int value); + + /** + * @brief + * Extract the date parts + * + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * + */ + void GetDate(int& year, int& month, int& day) const; + + /** + * @brief + * Extract time parts + * + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * @param fsec - Place holder for fractional part of the seconds + * + */ + void GetTime(int& hour, int& min, int& sec, int& fsec) const; + + /** + * @brief + * Set the date part + * + * @param year - Year value + * @param month - Month value + * @param day - Day value + * + */ + void SetDate(int year, int month, int day); + + /** + * @brief + * Set the time part + * + * @param hour - Hour value + * @param min - Minute value + * @param sec - Second value + * @param fsec - Place holder for fractional part of the seconds + * + */ + void SetTime(int hour, int min, int sec, int fsec); + + /** + * @brief + * Extract date and time parts + * + * @param year - Place holder for year value + * @param month - Place holder for month value + * @param day - Place holder for day value + * @param hour - Place holder for hour value + * @param min - Place holder for minute value + * @param sec - Place holder for second value + * @param fsec - Place holder for fractional part of the seconds + * + */ + void GetDateTime(int& year, int& month, int& day, int& hour, int& min, int& sec, int& fsec) const; + + /** + * @brief + * Set the timestamp value from given date time parts + * + * @param year - Year value + * @param month - Month value + * @param day - Day value + * @param hour - Hour value + * @param min - Minutes value + * @param sec - Seconds value + * @param fsec - Fractional part of seconds value + * @param timeZone - name of a time zone to use [optional] + * + */ + void SetDateTime(int year, int month, int day, int hour, int min, int sec, int fsec, const ostring& timeZone = OTEXT("")); + + /** + * @brief + * Return the name of the current time zone + * + * @warning + * Returns an empty string if the timestamp type is TimeStamp::NoTimeZone + * + */ + ostring GetTimeZone() const; + + /** + * @brief + * Set the given time zone to the timestamp + * + * @warning + * - The timestamp must have a valid value before setting the timezone + * - Applies to TimeStamp::WithTimeZone only + * + */ + void SetTimeZone(const ostring& timeZone); + + /** + * @brief + * Return the time zone (hour, minute) offsets + * + * @param hour - Place holder for hour value + * @param min - Place holder for min value + * + */ + void GetTimeZoneOffset(int& hour, int& min) const; + + /** + * @brief + * Subtract the given two timestamp and store the result into the given Interval + * + * @param lsh - Timestamp value + * @param rsh - Timestamp to subtract + * @param result - result difference + * + * @note + * the Interval object type must match the type of range resulting from the timestamp difference + * + */ + static void Substract(const Timestamp& lsh, const Timestamp& rsh, Interval& result); + + /** + * @brief + * Assign to the timestamp object the value provided by the input date time string + * + * @param data - String date time + * @param format - format of the date time provided in parameter 'data' + * + * @note + * For date time formats, refer to the Oracle SQL documentation + * + */ + void FromString(const ostring& data, const ostring& format = OCI_STRING_FORMAT_DATE); + + /** + * @brief + * Convert the timestamp value to a string using the given format and precision + * + * @param format - date time / timestamp format to use + * @param precision - precision for milliseconds + * + * @note + * For date time / timestamp formats, refer to the Oracle SQL documentation + * + */ + ostring ToString(const ostring& format, int precision) const; + + /** + * @brief + * Convert the timestamp value to a string using default date format and no precision + * + */ + ostring ToString() const override; + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Timestamp Clone() const; + + /** + * @brief + * Increment the timestamp by 1 day + * + */ + Timestamp& operator ++ (); + + /** + * @brief + * Increment the timestamp by 1 day + * + */ + Timestamp operator ++ (int); + + /** + * @brief + * Decrement the Timestamp by 1 day + * + */ + Timestamp& operator -- (); + + /** + * @brief + * Decrement the Timestamp by 1 day + * + */ + Timestamp operator -- (int); + + /** + * @brief + * Return a new Timestamp holding the current Timestamp value incremented by the given number of days + * + */ + Timestamp operator + (int value) const; + + /** + * @brief + * Return a new Timestamp holding the current Timestamp value decremented by the given number of days + * + */ + Timestamp operator - (int value) const; + + /** + * @brief + * Return an interval storing the difference between the current timestamp and the given one + * + */ + Interval operator - (const Timestamp& other); + + /** + * @brief + * Increment the Timestamp by the given number of days + * + */ + Timestamp& operator += (int value); + + /** + * @brief + * Decrement the Timestamp by the given number of days + * + */ + Timestamp& operator -= (int value); + + /** + * @brief + * Return a new Timestamp holding the sum of the current Timestamp value and the given Interval value + * + */ + Timestamp operator + (const Interval& other) const; + + /** + * @brief + * Return a new Timestamp holding the difference of the current Timestamp value and the given Interval value + * + */ + Timestamp operator - (const Interval& other) const; + + /** + * @brief + * Increment the current Value with the given Interval value + * + */ + Timestamp& operator += (const Interval& other); + + /** + * @brief + * Decrement the current Value with the given Interval value + * + */ + Timestamp& operator -= (const Interval& other); + + /** + * @brief + * Indicates if the current Timestamp value is equal to the given Timestamp value + * + */ + bool operator == (const Timestamp& other) const; + + /** + * @brief + * Indicates if the current Timestamp value is not equal the given Timestamp value + * + */ + bool operator != (const Timestamp& other) const; + + /** + * @brief + * Indicates if the current Timestamp value is superior to the given Timestamp value + * + */ + bool operator > (const Timestamp& other) const; + + /** + * @brief + * Indicates if the current Timestamp value is inferior to the given Timestamp value + * + */ + bool operator < (const Timestamp& other) const; + + /** + * @brief + * Indicates if the current Timestamp value is superior or equal to the given Timestamp value + * + */ + bool operator >= (const Timestamp& other) const; + + /** + * @brief + * Indicates if the current Timestamp value is inferior or equal to the given Timestamp value + * + */ + bool operator <= (const Timestamp& other) const; + + private: + + int Compare(const Timestamp& other) const; + + Timestamp(OCI_Timestamp* pTimestamp, core::Handle* parent = nullptr); + }; + + /** + * @brief + * Object identifying the SQL data type LOB (CLOB, NCLOB and BLOB) + * + * This class wraps the OCILIB object handle OCI_Lob and its related methods + * + */ + template + class Lob : public core::HandleHolder + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class Collection; + + public: + + /** + * @brief + * Create an empty null Lob instance + * + */ + Lob(); + + /** + * @brief + * Parametrized constructor + * + * @param connection - Parent connection + * + * @note + * the lob object must not be accessed anymore once the parent connection object gets out of scope + * + */ + Lob(const Connection& connection); + + /** + * @brief + * Read a portion of a lob + * + * @param length - Maximum number of characters or bytes to read + * + * @return + * The content read from the lob + * + */ + T Read(unsigned int length); + + /** + * @brief + * Write the given content at the current position within the lob + * + * @param content - content to write + * + * @return + * Number of character or bytes written into the lob + * + */ + unsigned int Write(const T& content); + + /** + * @brief + * Append the given content to the lob + * + * @param content - content to write + * + * @return + * Number of character or bytes written into the lob + * + */ + unsigned int Append(const T& content); + + /** + * @brief + * Append the given lob content to the lob + * + * @param other - source lob + * + */ + void Append(const Lob& other); + + /** + * @brief + * Move the current position within the lob for read/write operations + * + * @param seekMode - Seek mode + * @param offset - offset from current position + * + * @note + * Positions start at 0. + * + * @return + * true on success otherwise false + * + */ + bool Seek(SeekMode seekMode, big_uint offset); + + /** + * @brief + * return the type of lob + * + */ + LobType GetType() const; + + /** + * @brief + * Returns the current R/W offset within the lob + * + */ + big_uint GetOffset() const; + + /** + * @brief + * Returns the number of characters or bytes contained in the lob + * + */ + big_uint GetLength() const; + + /** + * @brief + * Returns the lob maximum possible size + * + */ + big_uint GetMaxSize() const; + + /** + * @brief + * Returns the current lob chunk size + * + * @note + * This chunk size corresponds to the chunk size used by the LOB data layer + * when accessing and modifying the LOB value. According to Oracle + * documentation, performance will be improved if the application issues + * read or write requests using a multiple of this chunk size + * + */ + big_uint GetChunkSize() const; + + /** + * @brief + * Return the lob parent connection + * + */ + Connection GetConnection() const; + + /** + * @brief + * Truncate the lob to a shorter length + * + * @param length - New length in characters or bytes + * + */ + void Truncate(big_uint length); + + /** + * @brief + * Erase a portion of the lob at a given position + * + * @param offset - Absolute position in source lob + * @param length - Number of bytes or characters to erase + * + * @note + * Absolute position starts at 0. + * Erasing means that space or null values overwrite the existing LOB value. + * + * @return + * Number of characters or bytes erased + * + */ + big_uint Erase(big_uint offset, big_uint length); + + /** + * @brief + * Copy the given portion of the lob content to another one + * + * @param dest - Destination lob + * @param offset - Absolute position in the lob + * @param offsetDest - Absolute position in the destination lob + * @param length - Number of characters or bytes to copy + * + * @note + * Absolute position starts at 0. + * + */ + void Copy(Lob& dest, big_uint offset, big_uint offsetDest, big_uint length) const; + + /** + * @brief + * Check if the given lob is a temporary lob + * + */ + bool IsTemporary() const; + + /** + * @brief + * Check if the given lob is a remote lob + * + */ + bool IsRemote() const; + + /** + * @brief + * Open explicitly a Lob + * + * @param mode - open mode + * + * @note + * - A call to Open() is not necessary to manipulate a Lob. + * - If a lob has not been opened explicitly, triggers are fired and + * indexes updated at every read/write/append operation + * + */ + void Open(OpenMode mode); + + /** + * @brief + * Flush the lob content to the server (if applicable) + * + */ + void Flush(); + + /** + * @brief + * Close explicitly a Lob + * + * @note + * - A call to Close() is not necessary to manipulate a Lob. + * + */ + void Close(); + + /** + * @brief + * Enable / disable buffering mode on the given lob object + * + * @param value - Enable/disable buffering mode + * + * @note + * Oracle "LOB Buffering Subsystem" allows client applications + * to speedup read/write of small buffers on Lobs Objects. + * Check Oracle Documentation for more details on "LOB Buffering Subsystem". + * This reduces the number of network round trips and LOB versions, thereby + * improving LOB performance significantly. + * + * @warning + * According to Oracle documentation the following operations are not permitted + * on Lobs when buffering is on : Copy(), Append(), Erase(), GetLength(), Truncate() + * + */ + void EnableBuffering(bool value); + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Lob Clone() const; + + /** + * @brief + * Appending the given lob content to the current lob content + * + */ + Lob& operator += (const Lob& other); + + /** + * @brief + * Indicates if the current lob value is equal to the given lob value + * + */ + bool operator == (const Lob& other) const; + + /** + * @brief + * Indicates if the current lob value is not equal the given lob value + * + */ + bool operator != (const Lob& other) const; + + private: + + bool Equals(const Lob& other) const; + + Lob(OCI_Lob* pLob, core::Handle* parent = nullptr); + + }; + + /** + * + * @brief + * Class handling CLOB oracle type + * + * @note + * Length and size arguments / returned values are expressed in number of characters + * + */ + typedef Lob Clob; + + /** + * + * @brief + * Class handling NCLOB oracle type + * + * @note + * Length and size arguments / returned values are expressed in number of characters + * + */ + typedef Lob NClob; + + /** + * + * @brief + * Class handling BLOB oracle type + * + * @note + * Length and size arguments / returned values are expressed in number of bytes + * + */ + typedef Lob Blob; + + /** + * + * @brief + * Object identifying the SQL data type BFILE. + * + * This class wraps the OCILIB object handle OCI_File and its related methods + * + */ + class File : public core::HandleHolder + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class Collection; + + public: + + /** + * @brief + * Create an empty null File instance + * + */ + File(); + + /** + * @brief + * Parametrized constructor + * + * @param connection - Parent connection + * + * @note + * the file object must not be accessed anymore once the parent connection object gets out of scope + * + */ + File(const Connection& connection); + + /** + * @brief + * Parametrized constructor + * + * @param connection - Parent connection + * @param directory - File directory + * @param name - File name + * + * this convenient constructor calls File::SetInfos() + * + * @note + * the file object must not be accessed anymore once the parent connection object gets out of scope + * + */ + File(const Connection& connection, const ostring& directory, const ostring& name); + + /** + * @brief + * Read a portion of a file + * + * @param size - Maximum number of bytes to read + * + * @return + * The content read from the file + * + */ + Raw Read(unsigned int size); + + /** + * @brief + * Move the current position within the file for read/write operations + * + * @param seekMode - Seek mode + * @param offset - offset from current position + * + * @note + * Positions start at 0. + * + * @return + * true on success otherwise false + * + */ + bool Seek(SeekMode seekMode, big_uint offset); + + /** + * @brief + * Check if the given file exists on server + * + * @note + * For local FILEs object, SetInfos() must be called before calling Exists() + * + */ + bool Exists() const; + + /** + * @brief + * Returns the current R/W offset within the file + * + */ + big_uint GetOffset() const; + + /** + * @brief + * Returns the number of bytes contained in the file + * + */ + big_uint GetLength() const; + + /** + * @brief + * Return the file parent connection + * + */ + Connection GetConnection() const; + + /** + * @brief + * Set the directory and file name of our file object + * + * @param directory - File directory + * @param name - File name + * + * @note + * - For local FILEs only + * - Files fetched from resultset can't be assigned a new directory and name + * + */ + void SetInfos(const ostring& directory, const ostring& name); + + /** + * @brief + * Return the file name + * + */ + ostring GetName() const; + + /** + * @brief + * Return the file directory + * + */ + ostring GetDirectory() const; + + /** + * @brief + * Open a file for reading on the server + * + */ + void Open(); + + /** + * @brief + * Close the file on the server + * + */ + void Close(); + + /** + * @brief + * Check if the specified file is currently opened on the server by our object + * + */ + bool IsOpened() const; + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + File Clone() const; + + /** + * @brief + * Indicates if the current file value is equal the given file value + * + */ + bool operator == (const File& other) const; + + /** + * @brief + * Indicates if the current file value is not equal the given file value + * + */ + bool operator != (const File& other) const; + + private: + + bool Equals(const File& other) const; + + File(OCI_File* pFile, core::Handle* parent = nullptr); + }; + + /** + * @brief + * Provides type information on Oracle Database objects + * + * This class wraps the OCILIB object handle OCI_TypeInfo and its related methods + * + */ + class TypeInfo : public core::HandleHolder + { + friend class Object; + friend class Reference; + template + friend class Collection; + friend class Column; + public: + + /** + * @brief + * Type of object information enumerated values + * + */ + enum TypeInfoTypeValues + { + /** Database Table information */ + Table = OCI_TIF_TABLE, + /** Database View information */ + View = OCI_TIF_VIEW, + /** Database type information */ + Type = OCI_TIF_TYPE + }; + + /** + * @brief + * Type of object information + * + * Possible values are TypeInfo::TypeInfoTypeValues + * + */ + typedef core::Enum TypeInfoType; + + /** + * @brief + * Parametrized constructor + * + * @param connection - Parent connection + * @param name - Type name + * @param type - Kind of type to retrieve + * + * @note + * the TypeInfo object must not be accessed anymore once the parent connection object gets out of scope + * + */ + TypeInfo(const Connection& connection, const ostring& name, TypeInfoType type); + + /** + * @brief + * Return the type of the given TypeInfo object + * + */ + TypeInfoType GetType() const; + + /** + * @brief + * Return the type info name + * + */ + ostring GetName() const; + + /** + * @brief + * Return the connection associated with a statement + * + */ + Connection GetConnection() const; + + /** + * @brief + * Return the number of columns contained in the type + * + * @note + * - For table and views, it is the number of columns + * - For types, it is the number of member properties + * + */ + unsigned int GetColumnCount() const; + + /** + * @brief + * Return the column from its index in the resultset + * + * @param index - Column index + * + * @note + * Column position starts at 1. + * + * @note + * - For table and views, the returned column object describes a table/view column + * - For types, the returned column object describes an object property + * + */ + Column GetColumn(unsigned int index) const; + + /** + * @brief + * Indicate if the given UDT type is final + * + * @note + * Non-final types are virtual UDT type that can be inherited + * + * @return + * - For table and views, it returns true + * - For types, it returns true if the type is final and false if it is virtual + * + */ + boolean IsFinalType() const; + + /** + * @brief + * Return the super type of the given type (e.g. parent type for a derived ORACLE UDT type) + * + * @note + * This property is only valid for types + * + * @return + * - For table and views, it return a null TypeInfo object + * - For types: + * - returns a valid TypeInfo object wrapping the parent super type + * - returns a null TypeInfo object if the given type is NOT deriving from a base type + * + */ + TypeInfo GetSuperType() const; + + private: + + TypeInfo(OCI_TypeInfo* pTypeInfo); + }; + + /** + * @brief + * Object identifying the SQL data type OBJECT. + * + * This class wraps the OCILIB object handle OCI_Object and its related methods + * + */ + class Object : public core::HandleHolder, public core::Streamable + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Reference; + template + friend class Collection; + friend class Message; + + public: + + /** + * @brief + * Object Type enumerated values + * + */ + enum ObjectTypeValues + { + /** The object is persistent in the database */ + Persistent = OCI_OBJ_PERSISTENT, + /** The object is Transient */ + Transient = OCI_OBJ_TRANSIENT, + /** The object is a value member of another object */ + Value = OCI_OBJ_VALUE + }; + + /** + * @brief + * Object Type + * + * Possible values are Object::ObjectTypeValues + * + */ + typedef core::Enum ObjectType; + + /** + * @brief + * Create an empty null Object instance + * + */ + Object(); + + /** + * @brief + * Parametrized constructor + * + * @param typeInfo - type info descriptor + * + */ + Object(const TypeInfo& typeInfo); + + /** + * @brief + * Check if an object attribute is null + * + * @param name - Attribute name + * + */ + bool IsAttributeNull(const ostring& name) const; + + /** + * @brief + * Set the given object attribute to null + * + * @param name - Attribute name + * + */ + void SetAttributeNull(const ostring& name); + + /** + * @brief + * Return the TypeInfo object describing the object + * + */ + TypeInfo GetTypeInfo() const; + + /** + * @brief + * Creates a reference on the current object + * + */ + Reference GetReference() const; + + /** + * @brief + * Return the type of the given object + * + */ + ObjectType GetType() const; + + /** + * @brief + * Return the given object attribute value + * + * @tparam T - C++ object type to retrieve + * + * @param name - Attribute name + * + * @note + * Specialized version of this template function are provided for all supported types + * + */ + template + T Get(const ostring& name) const; + + /** + * @brief + * Assign the given value with the given object attribute value + * + * @tparam T - C++ object type to retrieve + * + * @param name - Attribute name + * @param value - value to assign + * + * @note + * Specialized version of this template function are provided for all supported types + * + */ + template + void Get(const ostring& name, T& value) const; + + /** + * @brief + * Assign the given collection with the given object attribute value of type collection + * + * @tparam T - C++ object type of the collection to retrieve + * + * @param name - Attribute name + * @param value - value to assign + * + * @note + * Specialized version of this template function are provided for all supported types + * + */ + template + void Get(const ostring& name, Collection& value) const; + + /** + * @brief + * Set the given object attribute value + * + * @tparam T - C++ object type to set + * + * @param name - Attribute name + * @param value - Attribute value + * + * @note + * Specialized version of this template function are provided for all supported types + * + */ + template + void Set(const ostring& name, const T& value); + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Object Clone() const; + + /** + * @brief + * return a string representation of the current object + * + */ + ostring ToString() const override; + + private: + + Object(OCI_Object* pObject, core::Handle* parent = nullptr); + }; + + /** + * @brief + * Object identifying the SQL data type REF. + * + * This class wraps the OCILIB object handle OCI_Ref and its related methods + * + */ + class Reference : public core::HandleHolder, public core::Streamable + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class Collection; + + public: + + /** + * @brief + * Create an empty null Reference instance + * + */ + Reference(); + + /** + * @brief + * Parametrized constructor + * + * @param typeInfo - type info descriptor + * + */ + Reference(const TypeInfo& typeInfo); + + /** + * @brief + * Return the TypeInfo object describing the referenced object + * + */ + TypeInfo GetTypeInfo() const; + + /** + * @brief + * Returns the object pointed by the reference + * + * @return + * The object may bu null is the current reference value is null + * + */ + Object GetObject() const; + + /** + * @brief + * Check if the reference points to an object or not. + * + */ + bool IsReferenceNull() const; + + /** + * @brief + * Nullify the given Ref handle + * + * @note + * this call clears the reference to object pointed by the reference object. + * + */ + void SetReferenceNull(); + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Reference Clone() const; + + /** + * @brief + * return a string representation of the current reference + * + */ + ostring ToString() const override; + + private: + + Reference(OCI_Ref* pRef, core::Handle* parent = nullptr); + }; + + /** + * @brief + * Class used for handling transient collection value. + * it is used internally by the Collection class: + * - the Collection<> indexer operator in order to provide lvalue for read/write access + * - the CollectionIterator class + * + */ + template + class CollectionElement + { + template + friend class CollectionIterator; + + public: + + typedef T ValueType; + typedef Collection CollectionType; + + CollectionElement(); + CollectionElement(CollectionType* coll, unsigned int pos); + operator T() const; + CollectionElement& operator = (const ValueType& other); + CollectionElement& operator = (const CollectionElement& other); + bool IsNull() const; + void SetNull(); + + private: + + CollectionType* _coll; + unsigned int _pos; + }; + + /** + * @brief + * STL compliant Collection Random iterator class + * + * @warning this iterator does not support the operator[] + * + */ + template + class CollectionIterator + { + public: + + template + friend class Collection; + + typedef typename T::ValueType value_type; + typedef Collection CollectionType; + + typedef std::random_access_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef ptrdiff_t distance_type; + typedef value_type* pointer; + typedef value_type& reference; + + CollectionIterator(); + CollectionIterator(const CollectionIterator& other); + + CollectionIterator& operator = (const CollectionIterator& other); + + CollectionIterator& operator += (difference_type value); + CollectionIterator& operator -= (difference_type value); + + T& operator*(); + T* operator->(); + + CollectionIterator& operator++(); + CollectionIterator& operator--(); + + CollectionIterator operator++(int); + CollectionIterator operator--(int); + + CollectionIterator operator + (difference_type value); + CollectionIterator operator - (difference_type value); + + difference_type operator - (const CollectionIterator& other); + + bool operator == (const CollectionIterator& other); + bool operator != (const CollectionIterator& other); + bool operator > (const CollectionIterator& other); + bool operator < (const CollectionIterator& other); + bool operator >= (const CollectionIterator& other); + bool operator <= (const CollectionIterator& other); + + protected: + + CollectionIterator(CollectionType* collection, unsigned int pos); + + T _elem; + }; + + /** + * @brief + * Object identifying the SQL data types VARRAY and NESTED TABLE. + * + * This class wraps the OCILIB object handle OCI_Coll and its related methods + * + */ + template + class Collection : public core::HandleHolder, public core::Streamable + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + friend class Object; + template + friend class CollectionIterator; + template + friend class Collection; + + public: + + /** + * @brief + * Collection type enumerated values + * + */ + enum CollectionTypeValues + { + /** Collection is a VARRAY */ + Varray = OCI_COLL_VARRAY, + /** Collection is a NESTED TABLE */ + NestedTable = OCI_COLL_NESTED_TABLE, + /** Collection is a PL/SQL TABLE INDEX BY */ + IndexedTable = OCI_COLL_INDEXED_TABLE + }; + + /** + * @brief + * Collection type + * + * Possible values are Collection::CollectionTypeValues + * + */ + typedef core::Enum CollectionType; + + /** + * @brief + * Create an empty null Collection instance + * + */ + Collection(); + + /** + * @brief + * Parametrized constructor + * + * @param typeInfo - type info descriptor + * + */ + Collection(const TypeInfo& typeInfo); + + /** + * @brief + * Return the type of the collection + * + */ + CollectionType GetType() const; + + /** + * @brief + * Returns the maximum number of elements for the collection + * + */ + unsigned int GetMax() const; + + /** + * @brief + * Returns the total number of elements in the collection + * + */ + unsigned int GetSize() const; + + /** + * @brief + * Returns the current number of elements in the collection + * + * @note + * - For VARRAYs, it returns the same value than GetSize() as VARRAYs cannot contains holes + * - For Nested Tables that are spare collections that can have holes, it returns the total number + * of elements minus the total of deleted elements + * + */ + unsigned int GetCount() const; + + /** + * @brief + * Trim the given number of elements from the end of the collection + * + * @param size - Number of elements to trim + * + */ + void Truncate(unsigned int size); + + /** + * @brief + * Clear all items of the collection + * + */ + + void Clear(); + + /** + * @brief + * check if the element at the given index is null + * + * @param index - Index of the element + * + * @note + * Collection Index start at 1 + * + */ + bool IsElementNull(unsigned int index) const; + + /** + * @brief + * Nullify the element at the given index + * + * @param index - Index of the element + * + * @note + * Collection Index start at 1 + * + */ + void SetElementNull(unsigned int index); + + /** + * @brief + * Delete the element at the given position in the Nested Table Collection + * + * @param index - Index of the element to delete + * + * @note + * Collection indexes start at position 1. + * + * @warning + * Delete() is only valid for nested tables (e.g. when collection type is Collection::NestedTable + * + * @return + * - if the input collection is a nested table, it returns true if the element is successfully deleted + * - if the input collection is a VARRAY, it always returns false + * + */ + bool Delete(unsigned int index) const; + + /** + * @brief + * Return the collection element value at the given position + * + * @param index - Index of the element + * + */ + T Get(unsigned int index) const; + + /** + * @brief + * Set the collection element value at the given position + * + * @param index - Index of the element + * @param value - Value to set + * + */ + void Set(unsigned int index, const T& value); + + /** + * @brief + * Append the given element value at the end of the collection + * + * @param value - Value to add + * + * + */ + void Append(const T& value); + + /** + * @brief + * Return the type information object associated to the collection + * + */ + TypeInfo GetTypeInfo() const; + + /** + * @brief + * Clone the current instance to a new one performing deep copy + * + */ + Collection Clone() const; + + /** + * @brief + * return a string representation of the current collection + * + */ + ostring ToString() const override; + + /** + * @brief + * Common iterator declaration + * + */ + typedef CollectionIterator > iterator; + + /** + * @brief + * Common const iterator declaration + * + */ + typedef CollectionIterator > const_iterator; + + /** + * @brief + * Returns an iterator pointing to the first element in the collection + * + */ + iterator begin(); + + /** + * @brief + * Returns a const iterator pointing to the first element in the collection + * + */ + const_iterator begin() const; + + /** + * @brief + * Returns an iterator referring to the past-the-end element in the collection + * + */ + iterator end(); + + /** + * @brief + * Returns a const iterator referring to the past-the-end element in the collection + * + */ + const_iterator end() const; + + /** + * @brief + * Returns the element at a given position in the collection. + * + */ + CollectionElement operator [] (unsigned int index); + + /** + * @brief + * Returns the element at a given position in the collection. + * + */ + CollectionElement operator [](unsigned int index) const; + + private: + + static T GetElem(OCI_Elem* elem, core::Handle* parent); + + static void SetElem(OCI_Elem* elem, const T& value); + + Collection(OCI_Coll* pColl, core::Handle* parent = nullptr); + }; + + /** + * @brief + * Object identifying the SQL data type LONG. + * + * This class wraps the OCILIB object handle OCI_LONG of type OCI_CLONG and its related methods + * + */ + template + class Long : public core::HandleHolder + { + friend class Statement; + friend class Resultset; + friend class support::BindArray; + + public: + + /** + * @brief + * Create an empty null Long instance + * + */ + Long(); + + /** + * @brief + * Constructor + * + * @param statement - statement object that will handle operations on the long buffer + * + */ + Long(const Statement& statement); + + /** + * @brief + * Write the given string into the long Object + * + * @param content - string to write + * + * @return + * Number of character written + * + */ + unsigned int Write(const T& content); + + /** + * @brief + * Return the buffer length + * + */ + unsigned int GetLength() const; + + /** + * @brief + * Return the string read from a fetch sequence + * + */ + T GetContent() const; + + private: + + Long(OCI_Long* pLong, core::Handle* parent = nullptr); + }; + + /** + * + * @brief + * Class handling LONG oracle type + * + * @note + * Length and size arguments / returned values are expressed in number of characters + * + */ + typedef Long Clong; + + /** + * + * @brief + * Class handling LONG RAW oracle type + * + * @note + * Length and size arguments / returned values are expressed in number of bytes + * + */ + typedef Long Blong; + + /** + * @brief + * Provides SQL bind information + * + * This class wraps the OCILIB object handle OCI_Bind and its related methods + * + */ + class BindInfo : public core::HandleHolder + { + friend class Statement; + + public: + + /** + * @brief + * Bind direction enumerated values + * + */ + enum BindDirectionValues + { + /** Input bind variable (will be not modified as it is an input value for the server) */ + In = OCI_BDM_IN, + /** Output bind variable (will be modified as it is an output value by the server ) */ + Out = OCI_BDM_OUT, + /** Input / Output bind variable (can be modified as it is an input value that can be modified by the server) */ + InOut = OCI_BDM_IN_OUT + }; + + /** + * @brief + * Bind direction + * + * Possible values are BindInfo::BindDirectionValues + * + */ + typedef core::Enum BindDirection; + + /** + * @brief + * Vector type values + * + */ + enum VectorTypeValues + { + /** Vector is binded as an array in a regular DML array operation */ + AsArray = 1, + /** Vector is binded as a PL/SQL index by table */ + AsPlSqlTable = 2 + }; + + /** + * @brief + * Vector type + * + * Possible values are BindInfo::VectorTypeValues + * + */ + typedef core::Enum VectorType; + + /** + * @brief + * Return the name of the bind object + * + */ + ostring GetName() const; + + /** + * @brief + * Return the OCILIB type of the data associated with the bind object + * + */ + DataType GetType() const; + + /** + * @brief + * Return the OCILIB object subtype of a column + * + * @note + * This call is valid for the following OCILIB types: + * - Scalar numeric types + * - Clong and Blong + * - Clob, NClob and Blob + * - File + * - Timestamp + * - Interval + * + * @warning + * - Cast returned values to the matching C++ class GetType() property type. + * - For scalar numeric types, cast returned value to ocilib::NumericType values. + * - For a non valid type, it returns 0. + * + */ + unsigned int GetSubType() const; + + /** + * @brief + * Return the number of elements associated with the bind object + * + * @return + * - For single binds, it returns 1 + * - For vector binds, it returns the number of element in the bind array + * + */ + unsigned int GetDataCount() const; + + /** + * @brief + * Return the statement associated with the bind object + * + */ + Statement GetStatement() const; + + /** + * @brief + * Mark as null or not null the current bind real value(s) used in SQL statements + * + * @param value - null status value + * @param index - Only valid for vectors : index of the element to check + * + * @note + * There is no notion of null value in C C++ for scalar types. + * It's necessary to explicitly tell Oracle that the bind has a null value. + * It must be done before an Execute() call + * + * @warning + * For handled based data types (non scalar types), OCILIB performs an extra + * check on handles and set the bind status to null is the handle is null + * + * @warning + * Index starts with 1 + * + */ + void SetDataNull(bool value, unsigned int index = 1); + + /** + * @brief + * Check if the current bind value(s) used in SQL statements is marked as NULL + * + * @param index - Only valid for vectors : index of the element to check + * + * @note + * If the bind is related to a single host variable, don't use the parameter index + * If the bind is related to host vectors, the parameter 'index' refers to the index in the vector + * + * @warning + * Index starts with 1 + * + */ + bool IsDataNull(unsigned int index = 1) const; + + /** + * @brief + * Set the charset form of the given character based bind object + * + * @param value - charset form + * + * @note + * This call has to be made after Statement::Prepare() but before Statement::Execute() + * + * @warning + * This call does nothing the bind data type is not ocilib::TypeString or ocilib::TypeLong + * + */ + void SetCharsetForm(CharsetForm value); + + /** + * @brief + * Get the direction mode + * + */ + BindDirection GetDirection() const; + + private: + + BindInfo(OCI_Bind* pBind, core::Handle* parent); + }; + + /** + * @brief + * Object used for executing SQL or PL/SQL statement and returning the produced results. + * + * This class wraps the OCILIB object handle OCI_Statement and its related methods + * + */ + class Statement : public core::HandleHolder + { + friend class Exception; + friend class Resultset; + template + friend class Long; + friend class BindInfo; + friend class BindObject; + + public: + + /** + * @brief + * Statement Type enumerated values + * + */ + enum StatementTypeValues + { + /** SELECT statement */ + TypeSelect = OCI_CST_SELECT, + /** UPDATE statement */ + TypeUpdate = OCI_CST_UPDATE, + /** DELETE statement */ + TypeDelete = OCI_CST_DELETE, + /** INSERT statement */ + TypeInsert = OCI_CST_INSERT, + /** CREATE statement */ + TypeCreate = OCI_CST_CREATE, + /** DROP statement */ + TypeDrop = OCI_CST_DROP, + /** ALTER statement */ + TypeAlter = OCI_CST_ALTER, + /** BEGIN statement */ + TypeBegin = OCI_CST_BEGIN, + /** DECLARE statement */ + TypeDeclare = OCI_CST_DECLARE, + /** CALL statement */ + TypeCall = OCI_CST_CALL, + /** MERGE statement */ + TypeMerge = OCI_CST_MERGE + }; + + /** + * @brief + * Statement Type + * + * Possible values are Statement::StatementTypeValues + * + */ + typedef core::Enum StatementType; + + /** + * @brief + * Fetch Modes enumerated values + * + */ + enum FetchModeValues + { + /** Statement is forward only */ + FetchForward = OCI_SFM_DEFAULT, + /** Statement is scrollable */ + FetchScrollable = OCI_SFM_SCROLLABLE + }; + + /** + * @brief + * Fetch Modes + * + * Possible values are Statement::FetchModeValues + * + */ + typedef core::Enum FetchMode; + + /** + * @brief + * Bind Modes enumerated values + * + */ + enum BindModeValues + { + /** Bind variables are binded by name */ + BindByPosition = OCI_BIND_BY_POS, + /** Bind variables are binded by position */ + BindByName = OCI_BIND_BY_NAME + }; + + /** + * @brief + * Bind Modes + * + * Possible values are Statement::BindModeValues + * + */ + typedef core::Enum BindMode; + + /** + * @brief + * LONG data type mapping modes enumerated values + * + */ + enum LongModeValues + { + /** LONG and LONG RAW are mapped to Long objects */ + LongExplicit = OCI_LONG_EXPLICIT, + /** LONG and LONG RAW are mapped to ostring objects */ + LongImplicit = OCI_LONG_IMPLICIT + }; + + /** + * @brief + * LONG data type mapping modes + * + * Possible values are Statement::LongModeValues + * + */ + typedef core::Enum LongMode; + + /** + * @brief + * Create an empty null Statement instance + * + */ + Statement(); + + /** + * @brief + * Parametrized constructor + * + * @param connection - Parent connection + * + * @note + * - The statement object must not be accessed anymore once the parent connection object gets out of scope + * + */ + Statement(const Connection& connection); + + /** + * @brief + * Return the connection associated with a statement + * + */ + Connection GetConnection() const; + + /** + * @brief + * Describe the select list of a SQL select statement. + * + * @param sql - SELECT sql statement + * + * @note + * This call sends the SELECT SQL order to the server for retrieving the + * description of the select order only. + * The command is not executed. + * This call is only useful to retrieve information on the associated resultset + * Call GetResultset() after Describe() to access to SELECT list information + * + * @note + * This call prepares the statement (internal call to Prepare()) and ask + * the Oracle server to describe the output SELECT list. + * Execute() can be called after Describe() in order to execute the + * statement, which means that the server will parse, and describe again the SQL + * order. + * + * @warning + * Do not use Describe() unless you're only interested in the resultset + * information because the statement will be parsed again when executed and thus + * leading to unnecessary server round trips and less performance + * + */ + void Describe(const ostring& sql); + + /** + * @brief + * Parse a SQL statement or PL/SQL block. + * + * @param sql - SQL order - PL/SQL block + * + * @note + * This call sends the SQL or PL/SQL command to the server for parsing only. + * The command is not executed. + * This call is only useful to check is a command is valid or not. + * + * @note + * This call prepares the statement (internal call to Prepare()) and ask + * the Oracle server to parse its SQL or PL/SQL command. + * Execute() can be call after Parse() in order to execute the + * statement, which means that the server will parse again the command. + * + * @warning + * Do not use Parse() unless you're only interested in the parsing result + * because the statement will be parsed again when executed and thus leading to + * unnecessary server round trips and less performance + * + */ + void Parse(const ostring& sql); + + /** + * @brief + * Prepare a SQL statement or PL/SQL block. + * + * @param sql - SQL order or PL/SQL block + * + * @note + * With version 1.3.0 and above, do not call this function for fetched statements (REF cursors) + * + */ + void Prepare(const ostring& sql); + + /** + * @brief + * Execute a prepared SQL statement or PL/SQL block. + * + */ + void ExecutePrepared(); + + /** + * @brief + * Prepare and execute a SQL statement or PL/SQL block. + * + * @param sql - SQL order - PL/SQL block + * + */ + void Execute(const ostring& sql); + + /** + * @brief + * Execute the prepared statement, retrieve all resultsets, and call the given callback for each row of each resultsets + * + * @tparam TFetchCallback - type of the fetch callback + * + * @param callback - User defined callback + * + * @note + * The user defined callback function must conform to the following prototype: + * bool callback(const Resultset &) + * It shall return true to continue fetching the resultset or false to stop the fetch + * + * @return + * The number of rows fetched + * + */ + template + unsigned int ExecutePrepared(T callback); + + /** + * @brief + * Execute the prepared statement, retrieve all resultsets, and call the given callback + * with adapted type wit for each row of each resultsets + * + * @tparam TAdapter - type of the adapter callback + * @tparam TFetchCallback - type of the fetch callback + * + * @param callback - User defined callback + * @param adapter - User defined adapter function + * + * @note + * The user defined callback function must conform to the following prototype: + * bool callback(const Resultset &) + * It shall return true to continue fetching the resultset or false to stop the fetch + * + * @return + * The number of rows fetched + * + */ + template + unsigned int ExecutePrepared(T callback, U adapter); + + /** + * @brief + * Execute the given SQL statement, retrieve all resultsets, and call the given callback for each row of each resultsets + * + * @tparam TFetchCallback - type of the fetch callback + * + * @param sql - SQL order - PL/SQL block + * @param callback - User defined callback + * + * @note + * The user defined callback function must conform to the following prototype: + * bool callback(const Resultset &) + * It shall return true to continue fetching the resultset or false to stop the fetch + * + * @return + * The number of rows fetched + * + */ + template + unsigned int Execute(const ostring& sql, T callback); + + /** + * @brief + * Execute the given SQL statement, retrieve all resultsets, and call the given callback + * with adapted type wit for each row of each resultsets + * + * @tparam TAdapter - type of the adapter callback + * @tparam TFetchCallback - type of the fetch callback + * + * @param sql - SQL order - PL/SQL block + * @param callback - User defined callback + * @param adapter - User defined adapter function + * + * @note + * The user defined callback function must conform to the following prototype: + * bool callback(const Resultset &) + * It shall return true to continue fetching the resultset or false to stop the fetch + * + * @return + * The number of rows fetched + * + */ + template + unsigned int Execute(const ostring& sql, T callback, U adapter); + + /** + * @brief + * Return the number of rows affected by the SQL statement + * + * + * The returned value is : + * - For UPDATEs : number of rows updated + * - For INSERTs : number of rows inserted + * - For DELETEs : number of rows deleted + * + * @note + * For SELECTs statements, use GetRowCount() instead + * + */ + unsigned int GetAffectedRows() const; + + /** + * @brief + * Return the last SQL or PL/SQL statement prepared or executed by the statement + * + */ + ostring GetSql() const; + + /** + * @brief + * Return the server SQL_ID of the last SQL or PL/SQL statement prepared or executed by the statement + * + */ + ostring GetSqlIdentifier() const; + + /** + * @brief + * Retrieve the resultset from an executed statement + * + * @note + * See @ref OcilibCApiFetching for more details about what statements can return resultsets + * + * @warning + * If the statement has not been prepared and executed, null resultset object will be returned + * + */ + Resultset GetResultset(); + + /** + * @brief + * Retrieve the next available resultset + * + * @note + * it is only valid for the following statements: + * - Statements executing SQL UPDATE/DELETE using a RETURNING INTO clause + * - Statements implicitly returned from PL/SQL procedure or blocks (new feature in Oracle 12cR1) using + * DBMS_SQL.RETURN_RESULT() + * + * @note + * SQL statements with a 'returning' clause can return multiple resultsets. + * When arrays of program variables are binded to the statement, Oracle will + * execute the statement for every row (iteration). + * Each iteration generates a resultset that can be fetched like regular ones. + * + * @note + * Starting withOracle 12cR1, PL/SQ procedure and blocks can return multiple implicit resultsets + * Refer to Oracle documentation for more information. + * + */ + Resultset GetNextResultset(); + + /** + * @brief + * Set the input array size for bulk operations + * + * @param size - Array size + * + * @warning + * Do not use SetBindArraySize() for PL/SQL tables binding + * + * @note + * SetBindArraySize() is used to set the size of input bind array when using + * arrays for DML statements. + * SetBindArraySize() MUST be called to set the maximum size of the arrays + * to bind to the statement before any of its execution. This initial call must + * be bone AFTER OPrepare() and BEFORE any Bind() call taking vectors as parameter. + * + * @note + * SetBindArraySize() can optionally be called before any later Execute() + * call in order to notify the statement of the exact number of elements + * populating the input arrays for the next execution. The array size passed to + * later SetBindArraySize() calls cannot be greater than the initial size + * otherwise an exception will be thrown. + * + */ + void SetBindArraySize(unsigned int size); + + /** + * @brief + * Return the current input array size for bulk operations + * + */ + unsigned int GetBindArraySize() const; + + /** + * @brief + * Allow different host variables to be binded using the same bind name or + * position between executions of a prepared statement + * + * @param value - Rebinding mode allowed + * + * @note + * Default value is false + * + * @warning + * When using rebinding feature, host variable re-binded to a previously allocated + * bind MUST be of the same data type ! + * + */ + void AllowRebinding(bool value); + + /** + * @brief + * Indicate if rebinding is allowed on the statement + * + * @note + * See AllowRebinding() for more details + * + */ + bool IsRebindingAllowed() const; + + /** + * @brief + * Return the index of the bind from its name belonging to the statement + * + * @param name - Bind variable name + * + * @warning + * The bind name is case insensitive + * + * @note + * Bind indexes start with 1 in OCILIB + * + * @return + * Bind index on success or zero if the bind does not exists + * + */ + unsigned int GetBindIndex(const ostring& name) const; + + /** + * @brief + * Return the number of binds currently associated to a statement + * + */ + unsigned int GetBindCount() const; + + /** + * @brief + * Return the bind at the given index in the internal array of bind objects + * + * @param index - Bind position + * + * @warning + * Index starts at 1. + * + * @note + * Bind handle are created sequentially. For example, the third call to a + * Bind() call generates a bind object of index 3. + * + */ + BindInfo GetBind(unsigned int index) const; + + /** + * @brief + * Return a bind handle from its name + * + * @param name - Bind variable name + * + * @note + * Bind names must include a semicolon at the beginning. + * + */ + BindInfo GetBind(const ostring& name) const; + + /** + * @brief + * Bind an host variable + * + * @tparam T - C++ type of the host variable + * + * @param name - Bind name + * @param value - Host variable + * @param mode - bind direction mode + * + * @warning + * This method has built-in specialized versions for all supported types except ostring, Clong and Blong variables. + * For binding ostring, Clong and Blong variables, use the version with an extra parameter. + * + * @note + * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved + * automatically from the arguments. + * + */ + template + void Bind(const ostring& name, T& value, BindInfo::BindDirection mode); + + /** + * @brief + * Bind an host variable with more information + * + * @tparam T - C++ type of the host variable + * @tparam TExtraInfo - C++ type if the extra information needed for the bind call + * + * @param name - Bind name + * @param value - Host variable + * @param extraInfo - Extra information needed for the bind call + * @param mode - bind direction mode + * + * @warning + * This method has built-in specialized versions for ostring, Clong and Blong variables. + * Pass the maximum length/size of the variable in the parameter extraInfo + * + * @note + * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved + * automatically from the arguments. + * + */ + template + void Bind(const ostring& name, T& value, U extraInfo, BindInfo::BindDirection mode); + + /** + * @brief + * Bind a host collection variable + * + * @tparam T - C++ type of the host collection variable + * + * @param name - Bind name + * @param value - Host Collection variable + * @param mode - bind direction mode + * + */ + template + void Bind(const ostring& name, Collection& value, BindInfo::BindDirection mode); + + /** + * @brief + * Bind a vector of host variables + * + * @tparam T - C++ type of the host variable + * + * @param name - Bind name + * @param values - Vector of host variables + * @param mode - bind direction mode + * @param type - vector type (regular array or PL/SQL table) + * + * @warning + * This method has built-in specialized versions for all C++ native scalar types, Date time and Statement objects. + * For others types (ostring, Clong, Blong, Raw, Object, Reference, Collection, Timestamp, Interval), use versions with extra parameters. + * + * @note + * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved + * automatically from the arguments. + * + */ + template + void Bind(const ostring& name, std::vector& values, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); + + /** + * @brief + * Bind a vector of host variables with Oracle type information + * + * @tparam T - C++ type of the host variable + * + * @param name - Bind name + * @param values - Vector of host variables + * @param typeInfo - Object type information + * @param mode - bind direction mode + * @param type - vector type (regular array or PL/SQL table) + * + * @warning + * This method has built-in specialized versions for Object, Reference. + * + * @note + * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved + * automatically from the arguments. + * + */ + template + void Bind(const ostring& name, std::vector& values, TypeInfo& typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); + + /** + * @brief + * Bind a vector of host collection variables with Oracle type information + * + * @tparam T - collection C++ type of the host collection variables + * + * @param name - Bind name + * @param values - Vector of host collection variables + * @param typeInfo - Object type information + * @param mode - bind direction mode + * @param type - vector type (regular array or PL/SQL table) + * + */ + template + void Bind(const ostring& name, std::vector >& values, TypeInfo& typeInfo, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); + + /** + * @brief + * Bind a vector of host variables with more information + * + * @tparam T - C++ type of the host variable + * @tparam TExtraInfo - C++ type if the extra information needed for the bind call + * + * @param name - Bind name + * @param values - Vector of host variables + * @param extraInfo - Extra information needed for the bind call + * @param mode - bind direction mode + * @param type - vector type (regular array or PL/SQL table) + * + * @warning + * This method has built-in specialized versions for ostring, Raw , Clong, Blong, Timestamp, Interval variables. + * - For ostring, Clong, Blong, Raw : Pass the maximum length/size of variables in the parameter extraInfo + * - For Timestamp, Interval : Pass a value of the matching C++ class GetType() property type OR the underlying enumeration type. + * + * @note + * It is not necessary to specify the template data type in the bind call as all possible specializations can be resolved + * automatically from the arguments. + * + */ + template + void Bind(const ostring& name, std::vector& values, U extraInfo, BindInfo::BindDirection mode, BindInfo::VectorType type = BindInfo::AsArray); + + /** + * @brief + * Register a host variable as an output for a column present in a SQL RETURNING INTO clause + * + * @tparam T - C++ type of the host variable + * + * @param name - Bind name + * + * @warning + * This method has built-in specialized versions for all supported types except: + * - Timestamp and Interval, Object and Reference : use the version that takes a TypeInfo parameter + * - ostring and Raw : use the version that takes an extraInfo parameter + * + * @note + * Statement, Blong and Clong are not supported for register calls + * + * @warning + * It is necessary to specify the template data type in the register call + * + */ + template + void Register(const ostring& name); + + /** + * @brief + * Register a host variable with Oracle type information as an output for a column present in a SQL RETURNING INTO clause + * + * @tparam T - C++ type of the host variable + * @tparam TExtraInfo - C++ type if the extra information needed for the bind call + * + * @param name - Bind name + * @param extraInfo - Extra information needed for the bind call + * + * @warning + * This method has built-in specialized versions for Object and Reference. + * + * @warning + * It is necessary to specify the template data type in the register call + * + */ + template + void Register(const ostring& name, U& extraInfo); + + /** + * @brief + * Register a host variable with more information as an output for a column present in a SQL RETURNING INTO clause + * + * @tparam T - C++ type of the host variable + * @tparam TExtraInfo - C++ type if the extra information needed for the bind call + * + * @param name - Bind name + * @param extraInfo - Extra information needed for the bind call + * + * @warning + * This method has built-in specialized versions for ostring and Raw variables. + * Pass the maximum length/size of variables in the parameter extraInfo + * + * @note + * It is necessary to specify the template data type in the register call + * + */ + template + void Register(const ostring& name, U extraInfo); + + /** + * @brief + * Return the type of a SQL statement + * + */ + StatementType GetStatementType() const; + + /** + * @brief + * Return the error position (in terms of characters) in the SQL statement + * where the error occurred in case of SQL parsing error + * + * @note + * Positions start at 1. + * + */ + unsigned int GetSqlErrorPos() const; + + /** + * @brief + * Set the fetch mode of a SQL statement + * + * @param value - fetch mode value + * + * @warning + * SetFetchMode() MUST be called before any Execute() call + * + */ + void SetFetchMode(FetchMode value); + + /** + * @brief + * Return the fetch mode of a SQL statement + * + * @note + * Default value is Statement::FetchForward + * + */ + FetchMode GetFetchMode() const; + + /** + * @brief + * Set the binding mode of a SQL statement + * + * @param value - binding mode value + * + */ + void SetBindMode(BindMode value); + + /** + * @brief + * Return the binding mode of a SQL statement + * + * @note + * Default value is Statement::BindByName + * + */ + BindMode GetBindMode() const; + + /** + * @brief + * Set the number of rows fetched per internal server fetch call + * + * @param value - number of rows to fetch + * + */ + void SetFetchSize(unsigned int value); + + /** + * @brief + * Return the number of rows fetched per internal server fetch call + * + * @note + * Default value is set to constant OCI_FETCH_SIZE + * + */ + unsigned int GetFetchSize() const; + + /** + * @brief + * Set the number of rows pre-fetched by OCI Client + * + * @param value - number of rows to pre-fetch + * + * @note + * To turn off pre-fetching, set both attributes (size and memory) to 0. + * + */ + void SetPrefetchSize(unsigned int value); + + /** + * @brief + * Return the number of rows pre-fetched by OCI Client + * + * @note + * Default value is set to constant OCI_PREFETCH_SIZE + * + */ + unsigned int GetPrefetchSize() const; + + /** + * @brief + * Set the amount of memory pre-fetched by OCI Client + * + * @param value - amount of memory to fetch + * + * @note + * Default value is 0 and the pre-fetch size attribute is used instead. + * When both attributes are set (pre-fetch size and memory) and pre-fetch memory + * value can hold more rows than specified by pre-fetch size, OCI uses pre-fetch + * size instead. + * + * @note + * OCILIB set pre-fetch attribute to OCI_PREFETCH_SIZE when a statement is created. + * To setup a big value for SetPrefetchMemory(), you must call + * SetPrefetchSize() to 0 to make OCI consider this attribute. + * + */ + void SetPrefetchMemory(unsigned int value); + + /** + * @brief + * Return the amount of memory used to retrieve rows pre-fetched by OCI Client + * + * @note + * Default value is 0 + * + */ + unsigned int GetPrefetchMemory() const; + + /** + * @brief + * Set the LONG data type piece buffer size + * + * @param value - maximum size for long buffer + * + */ + void SetLongMaxSize(unsigned int value); + + /** + * @brief + * Return the LONG data type piece buffer size + * + * @note + * Default value is set to constant OCI_SIZE_LONG + * + */ + unsigned int GetLongMaxSize() const; + + /** + * @brief + * Set the long data type handling mode of a SQL statement + * + * @param value - long mode value + * + * @note + * LONG RAWs can't be handled with Statement::LongImplicit mode + * + */ + void SetLongMode(LongMode value); + + /** + * @brief + * Return the long data type handling mode of a SQL statement + * + */ + LongMode GetLongMode() const; + + /** + * @brief + * Return the Oracle SQL code the command held by the statement + * + * @warning + * GetSQLCommand() must be called after the statement has be executed + * because that's the server engine that computes the SQL command code + * + * @note + * The SQL command list is available in Oracle documentations and guides + * + */ + unsigned int GetSQLCommand() const; + + /** + * @brief + * Return the verb of the SQL command held by the statement + * + * @warning + * GetSQLVerb() must be called after the statement has been executed + * because that's the server engine that computes the SQL verb + * + * @note + * The SQL verb list is available in Oracle documentations and guides + * + */ + ostring GetSQLVerb() const; + + /** + * @brief + * Returns all errors that occurred within a DML array statement execution + * + */ + void GetBatchErrors(std::vector& exceptions); + + private: + + static bool IsResultsetHandle(core::Handle* handle); + static void OnFreeSmartHandle(SmartHandle* smartHandle); + + Statement(OCI_Statement* stmt, core::Handle* parent = nullptr); + + support::BindsHolder* GetBindsHolder(bool create) const; + + void ReleaseResultsets() const; + + void SetLastBindMode(BindInfo::BindDirection mode); + + void SetInData() const; + void SetOutData() const; + void ClearBinds() const; + + template + void Bind1(M& method, const ostring& name, T& value, BindInfo::BindDirection mode); + + template + void Bind2(M& method, const ostring& name, T& value, BindInfo::BindDirection mode); + + template + void BindVector1(M& method, const ostring& name, std::vector& values, BindInfo::BindDirection mode, BindInfo::VectorType type); + + template + void BindVector2(M& method, const ostring& name, std::vector& values, BindInfo::BindDirection mode, U subType, BindInfo::VectorType type); + + template + unsigned int Fetch(T callback); + + template + unsigned int Fetch(T callback, U adapter); + }; + + /** + * @brief + * Database resultset + * + * This class wraps the OCILIB object handle OCI_Resultset and its related methods + * + */ + class Resultset : public core::HandleHolder + { + friend class Statement; + public: + + /** + * @brief + * Seek Modes enumerated values + * + */ + enum SeekModeValues + { + /** Seek is performed using a given absolute offset. The statement must be scrollable */ + SeekAbsolute = OCI_SFD_ABSOLUTE, + /** Seek is performed using a given relative offset from the current position. The statement must be scrollable */ + SeekRelative = OCI_SFD_RELATIVE + }; + + /** + * @brief + * Seek Modes + * + * Possible values are Resultset::SeekModeValues + * + */ + typedef core::Enum SeekMode; + + /** + * @brief + * Return the current value of the column at the given index in the resultset + * + * @tparam T - C++ type of the value to retrieve + * + * @param index - Column position + * + * @note + * Column position starts at 1. + * + */ + template + T Get(unsigned int index) const; + + /** + * @brief + * Assign to the current value of the column at the given index in the resultset + * + * @tparam T - C++ type of the value to retrieve + * + * @param index - Column position + * @param value - value to fill + * + * @note + * Column position starts at 1. + * + */ + template + void Get(unsigned int index, T& value) const; + + /** + * @brief + * Return the current value of the column from its name in the resultset + * + * @tparam T - C++ type of the value to retrieve + * + * @param name - Column name + * + * @note + * The column name is case insensitive. + * + */ + template + T Get(const ostring& name) const; + + /** + * @brief + * Assign to the current value of the column from its name in the resultset + * + * @tparam T - C++ type of the value to retrieve + * + * @param name - Column name + * @param value - value to fill + * + */ + template + void Get(const ostring& name, T& value) const; + + /** + * @brief + * Return a given user type from the current fetched row. + * It allow translating row column values returned by a query to a user defined type using the given adapter type + * + * @param value - User defined type value to be filled by the adapter function + * @param adapter - User defined adapter function + * + * @note + * The user defined adapter function must conform to the following prototype: + * bool adapter (const Resultset &, T &) + * It shall return true if it has filled the value from the resultset otherwise false + * + */ + template + bool Get(T& value, U adapter) const; + + /** + * @brief + * Fetch all rows in the resultset and call the given callback for row + * + * @param callback - User defined callback + * + * @note + * The user defined callback function must conform to the following prototype: + * bool callback(const Resultset &) + * It shall return true to continue fetching the resultset or false to stop the fetch + * + * @return + * The number of rows fetched + * + */ + template + unsigned int ForEach(T callback); + + /** + * @brief + * Fetch all rows in the resultset and call the given callback for row + * It allow translating row column values returned by a query to a user defined type using the given adapter type + * + * @param callback - User defined callback + * @param adapter - User defined adapter function + * + * @note + * The user defined adapter function must conform to the following prototype: + * [UserDefinedType] adapter (const Resultset &) + * The return value type must match the parameter of the callback method + * + * @note + * The user defined callback function must conform to the following prototype: + * bool callback(const [UserDefinedType] &) + * It shall return true to continue fetching the resultset or false to stop the fetch + * + * @return + * The number of rows fetched + * + */ + template + unsigned int ForEach(T callback, U adapter); + + /** + * @brief + * Fetch the next row of the resultset + * + * @note + * Next() works for normal and scrollable resultsets + * + * @return + * true on success otherwise false if : + * - Empty resultset + * - Last row already fetched + * + */ + bool Next(); + + /** + * @brief + * Fetch the previous row of the resultset + * + * @note + * Prev() works ONLY for scrollable resultsets + * + * @return + * true on success otherwise false if : + * - Empty resultset + * - First row already fetched + * + */ + bool Prev(); + + /** + * @brief + * Fetch the first row of the resultset + * + * @note + * First() works ONLY for scrollable resultsets + * + * @return + * true on success otherwise false if the resultset is empty + * + */ + bool First(); + + /** + * @brief + * Fetch the last row of the resultset + * + * @note + * Last() works ONLY for scrollable resultsets + * + * @return + * true on success otherwise false if the resultset is empty + * + */ + bool Last(); + + /** + * @brief + * Custom Fetch of the resultset + * + * @param mode - Fetch direction + * @param offset - Fetch offset + * + * @warning + * hSeek() works ONLY for scrollable resultsets + * + * @note + * If you intend to use Seek() on a scrollable statement and if any of the + * selected columns is a ref cursor or a nested table, you must set the fetching size + * to 1 using Statement::SetFetchSize() before calling Statement::GetResultset() + * Otherwise Seek() will fails with a OCI-10002 error + * + * @return + * true on success otherwise false the resultset is empty or seek offset out of bounds + * + */ + bool Seek(SeekMode mode, int offset); + + /** + * @brief + * Retrieve the number of rows fetched so far + * + */ + unsigned int GetCount() const; + + /** + * @brief + * Retrieve the current row index + * + * @note + * - GetCurrentRow() returns the current row number starting from 1 + * - If the resultset has not been fetched or if the resultset is empty, it returns 0 + * - If the resultset has been fully fetched, it returns the last fetched row number + * + */ + unsigned int GetCurrentRow() const; + + /** + * @brief + * Return the index of the column in the result from its name + * + * @param name - Column name + * + * @warning + * The column name is case insensitive + * + * @note + * Column position starts at 1. + * + */ + unsigned int GetColumnIndex(const ostring& name) const; + + /** + * @brief + * Return the number of columns in the resultset + * + */ + unsigned int GetColumnCount() const; + + /** + * @brief + * Return the column from its index in the resultset + * + * @param index - Column index + * + * @note + * Column position starts at 1. + * + */ + Column GetColumn(unsigned int index) const; + + /** + * @brief + * Return the column from its name in the resultset + * + * @param name - Column name + * + * @note + * The column name is case insensitive + * + */ + Column GetColumn(const ostring& name) const; + + /** + * @brief + * Check if the current row value is null for the column at the given index + * + * @param index - Column index + * + * @note + * Column position starts at 1. + * + */ + bool IsColumnNull(unsigned int index) const; + + /** + * @brief + * Check if the current row value is null for the column of the given name + * + * @param name - Column name + * + */ + bool IsColumnNull(const ostring& name) const; + + /** + * @brief + * Return the statement associated with the resultset + * + */ + Statement GetStatement() const; + + /** + * @brief + * Convenient operator overloading that performs a call to Next() + * + */ + bool operator ++ (int); + + /** + * @brief + * Convenient operator overloading that performs a call to Prev() + * + */ + bool operator -- (int); + + /** + * @brief + * Convenient operator overloading that performs a call to Seek() + * with Resultset::SeekRelative and the given offset + * + */ + bool operator += (int offset); + + /** + * @brief + * Convenient operator overloading that performs a call to Seek() + * with Resultset::SeekRelative and the given offset that is internally negated + * + */ + bool operator -= (int offset); + + private: + + Resultset(OCI_Resultset* resultset, core::Handle* parent); + }; + + /** + * @brief + * Encapsulate a Resultset column or object member properties + * + * This class wraps the OCILIB object handle OCI_Column and its related methods + * + */ + class Column : public core::HandleHolder + { + friend class TypeInfo; + friend class Resultset; + + public: + + /** + * @brief + * Column properties flags values + * + */ + enum PropertyFlagsValues + { + /** The column has no flags or the OCI client does not support it */ + NoFlags = OCI_CPF_NONE, + /** - If Set, the column is an IDENTITY column + - Otherwise, it is not an IDENTITY column */ + IsIdentity = OCI_CPF_IS_IDENTITY, + /** Only valid when IsIdentity is set: + - If set, means that the value is "ALWAYS GENERATED" + - Otherwise means that the value is "GENERATED BY" */ + IsGeneratedAlways = OCI_CPF_IS_GEN_ALWAYS, + /** Only valid when IsIdentity is set: + - If set, means that the value is generated by default on NULL */ + IsGeneratedByDefaultOnNull = OCI_CPF_IS_GEN_BY_DEFAULT_ON_NULL, + /** If set, Column is an implicitly generated logical partitioning column for container_map enabled object */ + IsLogicalPartitioning = OCI_CPF_IS_LPART, + /** If set, Column is a CON_ID column implicitly generated by CONTAINERS() or is an ORIGIN_CON_ID column implicitly generated for Extended Data Link */ + IsGeneratedByContainers = OCI_CPF_IS_CONID + }; + + /** + * @brief + * Column properties flags + * + * Possible values are Column::PropertyFlagsValues + * + */ + typedef core::Flags PropertyFlags; + + /** + * @brief + * Return the Column name + * + */ + ostring GetName() const; + + /** + * @brief + * Return the Oracle SQL type name of the column data type + * + * @note + * For possible values, consults Oracle Documentation + * + */ + ostring GetSQLType() const; + + /** + * @brief + * Return the Oracle SQL Full name including precision and size of the + * column data type + * + * @note + * This function returns a description that matches the one given by SQL*Plus + * + */ + ostring GetFullSQLType() const; + + /** + * @brief + * Return the type of the given column + * + */ + DataType GetType() const; + + /** + * @brief + * Return the OCILIB object subtype of a column + * + * @note + * This call is valid for the following OCILIB types: + * - Clong and Blong + * - Clob, NClob and Blob + * - File + * - Timestamp + * - Interval + * + * @warning + * - Cast returned values to the matching C++ class GetType() property type. + * - For a non valid type, it returns 0. + * + */ + unsigned int GetSubType() const; + + /** + * @brief + * Return the charset form of the given column + * + */ + CharsetForm GetCharsetForm() const; + + /** + * @brief + * Return the collation ID of the given column + * + */ + CollationID GetCollationID() const; + + /** + * @brief + * Return the size of the column + * + * @note + * For all types, the size is expressed is bytes, excepted for character + * based columns that were created with a character based size or of type NCHAR/NVARCHAR + * + */ + unsigned int GetSize() const; + + /** + * @brief + * Return the scale of the column for numeric columns + * + */ + int GetScale() const; + + /** + * @brief + * Return the precision of the column for numeric columns + * + */ + int GetPrecision() const; + + /** + * @brief + * Return the fractional precision of the column for Timestamp and Interval columns + * + */ + int GetFractionalPrecision() const; + + /** + * @brief + * Return the leading precision of the column for Interval columns + * + */ + int GetLeadingPrecision() const; + + /** + * @brief + * Return the column property flags + * + * @note + * This was introduced in Oracle 12cR1. + * It is currently used for identifying Identity columns. + * For earlier versions, it always return Columns::NoFlags + * + */ + PropertyFlags GetPropertyFlags() const; + + /** + * @brief + * Return true if the column is nullable otherwise false + * + */ + bool IsNullable() const; + + /** + * @brief + * Return true if the length of the column is character-length or false if it is byte-length + * + * @note + * This was introduced in Oracle 9i. So for version that are not supporting this + * property, it always return false + * + */ + bool IsCharSemanticUsed() const; + + /** + * @brief + * Return the type information object associated to the column + * + * @note + * This call is used only for Named Object typed and collection columns. + * It returns a null object if the column is not a Named Object or a collection. + * + */ + TypeInfo GetTypeInfo() const; + + private: + + Column(OCI_Column* pColumn, core::Handle* parent); + }; + + /** + * @brief + * Subscription to database or objects changes + * + * This class wraps the OCILIB object handle OCI_Subscription and its related methods + * + * @warning + * Environment::Events flag must be passed to Environment::Initialize() to be able to use subscriptions + + */ + class Subscription : public core::HandleHolder + { + friend class Event; + + public: + + /** + * @typedef NotifyHandlerProc + * + * @brief + * User callback for subscriptions event notifications + * + */ + typedef void (*NotifyHandlerProc) (Event& evt); + + /** + * @brief + * Subscription changes flags values + * + */ + enum ChangeTypesValues + { + /** Request for changes at objects (e.g. tables) level (DDL / DML) */ + ObjectChanges = OCI_CNT_OBJECTS, + /** Request for changes at rows level (DML) */ + RowChanges = OCI_CNT_ROWS, + /** Request for changes at database level (startup, shutdown) */ + DatabaseChanges = OCI_CNT_DATABASES, + /** Request for all changes */ + AllChanges = OCI_CNT_ALL + }; + + /** + * @brief + * Subscription changes flags + * + * Possible values are Subscription::ChangeTypesValues + * + */ + typedef core::Flags ChangeTypes; + + /** + * @brief + * Default constructor + * + */ + Subscription(); + + /** + * @brief + * Register a notification against the given database + * + * @param connection - Connection handle + * @param name - Notification name + * @param changeTypes - Subscription type + * @param handler - User handler callback + * @param port - Port to use for notifications + * @param timeout - notification timeout + * + * @note + * Requires Oracle Client 10gR2 or above + * + */ + void Register(const Connection& connection, const ostring& name, ChangeTypes changeTypes, NotifyHandlerProc handler, unsigned int port = 0, unsigned int timeout = 0); + + /** + * @brief + * Unregister a previously registered notification + * + * @note + * Environment::Cleanup() will automatically unregister any non unregistered subscriptions + * + * @note + * If the database connection passed to Register() + * has been closed by the time that the application calls + * Unregister(), the library internally reconnects + * to the given database, performs the unregistration and then disconnects + * + */ + void Unregister(); + + /** + * @brief + * Add a SQL query to monitor + * + */ + void Watch(const ostring& sql); + + /** + * @brief + * Return the name of the given registered subscription + * + */ + ostring GetName() const; + + /** + * @brief + * Return the timeout of the given registered subscription + * + */ + unsigned int GetTimeout() const; + + /** + * @brief + * Return the port used by the notification + * + */ + unsigned int GetPort() const; + + /** + * @brief + * Return the connection associated with a subscription handle + * + * @note + * It may return a null connection object if the connection used at Register() time has been closed + * + */ + Connection GetConnection() const; + + private: + + Subscription(OCI_Subscription* pSubcription); + }; + + /** + * @brief + * Subscription Event + * + * This class wraps the OCILIB object handle OCI_Event and its related methods + * + * @warning + * Environment::Events flag must be passed to Environment::Initialize() to be able to use subscriptions + * + */ + class Event : public core::HandleHolder + { + friend class Subscription; + friend class Environment; + + public: + + /** + * @brief + * Event type enumerated values + * + */ + enum EventTypeValues + { + /** A database has been started up */ + DatabaseStart = OCI_ENT_STARTUP, + /** A database has been shut down */ + DatabaseShutdown = OCI_ENT_SHUTDOWN, + /** A database has been shut down (RAC) */ + DatabaseShutdownAny = OCI_ENT_SHUTDOWN_ANY, + /** A database has been dropped */ + DatabaseDrop = OCI_ENT_DROP_DATABASE, + /** The notification is timed out */ + Unregister = OCI_ENT_DEREGISTER, + /** A database object has been modified */ + ObjectChanged = OCI_ENT_OBJECT_CHANGED + }; + + /** + * @brief + * Event type + * + * Possible values are Event::EventTypeValues + * + */ + typedef core::Enum EventType; + + /** + * @brief + * Object events enumerated values + * + */ + enum ObjectEventValues + { + /** An insert has been performed */ + ObjectInserted = OCI_ONT_INSERT, + /** An update has been performed */ + ObjectUpdated = OCI_ONT_UPDATE, + /** A delete has been performed */ + ObjectDeleted = OCI_ONT_DELETE, + /** An alter has been performed */ + ObjectAltered = OCI_ONT_ALTER, + /** A drop has been performed */ + ObjectDropped = OCI_ONT_DROP, + /** Generic undefined action * */ + ObjectGeneric = OCI_ONT_GENERIC + }; + + /** + * @brief + * Object events + * + * Possible values are Event::ObjectEventValues + * + */ + typedef core::Enum ObjectEvent; + + /** + * @brief + * Return the type of event reported by a notification + * + */ + EventType GetType() const; + + /** + * @brief + * Return the type of operation reported by a notification + + * @note + * This call is only valid when GetType() reports the event type Event::ObjectChanged + * + */ + ObjectEvent GetObjectEvent() const; + + /** + * @brief + * Return the name of the database that generated the event + * + */ + ostring GetDatabaseName() const; + + /** + * @brief + * Return the name of the object that generated the event + * + * @note + * Database object name follows the pattern "[schema_name].object_name" + * + */ + ostring GetObjectName() const; + + /** + * @brief + * Return the rowid of the altered database object row + * + */ + ostring GetRowID() const; + + /** + * @brief + * Return the subscription that generated this event + * + */ + Subscription GetSubscription() const; + + private: + + Event(OCI_Event* pEvent); + }; + + /** + * @brief + * AQ identified agent for messages delivery + * + * This class wraps the OCILIB object handle OCI_Agent and its related methods + * + */ + class Agent : public core::HandleHolder + { + friend class Message; + friend class Dequeue; + + public: + + /** + * @brief + * Create an AQ agent object + * + * @param connection - Connection object + * @param name - Agent name + * @param address - Agent address + * + * @note + * An AQ agent object is : + * - used as recipient information when enqueuing a message + * - used as sender information when dequeuing a message + * - used for listening message only from identified senders + * + * @note + * the AQ agent address can be any Oracle identifier, up to 128 bytes. + * the AQ agent name can be any Oracle identifier, up to 30 bytes. + * + * @note + * the Agent object must not be accessed anymore once the parent connection object gets out of scope + * + */ + Agent(const Connection& connection, const ostring& name = OTEXT(""), const ostring& address = OTEXT("")); + + /** + * @brief + * Get the given AQ agent name + * + */ + ostring GetName() const; + + /** + * @brief + * Set the given AQ agent name + * + * @param value - AQ agent name + * + * @note + * the AQ agent name is used to identified an message send or recipient when enqueuing/dequeuing a message + * + * @note + * the AQ agent name can be any Oracle identifier, up to 30 bytes. + * + */ + void SetName(const ostring& value); + + /** + * @brief + * Get the given AQ agent address + * + * @note + * See SetAddress() for more details + * + */ + ostring GetAddress() const; + + /** + * @brief + * Set the given AQ agent address + * + * @param value - AQ agent address + * + * @note + * the parameter 'address' must be of the form : [schema.]queue_name[\@dblink] + * + * @note + * the AQ agent address can be any Oracle identifier, up to 128 bytes. + * + */ + void SetAddress(const ostring& value); + + private: + + Agent(OCI_Agent* pAgent, core::Handle* parent); + }; + + /** + * @brief + * AQ message + * + * This class wraps the OCILIB object handle OCI_Msg and its related methods + * + */ + class Message : public core::HandleHolder + { + friend class Dequeue; + + public: + + /** + * @brief + * Message state enumerated values + * + */ + enum MessageStateValues + { + /** The message is ready to be processed */ + Ready = OCI_AMS_READY, + /** The message delay has not yet completed */ + Waiting = OCI_AMS_WAITING, + /** The message has been processed */ + Processed = OCI_AMS_PROCESSED, + /** The message has moved to exception queue */ + Expired = OCI_AMS_EXPIRED + }; + + /** + * @brief + * Message state + * + * Possible values are Message::MessageStateValues + * + */ + typedef core::Enum MessageState; + + /** + * @brief + * Create a message object based on the given payload type + * + * @param typeInfo - Type info object + * + * @note + * OCILIB supports 2 type of message payload : + * - Oracle types (UDT) + * - RAW data + * + * @note + * Oracle Type AnyData is not supported in the current version of OCILIB + * + * @note + * the parameter 'typinf' indicates the type of payload : + * - For object payload, retrieve the object type information object from the given type name + * - For RAW payload, you MUST pass the object type information object from the type name "SYS.RAW" as object type name + * + * @warning + * Newly created Message handles have NULL payloads. + * For Message handling Objects payloads, Get() returns a null Object until an object is assigned to the message. + * + * @note + * When a local Message object handle is enqueued, it keeps its attributes. If it's enqueued again, another + * identical message is posted into the queue. + * To reset a message and empty all its properties, call Reset() + * + */ + Message(const TypeInfo& typeInfo); + + /** + * @brief + * Reset all attributes of the message + * + * @warning + * Reset() clears the message payload and set it to NULL + * + */ + void Reset(); + + /** + * @brief + * Get the object payload of the message + * + */ + template + T GetPayload(); + + /** + * @brief + * Set the object payload of the message + * + * @param value - Object payload + * + */ + template + void SetPayload(const T& value); + + /** + * @brief + * return the time the message was enqueued + * + * @note + * Only use this function for message dequeued from queues + * + */ + Date GetEnqueueTime() const; + + /** + * @brief + * Return the number of attempts that have been made to dequeue the message + * + */ + int GetAttemptCount() const; + + /** + * @brief + * Return the state of the message at the time of the dequeue + * + */ + MessageState GetState() const; + + /** + * @brief + * Return the ID of the message + * + * @note + * The message ID is : + * - generated when the message is enqueued in the queue + * - retrieved when the message is dequeued from the queue + * + */ + Raw GetID() const; + + /** + * @brief + * Return the duration that the message is available for dequeuing + * + * @note + * see SetExpiration() for more details + * + */ + int GetExpiration() const; + + /** + * @brief + * set the duration that the message is available for dequeuing + * + * @param value - duration in seconds + * + * @note + * This parameter is an offset from the delay (see SetEnqueueDelay()) + * While waiting for expiration, the message state is set to Message::Ready. + * If the message is not dequeued before it expires, it will be moved to the exception queue + * with the state Message::Expired. + * + * @note + * If parameter 'value' is set to -1 (default value), the message will not expire + * + * @warning + * Expiration processing requires the queue monitor to be started. + * + */ + void SetExpiration(int value); + + /** + * @brief + * Return the number of seconds that a message is delayed for dequeuing + * + * @note + * see SetEnqueueDelay() for more details + * + */ + int GetEnqueueDelay() const; + + /** + * @brief + * set the number of seconds to delay the enqueued message + * + * @param value - Delay in seconds + * + * @note + * The delay represents the number of seconds after which a message is available for dequeuing. + * When the message is enqueued, its state is set to Message::Waiting. + * When the delay expires, its state is set to Message::Ready. + * + * @note + * If parameter 'value' is set to zero (default value), the message will be immediately available + * for dequeuing + * + * @warning + * Dequeuing by Message ID overrides the delay specification. + * + * @warning + * Delaying processing requires the queue monitor to be started. + * + */ + void SetEnqueueDelay(int value); + + /** + * @brief + * Return the priority of the message + * + * @note + * see SetPriority() for more details + * + */ + int GetPriority() const; + + /** + * @brief + * Set the priority of the message + * + * @param value - Message priority + * + * @note + * - The priority can be any number, including negative numbers. + * - A smaller number indicates higher priority. + * - Default value is zero. + * + */ + void SetPriority(int value); + + /** + * @brief + * Return the original ID of the message in the last queue that generated this message + * + * @warning + * When a message is propagated from/to different queues, this ID is the one generated for the + * message in the previous queue. + * + */ + Raw GetOriginalID() const; + + /** + * @brief + * Set the original ID of the message in the last queue that generated this message + * + * @param value - Message ID + * + * @warning + * When a message is propagated from/to different queues, this ID is the one generated for the + * message in the previous queue. + * + */ + void SetOriginalID(const Raw& value); + + /** + * @brief + * Get the correlation identifier of the message + * + * @note + * see SetCorrelation() for more details + * + */ + ostring GetCorrelation() const; + + /** + * @brief + * Set the correlation identifier of the message + * + * @param value - Message correlation text + * + * @note + * see Dequeue::SetCorrelation() for more details + * + */ + void SetCorrelation(const ostring& value); + + /** + * @brief + * Get the Exception queue name of the message + * + * @warning + * When calling this function on a message retrieved with Dequeue::Get(), the returned value is + * empty if the default exception queue associated with the current queue is used (e.g. no user + * defined specified at enqueue time for the message) + * + * @note + * see SetExceptionQueue() for more details + * + */ + ostring GetExceptionQueue() const; + + /** + * @brief + * Set the name of the queue to which the message is moved to if it cannot be + * processed successfully + * + * @param value - Exception queue name + * + * @warning + * From Oracle Documentation : + * + * "Messages are moved into exception queues in two cases : + * - If the number of unsuccessful dequeue attempts has exceeded the attribute 'max_retries' of + * given queue + * - if the message has expired. + * + * All messages in the exception queue are in the EXPIRED state. + * + * The default is the exception queue associated with the queue table. + * + * If the exception queue specified does not exist at the time of the move the message will be + * moved to the default exception queue associated with the queue table and a warning will be + * logged in the alert file. + * + * This attribute must refer to a valid queue name." + * + */ + void SetExceptionQueue(const ostring& value); + + /** + * @brief + * Return the original sender of the message + * + * @return + * Valid agent object if set at enqueue time otherwise a null agent object + * + */ + Agent GetSender() const; + + /** + * @brief + * Set the original sender of the message + * + * @param agent - Message sender + * + */ + void SetSender(const Agent& agent); + + /** + * @brief + * Set the recipient list of a message to enqueue + * + * @param agents - Recipients list + * + * @warning + * This function should only be used for queues which allow multiple consumers. + * The default recipients are the queue subscribers. + * + */ + void SetConsumers(std::vector& agents); + + private: + + Message(OCI_Msg* pMessage, core::Handle* parent); + }; + + /** + * @brief + * Enqueue object for queuing messages into an Oracle Queue + * + * This class wraps the OCILIB object handle OCI_Enqueue and its related methods + * + */ + class Enqueue : public core::HandleHolder + { + public: + + /** + * @brief + * Message enqueuing mode enumerated values + * + */ + enum EnqueueModeValues + { + /** Enqueue message before another message */ + Before = OCI_ASD_BEFORE, + /** Enqueue message before all messages */ + OnTop = OCI_ASD_TOP + }; + + /** + * @brief + * Message enqueuing mode + * + * Possible values are Enqueue::EnqueueModeValues + * + */ + typedef core::Enum EnqueueMode; + + /** + * @brief + * Message visibility enumerated values + * + */ + enum EnqueueVisibilityValues + { + /** Enqueue is an independent transaction */ + Immediate = OCI_AMV_IMMEDIATE, + /** Enqueue is part of current transaction */ + OnCommit = OCI_AMV_ON_COMMIT + }; + + /** + * @brief + * Message visibility after begin queued + * + * Possible values are Enqueue::EnqueueVisibilityValues + * + */ + typedef core::Enum EnqueueVisibility; + + /** + * @brief + * Create a Enqueue object for the given queue + * + * @param typeInfo - Type info handle + * @param queueName - Queue name + * + * @note + * OCILIB supports 2 types of message payload : + * - Oracle types (UDT) + * - RAW data + * + * @note + * Oracle Type AnyData is not supported in the current version of OCILIB + * + * @note + * the parameter 'typeInfo' indicates the type of payload to enqueue to the given queue : + * - For object payload, retrieve the object type information object from the given type name + * - For RAW payload, you MUST pass the object type information object from the type name "SYS.RAW" as object type name + * + */ + Enqueue(const TypeInfo& typeInfo, const ostring& queueName); + + /** + * @brief + * Enqueue a message the on queue associated to the Enqueue object + * + * @param message - Message to enqueue + * + */ + void Put(const Message& message); + + /** + * @brief + * Get the enqueuing/locking behavior + * + * @note + * see SetVisibility() for more details + * + */ + EnqueueVisibility GetVisibility() const; + + /** + * @brief + * Set whether the new message is enqueued as part of the current transaction + * + * @param value - Enqueuing visibility + * + * @note + * Default value is Enqueue::OnCommit + * + */ + void SetVisibility(EnqueueVisibility value); + + /** + * @brief + * Return the enqueuing mode of messages to enqueue + * + * @note + * see SetMode() for more details + * + */ + EnqueueMode GetMode() const; + + /** + * @brief + * Set the enqueuing mode of messages to put in the queue + * + * @param value - enqueuing mode + * + * @note + * Default value is Enqueue::OnTop + * + * @note + * if the parameter 'value' is set to Enqueue::Before, the application must + * call SetRelativeMsgID() before enqueuing the next message in the queue. + * + * @note + * In order to stop enqueuing message using a sequence deviation, call + * SetMode() with the value Enqueue::OnTop + * + */ + void SetMode(EnqueueMode value); + + /** + * @brief + * Get the current associated message identifier used for enqueuing messages + * using a sequence deviation + * + * @note + * see SetRelativeMsgID() for more details + * + */ + + Raw GetRelativeMsgID() const; + + /** + * @brief + * Set a message identifier to use for enqueuing messages using a sequence deviation + * + * @param value - message identifier + * + * @note + * This call is only valid if SetMode() has been called with the value Enqueue::Before + * + * @note + * see SetMode() for more details + * + */ + void SetRelativeMsgID(const Raw& value); + }; + + /** + * @brief + * Dequeue object for dequeuing messages into an Oracle Queue + * + * This class wraps the OCILIB object handle OCI_Dequeue and its related methods + * + */ + class Dequeue : public core::HandleHolder + { + friend class Environment; + + public: + + /** + * @typedef NotifyAQHandlerProc + * + * @brief + * User callback for dequeue event notifications + * + */ + typedef void (*NotifyAQHandlerProc) (Dequeue& dequeue); + + /** + * @brief + * Dequeue mode enumerated values + * + */ + enum DequeueModeValues + { + /** Read message without acquiring a lock */ + Browse = OCI_ADM_BROWSE, + /** Read and obtain write lock on message */ + Locked = OCI_ADM_LOCKED, + /** Read the message and delete it */ + Remove = OCI_ADM_REMOVE, + /** Confirm receipt of the message, but do not deliver the actual message content */ + Confirm = OCI_ADM_REMOVE_NODATA + }; + + /** + * @brief + * Dequeue mode + * + * Possible values are Dequeue::DequeueModeValues + * + */ + typedef core::Enum DequeueMode; + + /** + * @brief + * Message visibility enumerated values + * + */ + enum DequeueVisibilityValues + { + /** Dequeue is an independent transaction */ + Immediate = OCI_AMV_IMMEDIATE, + /** Dequeue is part of current transaction */ + OnCommit = OCI_AMV_ON_COMMIT + }; + + /** + * @brief + * Message visibility after begin dequeued + * + * Possible values are Dequeue::DequeueVisibilityValues + * + */ + typedef core::Enum DequeueVisibility; + + /** + * @brief + * Navigation Mode enumerated values + * + */ + enum NavigationModeValues + { + /** Retrieves the first message which is available */ + FirstMessage = OCI_ADN_FIRST_MSG, + /** Retrieves the next message which is available */ + NextMessage = OCI_ADN_NEXT_MSG, + /** Skips the remainder of the current transaction group (if any) + and retrieves the first message of the next transaction group.*/ + NextTransaction = OCI_ADN_NEXT_TRANSACTION + }; + + /** + * @brief + * Navigation Mode + * + * Possible values are Dequeue::NavigationModeValues + * + */ + typedef core::Enum NavigationMode; + + /** + * @brief + * Parametrized constructor + * + * @param typeInfo - Payload type info + * @param queueName - Queue name + * + */ + Dequeue(const TypeInfo& typeInfo, const ostring& queueName); + + /** + * @brief + * Dequeue messages from the given queue + * + * @warning + * When dequeuing from a multiple consumer queue, you need + * to set the navigation mode to NavigationMode::FirstMessage using + * SetNavigation() + * + * @return + * A valid Message handle on success otherwise a null Message on timeout + * + */ + Message Get(); + + /** + * @brief + * Listen for messages that match any recipient of the associated Agent list + * + * @param timeout - Timeout in second + * + * @note + * If an Agent handle is returned, messages are available for this agent. + * In order to retrieve its messages : + * - call SetConsumer() with the name of agent using Agent::GetName() + * - call Get() to dequeue it's pending messages + * + * @return + * An Agent handle for who messages are available on success otherwise an null agent object + */ + Agent Listen(int timeout); + + /** + * @brief + * Get the current consumer name associated with the dequeuing process. + * + * @note + * see SetConsumer() for more details + * + */ + ostring GetConsumer() const; + + /** + * @brief + * Set the current consumer name to retrieve message for. + * + * @param value - consumer name + * + * @warning + * If a queue is not set up for multiple consumers, SetConsumer() + * should not be called or called with an empty value + * + */ + void SetConsumer(const ostring& value); + + /** + * @brief + * Get the correlation identifier of the message to be dequeued + * + * @note + * see SetCorrelation() for more details + * + */ + ostring GetCorrelation() const; + + /** + * @brief + * set the correlation identifier of the message to be dequeued + * + * @param value - correlation identifier + * + * @note + * Special pattern matching characters, such as "%" or "_" can be used. + * If more than one message satisfies the pattern, the order of dequeuing is undetermined. + * + */ + void SetCorrelation(const ostring& value); + + /** + * @brief + * Get the message identifier of the message to be dequeued + * + * @note + * see SetRelativeMsgID() for more details + * + */ + Raw GetRelativeMsgID() const; + + /** + * @brief + * Set the message identifier of the message to be dequeued + * + * @param value - message identifier + * + */ + void SetRelativeMsgID(const Raw& value); + + /** + * @brief + * Get the dequeuing/locking behavior + * + * @note + * see SetVisibility() for more details + * + */ + DequeueVisibility GetVisibility() const; + + /** + * @brief + * Set whether the new message is dequeued as part of the current transaction + * + * @param value - dequeuing mode + * + * @warning + * The visibility parameter is ignored when using the dequeuing + * mode is Dequeue::Browse + * + * @note + * Default value is Dequeue::OnCommit + * + */ + void SetVisibility(DequeueVisibility value); + + /** + * @brief + * Get the dequeuing/locking behavior + * + * @note + * see SetMode() for more details + * + */ + DequeueMode GetMode() const; + + /** + * @brief + * Set the dequeuing/locking behavior + * + * @param value - dequeuing mode + * + * @note + * Default value is Dequeue::Remove + * + */ + void SetMode(DequeueMode value); + + /** + * @brief + * Return the navigation position of messages to retrieve from the queue + * + * @note + * see SetNavigation() for more details + * + */ + NavigationMode GetNavigation() const; + + /** + * @brief + * Set the position of messages to be retrieved. + * + * @param value - navigation position + * + * @note + * The dequeuing uses the following sequence : + * - find messages using the navigation position + * - apply search criteria (message correlation) + * - get message + * + * @note + * Default value is Dequeue::NextMessage + * + * @warning + * Dequeue::NextTransaction can only be used if message grouping is enabled for the given queue. + * + */ + void SetNavigation(NavigationMode value); + + /** + * @brief + * Return the time that Get() waits for messages if no messages are currently available + * + * @note + * see SetWaitTime() for more details + * + */ + int GetWaitTime() const; + + /** + * @brief + * Set the time that Get() waits for messages if no messages are currently available + * + * @param value - timeout in seconds + * + *@note + * - Any positive values in seconds are valid. + * - The value 0 is accepted and means Get() does not wait for + * messages and returns immediately if no messages are available + * - The value -1 is accepted and means Get() waits for ever (until + * a message is available in the queue) + * + * @note + * Default value is -1 (wait for ever) + * + */ + void SetWaitTime(int value); + + /** + * @brief + * Set the Agent list to listen to message for + * + * @param agents - vector of agents + * + */ + void SetAgents(std::vector& agents); + + /** + * @brief + * Subscribe for asynchronous messages notifications + * + * @param port - Port to use for notifications + * @param timeout - notification timeout + * @param handler - User handler callback fired when messages are ready to be dequeued + * + * @note + * Environment::Events flag must be passed to Environment::Initialize() to be able to use + * asynchronous messages notifications + * + * @note + * Requires Oracle Client 10gR2 or above + * + */ + void Subscribe(unsigned int port, unsigned int timeout, NotifyAQHandlerProc handler); + + /** + * @brief + * Unsubscribe for asynchronous messages notifications + * + * @note + * Requires Oracle Client 10gR2 or above + * + */ + void Unsubscribe(); + + private: + + Dequeue(OCI_Dequeue* pDequeue); + }; + + /** + * @brief + * Class allowing the administration of Oracle Queues + * + */ + class Queue + { + public: + + /** + * @brief + * Queue Type enumerated values + * + */ + enum QueueTypeValues + { + /** Normal queue */ + NormalQueue = OCI_AQT_NORMAL, + /** Exception queue */ + ExceptionQueue = OCI_AQT_EXCEPTION, + /** Non persistent queue */ + NonPersistentQueue = OCI_AQT_NON_PERSISTENT + }; + + /** + * @brief + * Queue Type + * + * Possible values are Queue::QueueTypeValues + * + */ + typedef core::Enum QueueType; + + /** + * @brief + * Create a queue + * + * @param connection - Database connection + * @param queue - Queue name + * @param table - Queue table name + * @param type - Queue type + * @param maxRetries - Maximum number of attempts to dequeue a message + * @param retryDelay - Number of seconds between attempts to dequeue a message + * @param retentionTime - number of seconds a message is retained in the queue table after + * being dequeued from the queue + * @param dependencyTracking - Parameter reserved for future use by Oracle (MUST be set to FALSE) + * @param comment - Description of the queue + * + * @note + * Parameter 'queue' can specify the schema where to create to queue ([schema.]queue_name) + * Queue names cannot be longer than 24 characters (Oracle limit for user queues) + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Create(const Connection& connection, const ostring& queue, const ostring& table, QueueType type = NormalQueue, + unsigned int maxRetries = 0, unsigned int retryDelay = 0, unsigned int retentionTime = 0, + bool dependencyTracking = false, const ostring& comment = OTEXT("")); + + /** + * @brief + * Alter the given queue + * + * @param connection - Database connection + * @param queue - Queue name + * @param maxRetries - Maximum number of attempts to dequeue a message + * @param retryDelay - Number of seconds between attempts to dequeue a message + * @param retentionTime - number of seconds a message is retained in the queue table after + * being dequeued from the queue + * @param comment - Description of the queue + * + * @note + * See Create() for more details + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Alter(const Connection& connection, const ostring& queue, + unsigned int maxRetries = 0, unsigned int retryDelay = 0, + unsigned int retentionTime = 0, const ostring& comment = OTEXT("")); + + /** + * @brief + * Drop the given queue + * + * @param connection - Database connection + * @param queue - Queue name + * + * @warning + * A queue can be dropped only if it has been stopped before. + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Drop(const Connection& connection, const ostring& queue); + + /** + * @brief + * Start the given queue + * + * @param connection - Database connection + * @param queue - Queue name + * @param enableEnqueue - Enable enqueue + * @param enableDequeue - Enable dequeue + * + * @warning + * For exception queues, only enqueuing is allowed + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.START_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Start(const Connection& connection, const ostring& queue, bool enableEnqueue = true, bool enableDequeue = true); + + /** + * @brief + * Stop enqueuing or dequeuing or both on the given queue + * + * @param connection - Database connection + * @param queue - Queue name + * @param stopEnqueue - Disable enqueue + * @param stopDequeue - Disable dequeue + * @param wait - Wait for current pending enqueues/dequeues + * + * @warning + * A queue cannot be stopped if there are pending transactions against the queue. + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.STOP_QUEUE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Stop(const Connection& connection, const ostring& queue, bool stopEnqueue = true, bool stopDequeue = true, bool wait = true); + }; + + /** + * @brief + * Class allowing the administration of Oracle Queue tables + * + */ + class QueueTable + { + public: + + /** + * + * @brief + * Grouping mode enumerated values + * + */ + enum GroupingModeValues + { + /** Each message is treated individually */ + None = OCI_AGM_NONE, + /** All messages enqueued in one transaction are considered part of + the same group and can be dequeued as a group of related messages */ + Transactionnal = OCI_AGM_TRANSACTIONNAL + }; + + /** + * @brief + * Grouping Mode + * + * Possible values are QueueTable::GroupingModeValues + * + */ + typedef core::Enum GroupingMode; + + /** + * + * @brief + * Purge mode enumerated values + * + */ + enum PurgeModeValues + { + /** Purge only buffered messages */ + Buffered = OCI_APM_BUFFERED, + /** Purge only persistent messages */ + Persistent = OCI_APM_PERSISTENT, + /** Purge all messages */ + All = OCI_APM_ALL + }; + + /** + * @brief + * Purge mode + * + * Possible values are QueueTable::PurgeModeValues + * + */ + typedef core::Enum PurgeMode; + + /** + * @brief + * Create a queue table for messages of the given type + * + * @param connection - Database connection + * @param table - Queue table name + * @param payloadType - Message type name + * @param multipleConsumers - Enable multiple consumers for each messages + * @param storageClause - Optional Additional clauses for the table storage + * @param sortList - Optional Additional columns name to use for sorting + * @param groupingMode - Optional Specifies if messages are grouped within a transaction + * @param comment - Optional Description of the queue table + * @param primaryInstance - Optional primary owner (instance) of the queue table + * @param secondaryInstance - Optional Owner of the queue table if the primary instance is not available + * @param compatible - Optional lowest database version with which the queue table is compatible + * + * @note + * Parameter 'table' can specify the schema where to create to queue table ([schema.]queue_table) + * Queue table names cannot be longer than 24 characters (Oracle limit for user queue tables) + * + * @note + * Possible values for parameter 'payloadType' : + * - For Oracle types (UDT) : use the type name ([schema.]type_name) + * - For RAW data : use "SYS.RAW" or "RAW" + * + * @note + * Possible values for parameter 'compatible' : + * - "8.0", "8.1", "10.0" + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.CREATE_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Create(const Connection& connection, const ostring& table, const ostring& payloadType, bool multipleConsumers, + const ostring& storageClause = OTEXT(""), const ostring& sortList = OTEXT(""), + GroupingMode groupingMode = None, const ostring& comment = OTEXT(""), + unsigned int primaryInstance = 0, unsigned int secondaryInstance = 0, + const ostring& compatible = OTEXT("")); + + /** + * @brief + * Alter the given queue table + * + * @param connection - Database connection + * @param table - Queue table name + * @param comment - Optional Description of the queue table + * @param primaryInstance - Optional primary owner (instance) of the queue table + * @param secondaryInstance - Optional Owner of the queue table if the primary instance is not available + * + * @note + * See Create() from more details + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.ALTER_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Alter(const Connection& connection, const ostring& table, const ostring& comment, unsigned int primaryInstance = 0, unsigned int secondaryInstance = 0); + + /** + * @brief + * Drop the given queue table + * + * @param connection - Database connection + * @param table - Queue table name + * @param force - Force the deletion of objects related to the queue table + * + * @note + * Possible values for 'force' : + * - true : all queues using the queue table and their associated propagation schedules are + * dropped automatically + * - false : All the queues using the given queue table must be stopped and dropped before the + * queue table can be dropped. + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.DROP_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Drop(const Connection& connection, const ostring& table, bool force = true); + + /** + * @brief + * Purge messages from the given queue table + * + * @param connection - Database connection + * @param table - Queue table name + * @param mode - Type of message to purge + * @param block - Lock all queues using the queue table while doing the purge + * @param condition - Optional SQL based conditions (see notes) + * + * @note + * For more information about the SQL purge conditions, refer to + * Oracle Streams - Advanced Queuing User's Guide for more details + * + * @warning + * This feature is only available from Oracle 10gR2. + * This function does nothing and returns TRUE is the server version is < Oracle 10gR2 + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.PURGE_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Purge(const Connection& connection, const ostring& table, PurgeMode mode, const ostring& condition = OTEXT(""), bool block = true); + + /** + * @brief + * Migrate a queue table from one version to another + * + * @param connection - Database connection + * @param table - Queue table name + * @param compatible - Optional database version with witch the queue table has to migrate + * + * @note + * Possible values for parameter 'compatible' : + * - "8.0", "8.1", "10.0" + * + * @note + * this call wraps the PL/SQL procedure DBMS_AQADM.MIGRATE_QUEUE_TABLE(). + * Refer to Oracle Streams - Advanced Queuing User's Guide for more details + * + */ + static void Migrate(const Connection& connection, const ostring& table, const ostring& compatible = OTEXT("")); + }; + + /** + * @brief + * Oracle Direct path loading encapsulation + * + * This class wraps the OCILIB object handle OCI_DirPath and its related methods + * + */ + class DirectPath : public core::HandleHolder + { + public: + + /** + * @brief + * Conversion mode enumerated values + * + */ + enum ConversionModeValues + { + /** Conversion fails on error */ + Default = OCI_DCM_DEFAULT, + /** Conversion does not fail on error */ + Force = OCI_DCM_FORCE + }; + + /** + * @brief + * Conversion Mode + * + * Possible values are DirectPath::ConversionModeValues + * + */ + typedef core::Enum ConversionMode; + + /** + * @brief + * Direct Operation Result enumerated values + * + */ + enum ResultValues + { + /** Conversion/load has been successful */ + ResultComplete = OCI_DPR_COMPLETE, + /** An error happened while converting/loading data */ + ResultError = OCI_DPR_ERROR, + /** The internal stream is full*/ + ResultFull = OCI_DPR_FULL, + /** A column has not been fully filled yet */ + ResultPartial = OCI_DPR_PARTIAL, + /** No data was found to convert/load */ + ResultEmpty = OCI_DPR_EMPTY + }; + + /** + * @brief + * Direct Operation Result + * + * Possible values are DirectPath::ResultValues + * + */ + typedef core::Enum Result; + + /** + * @brief + * Constructor + * + * @param typeInfo - Table type info object + * @param nbCols - Number of columns to load + * @param nbRows - Maximum of rows to handle per load operation + * @param partition - Partition name + * + * @note + * The partition name is not mandatory + * + * @note + * Parameter 'nbRows' is ignored for Oracle 8i. Prior to Oracle 9i, it's the + * OCI client that decides of the number of rows to process per convert/load calls. + * From Oracle 9i, OCI allows application to specify this value. Note that, the + * OCI client might not accept the input value. After Prepare() has + * been successfully called, GetMaxRows() returns the final number + * of rows used for the given direct path operation. + * + */ + DirectPath(const TypeInfo& typeInfo, unsigned int nbCols, unsigned int nbRows, const ostring& partition = OTEXT("")); + + /** + * @brief + * Describe a column to load into the given table + * + * @param colIndex - Column index + * @param name - Column name + * @param maxSize - Maximum input value size for a column entry + * @param format - Date or numeric format to use + * + * @note + * An error is thrown if : + * - If the column specified by the 'name' parameter is not found in the table + * referenced by the type info handle passed to the constructor + * - the index is out of bounds (= 0 or >= number of columns) + * + */ + void SetColumn(unsigned int colIndex, const ostring& name, unsigned int maxSize, const ostring& format = OTEXT("")); + + /** + * @brief + * Set the value of the given row/column array entry from the given string + * + * @tparam T - type of data to set (only supported types are ostring and Raw) + * + * @param rowIndex - Row index + * @param colIndex - Column index + * @param value - Value to set + * @param complete - Is the entry content fully provided ? + * + * @note + * Rows and columns indexes start at 1. + * + * @note + * Direct path support piece loading for LONGs and LOBs columns. When filling + * these columns, it's possible to provide input buffer piece by piece. In order + * to do so : + * - set the 'complete' parameter to false + * - Repeat calls to SetEntry() until the data is totally provided + * - The last call that set the last piece or an entry must specify the value + * true for the 'complete' parameter + * + * @warning + * Current Direct Path OCILIB implementation DOES NOT support setting entry + * content piece by piece as mentioned above. It was planned in the original design + * but not supported yet. So, always set the complete parameter to true. + * Setting entries content piece by piece may be supported in future releases + * + */ + template + void SetEntry(unsigned int rowIndex, unsigned int colIndex, const T& value, bool complete = true); + + /** + * @brief + * Reset internal arrays and streams to prepare another load + * + * @note + * Once some data have been converted or loaded, Reset() resets + * internal OCI structures in order to prepare another load operation + * (set entries, convert and load) + * + */ + void Reset(); + + /** + * @brief + * Prepares the OCI direct path load interface before any rows can be converted or loaded + * + */ + void Prepare(); + + /** + * @brief + * Convert provided user data to the direct path stream format + * + * @par Behavior + * - When using conversion mode DirectPath::Default, Convert() stops when + * any error is encountered and returns ResultError + * - When using conversion mode DirectPath::Force, Convert() does not stop + * on errors. Instead it discards any erred rows and returns ResultComplete once + * all rows are processed. + * + * @note + * List of faulted rows and columns can be retrieved using GetErrorRow() and GetErrorColumn() + * + * @note + * GetAffectedRows() returns the number of rows converted in the last call. + * + */ + DirectPath::Result Convert(); + + /** + * @brief + * Loads the data converted to direct path stream format + * + * @note + * List of faulted rows can be retrieved using GetErrorRow() + * + * @note + * GetAffectedRows() returns the number of rows successfully loaded in the last call. + * + */ + DirectPath::Result Load(); + + /** + * @brief + * Terminate a direct path operation and commit changes into the database + * + * @warning + * The direct path object cannot be used anymore after this call for any more loading operations + * + */ + void Finish(); + + /** + * @brief + * Terminate a direct path operation without committing changes + * + * @note + * Any pending loaded data are canceled. + * Any load completion operations, such as index maintenance operations, are not performed. + * + * @warning + * The direct path object cannot be used anymore after this call for any more loading operations + * + */ + void Abort(); + + /** + * @brief + * Execute a data save-point (server side) + * + * @note + * Executing a data save-point is not allowed for LOBs + * + */ + void Save(); + + /** + * @brief + * Flushes a partially loaded row from server + * + */ + void FlushRow(); + + /** + * @brief + * Set the current number of rows to convert and load + * + * @param value - Number of row to process + * + * @warning + * An OCILIB error will be thrown if the value exceeds the maximum number of + * rows in the internals arrays + * + */ + void SetCurrentRows(unsigned int value); + + /** + * @brief + * Return the current number of rows used in the OCILIB internal arrays of rows + * + * @return + * Internal current array size on SUCCESS otherwise 0 + * + */ + unsigned int GetCurrentRows() const; + + /** + * @brief + * Return the maximum number of rows allocated in the OCI and OCILIB internal arrays of rows + * + * @return + * Internal maximum array size on SUCCESS otherwise 0 + * + */ + unsigned int GetMaxRows() const; + + /** + * @brief + * Return the number of rows successfully loaded into the database so far + * + * @note + * Insertions are committed with Finish() + * + */ + unsigned int GetRowCount() const; + + /** + * @brief + * return the number of rows successfully processed during in the last + * conversion or loading call + * + * @note + * This function called after : + * + * - Convert(), returns the number of converted rows + * - Load(), returns the number of loaded rows + * + */ + unsigned int GetAffectedRows() const; + + /** + * @brief + * Set the default date format string for input conversion + * + * @param format - date format + * + * @note + * For string to date conversion, Oracle uses : + * - Column date format + * - Default date format (modified by this call) + * - Default global support environment setting + * + */ + void SetDateFormat(const ostring& format); + + /** + * @brief + * Set the parallel loading mode + * + * @param value - enable/disable parallel mode + * + * @note + * Default value is false. + * + * @note + * Setting the value to TRUE allows multiple load sessions to load the same + * segment concurrently + * + * @par Parallel loading mode (From Oracle documentation) + * + * A direct load operation requires that the object being loaded is locked to + * prevent DML on the object. + * Note that queries are lock-free and are allowed while the object is being loaded. + * - For a table load, if the option is set to: + * - false, then the table DML X-Lock is acquired. + * - true, then the table DML S-Lock is acquired. + * - For a partition load, if the option is set to: + * - false, then the table DML SX-Lock and partition DML X-Lock is acquired. + * - true, then the table DML SS-Lock and partition DML S-Lock is acquired. + * + */ + void SetParallel(bool value); + + /** + * @brief + * Set the logging mode for the loading operation + * + * @param value - enable/disable logging + * + * @par Logging mode (from Oracle Documentation) + * + * The NOLOG attribute of each segment determines whether image redo or + * invalidation redo is generated: + * - false : Use the attribute of the segment being loaded. + * - true : No logging. Overrides DDL statement, if necessary. + * + */ + void SetNoLog(bool value); + + /** + * @brief + * Set number of elements in the date cache + * + * @param value - Buffer size + * + * @note + * Default value is 0. + * + * @note + * Setting the value to 0 disables the cache + * + */ + void SetCacheSize(unsigned int value); + + /** + * @brief + * Set the size of the internal stream transfer buffer + * + * @param value - Buffer size + * + * @note + * Default value is 64KB. + * + */ + void SetBufferSize(unsigned int value); + + /** + * @brief + * Set the direct path conversion mode + * + * @param value - Conversion mode + * + * @note + * See Convert() for conversion mode details + * + * @note + * Default value is ConversionMode::Default + * + */ + void SetConversionMode(ConversionMode value); + + /** + * @brief + * Return the index of a column which caused an error during data conversion + * + * @warning + * Direct path column indexes start at 1. + * + * @note + * Errors may happen while data is converted to direct path stream format + * using Convert(). + * + * @par Usage after a Convert() call + * - When using conversion mode DirectPath::Default, Convert() returns + * DirectPath::ResultError on error and GetErrorColumn() returns the column index that + * caused the error. + * - When using conversion mode DirectPath::Force, Convert() returns + * DirectPath::ResultComplete even on errors. In order to retrieve the list of all column + * indexes that have erred, the application can call GetErrorColumn() + * repeatedly until it returns 0. + * + * @note + * The internal value is reset to 0 when calling Convert() + * + * @return + * 0 is no error occurs otherwise the index of the given column which caused an + * error + * + */ + unsigned int GetErrorColumn(); + + /** + * @brief + * Return the index of a row which caused an error during data conversion + * + * @warning + * Direct path row indexes start at 1. + * + * @note + * Errors may happen : + * - while data is converted to direct path stream format using Convert() + * - while data is loaded to database using Load() + * + * @par Usage after a Convert() call + * - When using conversion mode DirectPath::Default, Convert() returns + * DirectPath::ResultError on error and GetErrorRow() returns the row index that + * caused the error. + * - When using conversion mode DirectPath::Force, Convert() returns + * DirectPath::ResultComplete even on errors. In order to retrieve the list of all row + * indexes that have erred, the application can call GetErrorRow() repeatedly until it returns 0. + * + * @par Usage after a Load() call + * After a call to Load(), in order to retrieve the list of all faulted rows + * indexes, the application can call GetErrorRow() repeatedly until it returns 0. + * + * @note + * The internal value is reset to 0 when calling Convert(),Reset() or Load() + * + * @return + * 0 is no error occurs otherwise the index of the given row which caused an + * error + * + */ + + unsigned int GetErrorRow(); + }; + + +#define OCILIB_DEFINE_FLAG_OPERATORS(T) \ + inline core::Flags operator | (T a, T b) { return core::Flags(a) | core::Flags(b); } \ + + OCILIB_DEFINE_FLAG_OPERATORS(Environment::EnvironmentFlagsValues) + OCILIB_DEFINE_FLAG_OPERATORS(Environment::SessionFlagsValues) + OCILIB_DEFINE_FLAG_OPERATORS(Environment::StartFlagsValues) + OCILIB_DEFINE_FLAG_OPERATORS(Environment::StartModeValues) + OCILIB_DEFINE_FLAG_OPERATORS(Environment::ShutdownModeValues) + OCILIB_DEFINE_FLAG_OPERATORS(Environment::ShutdownFlagsValues) + OCILIB_DEFINE_FLAG_OPERATORS(Environment::AllocatedBytesValues) + OCILIB_DEFINE_FLAG_OPERATORS(Transaction::TransactionFlagsValues) + OCILIB_DEFINE_FLAG_OPERATORS(Column::PropertyFlagsValues) + OCILIB_DEFINE_FLAG_OPERATORS(Subscription::ChangeTypesValues) +} From b666eece0b2bd4a87447d2acd3ce3875098116b4 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 16:54:26 +0200 Subject: [PATCH 18/62] cleanup useless files updated makefile --- Makefile.in | 908 -------------------------------- demo/Makefile.in | 702 ------------------------ demo/Makefile_demo.in | 27 - doc/html/Makefile.in | 518 ------------------ src/Makefile.am | 17 +- src/Makefile.in | 1171 ----------------------------------------- 6 files changed, 8 insertions(+), 3335 deletions(-) delete mode 100644 Makefile.in delete mode 100644 demo/Makefile.in delete mode 100644 demo/Makefile_demo.in delete mode 100644 doc/html/Makefile.in delete mode 100644 src/Makefile.in diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index c80edf0b..00000000 --- a/Makefile.in +++ /dev/null @@ -1,908 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# Copyright (c) 2007-2020 Vincent ROGIER -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = . -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ - $(am__configure_deps) $(am__DIST_COMMON) -am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ - configure.lineno config.status.lineno -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = config.h -CONFIG_CLEAN_FILES = README ocilib.pc -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(pkgconfigdir)" -DATA = $(pkgconfig_DATA) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - cscope distdir dist dist-all distcheck -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ - $(LISP)config.h.in -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -CSCOPE = cscope -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/README.in \ - $(srcdir)/config.h.in $(srcdir)/ocilib.pc.in \ - $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ - $(top_srcdir)/config/config.sub \ - $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ - $(top_srcdir)/config/missing AUTHORS ChangeLog INSTALL \ - README THANKS LICENSE config/compile config/config.guess \ - config/config.sub config/install-sh config/ltmain.sh \ - config/missing -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ - || { sleep 5 && rm -rf "$(distdir)"; }; \ - else :; fi -am__post_remove_distdir = $(am__remove_distdir) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -DIST_TARGETS = dist-gzip -distuninstallcheck_listfiles = find . -type f -print -am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ - | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_RELEASE = @LT_RELEASE@ -LT_REVISION = @LT_REVISION@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OCILIB_CHARSET = @OCILIB_CHARSET@ -OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ -OCILIB_DOCS = @OCILIB_DOCS@ -OCILIB_IMPORT = @OCILIB_IMPORT@ -OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ -OCILIB_PREFIX = @OCILIB_PREFIX@ -ORACLE_HOME = @ORACLE_HOME@ -ORACLE_INCLUDES = @ORACLE_INCLUDES@ -ORACLE_LIBADD = @ORACLE_LIBADD@ -ORACLE_LIBNAME = @ORACLE_LIBNAME@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = doc/html reconf configure VERSION acocilib.m4 -SUBDIRS = doc/html src demo -DISTCLEANFILES = *~ \#*\# -MAINTAINERCLEANFILES = \ -Makefile Makefile.in config.cache config.log config.h.in \ -libtool acinclude.m4 aclocal.m4 acocilib.m4 configure stamp-h.in - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = ocilib.pc -all: config.h - $(MAKE) $(AM_MAKEFLAGS) all-recursive - -.SUFFIXES: -am--refresh: Makefile - @: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ - $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - echo ' $(SHELL) ./config.status'; \ - $(SHELL) ./config.status;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - $(SHELL) ./config.status --recheck - -$(top_srcdir)/configure: $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): - -config.h: stamp-h1 - @test -f $@ || rm -f stamp-h1 - @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 - -stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status config.h -$(srcdir)/config.h.in: $(am__configure_deps) - ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 - touch $@ - -distclean-hdr: - -rm -f config.h stamp-h1 -README: $(top_builddir)/config.status $(srcdir)/README.in - cd $(top_builddir) && $(SHELL) ./config.status $@ -ocilib.pc: $(top_builddir)/config.status $(srcdir)/ocilib.pc.in - cd $(top_builddir) && $(SHELL) ./config.status $@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool config.lt -install-pkgconfigDATA: $(pkgconfig_DATA) - @$(NORMAL_INSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ - done - -uninstall-pkgconfigDATA: - @$(NORMAL_UNINSTALL) - @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscope: cscope.files - test ! -s cscope.files \ - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) -clean-cscope: - -rm -f cscope.files -cscope.files: clean-cscope cscopelist -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files - -distdir: $(DISTFILES) - $(am__remove_distdir) - test -d "$(distdir)" || mkdir "$(distdir)" - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done - -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -755 \ - -exec chmod u+rwx,go+rx {} \; -o \ - ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ - ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ - || chmod -R a+r "$(distdir)" -dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__post_remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 - $(am__post_remove_distdir) - -dist-lzip: distdir - tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz - $(am__post_remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz - $(am__post_remove_distdir) - -dist-tarZ: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__post_remove_distdir) - -dist-shar: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__post_remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__post_remove_distdir) - -dist dist-all: - $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' - $(am__post_remove_distdir) - -# This target untars the dist file and tries a VPATH configuration. Then -# it guarantees that the distribution is self-contained by making another -# tarfile. -distcheck: dist - case '$(DIST_ARCHIVES)' in \ - *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ - *.tar.bz2*) \ - bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lz*) \ - lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ - *.tar.xz*) \ - xz -dc $(distdir).tar.xz | $(am__untar) ;;\ - *.tar.Z*) \ - uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ - *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ - *.zip*) \ - unzip $(distdir).zip ;;\ - esac - chmod -R a-w $(distdir) - chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst - chmod a-w $(distdir) - test -d $(distdir)/_build || exit 0; \ - dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ - && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ - && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build/sub \ - && ../../configure \ - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=../.. --prefix="$$dc_install_base" \ - && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ - && $(MAKE) $(AM_MAKEFLAGS) check \ - && $(MAKE) $(AM_MAKEFLAGS) install \ - && $(MAKE) $(AM_MAKEFLAGS) installcheck \ - && $(MAKE) $(AM_MAKEFLAGS) uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ - distuninstallcheck \ - && chmod -R a-w "$$dc_install_base" \ - && ({ \ - (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ - && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ - distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ - } || { rm -rf "$$dc_destdir"; exit 1; }) \ - && rm -rf "$$dc_destdir" \ - && $(MAKE) $(AM_MAKEFLAGS) dist \ - && rm -rf $(DIST_ARCHIVES) \ - && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ - && cd "$$am__cwd" \ - || exit 1 - $(am__post_remove_distdir) - @(echo "$(distdir) archives ready for distribution: "; \ - list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ - sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' -distuninstallcheck: - @test -n '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: trying to run $@ with an empty' \ - '$$(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - $(am__cd) '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left after uninstall:" ; \ - if test -n "$(DESTDIR)"; then \ - echo " (check DESTDIR support)"; \ - fi ; \ - $(distuninstallcheck_listfiles) ; \ - exit 1; } >&2 -distcleancheck: distclean - @if test '$(srcdir)' = . ; then \ - echo "ERROR: distcleancheck can only run from a VPATH build" ; \ - exit 1 ; \ - fi - @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ - || { echo "ERROR: files left in build directory after distclean:" ; \ - $(distcleancheck_listfiles) ; \ - exit 1; } >&2 -check-am: all-am -check: check-recursive -all-am: Makefile $(DATA) config.h -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(pkgconfigdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-hdr \ - distclean-libtool distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-pkgconfigDATA - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-pkgconfigDATA - -.MAKE: $(am__recursive_targets) all install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ - am--refresh check check-am clean clean-cscope clean-generic \ - clean-libtool cscope cscopelist-am ctags ctags-am dist \ - dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-generic \ - distclean-hdr distclean-libtool distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-pkgconfigDATA \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkgconfigDATA - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/demo/Makefile.in b/demo/Makefile.in deleted file mode 100644 index faf3c635..00000000 --- a/demo/Makefile.in +++ /dev/null @@ -1,702 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# Copyright (c) 2007-2020 Vincent ROGIER -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = demo -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = Makefile_demo -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(demodir)" -DATA = $(demo_DATA) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile_demo.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_RELEASE = @LT_RELEASE@ -LT_REVISION = @LT_REVISION@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OCILIB_CHARSET = @OCILIB_CHARSET@ -OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ -OCILIB_DOCS = @OCILIB_DOCS@ -OCILIB_IMPORT = @OCILIB_IMPORT@ -OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ -OCILIB_PREFIX = @OCILIB_PREFIX@ -ORACLE_HOME = @ORACLE_HOME@ -ORACLE_INCLUDES = @ORACLE_INCLUDES@ -ORACLE_LIBADD = @ORACLE_LIBADD@ -ORACLE_LIBNAME = @ORACLE_LIBNAME@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = foreign -SUBDIRS = . -CLEANFILES = *~ -demo_DATA = @OCILIB_DEMO_SOURCES@ Makefile_demo -demodir = $(prefix)/share/doc/$(PACKAGE)/demo -EXTRA_DIST = $(demo_DATA) -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign demo/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign demo/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): -Makefile_demo: $(top_builddir)/config.status $(srcdir)/Makefile_demo.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-demoDATA: $(demo_DATA) - @$(NORMAL_INSTALL) - @list='$(demo_DATA)'; test -n "$(demodir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(demodir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(demodir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(demodir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(demodir)" || exit $$?; \ - done - -uninstall-demoDATA: - @$(NORMAL_UNINSTALL) - @list='$(demo_DATA)'; test -n "$(demodir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(demodir)'; $(am__uninstall_files_from_dir) - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(DATA) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(demodir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-demoDATA - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-demoDATA - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am \ - install-demoDATA install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-demoDATA - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/demo/Makefile_demo.in b/demo/Makefile_demo.in deleted file mode 100644 index d87a9fcc..00000000 --- a/demo/Makefile_demo.in +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2007-2020 Vincent ROGIER -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -INCS = -I@OCILIB_PREFIX@/include -CFLAGS = -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ -LDFLAGS= @ORACLE_LIBADD@ -L@OCILIB_PREFIX@/lib -locilib -CC = @CC@ -SRCS = ocilib_demo.c -OBJS = $(SRCS:.c=.o) - -all: ocilib_demo - -demo: $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) - -.c.o: - $(CC) $(INCS) $(CFLAGS) -c -o $@ $< - -clean: - rm -f *~ $(OBJS) diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in deleted file mode 100644 index d7797fff..00000000 --- a/doc/html/Makefile.in +++ /dev/null @@ -1,518 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# Copyright (c) 2007-2020 Vincent ROGIER -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = doc/html -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(docdir)" -DATA = $(doc_DATA) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_RELEASE = @LT_RELEASE@ -LT_REVISION = @LT_REVISION@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OCILIB_CHARSET = @OCILIB_CHARSET@ -OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ -OCILIB_DOCS = @OCILIB_DOCS@ -OCILIB_IMPORT = @OCILIB_IMPORT@ -OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ -OCILIB_PREFIX = @OCILIB_PREFIX@ -ORACLE_HOME = @ORACLE_HOME@ -ORACLE_INCLUDES = @ORACLE_INCLUDES@ -ORACLE_LIBADD = @ORACLE_LIBADD@ -ORACLE_LIBNAME = @ORACLE_LIBNAME@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = $(prefix)/share/doc/$(PACKAGE)/html -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = foreign -CLEANFILES = *~ -doc_DATA = @OCILIB_DOCS@ -EXTRA_DIST = $(doc_DATA) -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/html/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign doc/html/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-docDATA: $(doc_DATA) - @$(NORMAL_INSTALL) - @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ - done - -uninstall-docDATA: - @$(NORMAL_UNINSTALL) - @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(DATA) -installdirs: - for dir in "$(DESTDIR)$(docdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-docDATA - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-docDATA - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am \ - install-docDATA install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ - uninstall-am uninstall-docDATA - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/Makefile.am b/src/Makefile.am index da66c97b..7dac01fc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,15 +64,14 @@ libocilib_la_SOURCES= \ libocilib_la_CFLAGS= -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS= @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -include_HEADERS= \ - $(top_srcdir)/include/ocilib.h \ - $(top_srcdir)/include/ocilibc/api.h \ - $(top_srcdir)/include/ocilibc/compat.h \ - $(top_srcdir)/include/ocilibc/config.h \ - $(top_srcdir)/include/ocilibc/types.h \ - $(top_srcdir)/include/ocilib.hpp \ - $(top_srcdir)/include/ocilibcpp/core.hpp \ - $(top_srcdir)/include/ocilibcpp/impl.hpp +nobase_include_HEADERS= \ + $(top_srcdir)/include/*.h \ + $(top_srcdir)/include/*.hpp \ + $(top_srcdir)/include/ocilibc/*.h \ + $(top_srcdir)/include/ocilibcpp/*.hpp \ + $(top_srcdir)/include/ocilibcpp/detail/*.hpp \ + $(top_srcdir)/include/ocilibcpp/detail/core/*.hpp \ + $(top_srcdir)/include/ocilibcpp/detail/support/*.hpp noinst_HEADERS= \ agent.h \ diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index f6c8453f..00000000 --- a/src/Makefile.in +++ /dev/null @@ -1,1171 +0,0 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2014 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# Copyright (c) 2007-2020 Vincent ROGIER -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ - $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ - $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ - $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \ - $(noinst_HEADERS) $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" -LTLIBRARIES = $(lib_LTLIBRARIES) -libocilib_la_DEPENDENCIES = -am_libocilib_la_OBJECTS = libocilib_la-array.lo libocilib_la-bind.lo \ - libocilib_la-callback.lo libocilib_la-connection.lo \ - libocilib_la-define.lo libocilib_la-exception.lo \ - libocilib_la-handle.lo libocilib_la-iterator.lo \ - libocilib_la-lob.lo libocilib_la-mutex.lo \ - libocilib_la-resultset.lo libocilib_la-string.lo \ - libocilib_la-timestamp.lo libocilib_la-collection.lo \ - libocilib_la-pool.lo libocilib_la-element.lo \ - libocilib_la-file.lo libocilib_la-hash.lo \ - libocilib_la-library.lo libocilib_la-long.lo \ - libocilib_la-number.lo libocilib_la-typeinfo.lo \ - libocilib_la-thread.lo libocilib_la-transaction.lo \ - libocilib_la-column.lo libocilib_la-date.lo \ - libocilib_la-error.lo libocilib_la-format.lo \ - libocilib_la-interval.lo libocilib_la-list.lo \ - libocilib_la-memory.lo libocilib_la-object.lo \ - libocilib_la-statement.lo libocilib_la-ref.lo \ - libocilib_la-threadkey.lo libocilib_la-dirpath.lo \ - libocilib_la-event.lo libocilib_la-subscription.lo \ - libocilib_la-agent.lo libocilib_la-dequeue.lo \ - libocilib_la-enqueue.lo libocilib_la-msg.lo \ - libocilib_la-queue.lo -libocilib_la_OBJECTS = $(am_libocilib_la_OBJECTS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -libocilib_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libocilib_la_CFLAGS) \ - $(CFLAGS) $(libocilib_la_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/config/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(libocilib_la_SOURCES) -DIST_SOURCES = $(libocilib_la_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -HEADERS = $(include_HEADERS) $(noinst_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_RELEASE = @LT_RELEASE@ -LT_REVISION = @LT_REVISION@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OCILIB_CHARSET = @OCILIB_CHARSET@ -OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ -OCILIB_DOCS = @OCILIB_DOCS@ -OCILIB_IMPORT = @OCILIB_IMPORT@ -OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ -OCILIB_PREFIX = @OCILIB_PREFIX@ -ORACLE_HOME = @ORACLE_HOME@ -ORACLE_INCLUDES = @ORACLE_INCLUDES@ -ORACLE_LIBADD = @ORACLE_LIBADD@ -ORACLE_LIBNAME = @ORACLE_LIBNAME@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CPPFLAGS = @ORACLE_INCLUDES@ -I$(top_srcdir)/include -lib_LTLIBRARIES = libocilib.la -libocilib_la_LIBADD = @ORACLE_LIBADD@ -libocilib_la_SOURCES= \ - agent.c \ - array.c \ - bind.c \ - callback.c \ - collection.c \ - column.c \ - connection.c \ - date.c \ - database.c \ - define.c \ - dequeue.c \ - dirpath.c \ - element.c \ - enqueue.c \ - environment.c \ - error.c \ - event.c \ - exception.c \ - file.c \ - format.c \ - handle.c \ - hash.c \ - helpers.c \ - interval.c \ - iterator.c \ - list.c \ - lob.c \ - long.c \ - memory.c \ - message.c \ - mutex.c \ - number.c \ - object.c \ - ocilib.c \ - pool.c \ - queue.c \ - reference.c \ - resultset.c \ - statement.c \ - strings.c \ - subscription.c \ - thread.c \ - threadkey.c \ - timestamp.c \ - transaction.c \ - typeinfo.c - -libocilib_la_CFLAGS = -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ -libocilib_la_LDFLAGS = @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -include_HEADERS= \ - $(top_srcdir)/include/ocilib.h \ - $(top_srcdir)/include/ocilibc/api.h \ - $(top_srcdir)/include/ocilibc/compat.h \ - $(top_srcdir)/include/ocilibc/config.h \ - $(top_srcdir)/include/ocilibc/types.h \ - $(top_srcdir)/include/ocilib.hpp \ - $(top_srcdir)/include/ocilibcpp/core.hpp \ - $(top_srcdir)/include/ocilibcpp/impl.hpp -noinst_HEADERS= \ - agent.h \ - array.h \ - bind.h \ - callback.h \ - collection.h \ - column.h \ - connection.h \ - database.h \ - date.h \ - define.h \ - defs.h \ - dequeue.h \ - dirpath.h \ - element.h \ - enqueue.h \ - environment.h \ - error.h \ - event.h \ - exception.h \ - file.h \ - format.h \ - handle.h \ - hash.h \ - helpers.h \ - import.h \ - interval.h \ - iterator.h \ - list.h \ - loader.h \ - lob.h \ - long.h \ - macros.h \ - memory.h \ - message.h \ - mutex.h \ - number.h \ - object.h \ - pool.h \ - queue.h \ - reference.h \ - resultset.h \ - statement.h \ - strings.h \ - subscription.h \ - thread.h \ - threadkey.h \ - timestamp.h \ - transaction.h \ - typeinfo.h \ - types.h \ - oci/types.h \ - oci/defs.h \ - oci/api.h - -CLEANFILES = *~ -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libocilib.la: $(libocilib_la_OBJECTS) $(libocilib_la_DEPENDENCIES) $(EXTRA_libocilib_la_DEPENDENCIES) - $(AM_V_CCLD)$(libocilib_la_LINK) -rpath $(libdir) $(libocilib_la_OBJECTS) $(libocilib_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-agent.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-array.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-bind.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-callback.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-collection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-column.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-connection.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-date.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-define.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-dequeue.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-dirpath.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-element.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-enqueue.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-error.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-event.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-exception.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-file.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-format.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-handle.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-hash.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-interval.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-iterator.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-library.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-list.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-lob.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-long.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-memory.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-msg.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-mutex.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-number.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-object.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-pool.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-queue.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-ref.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-resultset.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-statement.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-string.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-subscription.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-thread.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-threadkey.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-timestamp.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-transaction.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-typeinfo.Plo@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -libocilib_la-array.lo: array.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-array.lo -MD -MP -MF $(DEPDIR)/libocilib_la-array.Tpo -c -o libocilib_la-array.lo `test -f 'array.c' || echo '$(srcdir)/'`array.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-array.Tpo $(DEPDIR)/libocilib_la-array.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='array.c' object='libocilib_la-array.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-array.lo `test -f 'array.c' || echo '$(srcdir)/'`array.c - -libocilib_la-bind.lo: bind.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-bind.lo -MD -MP -MF $(DEPDIR)/libocilib_la-bind.Tpo -c -o libocilib_la-bind.lo `test -f 'bind.c' || echo '$(srcdir)/'`bind.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-bind.Tpo $(DEPDIR)/libocilib_la-bind.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bind.c' object='libocilib_la-bind.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-bind.lo `test -f 'bind.c' || echo '$(srcdir)/'`bind.c - -libocilib_la-callback.lo: callback.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-callback.lo -MD -MP -MF $(DEPDIR)/libocilib_la-callback.Tpo -c -o libocilib_la-callback.lo `test -f 'callback.c' || echo '$(srcdir)/'`callback.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-callback.Tpo $(DEPDIR)/libocilib_la-callback.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='callback.c' object='libocilib_la-callback.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-callback.lo `test -f 'callback.c' || echo '$(srcdir)/'`callback.c - -libocilib_la-connection.lo: connection.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-connection.lo -MD -MP -MF $(DEPDIR)/libocilib_la-connection.Tpo -c -o libocilib_la-connection.lo `test -f 'connection.c' || echo '$(srcdir)/'`connection.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-connection.Tpo $(DEPDIR)/libocilib_la-connection.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection.c' object='libocilib_la-connection.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-connection.lo `test -f 'connection.c' || echo '$(srcdir)/'`connection.c - -libocilib_la-define.lo: define.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-define.lo -MD -MP -MF $(DEPDIR)/libocilib_la-define.Tpo -c -o libocilib_la-define.lo `test -f 'define.c' || echo '$(srcdir)/'`define.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-define.Tpo $(DEPDIR)/libocilib_la-define.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='define.c' object='libocilib_la-define.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-define.lo `test -f 'define.c' || echo '$(srcdir)/'`define.c - -libocilib_la-exception.lo: exception.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-exception.lo -MD -MP -MF $(DEPDIR)/libocilib_la-exception.Tpo -c -o libocilib_la-exception.lo `test -f 'exception.c' || echo '$(srcdir)/'`exception.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-exception.Tpo $(DEPDIR)/libocilib_la-exception.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exception.c' object='libocilib_la-exception.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-exception.lo `test -f 'exception.c' || echo '$(srcdir)/'`exception.c - -libocilib_la-handle.lo: handle.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-handle.lo -MD -MP -MF $(DEPDIR)/libocilib_la-handle.Tpo -c -o libocilib_la-handle.lo `test -f 'handle.c' || echo '$(srcdir)/'`handle.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-handle.Tpo $(DEPDIR)/libocilib_la-handle.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='handle.c' object='libocilib_la-handle.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-handle.lo `test -f 'handle.c' || echo '$(srcdir)/'`handle.c - -libocilib_la-iterator.lo: iterator.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-iterator.lo -MD -MP -MF $(DEPDIR)/libocilib_la-iterator.Tpo -c -o libocilib_la-iterator.lo `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-iterator.Tpo $(DEPDIR)/libocilib_la-iterator.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='iterator.c' object='libocilib_la-iterator.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-iterator.lo `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c - -libocilib_la-lob.lo: lob.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-lob.lo -MD -MP -MF $(DEPDIR)/libocilib_la-lob.Tpo -c -o libocilib_la-lob.lo `test -f 'lob.c' || echo '$(srcdir)/'`lob.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-lob.Tpo $(DEPDIR)/libocilib_la-lob.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lob.c' object='libocilib_la-lob.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-lob.lo `test -f 'lob.c' || echo '$(srcdir)/'`lob.c - -libocilib_la-mutex.lo: mutex.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-mutex.lo -MD -MP -MF $(DEPDIR)/libocilib_la-mutex.Tpo -c -o libocilib_la-mutex.lo `test -f 'mutex.c' || echo '$(srcdir)/'`mutex.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-mutex.Tpo $(DEPDIR)/libocilib_la-mutex.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mutex.c' object='libocilib_la-mutex.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-mutex.lo `test -f 'mutex.c' || echo '$(srcdir)/'`mutex.c - -libocilib_la-resultset.lo: resultset.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-resultset.lo -MD -MP -MF $(DEPDIR)/libocilib_la-resultset.Tpo -c -o libocilib_la-resultset.lo `test -f 'resultset.c' || echo '$(srcdir)/'`resultset.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-resultset.Tpo $(DEPDIR)/libocilib_la-resultset.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='resultset.c' object='libocilib_la-resultset.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-resultset.lo `test -f 'resultset.c' || echo '$(srcdir)/'`resultset.c - -libocilib_la-string.lo: string.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-string.lo -MD -MP -MF $(DEPDIR)/libocilib_la-string.Tpo -c -o libocilib_la-string.lo `test -f 'string.c' || echo '$(srcdir)/'`string.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-string.Tpo $(DEPDIR)/libocilib_la-string.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='string.c' object='libocilib_la-string.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-string.lo `test -f 'string.c' || echo '$(srcdir)/'`string.c - -libocilib_la-timestamp.lo: timestamp.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-timestamp.lo -MD -MP -MF $(DEPDIR)/libocilib_la-timestamp.Tpo -c -o libocilib_la-timestamp.lo `test -f 'timestamp.c' || echo '$(srcdir)/'`timestamp.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-timestamp.Tpo $(DEPDIR)/libocilib_la-timestamp.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timestamp.c' object='libocilib_la-timestamp.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-timestamp.lo `test -f 'timestamp.c' || echo '$(srcdir)/'`timestamp.c - -libocilib_la-collection.lo: collection.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-collection.lo -MD -MP -MF $(DEPDIR)/libocilib_la-collection.Tpo -c -o libocilib_la-collection.lo `test -f 'collection.c' || echo '$(srcdir)/'`collection.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-collection.Tpo $(DEPDIR)/libocilib_la-collection.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='collection.c' object='libocilib_la-collection.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-collection.lo `test -f 'collection.c' || echo '$(srcdir)/'`collection.c - -libocilib_la-pool.lo: pool.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-pool.lo -MD -MP -MF $(DEPDIR)/libocilib_la-pool.Tpo -c -o libocilib_la-pool.lo `test -f 'pool.c' || echo '$(srcdir)/'`pool.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-pool.Tpo $(DEPDIR)/libocilib_la-pool.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pool.c' object='libocilib_la-pool.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-pool.lo `test -f 'pool.c' || echo '$(srcdir)/'`pool.c - -libocilib_la-element.lo: element.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-element.lo -MD -MP -MF $(DEPDIR)/libocilib_la-element.Tpo -c -o libocilib_la-element.lo `test -f 'element.c' || echo '$(srcdir)/'`element.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-element.Tpo $(DEPDIR)/libocilib_la-element.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='element.c' object='libocilib_la-element.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-element.lo `test -f 'element.c' || echo '$(srcdir)/'`element.c - -libocilib_la-file.lo: file.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-file.lo -MD -MP -MF $(DEPDIR)/libocilib_la-file.Tpo -c -o libocilib_la-file.lo `test -f 'file.c' || echo '$(srcdir)/'`file.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-file.Tpo $(DEPDIR)/libocilib_la-file.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='file.c' object='libocilib_la-file.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-file.lo `test -f 'file.c' || echo '$(srcdir)/'`file.c - -libocilib_la-hash.lo: hash.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-hash.lo -MD -MP -MF $(DEPDIR)/libocilib_la-hash.Tpo -c -o libocilib_la-hash.lo `test -f 'hash.c' || echo '$(srcdir)/'`hash.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-hash.Tpo $(DEPDIR)/libocilib_la-hash.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hash.c' object='libocilib_la-hash.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-hash.lo `test -f 'hash.c' || echo '$(srcdir)/'`hash.c - -libocilib_la-library.lo: library.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-library.lo -MD -MP -MF $(DEPDIR)/libocilib_la-library.Tpo -c -o libocilib_la-library.lo `test -f 'library.c' || echo '$(srcdir)/'`library.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-library.Tpo $(DEPDIR)/libocilib_la-library.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='library.c' object='libocilib_la-library.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-library.lo `test -f 'library.c' || echo '$(srcdir)/'`library.c - -libocilib_la-long.lo: long.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-long.lo -MD -MP -MF $(DEPDIR)/libocilib_la-long.Tpo -c -o libocilib_la-long.lo `test -f 'long.c' || echo '$(srcdir)/'`long.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-long.Tpo $(DEPDIR)/libocilib_la-long.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='long.c' object='libocilib_la-long.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-long.lo `test -f 'long.c' || echo '$(srcdir)/'`long.c - -libocilib_la-number.lo: number.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-number.lo -MD -MP -MF $(DEPDIR)/libocilib_la-number.Tpo -c -o libocilib_la-number.lo `test -f 'number.c' || echo '$(srcdir)/'`number.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-number.Tpo $(DEPDIR)/libocilib_la-number.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='number.c' object='libocilib_la-number.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-number.lo `test -f 'number.c' || echo '$(srcdir)/'`number.c - -libocilib_la-typeinfo.lo: typeinfo.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-typeinfo.lo -MD -MP -MF $(DEPDIR)/libocilib_la-typeinfo.Tpo -c -o libocilib_la-typeinfo.lo `test -f 'typeinfo.c' || echo '$(srcdir)/'`typeinfo.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-typeinfo.Tpo $(DEPDIR)/libocilib_la-typeinfo.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='typeinfo.c' object='libocilib_la-typeinfo.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-typeinfo.lo `test -f 'typeinfo.c' || echo '$(srcdir)/'`typeinfo.c - -libocilib_la-thread.lo: thread.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-thread.lo -MD -MP -MF $(DEPDIR)/libocilib_la-thread.Tpo -c -o libocilib_la-thread.lo `test -f 'thread.c' || echo '$(srcdir)/'`thread.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-thread.Tpo $(DEPDIR)/libocilib_la-thread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='thread.c' object='libocilib_la-thread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-thread.lo `test -f 'thread.c' || echo '$(srcdir)/'`thread.c - -libocilib_la-transaction.lo: transaction.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-transaction.lo -MD -MP -MF $(DEPDIR)/libocilib_la-transaction.Tpo -c -o libocilib_la-transaction.lo `test -f 'transaction.c' || echo '$(srcdir)/'`transaction.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-transaction.Tpo $(DEPDIR)/libocilib_la-transaction.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='transaction.c' object='libocilib_la-transaction.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-transaction.lo `test -f 'transaction.c' || echo '$(srcdir)/'`transaction.c - -libocilib_la-column.lo: column.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-column.lo -MD -MP -MF $(DEPDIR)/libocilib_la-column.Tpo -c -o libocilib_la-column.lo `test -f 'column.c' || echo '$(srcdir)/'`column.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-column.Tpo $(DEPDIR)/libocilib_la-column.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='column.c' object='libocilib_la-column.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-column.lo `test -f 'column.c' || echo '$(srcdir)/'`column.c - -libocilib_la-date.lo: date.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-date.lo -MD -MP -MF $(DEPDIR)/libocilib_la-date.Tpo -c -o libocilib_la-date.lo `test -f 'date.c' || echo '$(srcdir)/'`date.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-date.Tpo $(DEPDIR)/libocilib_la-date.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='date.c' object='libocilib_la-date.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-date.lo `test -f 'date.c' || echo '$(srcdir)/'`date.c - -libocilib_la-error.lo: error.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-error.lo -MD -MP -MF $(DEPDIR)/libocilib_la-error.Tpo -c -o libocilib_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-error.Tpo $(DEPDIR)/libocilib_la-error.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='error.c' object='libocilib_la-error.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c - -libocilib_la-format.lo: format.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-format.lo -MD -MP -MF $(DEPDIR)/libocilib_la-format.Tpo -c -o libocilib_la-format.lo `test -f 'format.c' || echo '$(srcdir)/'`format.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-format.Tpo $(DEPDIR)/libocilib_la-format.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='format.c' object='libocilib_la-format.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-format.lo `test -f 'format.c' || echo '$(srcdir)/'`format.c - -libocilib_la-interval.lo: interval.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-interval.lo -MD -MP -MF $(DEPDIR)/libocilib_la-interval.Tpo -c -o libocilib_la-interval.lo `test -f 'interval.c' || echo '$(srcdir)/'`interval.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-interval.Tpo $(DEPDIR)/libocilib_la-interval.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='interval.c' object='libocilib_la-interval.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-interval.lo `test -f 'interval.c' || echo '$(srcdir)/'`interval.c - -libocilib_la-list.lo: list.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-list.lo -MD -MP -MF $(DEPDIR)/libocilib_la-list.Tpo -c -o libocilib_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-list.Tpo $(DEPDIR)/libocilib_la-list.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='list.c' object='libocilib_la-list.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c - -libocilib_la-memory.lo: memory.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-memory.lo -MD -MP -MF $(DEPDIR)/libocilib_la-memory.Tpo -c -o libocilib_la-memory.lo `test -f 'memory.c' || echo '$(srcdir)/'`memory.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-memory.Tpo $(DEPDIR)/libocilib_la-memory.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='memory.c' object='libocilib_la-memory.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-memory.lo `test -f 'memory.c' || echo '$(srcdir)/'`memory.c - -libocilib_la-object.lo: object.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-object.lo -MD -MP -MF $(DEPDIR)/libocilib_la-object.Tpo -c -o libocilib_la-object.lo `test -f 'object.c' || echo '$(srcdir)/'`object.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-object.Tpo $(DEPDIR)/libocilib_la-object.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='object.c' object='libocilib_la-object.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-object.lo `test -f 'object.c' || echo '$(srcdir)/'`object.c - -libocilib_la-statement.lo: statement.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-statement.lo -MD -MP -MF $(DEPDIR)/libocilib_la-statement.Tpo -c -o libocilib_la-statement.lo `test -f 'statement.c' || echo '$(srcdir)/'`statement.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-statement.Tpo $(DEPDIR)/libocilib_la-statement.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='statement.c' object='libocilib_la-statement.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-statement.lo `test -f 'statement.c' || echo '$(srcdir)/'`statement.c - -libocilib_la-ref.lo: reference.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-ref.lo -MD -MP -MF $(DEPDIR)/libocilib_la-ref.Tpo -c -o libocilib_la-ref.lo `test -f 'reference.c' || echo '$(srcdir)/'`reference.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-ref.Tpo $(DEPDIR)/libocilib_la-ref.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='reference.c' object='libocilib_la-ref.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-ref.lo `test -f 'reference.c' || echo '$(srcdir)/'`reference.c - -libocilib_la-threadkey.lo: threadkey.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-threadkey.lo -MD -MP -MF $(DEPDIR)/libocilib_la-threadkey.Tpo -c -o libocilib_la-threadkey.lo `test -f 'threadkey.c' || echo '$(srcdir)/'`threadkey.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-threadkey.Tpo $(DEPDIR)/libocilib_la-threadkey.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='threadkey.c' object='libocilib_la-threadkey.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-threadkey.lo `test -f 'threadkey.c' || echo '$(srcdir)/'`threadkey.c - -libocilib_la-dirpath.lo: dirpath.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-dirpath.lo -MD -MP -MF $(DEPDIR)/libocilib_la-dirpath.Tpo -c -o libocilib_la-dirpath.lo `test -f 'dirpath.c' || echo '$(srcdir)/'`dirpath.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-dirpath.Tpo $(DEPDIR)/libocilib_la-dirpath.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dirpath.c' object='libocilib_la-dirpath.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-dirpath.lo `test -f 'dirpath.c' || echo '$(srcdir)/'`dirpath.c - -libocilib_la-event.lo: event.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-event.lo -MD -MP -MF $(DEPDIR)/libocilib_la-event.Tpo -c -o libocilib_la-event.lo `test -f 'event.c' || echo '$(srcdir)/'`event.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-event.Tpo $(DEPDIR)/libocilib_la-event.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event.c' object='libocilib_la-event.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-event.lo `test -f 'event.c' || echo '$(srcdir)/'`event.c - -libocilib_la-subscription.lo: subscription.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-subscription.lo -MD -MP -MF $(DEPDIR)/libocilib_la-subscription.Tpo -c -o libocilib_la-subscription.lo `test -f 'subscription.c' || echo '$(srcdir)/'`subscription.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-subscription.Tpo $(DEPDIR)/libocilib_la-subscription.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='subscription.c' object='libocilib_la-subscription.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-subscription.lo `test -f 'subscription.c' || echo '$(srcdir)/'`subscription.c - -libocilib_la-agent.lo: agent.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-agent.lo -MD -MP -MF $(DEPDIR)/libocilib_la-agent.Tpo -c -o libocilib_la-agent.lo `test -f 'agent.c' || echo '$(srcdir)/'`agent.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-agent.Tpo $(DEPDIR)/libocilib_la-agent.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='agent.c' object='libocilib_la-agent.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-agent.lo `test -f 'agent.c' || echo '$(srcdir)/'`agent.c - -libocilib_la-dequeue.lo: dequeue.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-dequeue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-dequeue.Tpo -c -o libocilib_la-dequeue.lo `test -f 'dequeue.c' || echo '$(srcdir)/'`dequeue.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-dequeue.Tpo $(DEPDIR)/libocilib_la-dequeue.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dequeue.c' object='libocilib_la-dequeue.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-dequeue.lo `test -f 'dequeue.c' || echo '$(srcdir)/'`dequeue.c - -libocilib_la-enqueue.lo: enqueue.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-enqueue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-enqueue.Tpo -c -o libocilib_la-enqueue.lo `test -f 'enqueue.c' || echo '$(srcdir)/'`enqueue.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-enqueue.Tpo $(DEPDIR)/libocilib_la-enqueue.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='enqueue.c' object='libocilib_la-enqueue.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-enqueue.lo `test -f 'enqueue.c' || echo '$(srcdir)/'`enqueue.c - -libocilib_la-msg.lo: message.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-msg.lo -MD -MP -MF $(DEPDIR)/libocilib_la-msg.Tpo -c -o libocilib_la-msg.lo `test -f 'message.c' || echo '$(srcdir)/'`message.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-msg.Tpo $(DEPDIR)/libocilib_la-msg.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='message.c' object='libocilib_la-msg.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-msg.lo `test -f 'message.c' || echo '$(srcdir)/'`message.c - -libocilib_la-queue.lo: queue.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-queue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-queue.Tpo -c -o libocilib_la-queue.lo `test -f 'queue.c' || echo '$(srcdir)/'`queue.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-queue.Tpo $(DEPDIR)/libocilib_la-queue.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='queue.c' object='libocilib_la-queue.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-queue.lo `test -f 'queue.c' || echo '$(srcdir)/'`queue.c - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-includeHEADERS: $(include_HEADERS) - @$(NORMAL_INSTALL) - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ - $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ - done - -uninstall-includeHEADERS: - @$(NORMAL_UNINSTALL) - @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) -installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-includeHEADERS - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: install-libLTLIBRARIES - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am \ - install-includeHEADERS install-info install-info-am \ - install-libLTLIBRARIES install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-includeHEADERS \ - uninstall-libLTLIBRARIES - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: From 1723d5f26f0237bdc93cef6987792780bb99fd75 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 17:55:40 +0200 Subject: [PATCH 19/62] update makefile to install new header properly now headers are installed in package folder "ocilib" --- src/Makefile.am | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7dac01fc..ebbb05e8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -64,17 +64,28 @@ libocilib_la_SOURCES= \ libocilib_la_CFLAGS= -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS= @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -nobase_include_HEADERS= \ - $(top_srcdir)/include/*.h \ - $(top_srcdir)/include/*.hpp \ - $(top_srcdir)/include/ocilibc/*.h \ - $(top_srcdir)/include/ocilibcpp/*.hpp \ - $(top_srcdir)/include/ocilibcpp/detail/*.hpp \ - $(top_srcdir)/include/ocilibcpp/detail/core/*.hpp \ - $(top_srcdir)/include/ocilibcpp/detail/support/*.hpp - + +ocilibcsubdir=$(pkgincludedir)/ocilibc +ocilibcsub_HEADERS = $(top_srcdir)/include/ocilibc/*.h + +ocilibcppsubdir=$(pkgincludedir)/ocilibcpp +ocilibcppsub_HEADERS = $(top_srcdir)/include/ocilibcpp/*.hpp + +ocilibcppdetailsubdir=$(pkgincludedir)/ocilibcpp/detail +ocilibcppdetailsub_HEADERS = $(top_srcdir)/include/ocilibcpp/detail/*.hpp + +ocilibcppdetailcoresubdir=$(pkgincludedir)/ocilibcpp/detail/core +ocilibcppdetailcoresub_HEADERS = $(top_srcdir)/include/ocilibcpp/detail/core/*.hpp + +ocilibcppdetailsupportsubdir=$(pkgincludedir)/ocilibcpp/detail/support +ocilibcppdetailsupportsub_HEADERS = $(top_srcdir)/include/ocilibcpp/detail/support/*.hpp + +pkginclude_HEADERS= \ + $(top_srcdir)/include/ocilib.h \ + $(top_srcdir)/include/ocilib.hpp + noinst_HEADERS= \ - agent.h \ + agent.h \ array.h \ bind.h \ callback.h \ @@ -124,8 +135,8 @@ noinst_HEADERS= \ transaction.h \ typeinfo.h \ types.h \ - oci/types.h \ - oci/defs.h \ - oci/api.h + oci/types.h \ + oci/defs.h \ + oci/api.h -CLEANFILES = *~ +CLEANFILES = *~ \ No newline at end of file From e3d7d5ba9dc600b53addb5913cc7bde7b8cecbda Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 18:00:02 +0200 Subject: [PATCH 20/62] revert previous cleanup --- Makefile.in | 908 ++++++++++++++++++++++++++++++++ demo/Makefile.in | 702 ++++++++++++++++++++++++ demo/Makefile_demo.in | 27 + doc/html/Makefile.in | 518 ++++++++++++++++++ src/Makefile.in | 1171 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 3326 insertions(+) create mode 100644 Makefile.in create mode 100644 demo/Makefile.in create mode 100644 demo/Makefile_demo.in create mode 100644 doc/html/Makefile.in create mode 100644 src/Makefile.in diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..c80edf0b --- /dev/null +++ b/Makefile.in @@ -0,0 +1,908 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright (c) 2007-2020 Vincent ROGIER +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(am__DIST_COMMON) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = README ocilib.pc +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(pkgconfigdir)" +DATA = $(pkgconfig_DATA) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + cscope distdir dist dist-all distcheck +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +CSCOPE = cscope +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/README.in \ + $(srcdir)/config.h.in $(srcdir)/ocilib.pc.in \ + $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ + $(top_srcdir)/config/config.sub \ + $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ + $(top_srcdir)/config/missing AUTHORS ChangeLog INSTALL \ + README THANKS LICENSE config/compile config/config.guess \ + config/config.sub config/install-sh config/ltmain.sh \ + config/missing +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +DIST_TARGETS = dist-gzip +distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCILIB_CHARSET = @OCILIB_CHARSET@ +OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ +OCILIB_DOCS = @OCILIB_DOCS@ +OCILIB_IMPORT = @OCILIB_IMPORT@ +OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ +OCILIB_PREFIX = @OCILIB_PREFIX@ +ORACLE_HOME = @ORACLE_HOME@ +ORACLE_INCLUDES = @ORACLE_INCLUDES@ +ORACLE_LIBADD = @ORACLE_LIBADD@ +ORACLE_LIBNAME = @ORACLE_LIBNAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +ACLOCAL_AMFLAGS = -I m4 +EXTRA_DIST = doc/html reconf configure VERSION acocilib.m4 +SUBDIRS = doc/html src demo +DISTCLEANFILES = *~ \#*\# +MAINTAINERCLEANFILES = \ +Makefile Makefile.in config.cache config.log config.h.in \ +libtool acinclude.m4 aclocal.m4 acocilib.m4 configure stamp-h.in + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = ocilib.pc +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +am--refresh: Makefile + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +README: $(top_builddir)/config.status $(srcdir)/README.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +ocilib.pc: $(top_builddir)/config.status $(srcdir)/ocilib.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__post_remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) + +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) + +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) + +dist-tarZ: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__post_remove_distdir) + +dist-shar: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__post_remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__post_remove_distdir) + +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir) + chmod u+w $(distdir) + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=../.. --prefix="$$dc_install_base" \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__post_remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(pkgconfigdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-hdr \ + distclean-libtool distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-pkgconfigDATA + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-pkgconfigDATA + +.MAKE: $(am__recursive_targets) all install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--refresh check check-am clean clean-cscope clean-generic \ + clean-libtool cscope cscopelist-am ctags ctags-am dist \ + dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ + dist-xz dist-zip distcheck distclean distclean-generic \ + distclean-hdr distclean-libtool distclean-tags distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-pkgconfigDATA \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-pkgconfigDATA + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/demo/Makefile.in b/demo/Makefile.in new file mode 100644 index 00000000..faf3c635 --- /dev/null +++ b/demo/Makefile.in @@ -0,0 +1,702 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright (c) 2007-2020 Vincent ROGIER +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = demo +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = Makefile_demo +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(demodir)" +DATA = $(demo_DATA) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile_demo.in +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCILIB_CHARSET = @OCILIB_CHARSET@ +OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ +OCILIB_DOCS = @OCILIB_DOCS@ +OCILIB_IMPORT = @OCILIB_IMPORT@ +OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ +OCILIB_PREFIX = @OCILIB_PREFIX@ +ORACLE_HOME = @ORACLE_HOME@ +ORACLE_INCLUDES = @ORACLE_INCLUDES@ +ORACLE_LIBADD = @ORACLE_LIBADD@ +ORACLE_LIBNAME = @ORACLE_LIBNAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign +SUBDIRS = . +CLEANFILES = *~ +demo_DATA = @OCILIB_DEMO_SOURCES@ Makefile_demo +demodir = $(prefix)/share/doc/$(PACKAGE)/demo +EXTRA_DIST = $(demo_DATA) +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign demo/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign demo/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +Makefile_demo: $(top_builddir)/config.status $(srcdir)/Makefile_demo.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-demoDATA: $(demo_DATA) + @$(NORMAL_INSTALL) + @list='$(demo_DATA)'; test -n "$(demodir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(demodir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(demodir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(demodir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(demodir)" || exit $$?; \ + done + +uninstall-demoDATA: + @$(NORMAL_UNINSTALL) + @list='$(demo_DATA)'; test -n "$(demodir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(demodir)'; $(am__uninstall_files_from_dir) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(demodir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-demoDATA + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-demoDATA + +.MAKE: $(am__recursive_targets) install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ + check-am clean clean-generic clean-libtool cscopelist-am ctags \ + ctags-am distclean distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-demoDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am uninstall-demoDATA + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/demo/Makefile_demo.in b/demo/Makefile_demo.in new file mode 100644 index 00000000..d87a9fcc --- /dev/null +++ b/demo/Makefile_demo.in @@ -0,0 +1,27 @@ +# Copyright (c) 2007-2020 Vincent ROGIER +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +INCS = -I@OCILIB_PREFIX@/include +CFLAGS = -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ +LDFLAGS= @ORACLE_LIBADD@ -L@OCILIB_PREFIX@/lib -locilib +CC = @CC@ +SRCS = ocilib_demo.c +OBJS = $(SRCS:.c=.o) + +all: ocilib_demo + +demo: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) + +.c.o: + $(CC) $(INCS) $(CFLAGS) -c -o $@ $< + +clean: + rm -f *~ $(OBJS) diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in new file mode 100644 index 00000000..d7797fff --- /dev/null +++ b/doc/html/Makefile.in @@ -0,0 +1,518 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright (c) 2007-2020 Vincent ROGIER +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = doc/html +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(docdir)" +DATA = $(doc_DATA) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCILIB_CHARSET = @OCILIB_CHARSET@ +OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ +OCILIB_DOCS = @OCILIB_DOCS@ +OCILIB_IMPORT = @OCILIB_IMPORT@ +OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ +OCILIB_PREFIX = @OCILIB_PREFIX@ +ORACLE_HOME = @ORACLE_HOME@ +ORACLE_INCLUDES = @ORACLE_INCLUDES@ +ORACLE_LIBADD = @ORACLE_LIBADD@ +ORACLE_LIBNAME = @ORACLE_LIBNAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = $(prefix)/share/doc/$(PACKAGE)/html +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = foreign +CLEANFILES = *~ +doc_DATA = @OCILIB_DOCS@ +EXTRA_DIST = $(doc_DATA) +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/html/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign doc/html/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-docDATA: $(doc_DATA) + @$(NORMAL_INSTALL) + @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ + done + +uninstall-docDATA: + @$(NORMAL_UNINSTALL) + @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(docdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-docDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-docDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-docDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am uninstall-docDATA + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 00000000..f6c8453f --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,1171 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Copyright (c) 2007-2020 Vincent ROGIER +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \ + $(noinst_HEADERS) $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +libocilib_la_DEPENDENCIES = +am_libocilib_la_OBJECTS = libocilib_la-array.lo libocilib_la-bind.lo \ + libocilib_la-callback.lo libocilib_la-connection.lo \ + libocilib_la-define.lo libocilib_la-exception.lo \ + libocilib_la-handle.lo libocilib_la-iterator.lo \ + libocilib_la-lob.lo libocilib_la-mutex.lo \ + libocilib_la-resultset.lo libocilib_la-string.lo \ + libocilib_la-timestamp.lo libocilib_la-collection.lo \ + libocilib_la-pool.lo libocilib_la-element.lo \ + libocilib_la-file.lo libocilib_la-hash.lo \ + libocilib_la-library.lo libocilib_la-long.lo \ + libocilib_la-number.lo libocilib_la-typeinfo.lo \ + libocilib_la-thread.lo libocilib_la-transaction.lo \ + libocilib_la-column.lo libocilib_la-date.lo \ + libocilib_la-error.lo libocilib_la-format.lo \ + libocilib_la-interval.lo libocilib_la-list.lo \ + libocilib_la-memory.lo libocilib_la-object.lo \ + libocilib_la-statement.lo libocilib_la-ref.lo \ + libocilib_la-threadkey.lo libocilib_la-dirpath.lo \ + libocilib_la-event.lo libocilib_la-subscription.lo \ + libocilib_la-agent.lo libocilib_la-dequeue.lo \ + libocilib_la-enqueue.lo libocilib_la-msg.lo \ + libocilib_la-queue.lo +libocilib_la_OBJECTS = $(am_libocilib_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libocilib_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libocilib_la_CFLAGS) \ + $(CFLAGS) $(libocilib_la_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libocilib_la_SOURCES) +DIST_SOURCES = $(libocilib_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(include_HEADERS) $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OCILIB_CHARSET = @OCILIB_CHARSET@ +OCILIB_DEMO_SOURCES = @OCILIB_DEMO_SOURCES@ +OCILIB_DOCS = @OCILIB_DOCS@ +OCILIB_IMPORT = @OCILIB_IMPORT@ +OCILIB_LD_FLAG = @OCILIB_LD_FLAG@ +OCILIB_PREFIX = @OCILIB_PREFIX@ +ORACLE_HOME = @ORACLE_HOME@ +ORACLE_INCLUDES = @ORACLE_INCLUDES@ +ORACLE_LIBADD = @ORACLE_LIBADD@ +ORACLE_LIBNAME = @ORACLE_LIBNAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = @ORACLE_INCLUDES@ -I$(top_srcdir)/include +lib_LTLIBRARIES = libocilib.la +libocilib_la_LIBADD = @ORACLE_LIBADD@ +libocilib_la_SOURCES= \ + agent.c \ + array.c \ + bind.c \ + callback.c \ + collection.c \ + column.c \ + connection.c \ + date.c \ + database.c \ + define.c \ + dequeue.c \ + dirpath.c \ + element.c \ + enqueue.c \ + environment.c \ + error.c \ + event.c \ + exception.c \ + file.c \ + format.c \ + handle.c \ + hash.c \ + helpers.c \ + interval.c \ + iterator.c \ + list.c \ + lob.c \ + long.c \ + memory.c \ + message.c \ + mutex.c \ + number.c \ + object.c \ + ocilib.c \ + pool.c \ + queue.c \ + reference.c \ + resultset.c \ + statement.c \ + strings.c \ + subscription.c \ + thread.c \ + threadkey.c \ + timestamp.c \ + transaction.c \ + typeinfo.c + +libocilib_la_CFLAGS = -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ +libocilib_la_LDFLAGS = @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +include_HEADERS= \ + $(top_srcdir)/include/ocilib.h \ + $(top_srcdir)/include/ocilibc/api.h \ + $(top_srcdir)/include/ocilibc/compat.h \ + $(top_srcdir)/include/ocilibc/config.h \ + $(top_srcdir)/include/ocilibc/types.h \ + $(top_srcdir)/include/ocilib.hpp \ + $(top_srcdir)/include/ocilibcpp/core.hpp \ + $(top_srcdir)/include/ocilibcpp/impl.hpp +noinst_HEADERS= \ + agent.h \ + array.h \ + bind.h \ + callback.h \ + collection.h \ + column.h \ + connection.h \ + database.h \ + date.h \ + define.h \ + defs.h \ + dequeue.h \ + dirpath.h \ + element.h \ + enqueue.h \ + environment.h \ + error.h \ + event.h \ + exception.h \ + file.h \ + format.h \ + handle.h \ + hash.h \ + helpers.h \ + import.h \ + interval.h \ + iterator.h \ + list.h \ + loader.h \ + lob.h \ + long.h \ + macros.h \ + memory.h \ + message.h \ + mutex.h \ + number.h \ + object.h \ + pool.h \ + queue.h \ + reference.h \ + resultset.h \ + statement.h \ + strings.h \ + subscription.h \ + thread.h \ + threadkey.h \ + timestamp.h \ + transaction.h \ + typeinfo.h \ + types.h \ + oci/types.h \ + oci/defs.h \ + oci/api.h + +CLEANFILES = *~ +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libocilib.la: $(libocilib_la_OBJECTS) $(libocilib_la_DEPENDENCIES) $(EXTRA_libocilib_la_DEPENDENCIES) + $(AM_V_CCLD)$(libocilib_la_LINK) -rpath $(libdir) $(libocilib_la_OBJECTS) $(libocilib_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-agent.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-array.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-bind.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-callback.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-collection.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-column.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-connection.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-date.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-define.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-dequeue.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-dirpath.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-element.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-enqueue.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-error.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-event.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-exception.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-file.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-format.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-handle.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-hash.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-interval.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-iterator.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-library.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-list.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-lob.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-long.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-memory.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-msg.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-mutex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-number.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-object.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-queue.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-ref.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-resultset.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-statement.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-string.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-subscription.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-thread.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-threadkey.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-timestamp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-transaction.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libocilib_la-typeinfo.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +libocilib_la-array.lo: array.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-array.lo -MD -MP -MF $(DEPDIR)/libocilib_la-array.Tpo -c -o libocilib_la-array.lo `test -f 'array.c' || echo '$(srcdir)/'`array.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-array.Tpo $(DEPDIR)/libocilib_la-array.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='array.c' object='libocilib_la-array.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-array.lo `test -f 'array.c' || echo '$(srcdir)/'`array.c + +libocilib_la-bind.lo: bind.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-bind.lo -MD -MP -MF $(DEPDIR)/libocilib_la-bind.Tpo -c -o libocilib_la-bind.lo `test -f 'bind.c' || echo '$(srcdir)/'`bind.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-bind.Tpo $(DEPDIR)/libocilib_la-bind.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bind.c' object='libocilib_la-bind.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-bind.lo `test -f 'bind.c' || echo '$(srcdir)/'`bind.c + +libocilib_la-callback.lo: callback.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-callback.lo -MD -MP -MF $(DEPDIR)/libocilib_la-callback.Tpo -c -o libocilib_la-callback.lo `test -f 'callback.c' || echo '$(srcdir)/'`callback.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-callback.Tpo $(DEPDIR)/libocilib_la-callback.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='callback.c' object='libocilib_la-callback.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-callback.lo `test -f 'callback.c' || echo '$(srcdir)/'`callback.c + +libocilib_la-connection.lo: connection.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-connection.lo -MD -MP -MF $(DEPDIR)/libocilib_la-connection.Tpo -c -o libocilib_la-connection.lo `test -f 'connection.c' || echo '$(srcdir)/'`connection.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-connection.Tpo $(DEPDIR)/libocilib_la-connection.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='connection.c' object='libocilib_la-connection.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-connection.lo `test -f 'connection.c' || echo '$(srcdir)/'`connection.c + +libocilib_la-define.lo: define.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-define.lo -MD -MP -MF $(DEPDIR)/libocilib_la-define.Tpo -c -o libocilib_la-define.lo `test -f 'define.c' || echo '$(srcdir)/'`define.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-define.Tpo $(DEPDIR)/libocilib_la-define.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='define.c' object='libocilib_la-define.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-define.lo `test -f 'define.c' || echo '$(srcdir)/'`define.c + +libocilib_la-exception.lo: exception.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-exception.lo -MD -MP -MF $(DEPDIR)/libocilib_la-exception.Tpo -c -o libocilib_la-exception.lo `test -f 'exception.c' || echo '$(srcdir)/'`exception.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-exception.Tpo $(DEPDIR)/libocilib_la-exception.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exception.c' object='libocilib_la-exception.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-exception.lo `test -f 'exception.c' || echo '$(srcdir)/'`exception.c + +libocilib_la-handle.lo: handle.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-handle.lo -MD -MP -MF $(DEPDIR)/libocilib_la-handle.Tpo -c -o libocilib_la-handle.lo `test -f 'handle.c' || echo '$(srcdir)/'`handle.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-handle.Tpo $(DEPDIR)/libocilib_la-handle.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='handle.c' object='libocilib_la-handle.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-handle.lo `test -f 'handle.c' || echo '$(srcdir)/'`handle.c + +libocilib_la-iterator.lo: iterator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-iterator.lo -MD -MP -MF $(DEPDIR)/libocilib_la-iterator.Tpo -c -o libocilib_la-iterator.lo `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-iterator.Tpo $(DEPDIR)/libocilib_la-iterator.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='iterator.c' object='libocilib_la-iterator.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-iterator.lo `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c + +libocilib_la-lob.lo: lob.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-lob.lo -MD -MP -MF $(DEPDIR)/libocilib_la-lob.Tpo -c -o libocilib_la-lob.lo `test -f 'lob.c' || echo '$(srcdir)/'`lob.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-lob.Tpo $(DEPDIR)/libocilib_la-lob.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='lob.c' object='libocilib_la-lob.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-lob.lo `test -f 'lob.c' || echo '$(srcdir)/'`lob.c + +libocilib_la-mutex.lo: mutex.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-mutex.lo -MD -MP -MF $(DEPDIR)/libocilib_la-mutex.Tpo -c -o libocilib_la-mutex.lo `test -f 'mutex.c' || echo '$(srcdir)/'`mutex.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-mutex.Tpo $(DEPDIR)/libocilib_la-mutex.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mutex.c' object='libocilib_la-mutex.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-mutex.lo `test -f 'mutex.c' || echo '$(srcdir)/'`mutex.c + +libocilib_la-resultset.lo: resultset.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-resultset.lo -MD -MP -MF $(DEPDIR)/libocilib_la-resultset.Tpo -c -o libocilib_la-resultset.lo `test -f 'resultset.c' || echo '$(srcdir)/'`resultset.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-resultset.Tpo $(DEPDIR)/libocilib_la-resultset.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='resultset.c' object='libocilib_la-resultset.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-resultset.lo `test -f 'resultset.c' || echo '$(srcdir)/'`resultset.c + +libocilib_la-string.lo: string.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-string.lo -MD -MP -MF $(DEPDIR)/libocilib_la-string.Tpo -c -o libocilib_la-string.lo `test -f 'string.c' || echo '$(srcdir)/'`string.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-string.Tpo $(DEPDIR)/libocilib_la-string.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='string.c' object='libocilib_la-string.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-string.lo `test -f 'string.c' || echo '$(srcdir)/'`string.c + +libocilib_la-timestamp.lo: timestamp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-timestamp.lo -MD -MP -MF $(DEPDIR)/libocilib_la-timestamp.Tpo -c -o libocilib_la-timestamp.lo `test -f 'timestamp.c' || echo '$(srcdir)/'`timestamp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-timestamp.Tpo $(DEPDIR)/libocilib_la-timestamp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='timestamp.c' object='libocilib_la-timestamp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-timestamp.lo `test -f 'timestamp.c' || echo '$(srcdir)/'`timestamp.c + +libocilib_la-collection.lo: collection.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-collection.lo -MD -MP -MF $(DEPDIR)/libocilib_la-collection.Tpo -c -o libocilib_la-collection.lo `test -f 'collection.c' || echo '$(srcdir)/'`collection.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-collection.Tpo $(DEPDIR)/libocilib_la-collection.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='collection.c' object='libocilib_la-collection.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-collection.lo `test -f 'collection.c' || echo '$(srcdir)/'`collection.c + +libocilib_la-pool.lo: pool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-pool.lo -MD -MP -MF $(DEPDIR)/libocilib_la-pool.Tpo -c -o libocilib_la-pool.lo `test -f 'pool.c' || echo '$(srcdir)/'`pool.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-pool.Tpo $(DEPDIR)/libocilib_la-pool.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pool.c' object='libocilib_la-pool.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-pool.lo `test -f 'pool.c' || echo '$(srcdir)/'`pool.c + +libocilib_la-element.lo: element.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-element.lo -MD -MP -MF $(DEPDIR)/libocilib_la-element.Tpo -c -o libocilib_la-element.lo `test -f 'element.c' || echo '$(srcdir)/'`element.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-element.Tpo $(DEPDIR)/libocilib_la-element.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='element.c' object='libocilib_la-element.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-element.lo `test -f 'element.c' || echo '$(srcdir)/'`element.c + +libocilib_la-file.lo: file.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-file.lo -MD -MP -MF $(DEPDIR)/libocilib_la-file.Tpo -c -o libocilib_la-file.lo `test -f 'file.c' || echo '$(srcdir)/'`file.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-file.Tpo $(DEPDIR)/libocilib_la-file.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='file.c' object='libocilib_la-file.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-file.lo `test -f 'file.c' || echo '$(srcdir)/'`file.c + +libocilib_la-hash.lo: hash.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-hash.lo -MD -MP -MF $(DEPDIR)/libocilib_la-hash.Tpo -c -o libocilib_la-hash.lo `test -f 'hash.c' || echo '$(srcdir)/'`hash.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-hash.Tpo $(DEPDIR)/libocilib_la-hash.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hash.c' object='libocilib_la-hash.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-hash.lo `test -f 'hash.c' || echo '$(srcdir)/'`hash.c + +libocilib_la-library.lo: library.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-library.lo -MD -MP -MF $(DEPDIR)/libocilib_la-library.Tpo -c -o libocilib_la-library.lo `test -f 'library.c' || echo '$(srcdir)/'`library.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-library.Tpo $(DEPDIR)/libocilib_la-library.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='library.c' object='libocilib_la-library.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-library.lo `test -f 'library.c' || echo '$(srcdir)/'`library.c + +libocilib_la-long.lo: long.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-long.lo -MD -MP -MF $(DEPDIR)/libocilib_la-long.Tpo -c -o libocilib_la-long.lo `test -f 'long.c' || echo '$(srcdir)/'`long.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-long.Tpo $(DEPDIR)/libocilib_la-long.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='long.c' object='libocilib_la-long.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-long.lo `test -f 'long.c' || echo '$(srcdir)/'`long.c + +libocilib_la-number.lo: number.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-number.lo -MD -MP -MF $(DEPDIR)/libocilib_la-number.Tpo -c -o libocilib_la-number.lo `test -f 'number.c' || echo '$(srcdir)/'`number.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-number.Tpo $(DEPDIR)/libocilib_la-number.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='number.c' object='libocilib_la-number.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-number.lo `test -f 'number.c' || echo '$(srcdir)/'`number.c + +libocilib_la-typeinfo.lo: typeinfo.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-typeinfo.lo -MD -MP -MF $(DEPDIR)/libocilib_la-typeinfo.Tpo -c -o libocilib_la-typeinfo.lo `test -f 'typeinfo.c' || echo '$(srcdir)/'`typeinfo.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-typeinfo.Tpo $(DEPDIR)/libocilib_la-typeinfo.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='typeinfo.c' object='libocilib_la-typeinfo.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-typeinfo.lo `test -f 'typeinfo.c' || echo '$(srcdir)/'`typeinfo.c + +libocilib_la-thread.lo: thread.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-thread.lo -MD -MP -MF $(DEPDIR)/libocilib_la-thread.Tpo -c -o libocilib_la-thread.lo `test -f 'thread.c' || echo '$(srcdir)/'`thread.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-thread.Tpo $(DEPDIR)/libocilib_la-thread.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='thread.c' object='libocilib_la-thread.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-thread.lo `test -f 'thread.c' || echo '$(srcdir)/'`thread.c + +libocilib_la-transaction.lo: transaction.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-transaction.lo -MD -MP -MF $(DEPDIR)/libocilib_la-transaction.Tpo -c -o libocilib_la-transaction.lo `test -f 'transaction.c' || echo '$(srcdir)/'`transaction.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-transaction.Tpo $(DEPDIR)/libocilib_la-transaction.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='transaction.c' object='libocilib_la-transaction.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-transaction.lo `test -f 'transaction.c' || echo '$(srcdir)/'`transaction.c + +libocilib_la-column.lo: column.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-column.lo -MD -MP -MF $(DEPDIR)/libocilib_la-column.Tpo -c -o libocilib_la-column.lo `test -f 'column.c' || echo '$(srcdir)/'`column.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-column.Tpo $(DEPDIR)/libocilib_la-column.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='column.c' object='libocilib_la-column.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-column.lo `test -f 'column.c' || echo '$(srcdir)/'`column.c + +libocilib_la-date.lo: date.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-date.lo -MD -MP -MF $(DEPDIR)/libocilib_la-date.Tpo -c -o libocilib_la-date.lo `test -f 'date.c' || echo '$(srcdir)/'`date.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-date.Tpo $(DEPDIR)/libocilib_la-date.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='date.c' object='libocilib_la-date.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-date.lo `test -f 'date.c' || echo '$(srcdir)/'`date.c + +libocilib_la-error.lo: error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-error.lo -MD -MP -MF $(DEPDIR)/libocilib_la-error.Tpo -c -o libocilib_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-error.Tpo $(DEPDIR)/libocilib_la-error.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='error.c' object='libocilib_la-error.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c + +libocilib_la-format.lo: format.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-format.lo -MD -MP -MF $(DEPDIR)/libocilib_la-format.Tpo -c -o libocilib_la-format.lo `test -f 'format.c' || echo '$(srcdir)/'`format.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-format.Tpo $(DEPDIR)/libocilib_la-format.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='format.c' object='libocilib_la-format.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-format.lo `test -f 'format.c' || echo '$(srcdir)/'`format.c + +libocilib_la-interval.lo: interval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-interval.lo -MD -MP -MF $(DEPDIR)/libocilib_la-interval.Tpo -c -o libocilib_la-interval.lo `test -f 'interval.c' || echo '$(srcdir)/'`interval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-interval.Tpo $(DEPDIR)/libocilib_la-interval.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='interval.c' object='libocilib_la-interval.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-interval.lo `test -f 'interval.c' || echo '$(srcdir)/'`interval.c + +libocilib_la-list.lo: list.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-list.lo -MD -MP -MF $(DEPDIR)/libocilib_la-list.Tpo -c -o libocilib_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-list.Tpo $(DEPDIR)/libocilib_la-list.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='list.c' object='libocilib_la-list.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-list.lo `test -f 'list.c' || echo '$(srcdir)/'`list.c + +libocilib_la-memory.lo: memory.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-memory.lo -MD -MP -MF $(DEPDIR)/libocilib_la-memory.Tpo -c -o libocilib_la-memory.lo `test -f 'memory.c' || echo '$(srcdir)/'`memory.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-memory.Tpo $(DEPDIR)/libocilib_la-memory.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='memory.c' object='libocilib_la-memory.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-memory.lo `test -f 'memory.c' || echo '$(srcdir)/'`memory.c + +libocilib_la-object.lo: object.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-object.lo -MD -MP -MF $(DEPDIR)/libocilib_la-object.Tpo -c -o libocilib_la-object.lo `test -f 'object.c' || echo '$(srcdir)/'`object.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-object.Tpo $(DEPDIR)/libocilib_la-object.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='object.c' object='libocilib_la-object.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-object.lo `test -f 'object.c' || echo '$(srcdir)/'`object.c + +libocilib_la-statement.lo: statement.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-statement.lo -MD -MP -MF $(DEPDIR)/libocilib_la-statement.Tpo -c -o libocilib_la-statement.lo `test -f 'statement.c' || echo '$(srcdir)/'`statement.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-statement.Tpo $(DEPDIR)/libocilib_la-statement.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='statement.c' object='libocilib_la-statement.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-statement.lo `test -f 'statement.c' || echo '$(srcdir)/'`statement.c + +libocilib_la-ref.lo: reference.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-ref.lo -MD -MP -MF $(DEPDIR)/libocilib_la-ref.Tpo -c -o libocilib_la-ref.lo `test -f 'reference.c' || echo '$(srcdir)/'`reference.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-ref.Tpo $(DEPDIR)/libocilib_la-ref.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='reference.c' object='libocilib_la-ref.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-ref.lo `test -f 'reference.c' || echo '$(srcdir)/'`reference.c + +libocilib_la-threadkey.lo: threadkey.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-threadkey.lo -MD -MP -MF $(DEPDIR)/libocilib_la-threadkey.Tpo -c -o libocilib_la-threadkey.lo `test -f 'threadkey.c' || echo '$(srcdir)/'`threadkey.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-threadkey.Tpo $(DEPDIR)/libocilib_la-threadkey.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='threadkey.c' object='libocilib_la-threadkey.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-threadkey.lo `test -f 'threadkey.c' || echo '$(srcdir)/'`threadkey.c + +libocilib_la-dirpath.lo: dirpath.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-dirpath.lo -MD -MP -MF $(DEPDIR)/libocilib_la-dirpath.Tpo -c -o libocilib_la-dirpath.lo `test -f 'dirpath.c' || echo '$(srcdir)/'`dirpath.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-dirpath.Tpo $(DEPDIR)/libocilib_la-dirpath.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dirpath.c' object='libocilib_la-dirpath.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-dirpath.lo `test -f 'dirpath.c' || echo '$(srcdir)/'`dirpath.c + +libocilib_la-event.lo: event.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-event.lo -MD -MP -MF $(DEPDIR)/libocilib_la-event.Tpo -c -o libocilib_la-event.lo `test -f 'event.c' || echo '$(srcdir)/'`event.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-event.Tpo $(DEPDIR)/libocilib_la-event.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='event.c' object='libocilib_la-event.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-event.lo `test -f 'event.c' || echo '$(srcdir)/'`event.c + +libocilib_la-subscription.lo: subscription.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-subscription.lo -MD -MP -MF $(DEPDIR)/libocilib_la-subscription.Tpo -c -o libocilib_la-subscription.lo `test -f 'subscription.c' || echo '$(srcdir)/'`subscription.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-subscription.Tpo $(DEPDIR)/libocilib_la-subscription.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='subscription.c' object='libocilib_la-subscription.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-subscription.lo `test -f 'subscription.c' || echo '$(srcdir)/'`subscription.c + +libocilib_la-agent.lo: agent.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-agent.lo -MD -MP -MF $(DEPDIR)/libocilib_la-agent.Tpo -c -o libocilib_la-agent.lo `test -f 'agent.c' || echo '$(srcdir)/'`agent.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-agent.Tpo $(DEPDIR)/libocilib_la-agent.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='agent.c' object='libocilib_la-agent.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-agent.lo `test -f 'agent.c' || echo '$(srcdir)/'`agent.c + +libocilib_la-dequeue.lo: dequeue.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-dequeue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-dequeue.Tpo -c -o libocilib_la-dequeue.lo `test -f 'dequeue.c' || echo '$(srcdir)/'`dequeue.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-dequeue.Tpo $(DEPDIR)/libocilib_la-dequeue.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dequeue.c' object='libocilib_la-dequeue.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-dequeue.lo `test -f 'dequeue.c' || echo '$(srcdir)/'`dequeue.c + +libocilib_la-enqueue.lo: enqueue.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-enqueue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-enqueue.Tpo -c -o libocilib_la-enqueue.lo `test -f 'enqueue.c' || echo '$(srcdir)/'`enqueue.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-enqueue.Tpo $(DEPDIR)/libocilib_la-enqueue.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='enqueue.c' object='libocilib_la-enqueue.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-enqueue.lo `test -f 'enqueue.c' || echo '$(srcdir)/'`enqueue.c + +libocilib_la-msg.lo: message.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-msg.lo -MD -MP -MF $(DEPDIR)/libocilib_la-msg.Tpo -c -o libocilib_la-msg.lo `test -f 'message.c' || echo '$(srcdir)/'`message.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-msg.Tpo $(DEPDIR)/libocilib_la-msg.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='message.c' object='libocilib_la-msg.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-msg.lo `test -f 'message.c' || echo '$(srcdir)/'`message.c + +libocilib_la-queue.lo: queue.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -MT libocilib_la-queue.lo -MD -MP -MF $(DEPDIR)/libocilib_la-queue.Tpo -c -o libocilib_la-queue.lo `test -f 'queue.c' || echo '$(srcdir)/'`queue.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libocilib_la-queue.Tpo $(DEPDIR)/libocilib_la-queue.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='queue.c' object='libocilib_la-queue.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libocilib_la_CFLAGS) $(CFLAGS) -c -o libocilib_la-queue.lo `test -f 'queue.c' || echo '$(srcdir)/'`queue.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am \ + install-includeHEADERS install-info install-info-am \ + install-libLTLIBRARIES install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-includeHEADERS \ + uninstall-libLTLIBRARIES + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: From 734532b846245b56eee0ce07ff69882073a593c5 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 18:41:31 +0200 Subject: [PATCH 21/62] fixed makefile (in order to keep current behavior when installing headers) --- src/Makefile.am | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ebbb05e8..15e86991 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,22 +65,22 @@ libocilib_la_CFLAGS= -D@OCILIB_IMPORT@ -D@OCILIB_CHARSET@ @ORACLE_LIBNAME@ libocilib_la_LDFLAGS= @OCILIB_LD_FLAG@ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -ocilibcsubdir=$(pkgincludedir)/ocilibc +ocilibcsubdir=$(includedir)/ocilibc ocilibcsub_HEADERS = $(top_srcdir)/include/ocilibc/*.h -ocilibcppsubdir=$(pkgincludedir)/ocilibcpp +ocilibcppsubdir=$(includedir)/ocilibcpp ocilibcppsub_HEADERS = $(top_srcdir)/include/ocilibcpp/*.hpp -ocilibcppdetailsubdir=$(pkgincludedir)/ocilibcpp/detail +ocilibcppdetailsubdir=$(includedir)/ocilibcpp/detail ocilibcppdetailsub_HEADERS = $(top_srcdir)/include/ocilibcpp/detail/*.hpp -ocilibcppdetailcoresubdir=$(pkgincludedir)/ocilibcpp/detail/core +ocilibcppdetailcoresubdir=$(includedir)/ocilibcpp/detail/core ocilibcppdetailcoresub_HEADERS = $(top_srcdir)/include/ocilibcpp/detail/core/*.hpp -ocilibcppdetailsupportsubdir=$(pkgincludedir)/ocilibcpp/detail/support +ocilibcppdetailsupportsubdir=$(includedir)/ocilibcpp/detail/support ocilibcppdetailsupportsub_HEADERS = $(top_srcdir)/include/ocilibcpp/detail/support/*.hpp -pkginclude_HEADERS= \ +include_HEADERS= \ $(top_srcdir)/include/ocilib.h \ $(top_srcdir)/include/ocilib.hpp From d599e106b4760e3a5bb89c899a2702b6e02f8aa4 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 18:43:04 +0200 Subject: [PATCH 22/62] readed missing includes --- include/ocilibcpp/types.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/ocilibcpp/types.hpp b/include/ocilibcpp/types.hpp index 0ed3293a..ee1aefb5 100644 --- a/include/ocilibcpp/types.hpp +++ b/include/ocilibcpp/types.hpp @@ -20,6 +20,8 @@ #pragma once +#include +#include #include #include "ocilibcpp/core.hpp" From ed2b47c452a970032ddcd77867315ccbd2dbbf30 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 18:58:39 +0200 Subject: [PATCH 23/62] added namepace qualification when referencing librry types from the ocilib::support namespace --- .../ocilibcpp/detail/support/BindArray.hpp | 16 +++++----- .../ocilibcpp/detail/support/BindObject.hpp | 4 +-- .../detail/support/BindObjectAdaptor.hpp | 2 +- .../ocilibcpp/detail/support/BindResolver.hpp | 30 +++++++++---------- .../detail/support/BindTypeAdaptor.hpp | 2 +- .../ocilibcpp/detail/support/BindsHolder.hpp | 2 +- include/ocilibcpp/support.hpp | 22 +++++++------- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/include/ocilibcpp/detail/support/BindArray.hpp b/include/ocilibcpp/detail/support/BindArray.hpp index 84586247..625cbd99 100644 --- a/include/ocilibcpp/detail/support/BindArray.hpp +++ b/include/ocilibcpp/detail/support/BindArray.hpp @@ -28,7 +28,7 @@ namespace ocilib { namespace support { - inline BindArray::BindArray(const Statement& statement, const ostring& name, unsigned int mode) : BindObject(statement, name, mode), _object(nullptr) + inline BindArray::BindArray(const ocilib::Statement& statement, const ostring& name, unsigned int mode) : BindObject(statement, name, mode), _object(nullptr) { } @@ -79,7 +79,7 @@ namespace ocilib template - BindArray::BindArrayObject::BindArrayObject(const Statement& statement, const ostring& name, ObjectVector& vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize) + BindArray::BindArrayObject::BindArrayObject(const ocilib::Statement& statement, const ostring& name, ObjectVector& vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize) : _statement(statement), _name(name), _vector(vector), _data(nullptr), _isPlSqlTable(isPlSqlTable), _mode(mode), _elemCount(BindArrayObject::GetSize()), _elemSize(elemSize) { AllocData(); @@ -100,7 +100,7 @@ namespace ocilib } template<> - inline void BindArray::BindArrayObject::AllocData() + inline void BindArray::BindArrayObject::AllocData() { const size_t count = _elemSize * _elemCount; @@ -110,7 +110,7 @@ namespace ocilib } template<> - inline void BindArray::BindArrayObject ::AllocData() + inline void BindArray::BindArrayObject ::AllocData() { const size_t count = _elemSize * _elemCount; @@ -140,7 +140,7 @@ namespace ocilib } template<> - inline void BindArray::BindArrayObject::SetInData() + inline void BindArray::BindArrayObject::SetInData() { std::vector::iterator it, it_end; @@ -156,7 +156,7 @@ namespace ocilib } template<> - inline void BindArray::BindArrayObject::SetInData() + inline void BindArray::BindArrayObject::SetInData() { std::vector::iterator it, it_end; @@ -191,7 +191,7 @@ namespace ocilib } template<> - inline void BindArray::BindArrayObject::SetOutData() + inline void BindArray::BindArrayObject::SetOutData() { std::vector::iterator it, it_end; @@ -209,7 +209,7 @@ namespace ocilib } template<> - inline void BindArray::BindArrayObject::SetOutData() + inline void BindArray::BindArrayObject::SetOutData() { std::vector::iterator it, it_end; diff --git a/include/ocilibcpp/detail/support/BindObject.hpp b/include/ocilibcpp/detail/support/BindObject.hpp index 5bc04650..717228cc 100644 --- a/include/ocilibcpp/detail/support/BindObject.hpp +++ b/include/ocilibcpp/detail/support/BindObject.hpp @@ -28,7 +28,7 @@ namespace ocilib { namespace support { - inline BindObject::BindObject(const Statement& statement, const ostring& name, unsigned int mode) : _statement(statement), _name(name), _mode(mode) + inline BindObject::BindObject(const ocilib::Statement& statement, const ostring& name, unsigned int mode) : _statement(statement), _name(name), _mode(mode) { } @@ -41,7 +41,7 @@ namespace ocilib return _name; } - inline Statement BindObject::GetStatement() const + inline ocilib::Statement BindObject::GetStatement() const { return _statement; } diff --git a/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp b/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp index 5f251c10..014b0e6a 100644 --- a/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp +++ b/include/ocilibcpp/detail/support/BindObjectAdaptor.hpp @@ -60,7 +60,7 @@ namespace ocilib } template - BindObjectAdaptor::BindObjectAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object, unsigned int size) : + BindObjectAdaptor::BindObjectAdaptor(const ocilib::Statement& statement, const ostring& name, unsigned int mode, ObjectType& object, unsigned int size) : BindObject(statement, name, mode), _object(object), _data(core::OnAllocate(new NativeType[size + 1], size + 1)), diff --git a/include/ocilibcpp/detail/support/BindResolver.hpp b/include/ocilibcpp/detail/support/BindResolver.hpp index b9493916..5a74be4e 100644 --- a/include/ocilibcpp/detail/support/BindResolver.hpp +++ b/include/ocilibcpp/detail/support/BindResolver.hpp @@ -64,20 +64,20 @@ namespace ocilib template<> struct BindResolver : BindResolverScalarType {}; template<> struct BindResolver : BindResolverScalarType {}; template<> struct BindResolver : BindResolverScalarType {}; - template<> struct BindResolver : BindResolverType {}; - template<> struct BindResolver : BindResolverType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; - template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverType {}; + template<> struct BindResolver : BindResolverType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; + template<> struct BindResolver : BindResolverHandleType {}; } } diff --git a/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp b/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp index 9b0cd07a..6cdb5af7 100644 --- a/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp +++ b/include/ocilibcpp/detail/support/BindTypeAdaptor.hpp @@ -45,7 +45,7 @@ namespace ocilib } template - BindTypeAdaptor::BindTypeAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object) : + BindTypeAdaptor::BindTypeAdaptor(const ocilib::Statement& statement, const ostring& name, unsigned int mode, ObjectType& object) : BindObject(statement, name, mode), _object(object), _data(core::OnAllocate(new NativeType)) diff --git a/include/ocilibcpp/detail/support/BindsHolder.hpp b/include/ocilibcpp/detail/support/BindsHolder.hpp index 0f4626fa..86bbbd38 100644 --- a/include/ocilibcpp/detail/support/BindsHolder.hpp +++ b/include/ocilibcpp/detail/support/BindsHolder.hpp @@ -26,7 +26,7 @@ namespace ocilib { namespace support { - inline BindsHolder::BindsHolder(const Statement& statement) : _statement(statement) + inline BindsHolder::BindsHolder(const ocilib::Statement& statement) : _statement(statement) { } diff --git a/include/ocilibcpp/support.hpp b/include/ocilibcpp/support.hpp index 68923fcc..6840a787 100644 --- a/include/ocilibcpp/support.hpp +++ b/include/ocilibcpp/support.hpp @@ -37,13 +37,13 @@ namespace ocilib { public: - BindObject(const Statement& statement, const ostring& name, unsigned int mode); + BindObject(const ocilib::Statement& statement, const ostring& name, unsigned int mode); virtual ~BindObject() noexcept; ostring GetName() const; - Statement GetStatement() const; + ocilib::Statement GetStatement() const; unsigned int GetMode() const; @@ -52,7 +52,7 @@ namespace ocilib protected: - const Statement& _statement; + const ocilib::Statement& _statement; ostring _name; unsigned int _mode; }; @@ -61,7 +61,7 @@ namespace ocilib { public: - BindArray(const Statement& statement, const ostring& name, unsigned int mode); + BindArray(const ocilib::Statement& statement, const ostring& name, unsigned int mode); virtual ~BindArray() noexcept; template @@ -99,7 +99,7 @@ namespace ocilib typedef std::vector ObjectVector; typedef typename BindResolver::OutputType NativeType; - BindArrayObject(const Statement& statement, const ostring& name, ObjectVector& vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize); + BindArrayObject(const ocilib::Statement& statement, const ostring& name, ObjectVector& vector, bool isPlSqlTable, unsigned int mode, unsigned int elemSize); virtual ~BindArrayObject() noexcept; void SetInData() override; void SetOutData() override; @@ -116,7 +116,7 @@ namespace ocilib void AllocData(); void FreeData() const; - const Statement& _statement; + const ocilib::Statement& _statement; ostring _name; ObjectVector& _vector; NativeType* _data; @@ -132,7 +132,7 @@ namespace ocilib template class BindObjectAdaptor : public BindObject { - friend class Statement; + friend class ocilib::Statement; public: @@ -144,7 +144,7 @@ namespace ocilib void SetInData() override; void SetOutData() override; - BindObjectAdaptor(const Statement& statement, const ostring& name, unsigned int mode, ObjectType& object, unsigned int size); + BindObjectAdaptor(const ocilib::Statement& statement, const ostring& name, unsigned int mode, ObjectType& object, unsigned int size); virtual ~BindObjectAdaptor() noexcept; private: @@ -157,7 +157,7 @@ namespace ocilib template class BindTypeAdaptor : public BindObject { - friend class Statement; + friend class ocilib::Statement; public: @@ -182,7 +182,7 @@ namespace ocilib { public: - BindsHolder(const Statement& statement); + BindsHolder(const ocilib::Statement& statement); ~BindsHolder() noexcept; void Clear(); @@ -195,7 +195,7 @@ namespace ocilib private: std::vector _bindObjects; - const Statement& _statement; + const ocilib::Statement& _statement; }; } } From a65ca7a74de2a95c69c3ab8ca071becb11f3acc9 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 19:38:51 +0200 Subject: [PATCH 24/62] re-disabled some resharper code analysis rules per file as code base must retain C++03 compatibility --- include/ocilib.hpp | 2 +- include/ocilibcpp/config.hpp | 2 ++ include/ocilibcpp/core.hpp | 7 +++++++ include/ocilibcpp/detail/Collection.hpp | 2 ++ .../ocilibcpp/detail/CollectionElement.hpp | 2 ++ .../ocilibcpp/detail/CollectionIterator.hpp | 2 ++ include/ocilibcpp/detail/Connection.hpp | 5 +++++ include/ocilibcpp/detail/Dequeue.hpp | 4 ++++ include/ocilibcpp/detail/Enqueue.hpp | 2 ++ include/ocilibcpp/detail/Environment.hpp | 4 ++++ include/ocilibcpp/detail/File.hpp | 3 +++ include/ocilibcpp/detail/Interval.hpp | 3 +++ include/ocilibcpp/detail/Lob.hpp | 6 ++++++ include/ocilibcpp/detail/Message.hpp | 4 ++++ include/ocilibcpp/detail/Object.hpp | 4 ++++ include/ocilibcpp/detail/Pool.hpp | 4 ++++ include/ocilibcpp/detail/Reference.hpp | 3 +++ include/ocilibcpp/detail/Statement.hpp | 21 ++++++++++++++++--- include/ocilibcpp/detail/Timestamp.hpp | 3 +++ .../ocilibcpp/detail/core/ConcurrentList.hpp | 5 +++++ .../ocilibcpp/detail/core/ConcurrentMap.hpp | 3 +++ include/ocilibcpp/detail/core/Flags.hpp | 2 ++ .../ocilibcpp/detail/core/HandleHolder.hpp | 2 ++ include/ocilibcpp/detail/core/Lockable.hpp | 5 +++++ include/ocilibcpp/detail/core/Utils.hpp | 3 +++ .../ocilibcpp/detail/support/BindObject.hpp | 4 +++- include/ocilibcpp/support.hpp | 6 ++++++ include/ocilibcpp/types.hpp | 6 ++++++ 28 files changed, 114 insertions(+), 5 deletions(-) diff --git a/include/ocilib.hpp b/include/ocilib.hpp index f415e57f..bf07a926 100644 --- a/include/ocilib.hpp +++ b/include/ocilib.hpp @@ -120,7 +120,7 @@ namespace ocilib #include "ocilibcpp/detail/core/SmartHandle.hpp" #include "ocilibcpp/detail/core/MemoryDebugInfo.hpp" -/* Including supoprt implementations */ +/* Including support implementations */ #include "ocilibcpp/detail/support/BindResolver.hpp" #include "ocilibcpp/detail/support/BindObject.hpp" diff --git a/include/ocilibcpp/config.hpp b/include/ocilibcpp/config.hpp index c3cfd4da..311d6f04 100644 --- a/include/ocilibcpp/config.hpp +++ b/include/ocilibcpp/config.hpp @@ -23,6 +23,8 @@ #include #include +// ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage + /* Including C API declarations */ extern "C" { diff --git a/include/ocilibcpp/core.hpp b/include/ocilibcpp/core.hpp index fbd8e309..5ea1b91f 100644 --- a/include/ocilibcpp/core.hpp +++ b/include/ocilibcpp/core.hpp @@ -25,6 +25,13 @@ #include "ocilibcpp/config.hpp" +// ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage +// ReSharper disable CppClangTidyHicppSpecialMemberFunctions +// ReSharper disable CppClangTidyCppcoreguidelinesSpecialMemberFunctions +// ReSharper disable CppClangTidyModernizeUseNodiscard +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/Collection.hpp b/include/ocilibcpp/detail/Collection.hpp index d5d80b6c..dea66e7a 100644 --- a/include/ocilibcpp/detail/Collection.hpp +++ b/include/ocilibcpp/detail/Collection.hpp @@ -22,6 +22,8 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyMiscMisplacedConst + namespace ocilib { diff --git a/include/ocilibcpp/detail/CollectionElement.hpp b/include/ocilibcpp/detail/CollectionElement.hpp index 88523e33..6ff0b4b6 100644 --- a/include/ocilibcpp/detail/CollectionElement.hpp +++ b/include/ocilibcpp/detail/CollectionElement.hpp @@ -22,6 +22,8 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment + namespace ocilib { diff --git a/include/ocilibcpp/detail/CollectionIterator.hpp b/include/ocilibcpp/detail/CollectionIterator.hpp index 14e08ed2..9b1848ba 100644 --- a/include/ocilibcpp/detail/CollectionIterator.hpp +++ b/include/ocilibcpp/detail/CollectionIterator.hpp @@ -22,6 +22,8 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyCertOop54Cpp + namespace ocilib { diff --git a/include/ocilibcpp/detail/Connection.hpp b/include/ocilibcpp/detail/Connection.hpp index 2e2b790e..43446d00 100644 --- a/include/ocilibcpp/detail/Connection.hpp +++ b/include/ocilibcpp/detail/Connection.hpp @@ -22,6 +22,11 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault +// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam +// ReSharper disable CppClangTidyHicppUseEmplace + namespace ocilib { diff --git a/include/ocilibcpp/detail/Dequeue.hpp b/include/ocilibcpp/detail/Dequeue.hpp index d6497779..00787534 100644 --- a/include/ocilibcpp/detail/Dequeue.hpp +++ b/include/ocilibcpp/detail/Dequeue.hpp @@ -22,6 +22,10 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto +// ReSharper disable CppClangTidyMiscMisplacedConst + namespace ocilib { diff --git a/include/ocilibcpp/detail/Enqueue.hpp b/include/ocilibcpp/detail/Enqueue.hpp index 5ed4a760..bb315e64 100644 --- a/include/ocilibcpp/detail/Enqueue.hpp +++ b/include/ocilibcpp/detail/Enqueue.hpp @@ -22,6 +22,8 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyMiscMisplacedConst + namespace ocilib { diff --git a/include/ocilibcpp/detail/Environment.hpp b/include/ocilibcpp/detail/Environment.hpp index d451dfd7..cba8032f 100644 --- a/include/ocilibcpp/detail/Environment.hpp +++ b/include/ocilibcpp/detail/Environment.hpp @@ -22,6 +22,10 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto + namespace ocilib { diff --git a/include/ocilibcpp/detail/File.hpp b/include/ocilibcpp/detail/File.hpp index e1e13a8b..1af36d1b 100644 --- a/include/ocilibcpp/detail/File.hpp +++ b/include/ocilibcpp/detail/File.hpp @@ -22,6 +22,9 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault + namespace ocilib { diff --git a/include/ocilibcpp/detail/Interval.hpp b/include/ocilibcpp/detail/Interval.hpp index b829b4a8..b81780a9 100644 --- a/include/ocilibcpp/detail/Interval.hpp +++ b/include/ocilibcpp/detail/Interval.hpp @@ -22,6 +22,9 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault + namespace ocilib { diff --git a/include/ocilibcpp/detail/Lob.hpp b/include/ocilibcpp/detail/Lob.hpp index 0a1d0cd5..507ccc6c 100644 --- a/include/ocilibcpp/detail/Lob.hpp +++ b/include/ocilibcpp/detail/Lob.hpp @@ -22,6 +22,12 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto +// ReSharper disable CppClangTidyMiscMisplacedConst + namespace ocilib { diff --git a/include/ocilibcpp/detail/Message.hpp b/include/ocilibcpp/detail/Message.hpp index 71f0627b..8d58cd49 100644 --- a/include/ocilibcpp/detail/Message.hpp +++ b/include/ocilibcpp/detail/Message.hpp @@ -22,6 +22,10 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto +// ReSharper disable CppClangTidyMiscMisplacedConst + namespace ocilib { diff --git a/include/ocilibcpp/detail/Object.hpp b/include/ocilibcpp/detail/Object.hpp index 532a7041..db5d46a6 100644 --- a/include/ocilibcpp/detail/Object.hpp +++ b/include/ocilibcpp/detail/Object.hpp @@ -22,6 +22,10 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault +// ReSharper disable CppClangTidyMiscMisplacedConst + namespace ocilib { diff --git a/include/ocilibcpp/detail/Pool.hpp b/include/ocilibcpp/detail/Pool.hpp index fd21d01c..fcf386fe 100644 --- a/include/ocilibcpp/detail/Pool.hpp +++ b/include/ocilibcpp/detail/Pool.hpp @@ -22,6 +22,10 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault +// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam + namespace ocilib { diff --git a/include/ocilibcpp/detail/Reference.hpp b/include/ocilibcpp/detail/Reference.hpp index 8eb10e2b..bfb0ca14 100644 --- a/include/ocilibcpp/detail/Reference.hpp +++ b/include/ocilibcpp/detail/Reference.hpp @@ -22,6 +22,9 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault + namespace ocilib { diff --git a/include/ocilibcpp/detail/Statement.hpp b/include/ocilibcpp/detail/Statement.hpp index b63a9b4f..6323c52a 100644 --- a/include/ocilibcpp/detail/Statement.hpp +++ b/include/ocilibcpp/detail/Statement.hpp @@ -22,9 +22,24 @@ #include "ocilibcpp/types.hpp" -// ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam -// ReSharper disable CppClangTidyHicppUseEqualsDefault - + // ReSharper disable CppUseAuto + // ReSharper disable CppParameterMayBeConst + // ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage + // ReSharper disable CppClangTidyModernizeReturnBracedInitList + // ReSharper disable CppClangTidyModernizePassByValue + // ReSharper disable CppClangTidyHicppUseAuto + // ReSharper disable CppClangTidyModernizeUseAuto + // ReSharper disable CppClangTidyReadabilityInconsistentDeclarationParameterName + // ReSharper disable CppClangTidyPerformanceUnnecessaryValueParam + // ReSharper disable CppClangTidyHicppUseEqualsDefault + // ReSharper disable CppClangTidyModernizeLoopConvert + // ReSharper disable CppClangTidyModernizeUseEmplace + // ReSharper disable CppClangTidyModernizeUseEqualsDefault + // ReSharper disable CppClangTidyHicppUseEmplace + // ReSharper disable CppClangTidyCertOop54Cpp + // ReSharper disable CppClangTidyMiscMisplacedConst + // ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment + namespace ocilib { diff --git a/include/ocilibcpp/detail/Timestamp.hpp b/include/ocilibcpp/detail/Timestamp.hpp index 6d47905a..15085f54 100644 --- a/include/ocilibcpp/detail/Timestamp.hpp +++ b/include/ocilibcpp/detail/Timestamp.hpp @@ -22,6 +22,9 @@ #include "ocilibcpp/types.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault + namespace ocilib { diff --git a/include/ocilibcpp/detail/core/ConcurrentList.hpp b/include/ocilibcpp/detail/core/ConcurrentList.hpp index c9bd4bc3..ed2b3d40 100644 --- a/include/ocilibcpp/detail/core/ConcurrentList.hpp +++ b/include/ocilibcpp/detail/core/ConcurrentList.hpp @@ -24,6 +24,11 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/core/ConcurrentMap.hpp b/include/ocilibcpp/detail/core/ConcurrentMap.hpp index 633c0312..1351b741 100644 --- a/include/ocilibcpp/detail/core/ConcurrentMap.hpp +++ b/include/ocilibcpp/detail/core/ConcurrentMap.hpp @@ -22,6 +22,9 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/core/Flags.hpp b/include/ocilibcpp/detail/core/Flags.hpp index 7c69d9d0..315d29c2 100644 --- a/include/ocilibcpp/detail/core/Flags.hpp +++ b/include/ocilibcpp/detail/core/Flags.hpp @@ -22,6 +22,8 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyCertOop54Cpp + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/core/HandleHolder.hpp b/include/ocilibcpp/detail/core/HandleHolder.hpp index d19682ad..75d7087c 100644 --- a/include/ocilibcpp/detail/core/HandleHolder.hpp +++ b/include/ocilibcpp/detail/core/HandleHolder.hpp @@ -22,6 +22,8 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyBugproneUnhandledSelfAssignment + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/core/Lockable.hpp b/include/ocilibcpp/detail/core/Lockable.hpp index d32679ef..a34e2c42 100644 --- a/include/ocilibcpp/detail/core/Lockable.hpp +++ b/include/ocilibcpp/detail/core/Lockable.hpp @@ -22,6 +22,11 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/core/Utils.hpp b/include/ocilibcpp/detail/core/Utils.hpp index 6291075b..1aef0255 100644 --- a/include/ocilibcpp/detail/core/Utils.hpp +++ b/include/ocilibcpp/detail/core/Utils.hpp @@ -22,6 +22,9 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyHicppUseAuto +// ReSharper disable CppClangTidyModernizeUseAuto + namespace ocilib { namespace core diff --git a/include/ocilibcpp/detail/support/BindObject.hpp b/include/ocilibcpp/detail/support/BindObject.hpp index 717228cc..aa5ce7ad 100644 --- a/include/ocilibcpp/detail/support/BindObject.hpp +++ b/include/ocilibcpp/detail/support/BindObject.hpp @@ -22,7 +22,9 @@ #include "ocilibcpp/support.hpp" - // ReSharper disable CppClangTidyModernizePassByValue +// ReSharper disable CppClangTidyModernizePassByValue +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyModernizeUseEqualsDefault namespace ocilib { diff --git a/include/ocilibcpp/support.hpp b/include/ocilibcpp/support.hpp index 6840a787..d44b238d 100644 --- a/include/ocilibcpp/support.hpp +++ b/include/ocilibcpp/support.hpp @@ -22,6 +22,12 @@ #include "ocilibcpp/core.hpp" +// ReSharper disable CppClangTidyModernizeUseNodiscard +// ReSharper disable CppClangTidyHicppUseEqualsDefault +// ReSharper disable CppClangTidyHicppSpecialMemberFunctions +// ReSharper disable CppClangTidyCppcoreguidelinesSpecialMemberFunctions +// ReSharper disable CppClangTidyModernizePassByValue + namespace ocilib { namespace support diff --git a/include/ocilibcpp/types.hpp b/include/ocilibcpp/types.hpp index ee1aefb5..817a7034 100644 --- a/include/ocilibcpp/types.hpp +++ b/include/ocilibcpp/types.hpp @@ -27,6 +27,12 @@ #include "ocilibcpp/core.hpp" #include "ocilibcpp/support.hpp" +// ReSharper disable CppClangTidyCppcoreguidelinesMacroUsage +// ReSharper disable CppClangTidyModernizeUseNodiscard +// ReSharper disable CppClangTidyHicppSpecialMemberFunctions +// ReSharper disable CppClangTidyReadabilityRedundantDeclaration +// ReSharper disable CppFunctionIsNotImplemented + namespace ocilib { From 4c4318e23c14c901c8ec8653f4fe3e91f418ebf3 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Sun, 10 May 2020 19:40:29 +0200 Subject: [PATCH 25/62] updated nuspec with new headers --- nuget/ocilib.nuspec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nuget/ocilib.nuspec b/nuget/ocilib.nuspec index ae043ecb..4d79814a 100644 --- a/nuget/ocilib.nuspec +++ b/nuget/ocilib.nuspec @@ -34,7 +34,12 @@ It requires Oracle Client libraries (Regular or instant client). - + + + + + + From 0eac611d8d6ba0ebcc367a226fc0a3894120dff5 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 08:57:33 +0200 Subject: [PATCH 26/62] fixed doxygen documentation --- doxygen/Doxyfile.dox | 7 ++- include/ocilib.h | 17 +++++++ include/ocilib.hpp | 93 ++++++++++++++++++----------------- include/ocilibc/api.h | 77 +++++++++++++++-------------- include/ocilibc/compat.h | 2 +- include/ocilibc/config.h | 55 ++++++++++----------- include/ocilibc/types.h | 10 ++-- include/ocilibcpp/core.hpp | 36 +++++++++++++- include/ocilibcpp/support.hpp | 29 ++++++++++- 9 files changed, 207 insertions(+), 119 deletions(-) diff --git a/doxygen/Doxyfile.dox b/doxygen/Doxyfile.dox index 3f5725aa..84a844b5 100644 --- a/doxygen/Doxyfile.dox +++ b/doxygen/Doxyfile.dox @@ -817,7 +817,12 @@ INPUT = Introduction.txt \ Installation.txt \ DataTypes.txt \ ../ \ - ../include + ../include \ + ../include/ocilibc \ + ../include/ocilibcpp \ + ../include/ocilibcpp/detail \ + ../include/ocilibcpp/detail/core \ + ../include/ocilibcpp/detail/support # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/include/ocilib.h b/include/ocilib.h index fd4541d9..59bf8d04 100644 --- a/include/ocilib.h +++ b/include/ocilib.h @@ -38,6 +38,18 @@ extern "C" { #endif /* __cplusplus */ +/** + * @defgroup OcilibCApi C API + * @{ + * + */ + +/** +* @defgroup OcilibCApiSupportedCharsets Character sets +* @defgroup OcilibCApiDatatypes Data types +* @defgroup OcilibCApiEnvironmentVariables Environment Variables +*/ + #include "ocilibc/config.h" #include "ocilibc/types.h" #include "ocilibc/api.h" @@ -47,4 +59,9 @@ extern "C" { } #endif +/** + * @} OcilibCApi + */ + + #endif /* OCILIB_H_INCLUDED */ diff --git a/include/ocilib.hpp b/include/ocilib.hpp index bf07a926..55641fee 100644 --- a/include/ocilib.hpp +++ b/include/ocilib.hpp @@ -34,6 +34,7 @@ * @brief OCILIB ++ Namespace * */ + namespace ocilib { @@ -86,7 +87,52 @@ namespace ocilib * - Each C OCILIB object handle has its C++ class counter part. * - The whole OCILIB C Documentation (concepts, use cases, features) is still valid for OCILIB++ * - * @} + * @} OcilibCppApiOverview + */ + +/** + * @defgroup OcilibCppApiMainDemoApplication OCILIB main C++ demo application code + * @{ + * + * Main C++ demo source + * @include ocilib_demo.cpp + * + * @} OcilibCppApiMainDemoApplication + */ + + /** + * @defgroup OcilibCppApiDemoListApplication Some OCILIB C++ sample codes + * @{ + * + * Here are some C++ samples code. More samples can be found under the demo folder of ocilib packages. + * + * @par Fetching data + * @include fetch.cpp + * + * @par Binding vectors + * @include array.cpp + * + * @par Using collections + * @include coll.cpp + * + * @par Using connection pools + * @include pool.cpp + * + * @par Oracle 12c Implicit resultsets + * @include implicit_resultset.cpp + * + * @par Using Oracle objects + * @include object.cpp + * + * @par Database notifications + * @include notification.cpp + * + * @} OcilibCppApiDemoListApplication + */ + + /** + * + * @} OcilibCppApi */ } @@ -167,51 +213,6 @@ namespace ocilib #include "ocilibcpp/detail/Queue.hpp" #include "ocilibcpp/detail/QueueTable.hpp" -/** - * @defgroup OcilibCppApiMainDemoApplication OCILIB main C++ demo application code - * @{ - * - * Main C++ demo source - * @include ocilib_demo.cpp - * - * @} - */ - - /** - * @defgroup OcilibCppApiDemoListApplication Some OCILIB C++ sample codes - * @{ - * - * Here are some C++ samples code. More samples can be found under the demo folder of ocilib packages. - * - * @par Fetching data - * @include fetch.cpp - * - * @par Binding vectors - * @include array.cpp - * - * @par Using collections - * @include coll.cpp - * - * @par Using connection pools - * @include pool.cpp - * - * @par Oracle 12c Implicit resultsets - * @include implicit_resultset.cpp - * - * @par Using Oracle objects - * @include object.cpp - * - * @par Database notifications - * @include notification.cpp - * - * @} - */ - - /** - * - * @} - */ - #endif diff --git a/include/ocilibc/api.h b/include/ocilibc/api.h index b79059cf..0073d981 100644 --- a/include/ocilibc/api.h +++ b/include/ocilibc/api.h @@ -36,6 +36,12 @@ #include "ocilibc/types.h" +/** + * @addtogroup OcilibCApi + * @{ + * + */ + /** * @defgroup OcilibCApiInitialization Initializing the library * @{ @@ -269,7 +275,7 @@ OCI_EXPORT boolean OCI_API OCI_SetHAHandler ); /** - * @} + * @} OcilibCApiInitialization */ /** @@ -469,7 +475,7 @@ OCI_EXPORT const otext * OCI_API OCI_ErrorGetLocation ); /** - * @} + * @} OcilibCApiErrorHandling */ /** @@ -1392,7 +1398,7 @@ OCI_EXPORT unsigned int OCI_API OCI_GetMaxCursors ); /** - * @} + * @} OcilibCApiConnections */ /** @@ -1718,7 +1724,7 @@ OCI_EXPORT boolean OCI_API OCI_PoolSetStatementCacheSize ); /** - * @} + * @} OcilibCApiPools */ /** @@ -1990,7 +1996,7 @@ OCI_EXPORT unsigned int OCI_API OCI_TransactionGetTimeout ); /** - * @} + * @} OcilibCApiTransactions */ /** @@ -2323,7 +2329,7 @@ OCI_EXPORT const otext * OCI_API OCI_GetSQLVerb ); /** - * @} + * @} OcilibCApiStatements */ /** @@ -4265,7 +4271,7 @@ OCI_EXPORT unsigned int OCI_API OCI_BindGetAllocationMode ); /** - * @} + * @} OcilibCApiBinding */ /** @@ -6175,7 +6181,7 @@ OCI_EXPORT unsigned int OCI_API OCI_GetDataLength ); /** - * @} + * @} OcilibCApiFetching */ /** @@ -6286,7 +6292,7 @@ OCI_EXPORT const otext * OCI_API OCI_ServerGetOutput ); /** - * @} + * @} OcilibCApiPlSql */ /** @@ -7584,7 +7590,7 @@ OCI_EXPORT boolean OCI_API OCI_ElemSetNull ); /** - * @} + * @} OcilibCApiCollections */ /** @@ -8010,7 +8016,7 @@ OCI_EXPORT boolean OCI_API OCI_RegisterRef ); /** - * @} + * @} OcilibCApiFeatureReturningInto */ /** @@ -8027,7 +8033,7 @@ OCI_EXPORT boolean OCI_API OCI_RegisterRef * @par Example * @include rowid.c * - * @} + * @} OcilibCApiRowIds */ /** @@ -8415,7 +8421,7 @@ OCI_EXPORT OCI_Connection * OCI_API OCI_StatementGetConnection ); /** - * @} + * @} OcilibCApiStatementControl */ /** @@ -9158,7 +9164,7 @@ OCI_EXPORT boolean OCI_API OCI_LobIsRemote ); /** - * @} + * @} OcilibCApiLobs */ /** @@ -9547,7 +9553,7 @@ OCI_EXPORT OCI_Connection * OCI_API OCI_FileGetConnection ); /** - * @} + * @} OcilibCApiFiles */ /** @@ -9722,8 +9728,8 @@ OCI_EXPORT void * OCI_API OCI_LongGetBuffer ); /** -* @} -*/ + * @} OcilibCApiLongs + */ /** * @defgroup OcilibCApiOracleNumber Oracle NUMBER manipulation (optional) @@ -10099,13 +10105,10 @@ OCI_EXPORT int OCI_API OCI_NumberCompare ); /** -* @} -*/ - -/** - * @} + * @} OcilibCApiOracleNumber */ + /** * @defgroup OcilibCApiDatetimes Date/time manipulation * @{ @@ -10614,7 +10617,7 @@ OCI_EXPORT boolean OCI_API OCI_DateFromCTime ); /** - * @} + * @} OcilibCApiDatetimes */ /** @@ -11489,7 +11492,7 @@ OCI_EXPORT boolean OCI_API OCI_IntervalSubtract ); /** - * @} + * @} OcilibCApiTimestamps */ /** @@ -12927,7 +12930,7 @@ OCI_EXPORT boolean OCI_API OCI_RefToText ); /** - * @} + * @} OcilibCApiUserTypes */ /** @@ -12977,7 +12980,7 @@ OCI_EXPORT boolean OCI_API OCI_Break ); /** - * @} + * @} OcilibCApiAbort */ /** @@ -13170,7 +13173,7 @@ OCI_EXPORT OCI_TypeInfo * OCI_API OCI_TypeInfoGetSuperType ); /** - * @} + * @} OcilibCApiMetadata */ /** @@ -13418,7 +13421,7 @@ OCI_EXPORT boolean OCI_DescribeFmt ); /** - * @} + * @} OcilibCApiFormatting */ /** @@ -13710,7 +13713,7 @@ OCI_EXPORT OCI_HashEntry * OCI_API OCI_HashGetEntry ); /** - * @} + * @} OcilibCApiHashTables */ /** @@ -13938,7 +13941,7 @@ OCI_EXPORT void * OCI_API OCI_ThreadKeyGetValue ); /** - * @} + * @} OcilibCApiThreading */ /** @@ -14647,7 +14650,7 @@ OCI_EXPORT unsigned int OCI_API OCI_DirPathGetErrorRow ); /** - * @} + * @} OcilibCApiDirectPath */ /** @@ -16486,7 +16489,7 @@ OCI_EXPORT boolean OCI_API OCI_QueueTableMigrate ); /** - * @} + * @} OcilibCApiAdvancedQueuing */ /** @@ -16873,7 +16876,7 @@ OCI_EXPORT OCI_Subscription * OCI_API OCI_EventGetSubscription ); /** - * @} + * @} OcilibCApiSubscriptions */ /** @@ -17011,7 +17014,7 @@ OCI_EXPORT boolean OCI_API OCI_DatabaseShutdown ); /** - * @} + * @} OcilibCApiInstancesManagement */ /** @@ -17396,7 +17399,7 @@ OCI_EXPORT const void * OCI_API OCI_HandleGetSubscription ); /** - * @} + * @} OcilibCApiRawHandles */ /** @@ -17409,11 +17412,11 @@ OCI_EXPORT const void * OCI_API OCI_HandleGetSubscription * Portable Main demo application source * @include ocilib_demo.c * - * @} + * @} OcilibCApiDemoApplication */ /** -* @} +* @} OcilibCApi */ #endif /* OCILIB_API_H_INCLUDED */ diff --git a/include/ocilibc/compat.h b/include/ocilibc/compat.h index 2f4c166c..7ec81322 100644 --- a/include/ocilibc/compat.h +++ b/include/ocilibc/compat.h @@ -37,7 +37,7 @@ #include "ocilibc/api.h" /** - * @defgroup OcilibCApi C API + * @addtogroup OcilibCApi * @{ * */ diff --git a/include/ocilibc/config.h b/include/ocilibc/config.h index 03e9ab91..ec11cf46 100644 --- a/include/ocilibc/config.h +++ b/include/ocilibc/config.h @@ -35,7 +35,7 @@ #define OCILIB_CONFIG_H_INCLUDED /** - * @defgroup OcilibCApi C API + * @addtogroup OcilibCApi * @{ * */ @@ -147,7 +147,7 @@ #endif /** - * @defgroup OcilibCApiSupportedCharsets Character sets + * @addtogroup OcilibCApiSupportedCharsets * @{ * * OCILIB supports both ANSI and Unicode. @@ -310,19 +310,19 @@ OCI_EXPORT int ociwcscasecmp /* helpers mapping macros */ #ifdef OCI_CHARSET_ANSI - #define ostrdup ocistrdup - #define ostrcpy strcpy - #define ostrncpy strncpy - #define ostrcat strcat - #define ostrncat strncat - #define ostrlen strlen - #define ostrcmp strcmp - #define ostrcasecmp ocistrcasecmp - #define osprintf ocisprintf - #define ostrtol strtol - #define osscanf sscanf - #define otoupper toupper - #define oisdigit isdigit +#define ostrdup ocistrdup +#define ostrcpy strcpy +#define ostrncpy strncpy +#define ostrcat strcat +#define ostrncat strncat +#define ostrlen strlen +#define ostrcmp strcmp +#define ostrcasecmp ocistrcasecmp +#define osprintf ocisprintf +#define ostrtol strtol +#define osscanf sscanf +#define otoupper toupper +#define oisdigit isdigit #else #define ostrdup ociwcsdup #define ostrcpy wcscpy @@ -337,7 +337,6 @@ OCI_EXPORT int ociwcscasecmp #define osscanf swscanf #define otoupper towupper #define oisdigit iswdigit - #endif /* string size macros */ @@ -345,9 +344,13 @@ OCI_EXPORT int ociwcscasecmp #define otextsize(s) (ostrlen(s) * sizeof(otext)) /** - * @} + * @} OcilibCApiSupportedCharsets */ +/** + * @addtogroup OcilibCApiDatatypes + * @{ + /** * @typedef big_int * @@ -384,10 +387,6 @@ typedef unsigned int big_uint; #endif -/** - * @} - */ - /* boolean values */ #ifndef TRUE @@ -399,6 +398,10 @@ typedef unsigned int big_uint; #define boolean int #endif +/** + * @} OcilibCApiDatatypes + */ + /* versions extract macros */ #define OCI_VER_MAJ(v) (unsigned int) ((v)/100) @@ -1216,11 +1219,7 @@ typedef unsigned int big_uint; #define OCI_STRING_FORMAT_NUM_BIN OCI_STRING_FORMAT_NUM_BDOUBLE /** -* @} -*/ - -/** -* @defgroup OcilibCApiEnvironmentVariables Environment Variables +* @addtogroup OcilibCApiEnvironmentVariables * @{ * * Some environment variables can be defined in order to activate specific features @@ -1238,11 +1237,11 @@ typedef unsigned int big_uint; #define VAR_OCILIB_WORKAROUND_UTF16_COLUMN_NAME "OCILIB_WORKAROUND_UTF16_COLUMN_NAME" /** -* @} +* @} OcilibCApiEnvironmentVariables */ /** - * @} + * @} OcilibCApi */ #endif /* OCILIB_CONFIG_H_INCLUDED */ diff --git a/include/ocilibc/types.h b/include/ocilibc/types.h index 1ab55ad1..7fdd2f28 100644 --- a/include/ocilibc/types.h +++ b/include/ocilibc/types.h @@ -37,13 +37,13 @@ #include "ocilibc/config.h" /** - * @defgroup OcilibCApi C API + * @addtogroup OcilibCApi * @{ * */ /** - * @defgroup OcilibCApiDatatypes Data types + * @addtogroup OcilibCApiDatatypes * @{ * * OCILIB implements: @@ -712,7 +712,11 @@ typedef struct OCI_HashEntry } OCI_HashEntry; /** - * @} + * @} OcilibCApiDatatypes + */ + +/** + * @} OcilibCApi */ #endif /* OCILIB_OCILIB_TYPES_H_INCLUDED */ diff --git a/include/ocilibcpp/core.hpp b/include/ocilibcpp/core.hpp index 5ea1b91f..6011f973 100644 --- a/include/ocilibcpp/core.hpp +++ b/include/ocilibcpp/core.hpp @@ -34,6 +34,12 @@ namespace ocilib { + /** + * @namespace ocilib::core + * @brief OCILIB internal core classes + * + */ + namespace core { #ifdef OCILIBPP_HAS_ENABLEIF @@ -85,6 +91,10 @@ namespace ocilib */ Raw MakeRaw(AnyPointer result, unsigned int size); + /** + * @brief Internal usage. + * Determine if the given type is a supported numeric type + */ template struct SupportedNumeric { @@ -178,6 +188,10 @@ namespace ocilib unsigned int _flags; }; + /** + * @brief Internal usage. + * Provide a buffer class with RAII capabilities + */ template< typename T> class ManagedBuffer { @@ -196,6 +210,10 @@ namespace ocilib size_t _size; }; + /** + * @brief Internal usage. + * Locker object + */ class Locker { public: @@ -213,6 +231,10 @@ namespace ocilib MutexHandle _mutex; }; + /** + * @brief Internal usage. + * Base class for types that can be locked + */ class Lockable { public: @@ -230,6 +252,10 @@ namespace ocilib Locker* _locker; }; + /** + * @brief Internal usage. + * Map supporting conccurent access from multiple threads + */ template class ConcurrentMap : public Lockable { @@ -250,6 +276,10 @@ namespace ocilib }; + /** + * @brief Internal usage. + * List supporting conccurent access from multiple threads + */ template class ConcurrentList : public Lockable { @@ -275,6 +305,10 @@ namespace ocilib std::list _list; }; + /** + * @brief Internal usage. + * Interface for handling ownership and relationship of a C API handle + */ class Handle { public: @@ -286,7 +320,7 @@ namespace ocilib }; /** - * @brief + * @brief Internal usage. * Smart pointer class with reference counting for managing OCILIB object handles */ template diff --git a/include/ocilibcpp/support.hpp b/include/ocilibcpp/support.hpp index d44b238d..16ef6cb3 100644 --- a/include/ocilibcpp/support.hpp +++ b/include/ocilibcpp/support.hpp @@ -30,6 +30,12 @@ namespace ocilib { + /** + * @namespace ocilib::support + * @brief OCILIB internal support classes + * + */ + namespace support { /** @@ -38,7 +44,10 @@ namespace ocilib */ template struct BindResolver {}; - + /** + * @brief Internal usage. + * Base class for implementing bind translations for C++ objects and their counter parts in the C API + */ class BindObject { public: @@ -63,6 +72,10 @@ namespace ocilib unsigned int _mode; }; + /** + * @brief Internal usage. + * Class implementing bind translations between C++ vectors and C API arrays + */ class BindArray : public BindObject { public: @@ -135,6 +148,10 @@ namespace ocilib AbstractBindArrayObject* _object; }; + /** + * @brief Internal usage. + * Class implementing bind adapters between C++ class and C API types + */ template class BindObjectAdaptor : public BindObject { @@ -159,7 +176,11 @@ namespace ocilib NativeType* _data; unsigned int _size; }; - + + /** + * @brief Internal usage. + * Class implementing bind adapters between C++ types and C API types when C++ types do not exist in C + */ template class BindTypeAdaptor : public BindObject { @@ -184,6 +205,10 @@ namespace ocilib NativeType* _data; }; + /** + * @brief Internal usage. + * Class owning bind objects allowing to set/get C data prior/after a statement execution + */ class BindsHolder { public: From 1b7fe5777cb8aea5b946d8374a70b6c16eaaeb87 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 14:07:41 +0200 Subject: [PATCH 27/62] Fixed binding native numeric types when using OCI_BAM_INTERNAL --- src/defs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/defs.h b/src/defs.h index cd5ee267..10b3a755 100644 --- a/src/defs.h +++ b/src/defs.h @@ -425,6 +425,7 @@ typedef unsigned short dbtext; \ ( (IS_OCI_NUMBER(type, subtype)) || \ (OCI_CDT_TEXT != (type) && \ + OCI_CDT_NUMERIC != (type) && \ OCI_CDT_RAW != (type) && \ OCI_CDT_BOOLEAN != (type))) From 63851517412b4590fd5ade29f70c334dbb23421a Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 14:07:58 +0200 Subject: [PATCH 28/62] fixed typo --- include/ocilibcpp/core.hpp | 4 ++-- include/ocilibcpp/types.hpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/ocilibcpp/core.hpp b/include/ocilibcpp/core.hpp index 6011f973..80d434da 100644 --- a/include/ocilibcpp/core.hpp +++ b/include/ocilibcpp/core.hpp @@ -254,7 +254,7 @@ namespace ocilib /** * @brief Internal usage. - * Map supporting conccurent access from multiple threads + * Map supporting concurrent access from multiple threads */ template class ConcurrentMap : public Lockable @@ -278,7 +278,7 @@ namespace ocilib /** * @brief Internal usage. - * List supporting conccurent access from multiple threads + * List supporting concurrent access from multiple threads */ template class ConcurrentList : public Lockable diff --git a/include/ocilibcpp/types.hpp b/include/ocilibcpp/types.hpp index 817a7034..71f0b99a 100644 --- a/include/ocilibcpp/types.hpp +++ b/include/ocilibcpp/types.hpp @@ -32,6 +32,8 @@ // ReSharper disable CppClangTidyHicppSpecialMemberFunctions // ReSharper disable CppClangTidyReadabilityRedundantDeclaration // ReSharper disable CppFunctionIsNotImplemented +// ReSharper disable CppClangTidyCppcoreguidelinesSpecialMemberFunctions +// ReSharper disable CppClassCanBeFinal namespace ocilib { From af6892fd2e0e4f44df5e05a9f3a43daff30c17f6 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 14:08:47 +0200 Subject: [PATCH 29/62] Added test suite binding array with internal allocation --- tests/TestArray.cpp | 87 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/tests/TestArray.cpp b/tests/TestArray.cpp index 51b35f03..cd71fd51 100644 --- a/tests/TestArray.cpp +++ b/tests/TestArray.cpp @@ -1,9 +1,9 @@ #include "ocilib_tests.h" -TEST(TestArray, InsertArray) +TEST(TestArray, InsertExternalArray) { - ExecDML(OTEXT("create table TestArrayInsertArray(code int, name varchar2(50))")); - ExecDML(OTEXT("truncate table TestArrayInsertArray(code int, name varchar2(50))")); + ExecDML(OTEXT("create table TestExternalArrayInsertArray(code int, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestExternalArrayInsertArray")); ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); @@ -16,7 +16,7 @@ TEST(TestArray, InsertArray) int tab_int[ARRAY_SIZE]; char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; - ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestArrayInsertArray values(:i, :s)"))); + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestExternalArrayInsertArray values(:i, :s)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); @@ -35,13 +35,13 @@ TEST(TestArray, InsertArray) ASSERT_TRUE(OCI_ConnectionFree(conn)); ASSERT_TRUE(OCI_Cleanup()); - ExecDML(OTEXT("drop table TestArrayInsertArray")); + ExecDML(OTEXT("drop table TestExternalArrayInsertArray")); } -TEST(TestArray, InsertArrayError) +TEST(TestArray, InsertExternalArrayError) { - ExecDML(OTEXT("create table TestArrayInsertArrayError(code int NOT NULL, name varchar2(50))")); - ExecDML(OTEXT("truncate table TestArrayInsertArrayError(code int, name varchar2(50))")); + ExecDML(OTEXT("create table TestExternalArrayInsertArrayError(code int NOT NULL, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestExternalArrayInsertArrayError")); ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); @@ -54,7 +54,7 @@ TEST(TestArray, InsertArrayError) int tab_int[ARRAY_SIZE]; char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; - ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestArrayInsertArrayError values(:i, :s)"))); + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestExternalArrayInsertArrayError values(:i, :s)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); @@ -86,5 +86,72 @@ TEST(TestArray, InsertArrayError) ASSERT_TRUE(OCI_ConnectionFree(conn)); ASSERT_TRUE(OCI_Cleanup()); - ExecDML(OTEXT("drop table TestArrayInsertArrayError")); + ExecDML(OTEXT("drop table TestExternalArrayInsertArrayError")); +} + +TEST(TestArray, InsertInternalArray) +{ + ExecDML(OTEXT("create table TestInternalArrayInsertArray(code int, name varchar2(50), creation date)")); + ExecDML(OTEXT("truncate table TestInternalArrayInsertArray")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_SetBindAllocation(stmt, OCI_BAM_INTERNAL)); + + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestInternalArrayInsertArray values(:i, :s, :d)"))); + ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); + ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", NULL, 0)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", NULL, STRING_SIZE, 0)); + ASSERT_TRUE(OCI_BindArrayOfDates(stmt, ":d", NULL, 0)); + + auto sysdate = OCI_DateCreate(nullptr); + ASSERT_NE(nullptr, sysdate); + + auto tab_int = static_cast(OCI_BindGetData(OCI_GetBind(stmt,1))); + ASSERT_NE(nullptr, tab_int); + auto tab_str = static_cast(OCI_BindGetData(OCI_GetBind(stmt,2))); + ASSERT_NE(nullptr, tab_str); + auto tab_date = static_cast(OCI_BindGetData(OCI_GetBind(stmt,3))); + ASSERT_NE(nullptr, tab_date); + + for (int i = 0; i < ARRAY_SIZE; i++) + { + tab_int[i] = i + 1; + osprintf(tab_str + (i * (STRING_SIZE + 1)), STRING_SIZE, OTEXT("Name %d"), i + 1); + ASSERT_TRUE(OCI_DateAssign(tab_date[i], sysdate)); + } + + ASSERT_TRUE(OCI_Execute(stmt)); + + ASSERT_EQ(ARRAY_SIZE, OCI_GetAffectedRows(stmt)); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, OTEXT("select * from TestInternalArrayInsertArray"))); + + auto rslt = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rslt); + + int count = 0; + while (OCI_FetchNext(rslt)) + { + count++; + ostring str = "Name " + std::to_string(count); + ASSERT_EQ(count, OCI_GetInt(rslt, 1)); + ASSERT_EQ(str, OCI_GetString(rslt, 2)); + ASSERT_EQ(0, OCI_DateCompare(sysdate, OCI_GetDate(rslt, 3))); + } + + ASSERT_EQ(ARRAY_SIZE, count); + + ASSERT_TRUE(OCI_DateFree(sysdate)); + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop table TestInternalArrayInsertArray")); } From 9fe57cbd99a51782f8823767de9965a549045c48 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 14:23:06 +0200 Subject: [PATCH 30/62] added basic test for returning into --- tests/TestReturningInto.cpp | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/TestReturningInto.cpp diff --git a/tests/TestReturningInto.cpp b/tests/TestReturningInto.cpp new file mode 100644 index 00000000..983a396a --- /dev/null +++ b/tests/TestReturningInto.cpp @@ -0,0 +1,48 @@ +#include "ocilib_tests.h" + + +TEST(TestReturningInto, RegisterInt) +{ + ExecDML(OTEXT("create table TestReturningIntoRegisterInt(code int, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestReturningIntoRegisterInt")); + ExecDML(OTEXT("insert into TestReturningIntoRegisterInt values (1, 'name 1')")); + ExecDML(OTEXT("insert into TestReturningIntoRegisterInt values (2, 'name 2')")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("update TestReturningIntoRegisterInt set code = code + 10, name = name || ' updated' returning code into :code"))); + ASSERT_TRUE(OCI_RegisterInt(stmt, ":code")); + ASSERT_TRUE(OCI_Execute(stmt)); + + auto rslt = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rslt); + + int index = 0; + while (OCI_FetchNext(rslt)) + { + index++; + ASSERT_EQ(index + 10, OCI_GetInt(rslt, 1)); + } + + ASSERT_EQ(2, OCI_GetAffectedRows(stmt)); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, OTEXT("select count(*) from TestReturningIntoRegisterInt where name like '%updated'"))); + + rslt = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rslt); + + ASSERT_TRUE(OCI_FetchNext(rslt)); + ASSERT_EQ(2, OCI_GetInt(rslt, 1)); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop table TestReturningIntoRegisterInt")); +} \ No newline at end of file From 1a791e7bfec589c2289a4c927b198fa71d665caf Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 15:39:34 +0200 Subject: [PATCH 31/62] Fixed OCI_FetchSeek() with OCI_SFD_RELATIVE mode Refactored and renamed internal Fetch methods --- src/resultset.c | 93 ++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 59 deletions(-) diff --git a/src/resultset.c b/src/resultset.c index 51adc40d..17072344 100644 --- a/src/resultset.c +++ b/src/resultset.c @@ -348,10 +348,10 @@ boolean ResultsetExpandStrings } /* --------------------------------------------------------------------------------------------- * - * FetchPieces + * ResultsetFetchPieces * --------------------------------------------------------------------------------------------- */ -boolean FetchPieces +boolean ResultsetFetchPieces ( OCI_Resultset *rs ) @@ -567,10 +567,10 @@ boolean FetchPieces } /* --------------------------------------------------------------------------------------------- * - * ClearFetchedObjectInstances + * ResultsetClearFetchedObjectInstances * --------------------------------------------------------------------------------------------- */ -boolean ClearFetchedObjectInstances(OCI_Resultset *rs) +boolean ResultsetClearFetchedObjectInstances(OCI_Resultset *rs) { ENTER_FUNC ( @@ -603,10 +603,10 @@ boolean ClearFetchedObjectInstances(OCI_Resultset *rs) } /* --------------------------------------------------------------------------------------------- * - * FetchData + * ResultsetFetchData * --------------------------------------------------------------------------------------------- */ -boolean FetchData +boolean ResultsetFetchData ( OCI_Resultset *rs, int mode, @@ -623,7 +623,7 @@ boolean FetchData /* let's initialize the success flag to FALSE until the process completes */ - CHECK(ClearFetchedObjectInstances(rs)) + CHECK(ResultsetClearFetchedObjectInstances(rs)) /* internal fetch */ @@ -657,7 +657,7 @@ boolean FetchData else if (OCI_NEED_DATA == rs->fetch_status) { /* need to do a piecewise fetch */ - CHECK(FetchPieces(rs)) + CHECK(ResultsetFetchPieces(rs)) } /* check string buffer for Unicode builds that need buffer expansion */ @@ -734,10 +734,10 @@ boolean FetchData } /* --------------------------------------------------------------------------------------------- * - * FetchCustom + * ResultsetFetchCustom * --------------------------------------------------------------------------------------------- */ -boolean FetchCustom +boolean ResultsetFetchCustom ( OCI_Resultset *rs, int mode, @@ -752,67 +752,42 @@ boolean FetchCustom CHECK_PTR(OCI_IPC_RESULTSET, rs) - boolean result = FALSE; - switch (mode) { case OCI_SFD_RELATIVE: { - if (((offset > 0) && (rs->eof)) || - ((offset < 0) && (rs->bof)) || - (offset == 0)) - { - result = FALSE; - } - else - { - const int offset_save = offset; - - offset = offset - (int) (rs->row_fetched + rs->row_cur); - rs->row_cur = 1; + const boolean isOutOfBound = (offset > 0) && (rs->eof) || + (offset < 0) && (rs->bof) || + (offset == 0); - result = FetchData(rs, mode, offset); - - if (result) - { - rs->row_abs += offset_save; - } - } + CHECK(isOutOfBound == FALSE) + offset += rs->row_abs; break; } case OCI_SFD_ABSOLUTE: { - if (offset == 0) - { - result = FALSE; - } - else - { - rs->row_abs = 1; - rs->row_cur = 1; - - result = FetchData(rs, mode, offset); - - if (result) - { - rs->row_abs = offset; - - rs->bof = FALSE; - rs->eof = FALSE; - } - } - + CHECK(offset != 0) break; } default: { - result = FALSE; + CHECK(FALSE) break; } } - SET_RETVAL(result) + rs->row_abs = 1; + rs->row_cur = 1; + + CHECK(ResultsetFetchData(rs, OCI_SFD_ABSOLUTE, offset)) + + rs->row_abs = offset; + + rs->bof = FALSE; + rs->eof = FALSE; + + SET_SUCCESS() EXIT_FUNC() } @@ -918,7 +893,7 @@ boolean ResultsetFree /* free object instances from object cache */ - ClearFetchedObjectInstances(rs); + CHECK(ResultsetClearFetchedObjectInstances(rs)) /* free column pointers */ @@ -993,7 +968,7 @@ boolean ResultsetFetchPrev offset = 1 - (int) (rs->fetch_size + rs->row_fetched); } - CHECK(FetchData(rs, OCI_SFD_RELATIVE, offset)) + CHECK(ResultsetFetchData(rs, OCI_SFD_RELATIVE, offset)) if (rs->fetch_size > rs->row_abs) { @@ -1056,7 +1031,7 @@ boolean ResultsetFetchNext } else { - CHECK(FetchData(rs, OCI_SFD_NEXT, 0)) + CHECK(ResultsetFetchData(rs, OCI_SFD_NEXT, 0)) rs->bof = FALSE; rs->row_cur = 1; @@ -1131,7 +1106,7 @@ boolean ResultsetFetchFirst rs->row_abs = 1; rs->row_cur = 1; - CHECK(FetchData(rs, OCI_SFD_FIRST, 0)) + CHECK(ResultsetFetchData(rs, OCI_SFD_FIRST, 0)) CHECK(!rs->bof) @@ -1173,7 +1148,7 @@ boolean ResultsetFetchLast rs->row_abs = 0; rs->row_cur = 1; - result = FetchData(rs, OCI_SFD_LAST, 0); + result = ResultsetFetchData(rs, OCI_SFD_LAST, 0); if (result) { @@ -1215,7 +1190,7 @@ boolean ResultsetFetchSeek CHECK_SCROLLABLE_CURSOR_ACTIVATED(rs->stmt) CHECK_ENUM_VALUE(mode, SeekModeValues, OTEXT("Fetch Seek Mode")) - CHECK(FetchCustom(rs, (int)mode, offset)) + CHECK(ResultsetFetchCustom(rs, (int)mode, offset)) SET_SUCCESS() From 760aa3c095f7be7f99115b7af678ddcfc836ac0a Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 15:40:09 +0200 Subject: [PATCH 32/62] Add basic test for scrollable cursors --- tests/TestScrollabeCursor.cpp | 65 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 2 + tests/ocilib_tests.vcxproj.filters | 6 +++ 3 files changed, 73 insertions(+) create mode 100644 tests/TestScrollabeCursor.cpp diff --git a/tests/TestScrollabeCursor.cpp b/tests/TestScrollabeCursor.cpp new file mode 100644 index 00000000..ec69dac0 --- /dev/null +++ b/tests/TestScrollabeCursor.cpp @@ -0,0 +1,65 @@ +#include "ocilib_tests.h" + +void TestRow(OCI_Resultset *rslt, unsigned int index) +{ + ASSERT_EQ(index, OCI_GetCurrentRow(rslt)); + ASSERT_EQ(index, OCI_GetInt(rslt, 1)); + ASSERT_EQ(ostring("Row ") + std::to_string(index), ostring(OCI_GetString(rslt, 2))); +} + +TEST(TestScrollableCursor, Fetch) +{ + const unsigned int RowCount = 65; + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_SetFetchMode(stmt, OCI_SFM_SCROLLABLE)); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, OTEXT("select rownum, 'Row ' || rownum from (select 1 from dual connect by level <= 65)"))); + + auto rs = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rs); + + ASSERT_TRUE(OCI_FetchLast(rs)); + ASSERT_EQ(RowCount, OCI_GetRowCount(rs)); + TestRow(rs, RowCount); + + ASSERT_TRUE(OCI_FetchFirst(rs)); + TestRow(rs, 1); + + unsigned int index = 1; + while (OCI_FetchNext(rs)) + { + TestRow(rs, ++index); + } + + while (OCI_FetchPrev(rs)) + { + TestRow(rs, --index); + } + + TestRow(rs, 1); + + ASSERT_TRUE(OCI_FetchSeek(rs, OCI_SFD_ABSOLUTE, 30)); + TestRow(rs, 30); + + ASSERT_TRUE(OCI_FetchSeek(rs, OCI_SFD_RELATIVE, -25)); + TestRow(rs, 5); + + ASSERT_TRUE(OCI_FetchSeek(rs, OCI_SFD_RELATIVE, 42)); + TestRow(rs, 47); + + ASSERT_TRUE(OCI_FetchNext(rs)); + TestRow(rs, 48); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + +} diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index d1d7f024..9acb9266 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -110,6 +110,8 @@ + + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 395b4790..ee19a6ed 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -187,6 +187,12 @@ Tests suite + + Tests suite + + + Tests suite + From a3f7fab742febb2b7bd595871583faf55e6e4a25 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 21:25:07 +0200 Subject: [PATCH 33/62] added basic test for asynchrounous queue subscription --- tests/TestQueue.cpp | 119 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) diff --git a/tests/TestQueue.cpp b/tests/TestQueue.cpp index 4976cc09..b86796a0 100644 --- a/tests/TestQueue.cpp +++ b/tests/TestQueue.cpp @@ -1,6 +1,10 @@ +#include + #include "ocilib_tests.h" +static std::atomic MessageWithConsumersCount = 0; + TEST(TestQueue, SingleMessage) { ExecDML(OTEXT("create type TestQueueSingleMessageType as object(title varchar2(50), content varchar2(100))")); @@ -30,10 +34,10 @@ TEST(TestQueue, SingleMessage) ASSERT_NE(nullptr, deq); const auto msg_in = OCI_MsgCreate(inf); - ASSERT_NE(nullptr, deq); + ASSERT_NE(nullptr, msg_in); const auto obj_in = OCI_ObjectCreate(conn, inf); - ASSERT_NE(nullptr, deq); + ASSERT_NE(nullptr, obj_in); ASSERT_TRUE(OCI_ObjectSetString(obj_in, OTEXT("title"), OTEXT("NEXT MEETING"))); ASSERT_TRUE(OCI_ObjectSetString(obj_in, OTEXT("content"), OTEXT("12:00 PM IN STARBUCKS"))); @@ -67,4 +71,115 @@ TEST(TestQueue, SingleMessage) ASSERT_TRUE(OCI_Cleanup()); ExecDML(OTEXT("drop type TestQueueSingleMessageType")); +} + +void OnMessage(OCI_Dequeue* deq) +{ + ++MessageWithConsumersCount; + const auto msg_out = OCI_DequeueGet(deq); + ASSERT_NE(nullptr, msg_out); + + const auto obj_out = OCI_MsgGetObject(msg_out); + ASSERT_NE(nullptr, obj_out); + + ASSERT_EQ(ostring(OTEXT("NEXT MEETING")), ostring(OCI_ObjectGetString(obj_out, OTEXT("title")))); + ASSERT_EQ(ostring(OTEXT("12:00 PM IN STARBUCKS")), ostring(OCI_ObjectGetString(obj_out, OTEXT("content")))); +} + +TEST(TestQueue, MessageWithConsumers) +{ + ExecDML(OTEXT("create type TestQueueMessageWithConsumersType as object(title varchar2(50), content varchar2(100))")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT | OCI_ENV_EVENTS)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + // no check - for cleanup + OCI_QueueStop(conn, OTEXT("TestQueueMessageWithConsumers"), TRUE, TRUE, FALSE); + OCI_QueueDrop(conn, OTEXT("TestQueueMessageWithConsumers")); + OCI_QueueTableDrop(conn, OTEXT("TestQueueMessageWithConsumersTable"), TRUE); + // end no check + + ASSERT_TRUE(OCI_QueueTableCreate(conn, OTEXT("TestQueueMessageWithConsumersTable"), OTEXT("TestQueueMessageWithConsumersType"), NULL, NULL, TRUE, OCI_AGM_NONE, NULL, 0, 0, NULL)); + ASSERT_TRUE(OCI_QueueCreate(conn, OTEXT("TestQueueMessageWithConsumers"), OTEXT("TestQueueMessageWithConsumersTable"), OCI_AQT_NORMAL, 0, 0, 0, FALSE, NULL)); + ASSERT_TRUE(OCI_QueueStart(conn, OTEXT("TestQueueMessageWithConsumers"), TRUE, TRUE)); + + const auto inf = OCI_TypeInfoGet(conn, OTEXT("TestQueueMessageWithConsumersType"), OCI_TIF_TYPE); + ASSERT_NE(nullptr, inf); + + const auto enq = OCI_EnqueueCreate(inf, OTEXT("TestQueueMessageWithConsumers")); + ASSERT_NE(nullptr, enq); + + const auto deq1 = OCI_DequeueCreate(inf, OTEXT("TestQueueMessageWithConsumers")); + ASSERT_NE(nullptr, deq1); + + const auto deq2 = OCI_DequeueCreate(inf, OTEXT("TestQueueMessageWithConsumers")); + ASSERT_NE(nullptr, deq2); + + OCI_Agent* agents[2]; + + agents[0] = OCI_AgentCreate(conn, "C1", nullptr); + ASSERT_NE(nullptr, agents[0]); + agents[1] = OCI_AgentCreate(conn, "C2", nullptr); + ASSERT_NE(nullptr, agents[1]); + + ASSERT_TRUE(OCI_DequeueSetConsumer(deq1, "C1")); + ASSERT_TRUE(OCI_DequeueSetNavigation(deq1, OCI_ADN_FIRST_MSG)); + ASSERT_TRUE(OCI_DequeueSetConsumer(deq2, "C2")); + ASSERT_TRUE(OCI_DequeueSetNavigation(deq2, OCI_ADN_FIRST_MSG)); + + ASSERT_TRUE(OCI_DequeueSubscribe(deq1, 9998, 0, OnMessage)); + ASSERT_TRUE(OCI_DequeueSubscribe(deq2, 9999, 0, OnMessage)); + + const auto msg_in = OCI_MsgCreate(inf); + ASSERT_NE(nullptr, msg_in); + + const auto obj_in = OCI_ObjectCreate(conn, inf); + ASSERT_NE(nullptr, obj_in); + + ASSERT_TRUE(OCI_ObjectSetString(obj_in, OTEXT("title"), OTEXT("NEXT MEETING"))); + ASSERT_TRUE(OCI_ObjectSetString(obj_in, OTEXT("content"), OTEXT("12:00 PM IN STARBUCKS"))); + + ASSERT_TRUE(OCI_MsgSetObject(msg_in, obj_in)); + ASSERT_TRUE(OCI_MsgSetConsumers(msg_in, agents, 2)); + + MessageWithConsumersCount = 0; + + ASSERT_TRUE(OCI_EnqueuePut(enq, msg_in)); + + ASSERT_TRUE(OCI_MsgFree(msg_in)); + ASSERT_TRUE(OCI_ObjectFree(obj_in)); + + ASSERT_TRUE(OCI_Commit(conn)); + + const int MaxRetries = 15; + int retry = 1; + + while (MessageWithConsumersCount < 2 && retry <= MaxRetries) + { + Sleep(100); + retry++; + } + + ASSERT_EQ(MessageWithConsumersCount, 2); + + ASSERT_TRUE(OCI_DequeueUnsubscribe(deq1)); + ASSERT_TRUE(OCI_DequeueUnsubscribe(deq2)); + + ASSERT_TRUE(OCI_AgentFree(agents[0])); + ASSERT_TRUE(OCI_AgentFree(agents[1])); + + ASSERT_TRUE(OCI_EnqueueFree(enq)); + ASSERT_TRUE(OCI_DequeueFree(deq1)); + ASSERT_TRUE(OCI_DequeueFree(deq2)); + + ASSERT_TRUE(OCI_QueueStop(conn, OTEXT("TestQueueMessageWithConsumers"), TRUE, TRUE, FALSE)); + ASSERT_TRUE(OCI_QueueDrop(conn, OTEXT("TestQueueMessageWithConsumers"))); + ASSERT_TRUE(OCI_QueueTableDrop(conn, OTEXT("TestQueueMessageWithConsumersTable"), TRUE)); + + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop type TestQueueMessageWithConsumersType")); } \ No newline at end of file From 1a3c48eae7d53b538617e0290aa73b227f4bbb1c Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 11 May 2020 21:28:47 +0200 Subject: [PATCH 34/62] doxygen html doc generation options updates --- doxygen/Doxyfile.dox | 22 +- doxygen/Introduction.txt | 2 - doxygen/customdoxygen.css | 1764 +++++++++++++++++++++++++++++++++++++ doxygen/customfooter.html | 21 + doxygen/customheader.html | 56 ++ 5 files changed, 1852 insertions(+), 13 deletions(-) create mode 100644 doxygen/customdoxygen.css create mode 100644 doxygen/customfooter.html create mode 100644 doxygen/customheader.html diff --git a/doxygen/Doxyfile.dox b/doxygen/Doxyfile.dox index 84a844b5..cff75b38 100644 --- a/doxygen/Doxyfile.dox +++ b/doxygen/Doxyfile.dox @@ -44,14 +44,14 @@ PROJECT_NUMBER = 4.7.0 # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = +PROJECT_BRIEF = "Open source and cross platform Oracle Driver delivering efficient access to Oracle databases." # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = +PROJECT_LOGO = ../images/logo-160x120.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is @@ -313,7 +313,7 @@ OPTIMIZE_OUTPUT_SLICE = NO # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = hpp=C++ # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -1163,7 +1163,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = customheader.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1173,7 +1173,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = customfooter.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1185,7 +1185,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = customdoxygen.css # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets @@ -1219,7 +1219,7 @@ HTML_EXTRA_FILES = # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_HUE = 222 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A @@ -1227,7 +1227,7 @@ HTML_COLORSTYLE_HUE = 220 # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_SAT = 65 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 @@ -1238,7 +1238,7 @@ HTML_COLORSTYLE_SAT = 100 # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE_GAMMA = 80 +HTML_COLORSTYLE_GAMMA = 56 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this @@ -1266,7 +1266,7 @@ HTML_DYNAMIC_MENUS = YES # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_DYNAMIC_SECTIONS = YES +HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand @@ -1609,7 +1609,7 @@ MATHJAX_CODEFILE = # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. -SEARCHENGINE = NO +SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. There diff --git a/doxygen/Introduction.txt b/doxygen/Introduction.txt index 1a7f4ca2..7371b2c1 100644 --- a/doxygen/Introduction.txt +++ b/doxygen/Introduction.txt @@ -1,8 +1,6 @@ /** @mainpage Introduction - @image html logo-160x120.png - @section Intro Description OCILIB is an open source and portable Oracle C and C++ Driver that delivers really fast diff --git a/doxygen/customdoxygen.css b/doxygen/customdoxygen.css new file mode 100644 index 00000000..e2515926 --- /dev/null +++ b/doxygen/customdoxygen.css @@ -0,0 +1,1764 @@ +/* The standard CSS for doxygen 1.8.15 */ + +body, table, div, p, dl { + font: 400 14px/22px Roboto,sans-serif; +} + +p.reference, p.definition { + font: 400 14px/22px Roboto,sans-serif; +} + +/* @group Heading Levels */ + +h1.groupheader { + font-size: 150%; +} + +.title { + font: 400 14px/28px Roboto,sans-serif; + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2.groupheader { + border-bottom: 1px solid #879ECB; + color: #354C7B; + font-size: 150%; + font-weight: normal; + margin-top: 1.75em; + padding-top: 8px; + padding-bottom: 4px; + width: 100%; +} + +h3.groupheader { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd { + margin-top: 2px; +} + +p.starttd { + margin-top: 0px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +p.interli { +} + +p.interdd { +} + +p.intertd { +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #FFFFFF; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #FFFFFF; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited, a.line, a.line:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +ul { + overflow: hidden; /*Fixed: list item bullets overlap floating elements*/ +} + +#side-nav ul { + overflow: visible; /* reset ul rule for scroll bar in GENERATE_TREEVIEW window */ +} + +#main-nav ul { + overflow: visible; /* reset ul rule for the navigation bar drop down lists */ +} + +.fragment { + text-align: left; + direction: ltr; + overflow-x: auto; /*Fixed: fragment lines overlap floating elements*/ + overflow-y: hidden; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 0 0 1px 0; /*Fixed: last line underline overlap border*/ + margin: 4px 8px 4px 2px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +div.line:after { + content:"\000A"; + white-space: pre; +} + +div.line.glow { + background-color: cyan; + box-shadow: 0 0 10px cyan; +} + + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +.lineno { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +div.ah, span.ah { + background-color: black; + font-weight: bold; + color: #FFFFFF; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000 110%); +} + +div.classindex ul { + list-style: none; + padding-left: 0; +} + +div.classindex span.ai { + display: inline-block; +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 12px; + margin-right: 8px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl, img.inline { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F7F8FB; + border-left: 2px solid #9CAFD4; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +blockquote.DocNodeRTL { + border-left: 0; + border-right: 2px solid #9CAFD4; + margin: 0 4px 0 24px; + padding: 0 16px 0 12px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.memberdecls td, .fieldtable tr { + -webkit-transition-property: background-color, box-shadow; + -webkit-transition-duration: 0.5s; + -moz-transition-property: background-color, box-shadow; + -moz-transition-duration: 0.5s; + -ms-transition-property: background-color, box-shadow; + -ms-transition-duration: 0.5s; + -o-transition-property: background-color, box-shadow; + -o-transition-duration: 0.5s; + transition-property: background-color, box-shadow; + transition-duration: 0.5s; +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: cyan; + box-shadow: 0 0 15px cyan; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memSeparator { + border-bottom: 1px solid #DEE4F0; + line-height: 1px; + margin: 0px; + padding: 0px; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; + font-size: 80%; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtitle { + padding: 8px; + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + border-top-right-radius: 4px; + border-top-left-radius: 4px; + margin-bottom: -1px; + background-image: url('nav_f.png'); + background-repeat: repeat-x; + background-color: #E2E8F2; + line-height: 1.25; + font-weight: 300; + float:left; +} + +.permalink +{ + font-size: 65%; + display: inline-block; + vertical-align: middle; +} + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; + display: table !important; + width: 100%; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + font-weight: 400; + margin-left: 6px; +} + +.memname td { + vertical-align: bottom; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + background-color: #DFE5F1; + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 4px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 4px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 4px; + +} + +.overload { + font-family: "courier new",courier,monospace; + font-size: 65%; +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 10px 2px 10px; + background-color: #FBFCFD; + border-top-width: 0; + background-image:url('nav_g.png'); + background-repeat:repeat-x; + background-color: #FFFFFF; + /* opera specific markup */ + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 4px; + -moz-border-radius-bottomright: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 4px; + -webkit-border-bottom-right-radius: 4px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} +.paramname code { + line-height: 14px; +} + +.params, .retval, .exception, .tparams { + margin-left: 0px; + padding-left: 0px; +} + +.params .paramname, .retval .paramname, .tparams .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype, .tparams .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir, .tparams .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + +table.mlabels { + border-spacing: 0px; +} + +td.mlabels-left { + width: 100%; + padding: 0px; +} + +td.mlabels-right { + vertical-align: bottom; + padding: 0px; + white-space: nowrap; +} + +span.mlabels { + margin-left: 8px; +} + +span.mlabel { + background-color: #728DC1; + border-top:1px solid #5373B4; + border-left:1px solid #5373B4; + border-right:1px solid #C4CFE5; + border-bottom:1px solid #C4CFE5; + text-shadow: none; + color: white; + margin-right: 4px; + padding: 2px 3px; + border-radius: 3px; + font-size: 7pt; + white-space: nowrap; + vertical-align: middle; +} + + + +/* @end */ + +/* these are for tree view inside a (index) page */ + +div.directory { + margin: 10px 0px; + border-top: 1px solid #9CAFD4; + border-bottom: 1px solid #9CAFD4; + width: 100%; +} + +.directory table { + border-collapse:collapse; +} + +.directory td { + margin: 0px; + padding: 0px; + vertical-align: top; +} + +.directory td.entry { + white-space: nowrap; + padding-right: 6px; + padding-top: 3px; +} + +.directory td.entry a { + outline:none; +} + +.directory td.entry a img { + border: none; +} + +.directory td.desc { + width: 100%; + padding-left: 6px; + padding-right: 6px; + padding-top: 3px; + border-left: 1px solid rgba(0,0,0,0.05); +} + +.directory tr.even { + padding-left: 6px; + background-color: #F7F8FB; +} + +.directory img { + vertical-align: -30%; +} + +.directory .levels { + white-space: nowrap; + width: 100%; + text-align: right; + font-size: 9pt; +} + +.directory .levels span { + cursor: pointer; + padding-left: 2px; + padding-right: 2px; + color: #3D578C; +} + +.arrow { + color: #9CAFD4; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + font-size: 80%; + display: inline-block; + width: 16px; + height: 22px; +} + +.icon { + font-family: Arial, Helvetica; + font-weight: bold; + font-size: 12px; + height: 14px; + width: 16px; + display: inline-block; + background-color: #728DC1; + color: white; + text-align: center; + border-radius: 4px; + margin-left: 2px; + margin-right: 2px; +} + +.icona { + width: 24px; + height: 22px; + display: inline-block; +} + +.iconfopen { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderopen.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.iconfclosed { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('folderclosed.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +.icondoc { + width: 24px; + height: 18px; + margin-bottom: 4px; + background-image:url('doc.png'); + background-position: 0px -4px; + background-repeat: repeat-y; + vertical-align:top; + display: inline-block; +} + +table.directory { + font: 400 14px Roboto,sans-serif; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable caption { + caption-side: top; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +table.fieldtable { + /*width: 100%;*/ + margin-bottom: 10px; + border: 1px solid #A8B8D9; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #A8B8D9; + border-bottom: 1px solid #A8B8D9; + vertical-align: top; +} + +.fieldtable td.fieldname { + padding-top: 3px; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #A8B8D9; + /*width: 100%;*/ +} + +.fieldtable td.fielddoc p:first-child { + margin-top: 0px; +} + +.fieldtable td.fielddoc p:last-child { + margin-bottom: 2px; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + font-size: 90%; + color: #253555; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + font-weight: 400; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #A8B8D9; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + background-position: 0 -5px; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; + color: #283A5D; + font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +table.classindex +{ + margin: 10px; + white-space: nowrap; + margin-left: 3%; + margin-right: 3%; + width: 94%; + border: 0; + border-spacing: 0; + padding: 0; +} + +div.ingroups +{ + font-size: 8pt; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +.PageDocRTL-title div.headertitle { + text-align: right; + direction: rtl; +} + +dl { + padding: 0 0 0 0; +} + +/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug, dl.examples */ +dl.section { + margin-left: 0px; + padding-left: 0px; +} + +dl.section.DocNodeRTL { + margin-right: 0px; + padding-right: 0px; +} + +dl.note { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #D0C000; +} + +dl.note.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #FF0000; +} + +dl.warning.DocNodeRTL, dl.attention.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00D000; +} + +dl.pre.DocNodeRTL, dl.post.DocNodeRTL, dl.invariant.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #00D000; +} + +dl.deprecated { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #505050; +} + +dl.deprecated.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #505050; +} + +dl.todo { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #00C0E0; +} + +dl.todo.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #00C0E0; +} + +dl.test { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #3030E0; +} + +dl.test.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #3030E0; +} + +dl.bug { + margin-left: -7px; + padding-left: 3px; + border-left: 4px solid; + border-color: #C08050; +} + +dl.bug.DocNodeRTL { + margin-left: 0; + padding-left: 0; + border-left: 0; + margin-right: -7px; + padding-right: 3px; + border-right: 4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 6px; +} + + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectalign +{ + vertical-align: middle; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.plantumlgraph +{ + text-align: center; +} + +.diagraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #90A5CE; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#334975; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F4F6FA; + border: 1px solid #D8DFEE; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 8px 10px 10px; + width: 200px; +} + +.PageDocRTL-title div.toc { + float: left !important; + text-align: right; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +.PageDocRTL-title div.toc li { + background-position-x: right !important; + padding-left: 0 !important; + padding-right: 10px; +} + +div.toc h3 { + font: bold 12px/1.2 Arial,FreeSans,sans-serif; + color: #4665A2; + border-bottom: 0 none; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +.PageDocRTL-title div.toc li.level1 { + margin-left: 0 !important; + margin-right: 0; +} + +.PageDocRTL-title div.toc li.level2 { + margin-left: 0 !important; + margin-right: 15px; +} + +.PageDocRTL-title div.toc li.level3 { + margin-left: 0 !important; + margin-right: 30px; +} + +.PageDocRTL-title div.toc li.level4 { + margin-left: 0 !important; + margin-right: 45px; +} + +.inherit_header { + font-weight: bold; + color: gray; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.inherit_header td { + padding: 6px 0px 2px 5px; +} + +.inherit { + display: none; +} + +tr.heading h2 { + margin-top: 12px; + margin-bottom: 4px; +} + +/* tooltip related style info */ + +.ttc { + position: absolute; + display: none; +} + +#powerTip { + cursor: default; + white-space: nowrap; + background-color: white; + border: 1px solid gray; + border-radius: 4px 4px 4px 4px; + box-shadow: 1px 1px 7px gray; + display: none; + font-size: smaller; + max-width: 80%; + opacity: 0.9; + padding: 1ex 1em 1em; + position: absolute; + z-index: 2147483647; +} + +#powerTip div.ttdoc { + color: grey; + font-style: italic; +} + +#powerTip div.ttname a { + font-weight: bold; +} + +#powerTip div.ttname { + font-weight: bold; +} + +#powerTip div.ttdeci { + color: #006318; +} + +#powerTip div { + margin: 0px; + padding: 0px; + font: 12px/16px Roboto,sans-serif; +} + +#powerTip:before, #powerTip:after { + content: ""; + position: absolute; + margin: 0px; +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.s:after, #powerTip.s:before, +#powerTip.w:after, #powerTip.w:before, +#powerTip.e:after, #powerTip.e:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.nw:after, #powerTip.nw:before, +#powerTip.sw:after, #powerTip.sw:before { + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; +} + +#powerTip.n:after, #powerTip.s:after, +#powerTip.w:after, #powerTip.e:after, +#powerTip.nw:after, #powerTip.ne:after, +#powerTip.sw:after, #powerTip.se:after { + border-color: rgba(255, 255, 255, 0); +} + +#powerTip.n:before, #powerTip.s:before, +#powerTip.w:before, #powerTip.e:before, +#powerTip.nw:before, #powerTip.ne:before, +#powerTip.sw:before, #powerTip.se:before { + border-color: rgba(128, 128, 128, 0); +} + +#powerTip.n:after, #powerTip.n:before, +#powerTip.ne:after, #powerTip.ne:before, +#powerTip.nw:after, #powerTip.nw:before { + top: 100%; +} + +#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { + border-top-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} +#powerTip.n:before { + border-top-color: #808080; + border-width: 11px; + margin: 0px -11px; +} +#powerTip.n:after, #powerTip.n:before { + left: 50%; +} + +#powerTip.nw:after, #powerTip.nw:before { + right: 14px; +} + +#powerTip.ne:after, #powerTip.ne:before { + left: 14px; +} + +#powerTip.s:after, #powerTip.s:before, +#powerTip.se:after, #powerTip.se:before, +#powerTip.sw:after, #powerTip.sw:before { + bottom: 100%; +} + +#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { + border-bottom-color: #FFFFFF; + border-width: 10px; + margin: 0px -10px; +} + +#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { + border-bottom-color: #808080; + border-width: 11px; + margin: 0px -11px; +} + +#powerTip.s:after, #powerTip.s:before { + left: 50%; +} + +#powerTip.sw:after, #powerTip.sw:before { + right: 14px; +} + +#powerTip.se:after, #powerTip.se:before { + left: 14px; +} + +#powerTip.e:after, #powerTip.e:before { + left: 100%; +} +#powerTip.e:after { + border-left-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.e:before { + border-left-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +#powerTip.w:after, #powerTip.w:before { + right: 100%; +} +#powerTip.w:after { + border-right-color: #FFFFFF; + border-width: 10px; + top: 50%; + margin-top: -10px; +} +#powerTip.w:before { + border-right-color: #808080; + border-width: 11px; + top: 50%; + margin-top: -11px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } +} + +/* @group Markdown */ + +/* +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.markdownTableHead tr { +} + +table.markdownTableBodyLeft td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +th.markdownTableHeadLeft th.markdownTableHeadRight th.markdownTableHeadCenter th.markdownTableHeadNone { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft { + text-align: left +} + +th.markdownTableHeadRight { + text-align: right +} + +th.markdownTableHeadCenter { + text-align: center +} +*/ + +table.markdownTable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.markdownTable td, table.markdownTable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.markdownTable tr { +} + +th.markdownTableHeadLeft, th.markdownTableHeadRight, th.markdownTableHeadCenter, th.markdownTableHeadNone { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; +} + +th.markdownTableHeadLeft, td.markdownTableBodyLeft { + text-align: left +} + +th.markdownTableHeadRight, td.markdownTableBodyRight { + text-align: right +} + +th.markdownTableHeadCenter, td.markdownTableBodyCenter { + text-align: center +} + +.DocNodeRTL { + text-align: right; + direction: rtl; +} + +.DocNodeLTR { + text-align: left; + direction: ltr; +} + +table.DocNodeRTL { + width: auto; + margin-right: 0; + margin-left: auto; +} + +table.DocNodeLTR { + width: auto; + margin-right: auto; + margin-left: 0; +} + +tt, code, kbd, samp +{ + display: inline-block; + direction:ltr; +} +/* @end */ + +u { + text-decoration: underline; +} + diff --git a/doxygen/customfooter.html b/doxygen/customfooter.html new file mode 100644 index 00000000..0a63dd2e --- /dev/null +++ b/doxygen/customfooter.html @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/doxygen/customheader.html b/doxygen/customheader.html new file mode 100644 index 00000000..9f98f4a6 --- /dev/null +++ b/doxygen/customheader.html @@ -0,0 +1,56 @@ + + + + + + + + +$projectname: $title +$title + + + +$treeview +$search +$mathjax + +$extrastylesheet + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
$projectname +  $projectnumber +
+
$projectbrief
+
+
$projectbrief
+
$searchbox
+
+ + From 9638ab87ffc8ff0609b121f174397f1d273c225b Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 12 May 2020 09:20:05 +0200 Subject: [PATCH 35/62] added basic test suites for RowID, OCI_Thread, OCI_ThreadKey --- tests/TestQueue.cpp | 2 +- tests/TestRowId.cpp | 71 ++++++++++++++++++++++++++++++ tests/TestThread.cpp | 39 ++++++++++++++++ tests/TestThreadKey.cpp | 57 ++++++++++++++++++++++++ tests/ocilib_tests.h | 2 +- tests/ocilib_tests.vcxproj | 3 ++ tests/ocilib_tests.vcxproj.filters | 9 ++++ 7 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 tests/TestRowId.cpp create mode 100644 tests/TestThread.cpp create mode 100644 tests/TestThreadKey.cpp diff --git a/tests/TestQueue.cpp b/tests/TestQueue.cpp index b86796a0..7b1fb19a 100644 --- a/tests/TestQueue.cpp +++ b/tests/TestQueue.cpp @@ -73,7 +73,7 @@ TEST(TestQueue, SingleMessage) ExecDML(OTEXT("drop type TestQueueSingleMessageType")); } -void OnMessage(OCI_Dequeue* deq) +static void OnMessage(OCI_Dequeue* deq) { ++MessageWithConsumersCount; const auto msg_out = OCI_DequeueGet(deq); diff --git a/tests/TestRowId.cpp b/tests/TestRowId.cpp new file mode 100644 index 00000000..067ed755 --- /dev/null +++ b/tests/TestRowId.cpp @@ -0,0 +1,71 @@ +#include "ocilib_tests.h" + + +TEST(TestRowId, Fetch) +{ + ExecDML(OTEXT("create table TestRowIdFetch(code int, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestRowIdFetch")); + ExecDML(OTEXT("insert into TestRowIdFetch values (1, 'name 1')")); + ExecDML(OTEXT("insert into TestRowIdFetch values (2, 'name 2')")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + otext rowid1[OCI_SIZE_ROWID + 1] = OTEXT(""); + otext rowid2[OCI_SIZE_ROWID + 1] = OTEXT(""); + + ASSERT_TRUE(OCI_Immediate(conn, OTEXT("select rowid from TestRowIdFetch where code = 1"), OCI_ARG_TEXT, rowid1)); + ASSERT_TRUE(OCI_Immediate(conn, OTEXT("select rowid from TestRowIdFetch where code = 2"), OCI_ARG_TEXT, rowid2)); + + ASSERT_TRUE(ostring(rowid1).length() > 0); + ASSERT_TRUE(ostring(rowid2).length() > 0); + + ASSERT_NE(ostring(rowid1), ostring(rowid2)); + + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop table TestRowIdFetch")); +} + +TEST(TestRowId, Bind) +{ + ExecDML(OTEXT("create table TestRowIdBind(code int, name varchar2(50))")); + ExecDML(OTEXT("truncate table TestRowIdBind")); + ExecDML(OTEXT("insert into TestRowIdBind values (1, 'name 1')")); + ExecDML(OTEXT("insert into TestRowIdBind values (2, 'name 2')")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + otext rowid[OCI_SIZE_ROWID + 1] = OTEXT(""); + + ASSERT_TRUE(OCI_Immediate(conn, OTEXT("select rowid from TestRowIdBind where code = 2"), OCI_ARG_TEXT, rowid)); + + ASSERT_TRUE(ostring(rowid).length() > 0); + + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("select code, name, rowid from TestRowIdBind where rowid = :id"))); + ASSERT_TRUE(OCI_BindString(stmt, OTEXT(":id"), rowid, OCI_SIZE_ROWID)); + ASSERT_TRUE(OCI_Execute(stmt)); + + const auto rs = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rs); + + ASSERT_TRUE(OCI_FetchNext(rs)); + + ASSERT_EQ(2, OCI_GetInt(rs, 1)); + ASSERT_EQ(ostring(OTEXT("name 2")), OCI_GetString(rs, 2)); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop table TestRowIdBind")); +} \ No newline at end of file diff --git a/tests/TestThread.cpp b/tests/TestThread.cpp new file mode 100644 index 00000000..65974393 --- /dev/null +++ b/tests/TestThread.cpp @@ -0,0 +1,39 @@ +#include + +#include "ocilib_tests.h" + +const size_t MaxThread = 10; + +static std::atomic ThreadProcCallCount = 0; + +static void WorkerProc(OCI_Thread* thread, void* data) +{ + const void* id = OCI_HandleGetThreadID(thread); + ASSERT_NE(nullptr, id); + + ++ThreadProcCallCount; +} + +TEST(TestThreadKey, RunAndJoin) +{ + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT | OCI_ENV_THREADED)); + + std::array threads{}; + + for (auto& thread : threads) + { + thread = OCI_ThreadCreate(); + ASSERT_NE(nullptr, thread); + ASSERT_TRUE(OCI_ThreadRun(thread, WorkerProc, nullptr)); + } + + for (auto& thread : threads) + { + ASSERT_TRUE(OCI_ThreadJoin(thread)); + ASSERT_TRUE(OCI_ThreadFree(thread)); + } + + ASSERT_TRUE(OCI_Cleanup()); + + ASSERT_EQ(MaxThread, ThreadProcCallCount); +} diff --git a/tests/TestThreadKey.cpp b/tests/TestThreadKey.cpp new file mode 100644 index 00000000..01c4adaf --- /dev/null +++ b/tests/TestThreadKey.cpp @@ -0,0 +1,57 @@ +#include + +#include "ocilib_tests.h" + +const size_t MaxThread = 10; + +static std::atomic ThreadKeyFreeCount = 0; + +static void KeyCleanup(void* str) +{ + ++ThreadKeyFreeCount; + ASSERT_NE(nullptr, str); + delete [] static_cast(str); +} + +static void WorkerProc(OCI_Thread* thread, void* data) +{ + const void* id = OCI_HandleGetThreadID(thread); + ASSERT_NE(nullptr, id); + + auto str1= new char[100]; + sprintf(str1, "thread %p !\n", id); + + ASSERT_TRUE(OCI_ThreadKeySetValue(OTEXT("ID"), str1)); + + Sleep(10); + const auto str2 = static_cast(OCI_ThreadKeyGetValue(OTEXT("ID"))); + ASSERT_NE(nullptr, str2); + + ASSERT_EQ(std::string(str1), std::string(str2)); +} + +TEST(TestThreadKey, GetSetValue) +{ + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT | OCI_ENV_THREADED)); + + OCI_ThreadKeyCreate("ID", KeyCleanup); + + std::array threads{}; + + for (auto& thread : threads) + { + thread = OCI_ThreadCreate(); + ASSERT_NE(nullptr, thread); + ASSERT_TRUE(OCI_ThreadRun(thread, WorkerProc, nullptr)); + } + + for (auto& thread : threads) + { + ASSERT_TRUE(OCI_ThreadJoin(thread)); + ASSERT_TRUE(OCI_ThreadFree(thread)); + } + + ASSERT_TRUE(OCI_Cleanup()); + + ASSERT_EQ(MaxThread, ThreadKeyFreeCount); +} \ No newline at end of file diff --git a/tests/ocilib_tests.h b/tests/ocilib_tests.h index 6a4f4494..3b59fa1c 100644 --- a/tests/ocilib_tests.h +++ b/tests/ocilib_tests.h @@ -20,7 +20,7 @@ #define OCI_API __stdcall #include "../include/ocilib.h" -#define DBS OTEXT("") +#define DBS OTEXT("db18c") #define USR OTEXT("usr") #define PWD OTEXT("pwd") #define HOME OTEXT("") diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 9acb9266..371463d3 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -111,7 +111,10 @@ + + + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index ee19a6ed..684e07ea 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -193,6 +193,15 @@ Tests suite + + Tests suite + + + Tests suite + + + Tests suite + From 96ed5cfebbeea2425b108682c2e2684eac1913f2 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 13 May 2020 08:07:30 +0200 Subject: [PATCH 36/62] Added basic test suite for connection pool --- tests/TestPool.cpp | 49 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 1 + tests/ocilib_tests.vcxproj.filters | 3 ++ 3 files changed, 53 insertions(+) create mode 100644 tests/TestPool.cpp diff --git a/tests/TestPool.cpp b/tests/TestPool.cpp new file mode 100644 index 00000000..52333190 --- /dev/null +++ b/tests/TestPool.cpp @@ -0,0 +1,49 @@ +#include + +#include "ocilib_tests.h" + +const size_t MaxThread = 10; + +static std::atomic ConnCreatedCount = 0; + +static void WorkerProc(OCI_Thread* thread, void* data) +{ + const auto conn = OCI_PoolGetConnection(static_cast(data), nullptr); + ASSERT_NE(nullptr, conn); + + int anwser = 0; + OCI_Immediate(conn, "select 42 from dual", OCI_ARG_INT, &anwser); + ASSERT_EQ(42, anwser); + + ASSERT_TRUE(OCI_ConnectionFree(conn)); + + ++ConnCreatedCount; +} + +TEST(TestPool, SessionPoolGetMultipleConnections) +{ + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT | OCI_ENV_THREADED)); + + const auto pool = OCI_PoolCreate(DBS, USR, PWD, OCI_POOL_SESSION, OCI_SESSION_DEFAULT, 0, 10, 1); + ASSERT_NE(nullptr, pool); + + std::array threads{}; + + for (auto& thread : threads) + { + thread = OCI_ThreadCreate(); + ASSERT_NE(nullptr, thread); + ASSERT_TRUE(OCI_ThreadRun(thread, WorkerProc, pool)); + } + + for (auto& thread : threads) + { + ASSERT_TRUE(OCI_ThreadJoin(thread)); + ASSERT_TRUE(OCI_ThreadFree(thread)); + } + + ASSERT_TRUE(OCI_PoolFree(pool)); + ASSERT_TRUE(OCI_Cleanup()); + + ASSERT_EQ(MaxThread, ConnCreatedCount); +} diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 371463d3..3fe99aa7 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -107,6 +107,7 @@ + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 684e07ea..a272f1c1 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -202,6 +202,9 @@ Tests suite + + Tests suite + From 9dc29d4f958d4aa76b7f92a7552fd1edf60fe823 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 13 May 2020 08:32:40 +0200 Subject: [PATCH 37/62] added a basic test suite for PL/SQL tables --- tests/TestPlSqlTables.cpp | 82 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 1 + tests/ocilib_tests.vcxproj.filters | 3 ++ 3 files changed, 86 insertions(+) create mode 100644 tests/TestPlSqlTables.cpp diff --git a/tests/TestPlSqlTables.cpp b/tests/TestPlSqlTables.cpp new file mode 100644 index 00000000..47ee881d --- /dev/null +++ b/tests/TestPlSqlTables.cpp @@ -0,0 +1,82 @@ +#include "ocilib_tests.h" + + +TEST(TestPlSqlTables, BasicInOutStringTableBinding) +{ + ExecDML + ( + OTEXT("create package test_plsqltables as") + OTEXT(" type string_tab is table of varchar2(50) index by binary_integer;") + OTEXT(" procedure combine_values(value1 in string_tab, value2 in string_tab, result out string_tab);") + OTEXT("end;") + ); + + ExecDML + ( + OTEXT("create package body test_plsqltables as") + OTEXT(" procedure combine_values(value1 in string_tab, value2 in string_tab, result out string_tab) is") + OTEXT(" begin") + OTEXT(" for i in 1 ..value1.count") + OTEXT(" loop") + OTEXT(" result(i) := value1(i) || ' - ' || value2(i);") + OTEXT(" end loop;") + OTEXT(" end;") + OTEXT("end;") + ); + + const unsigned int ArraySize = 10; + const unsigned int StringSize = 50; + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + otext tab_names[ArraySize][StringSize + 1]; + otext tab_values[ArraySize][StringSize + 1]; + otext tab_results[ArraySize][StringSize + 1]; + + + ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("BEGIN test_plsqltables.combine_values(:tab_names, :tab_values, :tab_results); END;"))); + + /* set values */ + + for (unsigned int i = 0; i < ArraySize; i++) + { + sprintf(tab_names[i], "name %03d", i + 1); + sprintf(tab_values[i], "value %03d", i + 1); + + tab_results[i][0] = 0; + } + + /* prepare call and bind local arrays */ + + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_names"), reinterpret_cast(tab_names), StringSize, ArraySize)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_values"), reinterpret_cast(tab_values), StringSize, ArraySize)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_results"), reinterpret_cast(tab_results), StringSize, ArraySize)); + + ASSERT_TRUE(OCI_BindSetDirection(OCI_GetBind(stmt, 1), OCI_BDM_IN)); + ASSERT_TRUE(OCI_BindSetDirection(OCI_GetBind(stmt, 2), OCI_BDM_IN)); + ASSERT_TRUE(OCI_BindSetDirection(OCI_GetBind(stmt, 3), OCI_BDM_OUT)); + + /* execute */ + + ASSERT_TRUE(OCI_Execute(stmt)); + + otext buffer[512]; + + for (unsigned int i = 0; i < ArraySize; i++) + { + sprintf(buffer, "name %03d - value %03d", i + 1, i + 1); + ASSERT_EQ(ostring(buffer), tab_results[i]); + } + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop package test_plsqltables")); +} \ No newline at end of file diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 3fe99aa7..671c7c90 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -107,6 +107,7 @@ + diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index a272f1c1..b0757d13 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -205,6 +205,9 @@ Tests suite + + Tests suite + From b4d6be5a28a6f4f4fba52da9fe149c9f38d11ca2 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 13 May 2020 08:52:04 +0200 Subject: [PATCH 38/62] added basic test suite for Objects --- tests/TestObject.cpp | 57 ++++++++++++++++++++++++++++++ tests/ocilib_tests.vcxproj | 3 +- tests/ocilib_tests.vcxproj.filters | 3 ++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tests/TestObject.cpp diff --git a/tests/TestObject.cpp b/tests/TestObject.cpp new file mode 100644 index 00000000..d4fa7d6d --- /dev/null +++ b/tests/TestObject.cpp @@ -0,0 +1,57 @@ +#include "ocilib_tests.h" + + +TEST(TestObject, SetGetBasicProps) +{ + ExecDML(OTEXT("create type TestObjectSetGetBasicPropsVendor as object(code number, name varchar2(30))")); + ExecDML(OTEXT("create type TestObjectSetGetBasicPropsSale as object(code number, price float, name varchar2(30), ref varchar2(30), date_sale date, vendor TestObjectSetGetBasicPropsVendor)")); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto date = OCI_DateCreate(nullptr); + ASSERT_NE(nullptr, date); + + OCI_DateSysDate(date); + + const auto vendor = OCI_ObjectCreate(conn, OCI_TypeInfoGet(conn, OTEXT("TestObjectSetGetBasicPropsVendor"), OCI_TIF_TYPE)); + ASSERT_NE(nullptr, vendor); + ASSERT_TRUE(OCI_ObjectSetInt(vendor, OTEXT("CODE"), 134)); + ASSERT_TRUE(OCI_ObjectSetString(vendor, OTEXT("NAME"), OTEXT("JOHN SMITH"))); + + const auto sale = OCI_ObjectCreate(conn, OCI_TypeInfoGet(conn, "TestObjectSetGetBasicPropsSale", OCI_TIF_TYPE)); + ASSERT_NE(nullptr, vendor); + + ASSERT_TRUE(OCI_ObjectSetInt(sale, OTEXT("CODE"), 1)); + ASSERT_TRUE(OCI_ObjectSetDouble(sale, OTEXT("PRICE"), 12.99)); + ASSERT_TRUE(OCI_ObjectSetString(sale, OTEXT("NAME"), OTEXT("USB KEY 2go"))); + ASSERT_TRUE(OCI_ObjectSetString(sale, OTEXT("REF"), OTEXT("A56547WSAA"))); + ASSERT_TRUE(OCI_ObjectSetObject(sale, OTEXT("VENDOR"), vendor)); + ASSERT_TRUE(OCI_ObjectSetDate(sale, OTEXT("DATE_SALE"), date)); + + ASSERT_EQ(1, OCI_ObjectGetInt(sale, OTEXT("CODE"))); + ASSERT_EQ(12.99, OCI_ObjectGetDouble(sale, OTEXT("PRICE"))); + ASSERT_EQ(ostring(OTEXT("USB KEY 2go")), ostring( OCI_ObjectGetString(sale, OTEXT("NAME")))); + ASSERT_EQ(ostring(OTEXT("A56547WSAA")), ostring(OCI_ObjectGetString(sale, OTEXT("REF")))); + + const auto vendor2 = OCI_ObjectGetObject(sale, OTEXT("VENDOR")); + ASSERT_NE(nullptr, vendor2); + + ASSERT_EQ(134, OCI_ObjectGetInt(vendor2, OTEXT("CODE"))); + ASSERT_EQ(ostring(OTEXT("JOHN SMITH")), ostring(OCI_ObjectGetString(vendor2, OTEXT("NAME")))); + + const auto date2 = OCI_ObjectGetDate(sale, OTEXT("DATE_SALE")); + ASSERT_NE(nullptr, date2); + ASSERT_EQ(0, OCI_DateCompare(date, date2)); + + ASSERT_TRUE(OCI_ObjectFree(sale)); + ASSERT_TRUE(OCI_ObjectFree(vendor)); + ASSERT_TRUE(OCI_DateFree(date)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + ExecDML(OTEXT("drop type TestObjectSetGetBasicPropsVendor")); + ExecDML(OTEXT("drop type TestObjectSetGetBasicPropsSale")); +} \ No newline at end of file diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index 671c7c90..e390ad80 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -106,6 +106,7 @@ + @@ -136,7 +137,6 @@ pch.h Disabled WIN32;_DEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug Level3 @@ -153,7 +153,6 @@ pch.h Disabled X64;_DEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) - true EnableFastChecks MultiThreadedDebug Level3 diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index b0757d13..48ee29b8 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -208,6 +208,9 @@ Tests suite + + Tests suite + From 6485b19d1048be2dddfcafc69e714d695c0b1086 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 13 May 2020 09:19:06 +0200 Subject: [PATCH 39/62] fixed missing macros for unicode compatibility --- tests/TestArray.cpp | 20 ++++++++++---------- tests/TestCollection.cpp | 14 +++++++------- tests/TestConnection.cpp | 2 +- tests/TestNumber.cpp | 2 -- tests/TestObject.cpp | 2 +- tests/TestObjectInheritance.cpp | 2 +- tests/TestPlSqlTables.cpp | 12 ++++++------ tests/TestPool.cpp | 2 +- tests/TestQueue.cpp | 8 ++++---- tests/TestReportedIssues.cpp | 4 ++-- tests/TestReturningInto.cpp | 2 +- tests/TestScrollabeCursor.cpp | 2 +- tests/TestThreadKey.cpp | 2 +- 13 files changed, 36 insertions(+), 38 deletions(-) diff --git a/tests/TestArray.cpp b/tests/TestArray.cpp index cd71fd51..c9d36274 100644 --- a/tests/TestArray.cpp +++ b/tests/TestArray.cpp @@ -14,12 +14,12 @@ TEST(TestArray, InsertExternalArray) ASSERT_NE(nullptr, stmt); int tab_int[ARRAY_SIZE]; - char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; + otext tab_str[ARRAY_SIZE][STRING_SIZE + 1]; ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestExternalArrayInsertArray values(:i, :s)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); - ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); - ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); + ASSERT_TRUE(OCI_BindArrayOfInts(stmt, OTEXT(":i"), static_cast(tab_int), 0)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":s"), reinterpret_cast(tab_str), STRING_SIZE, 0)); for (int i = 0; i < ARRAY_SIZE; i++) { @@ -52,12 +52,12 @@ TEST(TestArray, InsertExternalArrayError) ASSERT_NE(nullptr, stmt); int tab_int[ARRAY_SIZE]; - char tab_str[ARRAY_SIZE][STRING_SIZE + 1]; + otext tab_str[ARRAY_SIZE][STRING_SIZE + 1]; ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestExternalArrayInsertArrayError values(:i, :s)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); - ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", static_cast(tab_int), 0)); - ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", reinterpret_cast(tab_str), STRING_SIZE, 0)); + ASSERT_TRUE(OCI_BindArrayOfInts(stmt, OTEXT(":i"), static_cast(tab_int), 0)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":s"), reinterpret_cast(tab_str), STRING_SIZE, 0)); for (int i = 0; i < ARRAY_SIZE; i++) { @@ -106,9 +106,9 @@ TEST(TestArray, InsertInternalArray) ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("insert into TestInternalArrayInsertArray values(:i, :s, :d)"))); ASSERT_TRUE(OCI_BindArraySetSize(stmt, ARRAY_SIZE)); - ASSERT_TRUE(OCI_BindArrayOfInts(stmt, ":i", NULL, 0)); - ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, ":s", NULL, STRING_SIZE, 0)); - ASSERT_TRUE(OCI_BindArrayOfDates(stmt, ":d", NULL, 0)); + ASSERT_TRUE(OCI_BindArrayOfInts(stmt, OTEXT(":i"), NULL, 0)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":s"), NULL, STRING_SIZE, 0)); + ASSERT_TRUE(OCI_BindArrayOfDates(stmt, OTEXT(":d"), NULL, 0)); auto sysdate = OCI_DateCreate(nullptr); ASSERT_NE(nullptr, sysdate); @@ -140,7 +140,7 @@ TEST(TestArray, InsertInternalArray) while (OCI_FetchNext(rslt)) { count++; - ostring str = "Name " + std::to_string(count); + ostring str = OTEXT("Name ") + TO_STRING(count); ASSERT_EQ(count, OCI_GetInt(rslt, 1)); ASSERT_EQ(str, OCI_GetString(rslt, 2)); ASSERT_EQ(0, OCI_DateCompare(sysdate, OCI_GetDate(rslt, 3))); diff --git a/tests/TestCollection.cpp b/tests/TestCollection.cpp index 624bb258..908c9ca2 100644 --- a/tests/TestCollection.cpp +++ b/tests/TestCollection.cpp @@ -26,7 +26,7 @@ void SelectCollection(ostring sql) { nbRows++; - ostring category = "category " + std::to_string(nbRows); + ostring category = OTEXT("category ") + TO_STRING(nbRows); ASSERT_EQ(category, ostring(OCI_GetString(rset, 1))); const auto coll = OCI_GetColl(rset, 2); @@ -48,10 +48,10 @@ void SelectCollection(ostring sql) const auto obj = OCI_ElemGetObject(elem); ASSERT_NE(nullptr, obj); - ostring itemName = "name " + std::to_string(itemIndex); + ostring itemName = OTEXT("name ") + TO_STRING(itemIndex); - ASSERT_EQ(itemIndex, OCI_ObjectGetInt(obj, "code")); - ASSERT_EQ(itemName, OCI_ObjectGetString(obj, "name")); + ASSERT_EQ(itemIndex, OCI_ObjectGetInt(obj, OTEXT("code"))); + ASSERT_EQ(itemName, OCI_ObjectGetString(obj, OTEXT("name"))); elem = OCI_IterGetNext(iter); } } @@ -101,10 +101,10 @@ void BindOutCollection(ostring type, ostring sql) const auto obj = OCI_ElemGetObject(elem); ASSERT_NE(nullptr, obj); - ostring itemName = "name " + std::to_string(itemIndex); + ostring itemName = OTEXT("name ") + TO_STRING(itemIndex); - ASSERT_EQ(itemIndex, OCI_ObjectGetInt(obj, "code")); - ASSERT_EQ(itemName, OCI_ObjectGetString(obj, "name")); + ASSERT_EQ(itemIndex, OCI_ObjectGetInt(obj, OTEXT("code"))); + ASSERT_EQ(itemName, OCI_ObjectGetString(obj, OTEXT("name"))); elem = OCI_IterGetNext(iter); } diff --git a/tests/TestConnection.cpp b/tests/TestConnection.cpp index 7177dd39..5e844ff8 100644 --- a/tests/TestConnection.cpp +++ b/tests/TestConnection.cpp @@ -74,7 +74,7 @@ TEST(TestConnection, Abort) auto callback = [](OCI_Thread* thread, void* data) { - ASSERT_FALSE(OCI_ExecuteStmt(static_cast(data), "begin dbms_lock.sleep(10); end;")); + ASSERT_FALSE(OCI_ExecuteStmt(static_cast(data), OTEXT("begin dbms_lock.sleep(10); end;"))); }; OCI_ThreadRun(thrd, callback, stmt); diff --git a/tests/TestNumber.cpp b/tests/TestNumber.cpp index 4d0b026e..4a434623 100644 --- a/tests/TestNumber.cpp +++ b/tests/TestNumber.cpp @@ -468,7 +468,6 @@ TEST(TestNumber, TestPositiveInfinity) ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); const auto number = OCI_NumberCreate(nullptr); - int value_test = 123456789, value_out = 0; ASSERT_TRUE(OCI_NumberFromText(number, OTEXT("~"), OCI_STRING_FORMAT_NUM)); ASSERT_TRUE(OCI_NumberToText(number, OCI_STRING_FORMAT_NUM, 512, buffer)); @@ -487,7 +486,6 @@ TEST(TestNumber, TestNegativeInfinity) ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); const auto number = OCI_NumberCreate(nullptr); - int value_test = 123456789, value_out = 0; ASSERT_TRUE(OCI_NumberFromText(number, OTEXT("-~"), OCI_STRING_FORMAT_NUM)); ASSERT_TRUE(OCI_NumberToText(number, OCI_STRING_FORMAT_NUM, 512, buffer)); diff --git a/tests/TestObject.cpp b/tests/TestObject.cpp index d4fa7d6d..d14bad2c 100644 --- a/tests/TestObject.cpp +++ b/tests/TestObject.cpp @@ -21,7 +21,7 @@ TEST(TestObject, SetGetBasicProps) ASSERT_TRUE(OCI_ObjectSetInt(vendor, OTEXT("CODE"), 134)); ASSERT_TRUE(OCI_ObjectSetString(vendor, OTEXT("NAME"), OTEXT("JOHN SMITH"))); - const auto sale = OCI_ObjectCreate(conn, OCI_TypeInfoGet(conn, "TestObjectSetGetBasicPropsSale", OCI_TIF_TYPE)); + const auto sale = OCI_ObjectCreate(conn, OCI_TypeInfoGet(conn, OTEXT("TestObjectSetGetBasicPropsSale"), OCI_TIF_TYPE)); ASSERT_NE(nullptr, vendor); ASSERT_TRUE(OCI_ObjectSetInt(sale, OTEXT("CODE"), 1)); diff --git a/tests/TestObjectInheritance.cpp b/tests/TestObjectInheritance.cpp index 71242958..b84adbec 100644 --- a/tests/TestObjectInheritance.cpp +++ b/tests/TestObjectInheritance.cpp @@ -15,7 +15,7 @@ TEST(TestObjectInheritance, OCI_TypeInfoGetSuperType) const auto stmt = OCI_StatementCreate(conn); ASSERT_NE(nullptr, stmt); - char buffer[512]; + otext buffer[512]; unsigned int size = sizeof(buffer) - 1; const auto racingCar = OCI_ObjectCreate(conn, OCI_TypeInfoGet(conn, OTEXT("TestObjectInheritanceRacingCar"), OCI_TIF_TYPE)); diff --git a/tests/TestPlSqlTables.cpp b/tests/TestPlSqlTables.cpp index 47ee881d..417eb19d 100644 --- a/tests/TestPlSqlTables.cpp +++ b/tests/TestPlSqlTables.cpp @@ -46,17 +46,17 @@ TEST(TestPlSqlTables, BasicInOutStringTableBinding) for (unsigned int i = 0; i < ArraySize; i++) { - sprintf(tab_names[i], "name %03d", i + 1); - sprintf(tab_values[i], "value %03d", i + 1); + osprintf(tab_names[i], StringSize, OTEXT("name %03d"), i + 1); + osprintf(tab_values[i], StringSize, OTEXT("value %03d"), i + 1); tab_results[i][0] = 0; } /* prepare call and bind local arrays */ - ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_names"), reinterpret_cast(tab_names), StringSize, ArraySize)); - ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_values"), reinterpret_cast(tab_values), StringSize, ArraySize)); - ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_results"), reinterpret_cast(tab_results), StringSize, ArraySize)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_names"), reinterpret_cast(tab_names), StringSize, ArraySize)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_values"), reinterpret_cast(tab_values), StringSize, ArraySize)); + ASSERT_TRUE(OCI_BindArrayOfStrings(stmt, OTEXT(":tab_results"), reinterpret_cast(tab_results), StringSize, ArraySize)); ASSERT_TRUE(OCI_BindSetDirection(OCI_GetBind(stmt, 1), OCI_BDM_IN)); ASSERT_TRUE(OCI_BindSetDirection(OCI_GetBind(stmt, 2), OCI_BDM_IN)); @@ -70,7 +70,7 @@ TEST(TestPlSqlTables, BasicInOutStringTableBinding) for (unsigned int i = 0; i < ArraySize; i++) { - sprintf(buffer, "name %03d - value %03d", i + 1, i + 1); + osprintf(buffer, StringSize, OTEXT("name %03d - value %03d"), i + 1, i + 1); ASSERT_EQ(ostring(buffer), tab_results[i]); } diff --git a/tests/TestPool.cpp b/tests/TestPool.cpp index 52333190..5e62f5e8 100644 --- a/tests/TestPool.cpp +++ b/tests/TestPool.cpp @@ -12,7 +12,7 @@ static void WorkerProc(OCI_Thread* thread, void* data) ASSERT_NE(nullptr, conn); int anwser = 0; - OCI_Immediate(conn, "select 42 from dual", OCI_ARG_INT, &anwser); + OCI_Immediate(conn, OTEXT("select 42 from dual"), OCI_ARG_INT, &anwser); ASSERT_EQ(42, anwser); ASSERT_TRUE(OCI_ConnectionFree(conn)); diff --git a/tests/TestQueue.cpp b/tests/TestQueue.cpp index 7b1fb19a..002ff38e 100644 --- a/tests/TestQueue.cpp +++ b/tests/TestQueue.cpp @@ -119,14 +119,14 @@ TEST(TestQueue, MessageWithConsumers) OCI_Agent* agents[2]; - agents[0] = OCI_AgentCreate(conn, "C1", nullptr); + agents[0] = OCI_AgentCreate(conn, OTEXT("C1"), nullptr); ASSERT_NE(nullptr, agents[0]); - agents[1] = OCI_AgentCreate(conn, "C2", nullptr); + agents[1] = OCI_AgentCreate(conn, OTEXT("C2"), nullptr); ASSERT_NE(nullptr, agents[1]); - ASSERT_TRUE(OCI_DequeueSetConsumer(deq1, "C1")); + ASSERT_TRUE(OCI_DequeueSetConsumer(deq1, OTEXT("C1"))); ASSERT_TRUE(OCI_DequeueSetNavigation(deq1, OCI_ADN_FIRST_MSG)); - ASSERT_TRUE(OCI_DequeueSetConsumer(deq2, "C2")); + ASSERT_TRUE(OCI_DequeueSetConsumer(deq2, OTEXT("C2"))); ASSERT_TRUE(OCI_DequeueSetNavigation(deq2, OCI_ADN_FIRST_MSG)); ASSERT_TRUE(OCI_DequeueSubscribe(deq1, 9998, 0, OnMessage)); diff --git a/tests/TestReportedIssues.cpp b/tests/TestReportedIssues.cpp index 4bb78571..f1f6416c 100644 --- a/tests/TestReportedIssues.cpp +++ b/tests/TestReportedIssues.cpp @@ -120,7 +120,7 @@ TEST(ReportedIssues, Issue225) ASSERT_TRUE(OCI_NumberFromText(numbers[i], TO_STRING(i+1).data(), nullptr)); } - ASSERT_TRUE(OCI_BindArrayOfNumbers(stmt, ":v", numbers.data(), static_cast(numbers.size()))); + ASSERT_TRUE(OCI_BindArrayOfNumbers(stmt, OTEXT(":v"), numbers.data(), static_cast(numbers.size()))); ASSERT_TRUE(OCI_BindSetDirection(OCI_GetBind(stmt, 1), OCI_BDM_IN_OUT)); ASSERT_TRUE(OCI_Execute(stmt)); @@ -129,7 +129,7 @@ TEST(ReportedIssues, Issue225) for (size_t i = 0; i < numbers.size(); i++) { otext buffer[100]; - osprintf(buffer, 100, OTEXT("v(%d) = %d"), i + 1, i + 1 + 10); + osprintf(buffer, 100, OTEXT("v(%d) = %d"), static_cast(i) + 1, static_cast(i) + 1 + 10); ASSERT_EQ(ostring(buffer), ostring(OCI_ServerGetOutput(conn))); } diff --git a/tests/TestReturningInto.cpp b/tests/TestReturningInto.cpp index 983a396a..e30d7211 100644 --- a/tests/TestReturningInto.cpp +++ b/tests/TestReturningInto.cpp @@ -17,7 +17,7 @@ TEST(TestReturningInto, RegisterInt) ASSERT_NE(nullptr, stmt); ASSERT_TRUE(OCI_Prepare(stmt, OTEXT("update TestReturningIntoRegisterInt set code = code + 10, name = name || ' updated' returning code into :code"))); - ASSERT_TRUE(OCI_RegisterInt(stmt, ":code")); + ASSERT_TRUE(OCI_RegisterInt(stmt, OTEXT(":code"))); ASSERT_TRUE(OCI_Execute(stmt)); auto rslt = OCI_GetResultset(stmt); diff --git a/tests/TestScrollabeCursor.cpp b/tests/TestScrollabeCursor.cpp index ec69dac0..8a813074 100644 --- a/tests/TestScrollabeCursor.cpp +++ b/tests/TestScrollabeCursor.cpp @@ -4,7 +4,7 @@ void TestRow(OCI_Resultset *rslt, unsigned int index) { ASSERT_EQ(index, OCI_GetCurrentRow(rslt)); ASSERT_EQ(index, OCI_GetInt(rslt, 1)); - ASSERT_EQ(ostring("Row ") + std::to_string(index), ostring(OCI_GetString(rslt, 2))); + ASSERT_EQ(ostring(OTEXT("Row ")) + TO_STRING(index), ostring(OCI_GetString(rslt, 2))); } TEST(TestScrollableCursor, Fetch) diff --git a/tests/TestThreadKey.cpp b/tests/TestThreadKey.cpp index 01c4adaf..57073629 100644 --- a/tests/TestThreadKey.cpp +++ b/tests/TestThreadKey.cpp @@ -34,7 +34,7 @@ TEST(TestThreadKey, GetSetValue) { ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT | OCI_ENV_THREADED)); - OCI_ThreadKeyCreate("ID", KeyCleanup); + OCI_ThreadKeyCreate(OTEXT("ID"), KeyCleanup); std::array threads{}; From 3ab824cd7821d8b4b7eaa85daabff68ee91fcbd1 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 14 May 2020 07:45:32 +0200 Subject: [PATCH 40/62] Fixed alllocation of OCI_Error new string members when using OCI_CHARSET_WIDE (introduced in the development of version 4.7.0) --- src/error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error.c b/src/error.c index 65362500..c7dcdaeb 100644 --- a/src/error.c +++ b/src/error.c @@ -122,7 +122,7 @@ void ErrorSet /* allocate storage for location */ if (err->location_len < location_len) { - err->location = realloc(err->location, location_len + 1); + err->location = realloc(err->location, (location_len + 1) * sizeof(otext)); } /* convert location if needed */ @@ -134,7 +134,7 @@ void ErrorSet if (err->message_len < total_len) { - err->message = realloc(err->message, total_len + 1); + err->message = realloc(err->message, (total_len + 1) * sizeof(otext)); } /* format message */ From 48f9b77a18b5edf009b8bc44617051139f0f62de Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 14 May 2020 08:32:32 +0200 Subject: [PATCH 41/62] Added a workaround when calling OCIAQEnq() and OCIAQDeq() that only takes ansi queue name even is oci is initialized in UTF6 mode ! --- src/defs.h | 2 ++ src/dequeue.c | 76 +++++++++++++++++++++++++++++++++++++---------- src/enqueue.c | 81 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 131 insertions(+), 28 deletions(-) diff --git a/src/defs.h b/src/defs.h index 10b3a755..3c10b31c 100644 --- a/src/defs.h +++ b/src/defs.h @@ -374,6 +374,8 @@ typedef unsigned short dbtext; #define OCI_ERR_AQ_LISTEN_TIMEOUT 25254 #define OCI_ERR_AQ_DEQUEUE_TIMEOUT 25228 #define OCI_ERR_SUB_BUG_OCI_UTF16 24915 +#define OCI_ERR_AQ_QUEUE_NAME_INVALID 25200 +#define OCI_ERR_AQ_QUEUE_NOT_EXIST 24010 #define OCI_DEFAUT_STMT_CACHE_SIZE 20 diff --git a/src/dequeue.c b/src/dequeue.c index 8568bdb1..76742e8d 100644 --- a/src/dequeue.c +++ b/src/dequeue.c @@ -237,12 +237,14 @@ OCI_Msg * DequeueGetMessage /* context */ OCI_IPC_DEQUEUE, dequeue ) - sword ret = OCI_SUCCESS; + sword ret = OCI_ERROR; void *p_ind = NULL; int dbsize = -1; dbtext* dbstr = NULL; + char* ansi_queue_name = NULL; + CHECK_PTR(OCI_IPC_DEQUEUE, dequeue) /* reset message */ @@ -258,26 +260,63 @@ OCI_Msg * DequeueGetMessage p_ind = &dequeue->msg->ind; } - ret = OCIAQDeq(dequeue->typinf->con->cxt, dequeue->typinf->con->err, - (OraText *) dbstr, dequeue->opth, dequeue->msg->proph, - dequeue->typinf->tdo, &dequeue->msg->payload, - (void **) &p_ind, &dequeue->msg->id, OCI_DEFAULT); + /* OCIAQDeq() parameter 'queue_name' is supposed to be either ANSI or UTF16 depending on the + * environment. It appears that whatever mode is used, OCIAQDeq() only takes ANSI strings ! + * Oracle might fix this issue at some point. + * Thus let's try to handle oracle future version fixing this issue. + * Make a first attempt using the correct way. + * If an error is reported let's try again using an ANSI string. + */ - /* check returned error code */ +#ifdef OCI_CHARSET_WIDE + const size_t attempt_max = 2; +#else + const size_t attempt_max = 1; +#endif - if (OCI_ERROR == ret) + size_t attempt_count = 0; + + while (OCI_ERROR == ret && ++attempt_count <= attempt_max) { - sb4 code = 0; + void* name = attempt_count == 1 ? (void*)dbstr : (void*) ansi_queue_name; - OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, - (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, - (ub4) OCI_HTYPE_ERROR); + ret = OCIAQDeq(dequeue->typinf->con->cxt, dequeue->typinf->con->err, + (OraText *)name, dequeue->opth, dequeue->msg->proph, + dequeue->typinf->tdo, &dequeue->msg->payload, + (void **) &p_ind, &dequeue->msg->id, OCI_DEFAULT); - /* raise error only if the call has not been timed out */ + /* check returned error code */ - if (OCI_ERR_AQ_DEQUEUE_TIMEOUT != code) + if (OCI_ERROR == ret) { - THROW(ExceptionOCI, dequeue->typinf->con->err, ret) + sb4 code = 0; + + OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, + (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, + (ub4) OCI_HTYPE_ERROR); + + #ifdef OCI_CHARSET_WIDE + + if (dbstr == name && (OCI_ERR_AQ_QUEUE_NAME_INVALID == code || + OCI_ERR_AQ_QUEUE_NOT_EXIST == code)) + { + /* non valid queue name in UTF16 mode, we have an Oracle client with OCIAQDeq() + * accepting only ANSI strings.* Let's try again with an ANSI string for queue name + */ + + const int len = (int)ostrlen(dequeue->name); + ansi_queue_name = MemoryAlloc(OCI_IPC_STRING, sizeof(char), len + 1, FALSE); + StringNativeToAnsi(dequeue->name, ansi_queue_name, len); + } + else + +#endif + /* raise error only if the call has not been timed out */ + + if (OCI_ERR_AQ_DEQUEUE_TIMEOUT != code) + { + THROW(ExceptionOCI, dequeue->typinf->con->err, ret) + } } } @@ -297,8 +336,11 @@ OCI_Msg * DequeueGetMessage dequeue->msg->obj = ObjectInitialize ( - dequeue->typinf->con, (OCI_Object*)dequeue->msg->obj, - dequeue->msg->payload, dequeue->typinf, NULL, -1, TRUE + dequeue->typinf->con, + (OCI_Object*)dequeue->msg->obj, + dequeue->msg->payload, + dequeue->typinf, + NULL, -1, TRUE ); CHECK_NULL(dequeue->msg->obj) @@ -313,6 +355,8 @@ OCI_Msg * DequeueGetMessage CLEANUP_AND_EXIT_FUNC ( StringReleaseDBString(dbstr); + + FREE(ansi_queue_name) ) } diff --git a/src/enqueue.c b/src/enqueue.c index bbd5694d..69417d89 100644 --- a/src/enqueue.c +++ b/src/enqueue.c @@ -127,17 +127,20 @@ boolean EnqueuePut /* context */ OCI_IPC_ENQUEUE, enqueue ) - dbtext *dbstr = NULL; - int dbsize = -1; void *payload = NULL; void *ind = NULL; + sword ret = OCI_ERROR; + + int dbsize = -1; + dbtext* dbstr = NULL; + + char* ansi_queue_name = NULL; + CHECK_PTR(OCI_IPC_ENQUEUE, enqueue) CHECK_PTR(OCI_IPC_MSG, msg) CHECK_COMPAT(enqueue->typinf->tdo == msg->typinf->tdo) - dbstr = StringGetDBString(enqueue->name, &dbsize); - /* get payload */ if (OCI_UNKNOWN != enqueue->typinf->typecode) @@ -156,20 +159,74 @@ boolean EnqueuePut /* enqueue message */ - CHECK_OCI - ( - enqueue->typinf->con->err, - OCIAQEnq, - enqueue->typinf->con->cxt, enqueue->typinf->con->err, - (OraText *) dbstr, enqueue->opth, msg->proph, - enqueue->typinf->tdo, &payload, &ind, NULL, OCI_DEFAULT - ) + dbstr = StringGetDBString(enqueue->name, &dbsize); + + /* OCIAQEnq() parameter 'queue_name' is supposed to be either ANSI or UTF16 depending on the + * environment. It appears that whatever mode is used, OCIAQEnq() only takes ANSI strings ! + * Oracle might fix this issue at some point. + * Thus let's try to handle oracle future version fixing this issue. + * Make a first attempt using the correct way. + * If an error is reported let's try again using an ANSI string. + */ + + +#ifdef OCI_CHARSET_WIDE + const size_t attempt_max = 2; +#else + const size_t attempt_max = 1; +#endif + + size_t attempt_count = 0; + while (OCI_ERROR == ret && ++attempt_count <= attempt_max) + { + void* name = attempt_count == 1 ? (void*)dbstr : (void*) ansi_queue_name; + + ret = OCIAQEnq(enqueue->typinf->con->cxt, enqueue->typinf->con->err, + (OraText*)name, enqueue->opth, msg->proph, + enqueue->typinf->tdo, &payload, &ind, NULL, OCI_DEFAULT); + + /* check returned error code */ + + if (OCI_ERROR == ret) + { + sb4 code = 0; + + OCIErrorGet((dvoid *)enqueue->typinf->con->err, (ub4) 1, + (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, + (ub4) OCI_HTYPE_ERROR); + + #ifdef OCI_CHARSET_WIDE + + if (dbstr == name && (OCI_ERR_AQ_QUEUE_NAME_INVALID == code || + OCI_ERR_AQ_QUEUE_NOT_EXIST == code)) + { + /* non valid queue name in UTF16 mode, we have an Oracle client with OCIAQDeq() + * accepting only ANSI strings.* Let's try again with an ANSI string for queue name + */ + + const int len = (int)ostrlen(enqueue->name); + ansi_queue_name = MemoryAlloc(OCI_IPC_STRING, sizeof(char), len + 1, FALSE); + StringNativeToAnsi(enqueue->name, ansi_queue_name, len); + } + else + +#endif + /* raise error only if the call has not been timed out */ + + { + THROW(ExceptionOCI, enqueue->typinf->con->err, ret) + } + } + } + SET_SUCCESS() CLEANUP_AND_EXIT_FUNC ( StringReleaseDBString(dbstr); + + FREE(ansi_queue_name) ) } From 64bf96e1fc0dc763907afde560774f455d7ed4dd Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Mon, 18 May 2020 23:31:58 +0200 Subject: [PATCH 42/62] - Fixed Exception copy constructor that only copied the error message since the refactoring made in v4.7.0 - Make sure to free previous value when setting exception error message --- include/ocilibcpp/detail/Exception.hpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/include/ocilibcpp/detail/Exception.hpp b/include/ocilibcpp/detail/Exception.hpp index 37702d1e..14164a1d 100644 --- a/include/ocilibcpp/detail/Exception.hpp +++ b/include/ocilibcpp/detail/Exception.hpp @@ -49,9 +49,9 @@ inline Exception::Exception(OCI_Error *err) noexcept SetWhat(OCI_ErrorGetString(err)); } -inline Exception::Exception(const Exception& other) noexcept : Exception(nullptr) +inline Exception::Exception(const Exception& other) noexcept : Exception() { - SetWhat(other._what); + *this = other; } inline Exception::~Exception() noexcept @@ -63,7 +63,14 @@ inline Exception& Exception::operator = (const Exception& other) noexcept { if (this != &other) { - _what = ostrdup(other._what); + _pStatement = other._pStatement; + _pConnnection = other._pConnnection; + _row = other._row; + _type = other._type; + _errLib = other._errLib; + _errOracle = other._errOracle; + + SetWhat(other._what); } return *this; @@ -71,6 +78,12 @@ inline Exception& Exception::operator = (const Exception& other) noexcept inline void Exception::SetWhat(const otext* value) noexcept { + if (_what) + { + delete[] _what; + _what = nullptr; + } + if (!value) { return; From c2ed853c915aef990c8b12698fd3af6c4f538dfc Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 27 May 2020 07:54:48 +0200 Subject: [PATCH 43/62] Reset Error source pointer when freeing objects that can be error source --- src/agent.c | 2 ++ src/bind.c | 2 ++ src/collection.c | 2 ++ src/connection.c | 12 +++--------- src/date.c | 2 ++ src/dequeue.c | 2 ++ src/dirpath.c | 2 ++ src/element.c | 2 ++ src/enqueue.c | 2 ++ src/error.c | 22 ++++++++++++++++++++++ src/error.h | 9 ++++++++- src/file.c | 2 ++ src/hash.c | 2 ++ src/interval.c | 2 ++ src/iterator.c | 2 ++ src/list.c | 2 ++ src/lob.c | 2 ++ src/long.c | 2 ++ src/message.c | 2 ++ src/mutex.c | 2 ++ src/number.c | 2 ++ src/object.c | 2 ++ src/pool.c | 2 ++ src/reference.c | 2 ++ src/resultset.c | 2 ++ src/statement.c | 13 ++----------- src/subscription.c | 5 ++++- src/thread.c | 4 +++- src/threadkey.c | 2 ++ src/timestamp.c | 2 ++ src/transaction.c | 2 ++ src/typeinfo.c | 2 ++ 32 files changed, 94 insertions(+), 23 deletions(-) diff --git a/src/agent.c b/src/agent.c index 54f7bbc9..56dfb9c1 100644 --- a/src/agent.c +++ b/src/agent.c @@ -135,6 +135,8 @@ boolean AgentFree MemoryFreeDescriptor((dvoid*)agent->handle, OCI_DTYPE_AQAGENT); } + ErrorResetSource(NULL, agent); + FREE(agent->address) FREE(agent->name) FREE(agent) diff --git a/src/bind.c b/src/bind.c index 045bfdd9..62eeaeb2 100644 --- a/src/bind.c +++ b/src/bind.c @@ -959,6 +959,8 @@ boolean BindFree } } + ErrorResetSource(NULL, bnd); + FREE(bnd->buffer.inds) FREE(bnd->buffer.obj_inds) FREE(bnd->buffer.lens) diff --git a/src/collection.c b/src/collection.c index 6b213ba9..aa43d410 100644 --- a/src/collection.c +++ b/src/collection.c @@ -147,6 +147,8 @@ boolean CollectionFree if (OCI_OBJECT_ALLOCATED_ARRAY != coll->hstate) { + ErrorResetSource(NULL, coll); + FREE(coll) } diff --git a/src/connection.c b/src/connection.c index d5a0668e..7c6f4bc2 100644 --- a/src/connection.c +++ b/src/connection.c @@ -962,7 +962,7 @@ boolean ConnectionLogOff /* free all type info objects */ ListForEach(con->tinfs, (POCI_LIST_FOR_EACH)TypeInfoDispose); - ListClear(con->tinfs), + ListClear(con->tinfs); /* free all transactions */ @@ -1028,14 +1028,6 @@ boolean ConnectionDispose CHECK_PTR(OCI_IPC_CONNECTION, con) - /* clear connection reference from current error object */ - - err = ErrorGet(FALSE, FALSE); - if (NULL != err && err->source_ptr == con) - { - err->source_ptr = NULL; - } - /* clear server output resources */ ConnectionDisableServerOutput(con); @@ -1085,6 +1077,8 @@ boolean ConnectionDispose con->trsns = NULL; con->tinfs = NULL; + ErrorResetSource(NULL, con); + SET_SUCCESS() EXIT_FUNC() diff --git a/src/date.c b/src/date.c index c7627dcc..91b025db 100644 --- a/src/date.c +++ b/src/date.c @@ -150,6 +150,8 @@ boolean DateFree if (OCI_OBJECT_ALLOCATED_ARRAY != date->hstate) { + ErrorResetSource(NULL, date); + FREE(date) } diff --git a/src/dequeue.c b/src/dequeue.c index 76742e8d..9258eae3 100644 --- a/src/dequeue.c +++ b/src/dequeue.c @@ -144,6 +144,8 @@ boolean DequeueFree /* free data */ + ErrorResetSource(NULL, dequeue); + FREE(dequeue->name) FREE(dequeue->pattern) FREE(dequeue->consumer) diff --git a/src/dirpath.c b/src/dirpath.c index 1ad600c3..fc16ce7a 100644 --- a/src/dirpath.c +++ b/src/dirpath.c @@ -461,6 +461,8 @@ boolean DirPathFree MemoryFreeHandle(dp->arr, OCI_HTYPE_DIRPATH_COLUMN_ARRAY); MemoryFreeHandle(dp->ctx, OCI_HTYPE_DIRPATH_CTX); + ErrorResetSource(NULL, dp); + FREE(dp) SET_SUCCESS() diff --git a/src/element.c b/src/element.c index 04dad2bf..0f9f710e 100644 --- a/src/element.c +++ b/src/element.c @@ -425,6 +425,8 @@ boolean ElementFree ElemFreeAllocatedData(elem); + ErrorResetSource(NULL, elem); + FREE(elem->tmpbuf) FREE(elem) diff --git a/src/enqueue.c b/src/enqueue.c index 69417d89..81d7c04e 100644 --- a/src/enqueue.c +++ b/src/enqueue.c @@ -103,6 +103,8 @@ boolean EnqueueFree MemoryFreeDescriptor((dvoid *) enqueue->opth, OCI_DTYPE_AQENQ_OPTIONS); + ErrorResetSource(NULL, enqueue); + FREE(enqueue->name) FREE(enqueue) diff --git a/src/error.c b/src/error.c index c7dcdaeb..14cd4f35 100644 --- a/src/error.c +++ b/src/error.c @@ -144,6 +144,28 @@ void ErrorSet err->message_len = max(err->message_len, (unsigned int)total_len); } +/* --------------------------------------------------------------------------------------------- * + * ErrorResetSource + * --------------------------------------------------------------------------------------------- */ + +void ErrorResetSource +( + OCI_Error* err, + void* source_ptr +) +{ + if (err == NULL) + { + err = ErrorGet(FALSE, FALSE); + } + + if (err != NULL && err->source_ptr == source_ptr) + { + err->source_ptr = NULL; + err->source_type = OCI_UNKNOWN; + } +} + /* --------------------------------------------------------------------------------------------- * * ErrorGet * --------------------------------------------------------------------------------------------- */ diff --git a/src/error.h b/src/error.h index a609604c..b98dd52f 100644 --- a/src/error.h +++ b/src/error.h @@ -46,7 +46,14 @@ void ErrorSet unsigned int source_type, const char *location, otext *message, - unsigned int row); + unsigned int row +); + +void ErrorResetSource +( + OCI_Error* err, + void* source_ptr +); OCI_Error * ErrorGet ( diff --git a/src/file.c b/src/file.c index f42e86c7..7eb320fc 100644 --- a/src/file.c +++ b/src/file.c @@ -229,6 +229,8 @@ boolean FileFree if (OCI_OBJECT_ALLOCATED_ARRAY != file->hstate) { + ErrorResetSource(NULL, file); + FREE(file) } diff --git a/src/hash.c b/src/hash.c index 0027fac2..1fe464fe 100644 --- a/src/hash.c +++ b/src/hash.c @@ -240,6 +240,8 @@ boolean HashFree FREE(table->items) } + ErrorResetSource(NULL, table); + FREE(table) SET_SUCCESS() diff --git a/src/interval.c b/src/interval.c index e412400c..84e2fbe7 100644 --- a/src/interval.c +++ b/src/interval.c @@ -170,6 +170,8 @@ boolean IntervalFree if (OCI_OBJECT_ALLOCATED_ARRAY != itv->hstate) { + ErrorResetSource(NULL, itv); + FREE(itv) } diff --git a/src/iterator.c b/src/iterator.c index 0a485792..4011e0fa 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -121,6 +121,8 @@ boolean IteratorFree /* free iterator structure */ + ErrorResetSource(NULL, iter); + FREE(iter) SET_SUCCESS() diff --git a/src/list.c b/src/list.c index b69306c4..35395af9 100644 --- a/src/list.c +++ b/src/list.c @@ -174,6 +174,8 @@ boolean ListFree MutexFree(list->mutex); } + ErrorResetSource(NULL, list); + FREE(list) SET_SUCCESS() diff --git a/src/lob.c b/src/lob.c index 3cd0f81e..e5391888 100644 --- a/src/lob.c +++ b/src/lob.c @@ -202,6 +202,8 @@ boolean LobFree if (OCI_OBJECT_ALLOCATED_ARRAY != lob->hstate) { + ErrorResetSource(NULL, lob); + FREE(lob) } diff --git a/src/long.c b/src/long.c index d1cba0f0..a151de37 100644 --- a/src/long.c +++ b/src/long.c @@ -120,6 +120,8 @@ boolean LongFree CHECK_PTR(OCI_IPC_LONG, lg) CHECK_OBJECT_FETCHED(lg) + ErrorResetSource(NULL, lg); + FREE(lg->buffer) FREE(lg) diff --git a/src/message.c b/src/message.c index 48b24d54..e68fe94a 100644 --- a/src/message.c +++ b/src/message.c @@ -152,6 +152,8 @@ boolean MessageFree MemoryFreeDescriptor((dvoid*)msg->proph, OCI_DTYPE_AQMSG_PROPERTIES); + ErrorResetSource(NULL, msg); + FREE(msg) SET_SUCCESS() diff --git a/src/mutex.c b/src/mutex.c index 55c87473..cf946583 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -130,6 +130,8 @@ boolean MutexFree /* free mutex structure */ + ErrorResetSource(NULL, mutex); + FREE(mutex) SET_SUCCESS() diff --git a/src/number.c b/src/number.c index a0fa0c31..dbd30ce5 100644 --- a/src/number.c +++ b/src/number.c @@ -660,6 +660,8 @@ boolean NumberFree if (OCI_OBJECT_ALLOCATED_ARRAY != number->hstate) { + ErrorResetSource(NULL, number); + FREE(number) } diff --git a/src/object.c b/src/object.c index f625d66b..82335374 100644 --- a/src/object.c +++ b/src/object.c @@ -932,6 +932,8 @@ boolean ObjectFree if (OCI_OBJECT_ALLOCATED_ARRAY != obj->hstate) { + ErrorResetSource(NULL, obj); + FREE(obj) } diff --git a/src/pool.c b/src/pool.c index 1e3e9032..dae6d081 100644 --- a/src/pool.c +++ b/src/pool.c @@ -114,6 +114,8 @@ boolean PoolDispose FREE(pool->user) FREE(pool->pwd) + ErrorResetSource(NULL, pool); + SET_SUCCESS() EXIT_FUNC() diff --git a/src/reference.c b/src/reference.c index 651bca15..0bcc3795 100644 --- a/src/reference.c +++ b/src/reference.c @@ -223,6 +223,8 @@ boolean ReferenceFree if (OCI_OBJECT_ALLOCATED_ARRAY != ref->hstate) { + ErrorResetSource(NULL, ref); + FREE(ref) } diff --git a/src/resultset.c b/src/resultset.c index 17072344..a0e34939 100644 --- a/src/resultset.c +++ b/src/resultset.c @@ -919,6 +919,8 @@ boolean ResultsetFree FREE(rs->defs) + ErrorResetSource(NULL, rs); + FREE(rs) EXIT_FUNC() diff --git a/src/statement.c b/src/statement.c index 86e3cd87..abdd5c42 100644 --- a/src/statement.c +++ b/src/statement.c @@ -1052,21 +1052,12 @@ boolean StatementDispose CHECK_PTR(OCI_IPC_STATEMENT, stmt) - OCI_Error* err = NULL; - - /* clear statement reference from current error object */ - - err = ErrorGet(FALSE, FALSE); - - if (NULL != err && err->source_ptr == stmt) - { - err->source_ptr = NULL; - } - /* reset data */ StatementReset(stmt); + ErrorResetSource(NULL, stmt); + SET_SUCCESS() EXIT_FUNC() diff --git a/src/subscription.c b/src/subscription.c index 30a2920e..75d7ec82 100644 --- a/src/subscription.c +++ b/src/subscription.c @@ -131,7 +131,10 @@ boolean SubscriptionDispose SET_SUCCESS() - EXIT_FUNC() + CLEANUP_AND_EXIT_FUNC + ( + ErrorResetSource(NULL, sub); + ) } /* --------------------------------------------------------------------------------------------- * diff --git a/src/thread.c b/src/thread.c index 2fa05610..4c95306b 100644 --- a/src/thread.c +++ b/src/thread.c @@ -158,9 +158,11 @@ boolean ThreadFree { MemoryFreeHandle(thread->err, OCI_HTYPE_ERROR); } - + /* free thread structure */ + ErrorResetSource(NULL, thread); + FREE(thread) SET_SUCCESS() diff --git a/src/threadkey.c b/src/threadkey.c index fc3bff7d..482303f5 100644 --- a/src/threadkey.c +++ b/src/threadkey.c @@ -108,6 +108,8 @@ boolean ThreadKeyFree /* free key structure */ + ErrorResetSource(NULL, key); + FREE(key) SET_SUCCESS() diff --git a/src/timestamp.c b/src/timestamp.c index 6d3b4cc9..817fd127 100644 --- a/src/timestamp.c +++ b/src/timestamp.c @@ -189,6 +189,8 @@ boolean TimestampFree if (OCI_OBJECT_ALLOCATED_ARRAY != tmsp->hstate) { + ErrorResetSource(NULL, tmsp); + FREE(tmsp) } diff --git a/src/transaction.c b/src/transaction.c index dc4e0303..26f354ce 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -55,6 +55,8 @@ boolean TransactionDispose trans->con->trs = NULL; } + ErrorResetSource(NULL, trans); + SET_SUCCESS() EXIT_FUNC() diff --git a/src/typeinfo.c b/src/typeinfo.c index 25e2d951..ac588843 100644 --- a/src/typeinfo.c +++ b/src/typeinfo.c @@ -81,6 +81,8 @@ boolean TypeInfoDispose FREE(typinf->schema) FREE(typinf->offsets) + ErrorResetSource(NULL, typinf); + SET_SUCCESS() EXIT_FUNC(); From 640a88a1d7fd53048cf028b9f21a5a0caa0dfbf1 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 27 May 2020 08:06:07 +0200 Subject: [PATCH 44/62] Added new exception OCI_ERR_UNFREED_BYTES raised by OCI_Cleanup() if OCILIB had unfreed data (e.g. bug in the library or user did not free some objects) --- include/ocilibc/config.h | 3 ++- src/environment.c | 8 ++++++++ src/exception.c | 21 ++++++++++++++++++--- src/exception.h | 6 ++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/include/ocilibc/config.h b/include/ocilibc/config.h index ec11cf46..770d874b 100644 --- a/include/ocilibc/config.h +++ b/include/ocilibc/config.h @@ -469,8 +469,9 @@ typedef unsigned int big_uint; #define OCI_ERR_XA_ENV_FROM_STRING 28 #define OCI_ERR_XA_CONN_FROM_STRING 29 #define OCI_ERR_BIND_EXTERNAL_NOT_ALLOWED 30 +#define OCI_ERR_UNFREED_BYTES 31 -#define OCI_ERR_COUNT 31 +#define OCI_ERR_COUNT 32 /* Public OCILIB handles */ diff --git a/src/environment.c b/src/environment.c index 0654e4e3..cbe6abd6 100644 --- a/src/environment.c +++ b/src/environment.c @@ -1641,6 +1641,14 @@ boolean EnvironmentCleanup success = FALSE; } + /* checks for non freed library memory */ + + if (Env.mem_bytes_lib > 0) + { + ExceptionUnfreedBytes(&call_context, Env.mem_bytes_lib); + success = FALSE; + } + /* free environment errors */ if (NULL != Env.lib_err) diff --git a/src/exception.c b/src/exception.c index 4e2afd7f..027bd0ea 100644 --- a/src/exception.c +++ b/src/exception.c @@ -128,7 +128,8 @@ static const otext * ErrorMessages[OCI_ERR_COUNT] = OTEXT("Argument '%ls' : Invalid value %d"), OTEXT("Cannot retrieve OCI environment from XA connection string '%ls'"), OTEXT("Cannot connect to database using XA connection string '%ls'"), - OTEXT("Binding '%ls': Passing non NULL host variable is not allowed when bind allocation mode is internal") + OTEXT("Binding '%ls': Passing non NULL host variable is not allowed when bind allocation mode is internal"), + OTEXT("Found %d non freed allocated bytes") }; #else @@ -165,7 +166,8 @@ static const otext * ErrorMessages[OCI_ERR_COUNT] = OTEXT("Argument '%s' : Invalid value %d"), OTEXT("Cannot retrieve OCI environment from XA connection string '%s'"), OTEXT("Cannot connect to database using XA connection string '%s'"), - OTEXT("Binding '%s': Passing non NULL host variable is not allowed when bind allocation mode is internal") + OTEXT("Binding '%s': Passing non NULL host variable is not allowed when bind allocation mode is internal"), + OTEXT("Found %d non freed allocated bytes") }; #endif @@ -518,7 +520,7 @@ void ExceptionOutOfBounds } /* --------------------------------------------------------------------------------------------- * -* OCI_ExceptionUnfreedData +* ExceptionUnfreedData * --------------------------------------------------------------------------------------------- */ void ExceptionUnfreedData @@ -531,6 +533,19 @@ void ExceptionUnfreedData EXCEPTION_IMPL(OCI_ERR_UNFREED_DATA, nb_elem, HandleNames[type_elem - 1]) } +/* --------------------------------------------------------------------------------------------- * +* ExceptionUnfreedBytes +* --------------------------------------------------------------------------------------------- */ + +void ExceptionUnfreedBytes +( + OCI_Context* ctx, + big_uint nb_bytes +) +{ + EXCEPTION_IMPL(OCI_ERR_UNFREED_BYTES, nb_bytes) +} + /* --------------------------------------------------------------------------------------------- * * ExceptionRuntimeLoading * --------------------------------------------------------------------------------------------- */ diff --git a/src/exception.h b/src/exception.h index dd25ea48..a1ca6d94 100644 --- a/src/exception.h +++ b/src/exception.h @@ -105,6 +105,12 @@ void ExceptionUnfreedData int nb_elem ); +void ExceptionUnfreedBytes +( + OCI_Context* ctx, + size_t nb_bytes +); + void ExceptionMaxBind ( OCI_Context* ctx From ce9a37f0b2df3afab001bc475de434d47f723476 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 27 May 2020 08:10:55 +0200 Subject: [PATCH 45/62] fixed ExceptionUnfreedBytes() declaration --- src/exception.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exception.h b/src/exception.h index a1ca6d94..b4630e45 100644 --- a/src/exception.h +++ b/src/exception.h @@ -108,7 +108,7 @@ void ExceptionUnfreedData void ExceptionUnfreedBytes ( OCI_Context* ctx, - size_t nb_bytes + big_uint nb_bytes ); void ExceptionMaxBind From a926ddbc87f8743453f80ce9fd7e0441ccc6da08 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 09:04:48 +0200 Subject: [PATCH 46/62] moved OCI_SetErrorHandler declation into OcilibCApiErrorHandling doxygem section --- include/ocilibc/api.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/include/ocilibc/api.h b/include/ocilibc/api.h index 0073d981..c4759889 100644 --- a/include/ocilibc/api.h +++ b/include/ocilibc/api.h @@ -231,22 +231,6 @@ OCI_EXPORT boolean OCI_API OCI_EnableWarnings boolean value ); -/** - * @brief - * Set the global error user handler - * - * @param handler - Pointer to error handler procedure - * - * @note - * Use this call to change or remove the user callback error handler installed by OCI_Initialize() - * - */ - -OCI_EXPORT boolean OCI_API OCI_SetErrorHandler -( - POCI_ERROR handler -); - /** * @brief * Set the High availability (HA) user handler @@ -327,6 +311,22 @@ OCI_EXPORT boolean OCI_API OCI_SetHAHandler * */ +/** + * @brief + * Set the global error user handler + * + * @param handler - Pointer to error handler procedure + * + * @note + * Use this call to change or remove the user callback error handler installed by OCI_Initialize() + * + */ + +OCI_EXPORT boolean OCI_API OCI_SetErrorHandler +( + POCI_ERROR handler +); + /** * @brief * Retrieve the last error or warning occurred within the last OCILIB call From 4a3d7dcc987cf4e2cf52580e92ca09bb77337512 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 10:02:06 +0200 Subject: [PATCH 47/62] Fixed #238 : lob to string conversion in OCI_GetString() returns truncated value when using UTF8 --- src/strings.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/strings.c b/src/strings.c index e611b532..61fc0215 100644 --- a/src/strings.c +++ b/src/strings.c @@ -845,23 +845,19 @@ unsigned int StringGetFromType res = LobRead2(lob, lob_buf, &char_count, &bytes_count); - if (bytes_count > 0) + if (bytes_count == 0) { - if (OCI_CLOB == lob->type) - { - len += StringAddToBuffer(buffer, len, (otext*)lob_buf, - ocharcount(bytes_count), quote); - } - else - { - len += StringBinaryToString(lob_buf, bytes_count, ptr + len); - } + break; } - if (bytes_count < bytes_requested) + if (OCI_CLOB == lob->type) { - /* lob eof reached */ - break; + len += StringAddToBuffer(buffer, len, (otext*)lob_buf, + ocharcount(bytes_count), quote); + } + else + { + len += StringBinaryToString(lob_buf, bytes_count, ptr + len); } } From f6d652b73700003ae78f6c8c6114094c5484a8d4 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 18:48:51 +0200 Subject: [PATCH 48/62] Fixed memory leak introduced during v4.7.0 refactoring --- src/iterator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/iterator.c b/src/iterator.c index 4011e0fa..403b968a 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -65,7 +65,8 @@ OCI_Iter * IteratorCreate /* create data element */ - CHECK_NULL(ElementInitialize(coll->con, iter->elem, NULL, (OCIInd *)NULL, coll->typinf)) + iter->elem = ElementInitialize(coll->con, iter->elem, NULL, (OCIInd*)NULL, coll->typinf); + CHECK_NULL(iter->elem) CLEANUP_AND_EXIT_FUNC ( From fcc63c60cdf5b09b549c639a9c31d90e376fac52 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 18:50:25 +0200 Subject: [PATCH 49/62] Fixed segfault in OCI_Cleanup() when using OCI_ENV_THREADED (introduced during the v4.7.0 refactoring) --- src/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.c b/src/error.c index 14cd4f35..48e3ec8c 100644 --- a/src/error.c +++ b/src/error.c @@ -178,7 +178,7 @@ OCI_Error * ErrorGet { OCI_Error *err = Env.lib_err; - if (Env.loaded && LIB_THREADED) + if (Env.loaded && LIB_THREADED && Env.key_errs != NULL) { if (ThreadKeyGet(Env.key_errs, (void **)(dvoid *)&err)) { From a9e7818de526870428d6a09f2d494320f0902a87 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 22:17:50 +0200 Subject: [PATCH 50/62] Fixed a tiny memory leak where using implicit resultsets (OCI_Statement structure was not freed) --- src/statement.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/statement.c b/src/statement.c index abdd5c42..f62c641c 100644 --- a/src/statement.c +++ b/src/statement.c @@ -1654,26 +1654,27 @@ boolean StatementReleaseResultsets CHECK_PTR(OCI_IPC_STATEMENT, stmt) - /* Release statements for implicit resultsets */ + /* release statements for implicit resultsets */ if (NULL != stmt->stmts) { - for (i = 0; i < stmt->nb_stmt; i++) + for (i = 0; i < stmt->nb_stmt; i++) { - if (stmt->rsts[i]) + if (stmt->stmts[i] != NULL) { StatementDispose(stmt->stmts[i]); + FREE(stmt->stmts[i]) } } - FREE(stmt->rsts) + FREE(stmt->stmts) } /* release resultsets */ if (NULL != stmt->rsts) { - for (i = 0; i < stmt->nb_rs; i++) + for (i = 0; i < stmt->nb_rs; i++) { - if (stmt->rsts[i]) + if (stmt->rsts[i] != NULL) { ResultsetFree(stmt->rsts[i]); } From e5820903ea6fe932868c4f18c62d529b0a213ded Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 22:22:18 +0200 Subject: [PATCH 51/62] added test suite for #238 fix --- tests/TestReportedIssues.cpp | 51 +++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/tests/TestReportedIssues.cpp b/tests/TestReportedIssues.cpp index f1f6416c..31e16851 100644 --- a/tests/TestReportedIssues.cpp +++ b/tests/TestReportedIssues.cpp @@ -139,8 +139,57 @@ TEST(ReportedIssues, Issue225) otext buffer[100]; ASSERT_NE(0, OCI_NumberToText(numbers[i], NULL, 100, buffer)); ASSERT_EQ(expected, ostring(buffer)); + ASSERT_TRUE(OCI_NumberFree(numbers[i])); } ASSERT_TRUE(OCI_ConnectionFree(conn)); ASSERT_TRUE(OCI_Cleanup()); -} \ No newline at end of file +} + + +#ifdef OCI_CHARSET_ANSI + +TEST(ReportedIssues, Issue238) +{ + ExecDML(OTEXT("create table FetchLobAsString(value clob)")); + + const char* nsl_lang = getenv("NLS_LANG"); + putenv("NLS_LANG=American_America.UTF8"); + + ASSERT_TRUE(OCI_Initialize(nullptr, HOME, OCI_ENV_DEFAULT)); + + const auto conn = OCI_ConnectionCreate(DBS, USR, PWD, OCI_SESSION_DEFAULT); + ASSERT_NE(nullptr, conn); + + const auto stmt = OCI_StatementCreate(conn); + ASSERT_NE(nullptr, stmt); + + ASSERT_TRUE(OCI_ExecuteStmt(stmt, OTEXT("declare c clob; begin c := c||rpad('a', 32767, 'a'); insert into FetchLobAsString values (c); end;"))); + ASSERT_TRUE(OCI_ExecuteStmt(stmt, OTEXT("select value from FetchLobAsString"))); + + auto rslt = OCI_GetResultset(stmt); + ASSERT_NE(nullptr, rslt); + + ASSERT_TRUE(OCI_FetchNext(rslt)); + + auto value = OCI_GetString(rslt, 1); + ASSERT_NE(nullptr, value); + auto len = strlen(value); + ASSERT_EQ(32767, len); + + ASSERT_TRUE(OCI_StatementFree(stmt)); + ASSERT_TRUE(OCI_ConnectionFree(conn)); + ASSERT_TRUE(OCI_Cleanup()); + + std::string new_nls_lang = "NLS_LANG="; + + if (nsl_lang) + { + new_nls_lang += nsl_lang; + } + putenv(new_nls_lang.data()); + + ExecDML(OTEXT("drop table FetchLobAsString;")); +} + +#endif \ No newline at end of file From 248409be873072d9e193af9a6f31583e81ff1d5b Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 22:28:52 +0200 Subject: [PATCH 52/62] test suite fixes --- tests/TestCollection.cpp | 3 +++ tests/TestConnection.cpp | 2 +- tests/ocilib_tests.h | 4 ++++ tests/ocilib_tests.vcxproj | 4 ++-- tests/ocilib_tests.vcxproj.filters | 6 +++--- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/TestCollection.cpp b/tests/TestCollection.cpp index 908c9ca2..d3d0534f 100644 --- a/tests/TestCollection.cpp +++ b/tests/TestCollection.cpp @@ -54,6 +54,8 @@ void SelectCollection(ostring sql) ASSERT_EQ(itemName, OCI_ObjectGetString(obj, OTEXT("name"))); elem = OCI_IterGetNext(iter); } + + ASSERT_TRUE(OCI_IterFree(iter)); } ASSERT_EQ(expectedRows, nbRows); @@ -110,6 +112,7 @@ void BindOutCollection(ostring type, ostring sql) ASSERT_EQ(expectedItems, itemIndex); + ASSERT_TRUE(OCI_IterFree(iter)); ASSERT_TRUE(OCI_CollFree(coll)); ASSERT_TRUE(OCI_StatementFree(stmt)); ASSERT_TRUE(OCI_ConnectionFree(conn)); diff --git a/tests/TestConnection.cpp b/tests/TestConnection.cpp index 5e844ff8..6f31ba4c 100644 --- a/tests/TestConnection.cpp +++ b/tests/TestConnection.cpp @@ -79,7 +79,7 @@ TEST(TestConnection, Abort) OCI_ThreadRun(thrd, callback, stmt); - Sleep(500); + Sleep(1000); ASSERT_TRUE(OCI_Break(conn)); ASSERT_TRUE(OCI_ThreadJoin(thrd)); diff --git a/tests/ocilib_tests.h b/tests/ocilib_tests.h index 3b59fa1c..284f338d 100644 --- a/tests/ocilib_tests.h +++ b/tests/ocilib_tests.h @@ -8,11 +8,15 @@ #include #ifdef _UNICODE + #ifndef OCI_CHARSET_WIDE #define OCI_CHARSET_WIDE + #endif #define TO_STRING std::to_wstring using ostring = std::wstring; #else + #ifndef OCI_CHARSET_ANSI #define OCI_CHARSET_ANSI + #endif #define TO_STRING std::to_string using ostring = std::string; #endif diff --git a/tests/ocilib_tests.vcxproj b/tests/ocilib_tests.vcxproj index e390ad80..53f83d16 100644 --- a/tests/ocilib_tests.vcxproj +++ b/tests/ocilib_tests.vcxproj @@ -102,7 +102,7 @@ - + @@ -152,7 +152,7 @@ NotUsing pch.h Disabled - X64;_DEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) + X64;__DEBUG;_CONSOLE;OCI_IMPORT_RUNTIME;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug Level3 diff --git a/tests/ocilib_tests.vcxproj.filters b/tests/ocilib_tests.vcxproj.filters index 48ee29b8..2d73735b 100644 --- a/tests/ocilib_tests.vcxproj.filters +++ b/tests/ocilib_tests.vcxproj.filters @@ -145,9 +145,6 @@ Tests suite - - Tests suite - Tests suite @@ -211,6 +208,9 @@ Tests suite + + Tests suite + From 3a8b8fcbef2bc993fcf991217a3cef717815b926 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 22:29:58 +0200 Subject: [PATCH 53/62] discard generated nugets in .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bdc15ed2..9f7fe373 100644 --- a/.gitignore +++ b/.gitignore @@ -177,3 +177,4 @@ $RECYCLE.BIN/ /tests/packages/*.* testlog.manifest *.testlog +/nuget/*.nupkg From 1786410a87092a77d5ed83ed67a85ab7fbcfe619 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Tue, 7 Jul 2020 22:35:21 +0200 Subject: [PATCH 54/62] Update local variable name in MemoryAlloc() --- src/memory.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/memory.c b/src/memory.c index c1e0889a..0cc11276 100644 --- a/src/memory.c +++ b/src/memory.c @@ -80,24 +80,24 @@ void * MemoryAlloc const size_t size = sizeof(OCI_MemoryBlock) + (block_size * block_count); - OCI_MemoryBlock* mem_block = (OCI_MemoryBlock *)malloc(size); + OCI_MemoryBlock* block = (OCI_MemoryBlock *)malloc(size); - if (NULL == mem_block) + if (NULL == block) { THROW(ExceptionMemory, ptr_type, size) } if (zero_fill) { - memset(mem_block, 0, size); + memset(block, 0, size); } - mem_block->type = ptr_type; - mem_block->size = (unsigned int) size; + block->type = ptr_type; + block->size = (unsigned int) size; - MemoryUpdateBytes(mem_block->type, mem_block->size); + MemoryUpdateBytes(block->type, block->size); - SET_RETVAL(((unsigned char*)mem_block) + sizeof(*mem_block)) + SET_RETVAL(((unsigned char*)block) + sizeof(*block)) EXIT_FUNC() } From b25bfc2bcd73ed8b38ab62952cbe38d28306abe7 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Wed, 15 Jul 2020 21:51:46 +0200 Subject: [PATCH 55/62] Fixed issue #239 --- src/statement.c | 6 ++++-- src/strings.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/statement.c b/src/statement.c index f62c641c..c4a5b39b 100644 --- a/src/statement.c +++ b/src/statement.c @@ -47,7 +47,8 @@ static unsigned int TimestampTypeValues[] = { OCI_TIMESTAMP, - OCI_TIMESTAMP_TZ, OCI_TIMESTAMP_LTZ + OCI_TIMESTAMP_TZ, + OCI_TIMESTAMP_LTZ }; static unsigned int IntervalTypeValues[] = @@ -61,7 +62,8 @@ static unsigned int IntervalTypeValues[] = static unsigned int LobTypeValues[] = { OCI_CLOB, - OCI_NCLOB, OCI_BLOB + OCI_NCLOB, + OCI_BLOB }; static unsigned int FileTypeValues[] = diff --git a/src/strings.c b/src/strings.c index 61fc0215..7cb143d2 100644 --- a/src/strings.c +++ b/src/strings.c @@ -850,14 +850,14 @@ unsigned int StringGetFromType break; } - if (OCI_CLOB == lob->type) + if (OCI_BLOB == lob->type) { - len += StringAddToBuffer(buffer, len, (otext*)lob_buf, - ocharcount(bytes_count), quote); + len += StringBinaryToString(lob_buf, bytes_count, ptr + len); } else { - len += StringBinaryToString(lob_buf, bytes_count, ptr + len); + len += StringAddToBuffer(buffer, len, (otext*)lob_buf, + ocharcount(bytes_count), quote); } } From 4af40fba59128abd4b3b532ced83b9e2871b9557 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 09:37:23 +0200 Subject: [PATCH 56/62] updated changelog for v.4.7.0 --- ChangeLog | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d7edd8e4..1c9ba269 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,44 @@ -2020-05-16 Version 4.7.0 Vincent Rogier vince.rogier@ocilib.net +2020-07-09 Version 4.7.0 Vincent Rogier vince.rogier@ocilib.net * Enhancements (C API) + - Library internal design changes (preparing v5.0.0) + * OCILIB code base has been layered in 2 distinct API layers: + - Internal API which has now its own separate design + - v4.7.0 internal API, while matching the public one in this version, has most of its methods renamed + - It will evolve differently, preparing new public APIs for future versions + - Public APIs exposing features to clients + - v4.7.0 is exposing the same public API as previous versions + - v5.0.0 will expose a different API + - Both will use same internal API + - Contextual error management enhancements + - As internal APIs cannot be called from outside the library, last error management has been simplified and improved + * Public headers reorganizatoion: + * Broke up ocilib.h content into multiple headers located in /include/ocilibc/ + * Broke up C++ headers content into multiple headers located in /include/ocilibcpp/ + + - Enhanced Error handing: + * Updated OCI_Cleanup(): if there are any unfreed allocated bytes by the library itself (e.g. OCILIB user objects not freed) + - it raises an error of type OCI_ERR_UNFREED_BYTES (with the amount of bytes in the error message) + - it completes cleanup and returns FALSE + * Added method OCI_ErrorGetLocation() to return the method name where the exception occured + * Updated method OCI_ErrorGetString() to return a string using the following format "Error occured at {Location}: {Description}" + * Fixes (C API) + - Issue 239: Fetching nclobs as strings return value in hexa format truncated values when nsl_lang is UTF8 + - Issue 238: Fetching clobs as strings return truncated values when nsl_lang is UTF8 + - Issue 236: Memory issue with OCI_BAM_INTERNAL and OCI_CDT_NUMERIC + - Fixed OCI_EnqueuePut() and OCI_DequeueGet() in OCI_CHARSET_WIDE charset mode (added a workaround for a known oracle client UTF16 bug) + - Fixed a minor memory leak when using implicit resultsets + * Fixes (C++ API) + + - Issue 230: Memory leaks while rebinding vectors + + * Miscellaneous + + - Extended C API Test suite that has now a much wider coverage 2020-04-18 Version 4.6.4 Vincent Rogier vince.rogier@ocilib.net From c88ef329cc0084825d422fb25d8ab8ec3d631ae7 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 09:37:53 +0200 Subject: [PATCH 57/62] updated changelog --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c9ba269..31a1a898 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,10 @@ -2020-07-09 Version 4.7.0 Vincent Rogier vince.rogier@ocilib.net +2020-07-16 Version 4.7.0 Vincent Rogier vince.rogier@ocilib.net * Enhancements (C API) - Library internal design changes (preparing v5.0.0) * OCILIB code base has been layered in 2 distinct API layers: - - Internal API which has now its own separate design + - Internal API that has now its own separate design - v4.7.0 internal API, while matching the public one in this version, has most of its methods renamed - It will evolve differently, preparing new public APIs for future versions - Public APIs exposing features to clients From e99ad529bc0712c353953cb749b0f3122296beab Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 09:45:15 +0200 Subject: [PATCH 58/62] Removed unused variable --- src/connection.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/connection.c b/src/connection.c index 7c6f4bc2..19f80e85 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1023,7 +1023,6 @@ boolean ConnectionDispose /* context */ OCI_IPC_CONNECTION, con ) - OCI_Error* err = NULL; unsigned int i = 0; CHECK_PTR(OCI_IPC_CONNECTION, con) From 720c8ee9d5fa28d5faf466b8a40103c17a53ee16 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 09:48:20 +0200 Subject: [PATCH 59/62] fixed typo in changelog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 31a1a898..449c0b56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,7 @@ - Both will use same internal API - Contextual error management enhancements - As internal APIs cannot be called from outside the library, last error management has been simplified and improved - * Public headers reorganizatoion: + * Public headers reorganization: * Broke up ocilib.h content into multiple headers located in /include/ocilibc/ * Broke up C++ headers content into multiple headers located in /include/ocilibcpp/ From 4eec974920e844a81118b0bee739390054fad9b9 Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 10:04:37 +0200 Subject: [PATCH 60/62] update ocilib version in C header --- include/ocilibc/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ocilibc/config.h b/include/ocilibc/config.h index 770d874b..12104874 100644 --- a/include/ocilibc/config.h +++ b/include/ocilibc/config.h @@ -86,8 +86,8 @@ * --------------------------------------------------------------------------------------------- */ #define OCILIB_MAJOR_VERSION 4 -#define OCILIB_MINOR_VERSION 6 -#define OCILIB_REVISION_VERSION 4 +#define OCILIB_MINOR_VERSION 7 +#define OCILIB_REVISION_VERSION 0 /* Import mode */ From 35ad5d341bf464ad21dab207dd91750c13badc3f Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 10:16:38 +0200 Subject: [PATCH 61/62] Update changelog --- ChangeLog | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 449c0b56..cbc4e155 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,10 +12,19 @@ - v5.0.0 will expose a different API - Both will use same internal API - Contextual error management enhancements - - As internal APIs cannot be called from outside the library, last error management has been simplified and improved - * Public headers reorganization: - * Broke up ocilib.h content into multiple headers located in /include/ocilibc/ - * Broke up C++ headers content into multiple headers located in /include/ocilibcpp/ + - As internal APIs cannot be called from outside the library, last error management has been simplified and improved + - Enhancements on internal methods implementation: + - Since v3.0.0 (back in 2008), OCILIB methods implementations are standardized to follow the same single exit point pattern + - Standardized entry point checks and exit points are based on extentive macros usage + - But the control flow was handled by a status variable leading to continuous and nested checks + - With 4.7.0, no more "if (STATUS) {...}" in the code. + - Instead, in case of errors, code directly jumps to exit points that can have cleanup code sections. + - See it as try {...} finally{...} + - Thus, code is now very sequential, much easier to read, with no nested error management/branching. + + - Public headers reorganization: + * Broke up ocilib.h content into multiple headers located in /include/ocilibc/ + * Broke up C++ headers content into multiple headers located in /include/ocilibcpp/ - Enhanced Error handing: * Updated OCI_Cleanup(): if there are any unfreed allocated bytes by the library itself (e.g. OCILIB user objects not freed) From db3238008a170e16da125cf75789adde8facc18e Mon Sep 17 00:00:00 2001 From: Vincent Rogier Date: Thu, 16 Jul 2020 10:34:55 +0200 Subject: [PATCH 62/62] updated code::blocks project file --- proj/mingw/ocilib_static_lib_mingw.cbp | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/proj/mingw/ocilib_static_lib_mingw.cbp b/proj/mingw/ocilib_static_lib_mingw.cbp index b80a64bb..8e7a81c1 100644 --- a/proj/mingw/ocilib_static_lib_mingw.cbp +++ b/proj/mingw/ocilib_static_lib_mingw.cbp @@ -72,6 +72,9 @@ + + @@ -90,7 +93,10 @@ - + + + @@ -111,13 +117,13 @@ - + - + - + @@ -132,7 +138,7 @@ - + @@ -144,22 +150,16 @@ - - - - - - - - - + + - + @@ -168,7 +168,7 @@ - +