OCILIB (C Driver for Oracle) 3.12.1
|
00001 /* 00002 +-----------------------------------------------------------------------------------------+ 00003 | | 00004 | OCILIB - C Driver for Oracle | 00005 | | 00006 | (C Wrapper for Oracle OCI) | 00007 | | 00008 | Website : http://www.ocilib.net | 00009 | | 00010 | Copyright (c) 2007-2013 Vincent ROGIER <vince.rogier@ocilib.net> | 00011 | | 00012 +-----------------------------------------------------------------------------------------+ 00013 | | 00014 | This library is free software; you can redistribute it and/or | 00015 | modify it under the terms of the GNU Lesser General Public | 00016 | License as published by the Free Software Foundation; either | 00017 | version 2 of the License, or (at your option) any later version. | 00018 | | 00019 | This library is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 00022 | Lesser General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU Lesser General Public | 00025 | License along with this library; if not, write to the Free | 00026 | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 00027 | | 00028 +-----------------------------------------------------------------------------------------+ 00029 */ 00030 00031 /* --------------------------------------------------------------------------------------------- * 00032 * $Id: ocilib_defs.h, Vincent Rogier $ 00033 * --------------------------------------------------------------------------------------------- */ 00034 00035 #ifndef OCILIB_OCILIB_DEFS_H_INCLUDED 00036 #define OCILIB_OCILIB_DEFS_H_INCLUDED 00037 00038 #include "ocilib.h" 00039 #include "oci_import.h" 00040 00041 /* ********************************************************************************************* * 00042 ORACLE VERSION DETECTION 00043 * ********************************************************************************************* */ 00044 00045 #ifdef OCI_IMPORT_RUNTIME 00046 00047 /* for runtime loading, set compile time version to the highest minimum 00048 version needed by OCILIB encapsulation of OCI */ 00049 00050 #define OCI_VERSION_COMPILE OCI_11_2 00051 00052 /* set runtime version to unknown, it will be guessed from symbols loading */ 00053 00054 #define OCI_VERSION_RUNTIME OCI_UNKNOWN 00055 00056 #else 00057 00058 #if defined(OCI_FNCODE_LOBGETCONTENTTYPE) /* = OCI_11_2 */ 00059 00060 #define OCI_VERSION_COMPILE OCI_11_2 00061 #define OCI_VERSION_RUNTIME OCI_11_2 00062 00063 #elif defined(OCI_FNCODE_LOBGETOPT) /* = OCI_11_1 */ 00064 00065 #define OCI_VERSION_COMPILE OCI_11_1 00066 #define OCI_VERSION_RUNTIME OCI_11_1 00067 00068 #elif defined(OCI_FNCODE_DBSHUTDOWN) /* = OCI_10_2 */ 00069 00070 #define OCI_VERSION_COMPILE OCI_10_2 00071 #define OCI_VERSION_RUNTIME OCI_10_2 00072 00073 #elif defined(OCI_FNCODE_LOBREAD2) /* = OCI_10_1 */ 00074 00075 #define OCI_VERSION_COMPILE OCI_10_1 00076 #define OCI_VERSION_RUNTIME OCI_10_1 00077 00078 #elif defined(OCI_FNCODE_STMTPREPARE2) /* = OCI_9_2 */ 00079 00080 #define OCI_VERSION_COMPILE OCI_9_2 00081 #define OCI_VERSION_RUNTIME OCI_9_2 00082 00083 #elif defined(OCI_FNCODE_CPOOLCREATE) /* = OCI_9_0 */ 00084 00085 #define OCI_VERSION_COMPILE OCI_9_0 00086 #define OCI_VERSION_RUNTIME OCI_9_0 00087 00088 #elif defined(OCIThreadHandle) /* = OCI_8_1 */ 00089 00090 #define OCI_VERSION_COMPILE OCI_8_1 00091 #define OCI_VERSION_RUNTIME OCI_8_1 00092 00093 #elif defined(OCIEnv) /* = OCI_8_0 */ 00094 00095 #define OCI_VERSION_COMPILE OCI_8_0 00096 #define OCI_VERSION_RUNTIME OCI_8_0 00097 00098 #else /* OCI_UNKNOWN */ 00099 00100 #define OCI_VERSION_COMPILE OCI_UNKNOWN 00101 #define OCI_VERSION_RUNTIME OCI_UNKNOWN 00102 00103 #endif 00104 00105 #endif 00106 00107 /* tries to enable Oracle 10g support for lobs > 4Go with OCILobxxx2() calls */ 00108 00109 #if defined(OCI_BIG_UINT_ENABLED) && defined(ORAXB8_DEFINED) 00110 00111 #define OCI_LOB2_API_ENABLED 00112 00113 #endif 00114 00115 /* ********************************************************************************************* * 00116 CHARSET AND STRING TYPES DETECTION 00117 * ********************************************************************************************* */ 00118 00119 /* mtext and dtext are public character types for meta and user string types 00120 We need to handle as well internal string types because : 00121 00122 - wchar_t is not the same type on all platforms (that is such a pain !), 00123 - OCI, in Unicode mode, uses Fixed length UTF16 encoding (2 bytes) 00124 00125 So, omtext and odtext were added to represent internal meta and user string 00126 types. 00127 00128 The following checks find out the real types and sizes of omtext and odtext 00129 */ 00130 00131 #if defined (OCI_CHARSET_ANSI) 00132 00133 #define omtext mtext 00134 #define odtext dtext 00135 00136 #elif defined (OCI_CHARSET_UTF8) 00137 00138 #define omtext mtext 00139 #define odtext dtext 00140 00141 #else 00142 00143 #define WCHAR_2_BYTES 0xFFFF 00144 #define WCHAR_4_BYTES 0x7FFFFFFF 00145 00146 #if WCHAR_MAX == WCHAR_4_BYTES 00147 00148 /* so, input/output conversion will be needed */ 00149 00150 #define OCI_CHECK_STRINGS 00151 00152 #endif 00153 00154 #ifdef OCI_METADATA_WIDE 00155 00156 #ifdef OCI_CHECK_STRINGS 00157 00158 /* conversion for meta string needed */ 00159 00160 #define OCI_CHECK_METASTRINGS 00161 00162 #endif 00163 00164 /* internal meta string type is UTF16 (2 bytes) */ 00165 00166 #define omtext unsigned short 00167 00168 #else 00169 00170 /* internal meta string type is char */ 00171 00172 #define omtext char 00173 00174 #endif 00175 00176 #ifdef OCI_USERDATA_WIDE 00177 00178 #ifdef OCI_CHECK_STRINGS 00179 00180 /* conversion for data string needed */ 00181 00182 #define OCI_CHECK_DATASTRINGS 00183 00184 #endif 00185 00186 /* internal data string type is UTF16 (2 bytes) */ 00187 00188 #define odtext unsigned short 00189 00190 #else 00191 00192 /* internal data string type is char */ 00193 00194 #define odtext char 00195 00196 #endif 00197 00198 #endif 00199 00200 /* ********************************************************************************************* * 00201 INTERNAL CONSTANTS 00202 * ********************************************************************************************* */ 00203 00204 /* --------------------------------------------------------------------------------------------- * 00205 * DEfault environnement mode 00206 * --------------------------------------------------------------------------------------------- */ 00207 00208 #ifdef OCI_METADATA_WIDE 00209 00210 #define OCI_ENV_MODE OCI_UTF16 00211 00212 #else 00213 00214 #define OCI_ENV_MODE OCI_DEFAULT 00215 00216 #endif 00217 00218 /* --------------------------------------------------------------------------------------------- * 00219 * Internal Pointer Codes 00220 * --------------------------------------------------------------------------------------------- */ 00221 00222 /* -- external C pointers ---- */ 00223 00224 #define OCI_IPC_VOID 1 00225 #define OCI_IPC_SHORT 2 00226 #define OCI_IPC_INT 3 00227 #define OCI_IPC_BIGINT 4 00228 #define OCI_IPC_DOUBLE 5 00229 #define OCI_IPC_FLOAT 6 00230 #define OCI_IPC_STRING 7 00231 #define OCI_IPC_PROC 8 00232 00233 /* -- external OCILIB handles - */ 00234 00235 #define OCI_IPC_ERROR 9 00236 #define OCI_IPC_TYPE_INFO 10 00237 #define OCI_IPC_CONNECTION 11 00238 #define OCI_IPC_POOL 12 00239 #define OCI_IPC_TRANSACTION 13 00240 #define OCI_IPC_STATEMENT 14 00241 #define OCI_IPC_RESULTSET 15 00242 #define OCI_IPC_COLUMN 16 00243 #define OCI_IPC_DATE 17 00244 #define OCI_IPC_TIMESTAMP 18 00245 #define OCI_IPC_INTERVAL 19 00246 #define OCI_IPC_LOB 20 00247 #define OCI_IPC_FILE 21 00248 #define OCI_IPC_LONG 22 00249 #define OCI_IPC_OBJECT 23 00250 #define OCI_IPC_COLLECTION 24 00251 #define OCI_IPC_ITERATOR 25 00252 #define OCI_IPC_ELEMENT 26 00253 #define OCI_IPC_HASHTABLE 27 00254 #define OCI_IPC_THREAD 28 00255 #define OCI_IPC_MUTEX 29 00256 #define OCI_IPC_BIND 30 00257 #define OCI_IPC_REF 31 00258 #define OCI_IPC_DIRPATH 32 00259 #define OCI_IPC_NOTIFY 33 00260 #define OCI_IPC_EVENT 34 00261 #define OCI_IPC_ARRAY 35 00262 #define OCI_IPC_MSG 36 00263 #define OCI_IPC_ENQUEUE 37 00264 #define OCI_IPC_DEQUEUE 38 00265 #define OCI_IPC_AGENT 39 00266 00267 /* ---- Internal pointers ----- */ 00268 00269 #define OCI_IPC_LIST 40 00270 #define OCI_IPC_LIST_ITEM 41 00271 #define OCI_IPC_BIND_ARRAY 42 00272 #define OCI_IPC_DEFINE 43 00273 #define OCI_IPC_DEFINE_ARRAY 44 00274 #define OCI_IPC_HASHENTRY 45 00275 #define OCI_IPC_HASHENTRY_ARRAY 46 00276 #define OCI_IPC_HASHVALUE 47 00277 #define OCI_IPC_THREADKEY 48 00278 #define OCI_IPC_OCIDATE 49 00279 #define OCI_IPC_TM 50 00280 #define OCI_IPC_RESULTSET_ARRAY 51 00281 #define OCI_IPC_PLS_SIZE_ARRAY 52 00282 #define OCI_IPC_PLS_RCODE_ARRAY 53 00283 #define OCI_IPC_SERVER_OUPUT 54 00284 #define OCI_IPC_INDICATOR_ARRAY 55 00285 #define OCI_IPC_LEN_ARRAY 56 00286 #define OCI_IPC_BUFF_ARRAY 57 00287 #define OCI_IPC_LONG_BUFFER 58 00288 #define OCI_IPC_TRACE_INFO 59 00289 #define OCI_IPC_DP_COL_ARRAY 60 00290 #define OCI_IPC_BATCH_ERRORS 61 00291 00292 #define OCI_IPC_COUNT OCI_IPC_BATCH_ERRORS 00293 00294 /* --------------------------------------------------------------------------------------------- * 00295 * Oracle conditionnal features 00296 * --------------------------------------------------------------------------------------------- */ 00297 00298 #define OCI_FEATURE_WIDE_USERDATA 1 00299 #define OCI_FEATURE_TIMESTAMP 2 00300 #define OCI_FEATURE_DIRPATH_DATE_CACHE 3 00301 #define OCI_FEATURE_STATEMENT_CACHING 4 00302 #define OCI_FEATURE_SCROLLABLE_CURSOR 5 00303 #define OCI_FEATURE_DATABASE_NOTIFY 6 00304 #define OCI_FEATURE_REMOTE_DBS_CONTROL 7 00305 #define OCI_FEATURE_HIGH_AVAILABILITY 8 00306 #define OCI_FEATURE_XA 9 00307 00308 #define OCI_FEATURE_COUNT OCI_FEATURE_XA 00309 00310 /* --------------------------------------------------------------------------------------------- * 00311 * handle types 00312 * --------------------------------------------------------------------------------------------- */ 00313 00314 #define OCI_HDLE_HANDLE 1 00315 #define OCI_HDLE_DESCRIPTOR 2 00316 #define OCI_HDLE_OBJECT 3 00317 00318 #define OCI_HDLE_COUNT OCI_HDLE_OBJECT 00319 00320 /* --------------------------------------------------------------------------------------------- * 00321 * statement status 00322 * --------------------------------------------------------------------------------------------- */ 00323 00324 #define OCI_STMT_CLOSED 1 00325 #define OCI_STMT_PARSED 2 00326 #define OCI_STMT_PREPARED 4 00327 #define OCI_STMT_DESCRIBED 8 00328 #define OCI_STMT_EXECUTED 16 00329 00330 #define OCI_STMT_STATES_COUNT 5 00331 00332 /* --------------------------------------------------------------------------------------------- * 00333 * connection states 00334 * --------------------------------------------------------------------------------------------- */ 00335 00336 #define OCI_CONN_ALLOCATED 1 00337 #define OCI_CONN_ATTACHED 2 00338 #define OCI_CONN_LOGGED 3 00339 00340 /* --------------------------------------------------------------------------------------------- * 00341 * objects status 00342 * --------------------------------------------------------------------------------------------- */ 00343 00344 #define OCI_OBJECT_ALLOCATED 1 00345 #define OCI_OBJECT_FETCHED_CLEAN 2 00346 #define OCI_OBJECT_FETCHED_DIRTY 3 00347 #define OCI_OBJECT_ALLOCATED_ARRAY 4 00348 #define OCI_OBJECT_ALLOCATED_BIND_STMT 5 00349 00350 /* --------------------------------------------------------------------------------------------- * 00351 * bind type 00352 * --------------------------------------------------------------------------------------------- */ 00353 00354 #define OCI_BIND_INPUT 1 00355 #define OCI_BIND_OUTPUT 2 00356 00357 /* --------------------------------------------------------------------------------------------- * 00358 * Type of schema describing 00359 * --------------------------------------------------------------------------------------------- */ 00360 00361 #define OCI_DESC_RESULTSET 1 00362 #define OCI_DESC_COLUMN 2 00363 #define OCI_DESC_TABLE 3 00364 #define OCI_DESC_TYPE 4 00365 #define OCI_DESC_COLLECTION 5 00366 00367 /* --------------------------------------------------------------------------------------------- * 00368 * Direct path object status 00369 * --------------------------------------------------------------------------------------------- */ 00370 00371 #define OCI_DPS_NOT_PREPARED 1 00372 #define OCI_DPS_PREPARED 2 00373 #define OCI_DPS_CONVERTED 3 00374 #define OCI_DPS_TERMINATED 4 00375 00376 #define OCI_DPS_COUNT OCI_DPS_TERMINATED 00377 00378 /* --------------------------------------------------------------------------------------------- * 00379 * internal statement fetch direction 00380 * --------------------------------------------------------------------------------------------- */ 00381 00382 #define OCI_SFD_NEXT 0x02 00383 #define OCI_SFD_FIRST 0x04 00384 #define OCI_SFD_LAST 0x08 00385 #define OCI_SFD_PREV 0x10 00386 00387 /* --------------------------------------------------------------------------------------------- * 00388 * internal direct path column types 00389 * --------------------------------------------------------------------------------------------- */ 00390 00391 #define OCI_DDT_TEXT 1 00392 #define OCI_DDT_BINARY 2 00393 #define OCI_DDT_NUMBER 3 00394 #define OCI_DDT_OTHERS 4 00395 00396 /* --------------------------------------------------------------------------------------------- * 00397 * output buffer server line size 00398 * --------------------------------------------------------------------------------------------- */ 00399 00400 #define OCI_OUPUT_LSIZE 255 00401 #define OCI_OUPUT_LSIZE_10G 32767 00402 00403 /* --------------------------------------------------------------------------------------------- * 00404 * offset for alignment computation 00405 * --------------------------------------------------------------------------------------------- */ 00406 00407 #define OCI_OFT_POINTER 1 00408 #define OCI_OFT_NUMBER 2 00409 #define OCI_OFT_DATE 4 00410 #define OCI_OFT_OBJECT 8 00411 #define OCI_OFT_SHORT 16 00412 #define OCI_OFT_INT 32 00413 #define OCI_OFT_BIGINT 64 00414 #define OCI_OFT_DOUBLE 128 00415 #define OCI_OFT_FLOAT 256 00416 #define OCI_OFT_TEXT 512 00417 #define OCI_OFT_STRUCT 1024 00418 00419 #define OCI_OFFSET_PAIR(a, b) (a + (b << 16)) 00420 00421 /* --------------------------------------------------------------------------------------------- * 00422 * string functions mapping 00423 * --------------------------------------------------------------------------------------------- */ 00424 00425 #ifdef OCI_METADATA_WIDE 00426 00427 #define mttoupper towupper 00428 #define mtisdigit iswdigit 00429 #define mtsscanf swscanf 00430 00431 #else 00432 00433 #define mttoupper toupper 00434 #define mtisdigit isdigit 00435 #define mtsscanf sscanf 00436 00437 #endif 00438 00439 /* --------------------------------------------------------------------------------------------- * 00440 * Internal integer types 00441 * --------------------------------------------------------------------------------------------- */ 00442 00443 #define OCI_NUM_NUMBER 0 00444 00445 /* --------------------------------------------------------------------------------------------- * 00446 * Unicode constants 00447 * --------------------------------------------------------------------------------------------- */ 00448 00449 /* OCI unicode flag */ 00450 00451 #ifndef OCI_UTF16ID 00452 00453 #define OCI_UTF16ID OCI_UCS2ID 00454 00455 #endif 00456 00457 /* unicode constants */ 00458 00459 #define UNI_SHIFT ((int) 10 ) 00460 #define UNI_BASE ((unsigned int) 0x0010000UL) 00461 #define UNI_MASK ((unsigned int) 0x3FFUL) 00462 #define UNI_REPLACEMENT_CHAR ((unsigned int) 0x0000FFFD) 00463 #define UNI_MAX_BMP ((unsigned int) 0x0000FFFF) 00464 #define UNI_MAX_UTF16 ((unsigned int) 0x0010FFFF) 00465 #define UNI_MAX_UTF32 ((unsigned int) 0x7FFFFFFF) 00466 #define UNI_MAX_LEGAL_UTF32 ((unsigned int) 0x0010FFFF) 00467 #define UNI_SUR_HIGH_START ((unsigned int) 0xD800) 00468 #define UNI_SUR_HIGH_END ((unsigned int) 0xDBFF) 00469 #define UNI_SUR_LOW_START ((unsigned int) 0xDC00) 00470 #define UNI_SUR_LOW_END ((unsigned int) 0xDFFF) 00471 00472 #define CVT_SRC_ILLEGAL 0 00473 #define CVT_SRC_EXHAUSTED -1 00474 #define CVT_DST_EXHAUSTED -2 00475 00476 #define CVT_STRICT 0 00477 #define CVT_LENIENT 1 00478 00479 #define UTF8_BYTES_PER_CHAR 4 00480 00481 /* --------------------------------------------------------------------------------------------- * 00482 * Local helper macros 00483 * --------------------------------------------------------------------------------------------- */ 00484 00485 /* check OCI status */ 00486 00487 #define OCI_NO_ERROR(res) ((res) == OCI_SUCCESS) 00488 00489 /* memory management helpers */ 00490 00491 #define OCI_FREE(ptr) OCI_MemFree(ptr), ptr = NULL; 00492 00493 /* indicator and nullity handlers */ 00494 00495 #define OCI_IND(exp) (sb2) ((exp) ? 0 : -1) 00496 00497 #define OCI_NOT_USED(p) (p) = (p); 00498 00499 /* miscellaneaous */ 00500 00501 #define OCI_NB_ARG_VERSION 3 00502 00503 #define OCI_LIB_THREADED (OCILib.env_mode & OCI_ENV_THREADED) 00504 00505 #define OCI_LIB_CONTEXT (OCILib.env_mode & OCI_ENV_CONTEXT) 00506 00507 #define OCI_RESULT(res) \ 00508 \ 00509 if (OCI_LIB_CONTEXT) \ 00510 OCI_SetStatus(res); \ 00511 00512 #ifdef _WINDOWS 00513 00514 #define OCI_CVT_CHAR 1 00515 00516 #else 00517 00518 #define OCI_CVT_CHAR 0 00519 00520 #endif 00521 00522 #define OCI_SQLCMD_COUNT 126 00523 00524 #define OCI_ERR_MSG_SIZE 512 00525 00526 #define OCI_DEF_ALIGN sizeof(void *) 00527 00528 #define ROUNDUP(amount, align) \ 00529 \ 00530 (((unsigned long)(amount)+((align)-1))&~((align)-1)) 00531 00532 #define OCI_SIZEOF_NUMBER 22 00533 #define OCI_SIZEOF_DATE 7 00534 00535 #define msizeof(s) (sizeof(s) / sizeof(mtext)) 00536 #define dsizeof(s) (sizeof(s) / sizeof(dtext)) 00537 00538 #define OCI_ERR_AQ_LISTEN_TIMEOUT 25254 00539 #define OCI_ERR_AQ_DEQUEUE_TIMEOUT 25228 00540 00541 #define OCI_DEFAUT_STMT_CACHE_SIZE 20 00542 00543 #endif /* OCILIB_OCILIB_DEFS_H_INCLUDED */ 00544