OCILIB (C Driver for Oracle) 3.9.2
|
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-2011 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, v 3.9.2 2011-07-13 00:00 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_SESSGET_SYSDBA) /* = 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_LOB_OPT_COMPRESS) /* = 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_DBSHUTDOWN_ABORT) /* = 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_ATTR_DB_CHARSET_ID) /* = 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_ATTR_STMTCACHESIZE) /* = OCI_9_2 */ 00079 00080 #define OCI_VERSION_COMPILE OCI_9_2 00081 #define OCI_VERSION_RUNTIME OCI_9_2 00082 00083 #elif defined(SQLT_PNTY) /* = 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_STRING 6 00230 #define OCI_IPC_PROC 7 00231 00232 /* -- external OCILIB handles - */ 00233 00234 #define OCI_IPC_ERROR 8 00235 #define OCI_IPC_TYPE_INFO 9 00236 #define OCI_IPC_CONNECTION 10 00237 #define OCI_IPC_POOL 11 00238 #define OCI_IPC_TRANSACTION 12 00239 #define OCI_IPC_STATEMENT 13 00240 #define OCI_IPC_RESULTSET 14 00241 #define OCI_IPC_COLUMN 15 00242 #define OCI_IPC_DATE 16 00243 #define OCI_IPC_TIMESTAMP 17 00244 #define OCI_IPC_INTERVAL 18 00245 #define OCI_IPC_LOB 19 00246 #define OCI_IPC_FILE 20 00247 #define OCI_IPC_LONG 21 00248 #define OCI_IPC_OBJECT 22 00249 #define OCI_IPC_COLLECTION 23 00250 #define OCI_IPC_ITERATOR 24 00251 #define OCI_IPC_ELEMENT 25 00252 #define OCI_IPC_HASHTABLE 26 00253 #define OCI_IPC_THREAD 27 00254 #define OCI_IPC_MUTEX 28 00255 #define OCI_IPC_BIND 29 00256 #define OCI_IPC_REF 30 00257 #define OCI_IPC_DIRPATH 31 00258 #define OCI_IPC_NOTIFY 32 00259 #define OCI_IPC_EVENT 33 00260 #define OCI_IPC_ARRAY 34 00261 #define OCI_IPC_MSG 35 00262 #define OCI_IPC_ENQUEUE 36 00263 #define OCI_IPC_DEQUEUE 37 00264 #define OCI_IPC_AGENT 38 00265 00266 /* ---- Internal pointers ----- */ 00267 00268 #define OCI_IPC_LIST 39 00269 #define OCI_IPC_LIST_ITEM 40 00270 #define OCI_IPC_BIND_ARRAY 41 00271 #define OCI_IPC_DEFINE 42 00272 #define OCI_IPC_DEFINE_ARRAY 43 00273 #define OCI_IPC_HASHENTRY 44 00274 #define OCI_IPC_HASHENTRY_ARRAY 45 00275 #define OCI_IPC_HASHVALUE 46 00276 #define OCI_IPC_THREADKEY 47 00277 #define OCI_IPC_OCIDATE 48 00278 #define OCI_IPC_TM 49 00279 #define OCI_IPC_RESULTSET_ARRAY 50 00280 #define OCI_IPC_PLS_SIZE_ARRAY 51 00281 #define OCI_IPC_PLS_RCODE_ARRAY 52 00282 #define OCI_IPC_SERVER_OUPUT 53 00283 #define OCI_IPC_INDICATOR_ARRAY 54 00284 #define OCI_IPC_LEN_ARRAY 55 00285 #define OCI_IPC_BUFF_ARRAY 56 00286 #define OCI_IPC_LONG_BUFFER 57 00287 #define OCI_IPC_TRACE_INFO 58 00288 #define OCI_IPC_DP_COL_ARRAY 59 00289 #define OCI_IPC_BATCH_ERRORS 60 00290 00291 /* --------------------------------------------------------------------------------------------- * 00292 * Oracle conditionnal features 00293 * --------------------------------------------------------------------------------------------- */ 00294 00295 #define OCI_FEATURE_WIDE_USERDATA 1 00296 #define OCI_FEATURE_TIMESTAMP 2 00297 #define OCI_FEATURE_DIRPATH_DATE_CACHE 3 00298 #define OCI_FEATURE_STATEMENT_CACHING 4 00299 #define OCI_FEATURE_SCROLLABLE_CURSOR 5 00300 #define OCI_FEATURE_DATABASE_NOTIFY 6 00301 #define OCI_FEATURE_REMOTE_DBS_CONTROL 7 00302 #define OCI_FEATURE_HIGH_AVAILABILITY 8 00303 00304 /* --------------------------------------------------------------------------------------------- * 00305 * handle types 00306 * --------------------------------------------------------------------------------------------- */ 00307 00308 #define OCI_HDLE_HANDLE 1 00309 #define OCI_HDLE_DESCRIPTOR 2 00310 #define OCI_HDLE_OBJECT 3 00311 00312 /* --------------------------------------------------------------------------------------------- * 00313 * statement status 00314 * --------------------------------------------------------------------------------------------- */ 00315 00316 #define OCI_STMT_CLOSED 1 00317 #define OCI_STMT_PARSED 2 00318 #define OCI_STMT_PREPARED 4 00319 #define OCI_STMT_DESCRIBED 8 00320 #define OCI_STMT_EXECUTED 16 00321 00322 #define OCI_STMT_STATES_COUNT 5 00323 00324 /* --------------------------------------------------------------------------------------------- * 00325 * connection states 00326 * --------------------------------------------------------------------------------------------- */ 00327 00328 #define OCI_CONN_ALLOCATED 1 00329 #define OCI_CONN_ATTACHED 2 00330 #define OCI_CONN_LOGGED 3 00331 00332 /* --------------------------------------------------------------------------------------------- * 00333 * objects status 00334 * --------------------------------------------------------------------------------------------- */ 00335 00336 #define OCI_OBJECT_ALLOCATED 1 00337 #define OCI_OBJECT_FETCHED_CLEAN 2 00338 #define OCI_OBJECT_FETCHED_DIRTY 3 00339 #define OCI_OBJECT_ALLOCATED_ARRAY 4 00340 #define OCI_OBJECT_ALLOCATED_BIND_STMT 5 00341 00342 /* --------------------------------------------------------------------------------------------- * 00343 * bind type 00344 * --------------------------------------------------------------------------------------------- */ 00345 00346 #define OCI_BIND_INPUT 1 00347 #define OCI_BIND_OUTPUT 2 00348 00349 /* --------------------------------------------------------------------------------------------- * 00350 * Type of schema describing 00351 * --------------------------------------------------------------------------------------------- */ 00352 00353 #define OCI_DESC_RESULTSET 1 00354 #define OCI_DESC_COLUMN 2 00355 #define OCI_DESC_TABLE 3 00356 #define OCI_DESC_TYPE 4 00357 #define OCI_DESC_COLLECTION 5 00358 00359 /* --------------------------------------------------------------------------------------------- * 00360 * Direct path object status 00361 * --------------------------------------------------------------------------------------------- */ 00362 00363 #define OCI_DPS_NOT_PREPARED 1 00364 #define OCI_DPS_PREPARED 2 00365 #define OCI_DPS_CONVERTED 3 00366 #define OCI_DPS_TERMINATED 4 00367 00368 /* --------------------------------------------------------------------------------------------- * 00369 * internal statement fetch direction 00370 * --------------------------------------------------------------------------------------------- */ 00371 00372 #define OCI_SFD_NEXT 0x02 00373 #define OCI_SFD_FIRST 0x04 00374 #define OCI_SFD_LAST 0x08 00375 #define OCI_SFD_PREV 0x10 00376 00377 /* --------------------------------------------------------------------------------------------- * 00378 * internal direct path column types 00379 * --------------------------------------------------------------------------------------------- */ 00380 00381 #define OCI_DDT_TEXT 1 00382 #define OCI_DDT_BINARY 2 00383 #define OCI_DDT_NUMBER 3 00384 #define OCI_DDT_OTHERS 4 00385 00386 /* --------------------------------------------------------------------------------------------- * 00387 * output buffer server line size 00388 * --------------------------------------------------------------------------------------------- */ 00389 00390 #define OCI_OUPUT_LSIZE 255 00391 #define OCI_OUPUT_LSIZE_10G 32767 00392 00393 /* --------------------------------------------------------------------------------------------- * 00394 * offset for alignment computation 00395 * --------------------------------------------------------------------------------------------- */ 00396 00397 #define OCI_OFT_POINTER 1 00398 #define OCI_OFT_NUMBER 2 00399 #define OCI_OFT_DATE 4 00400 #define OCI_OFT_OBJECT 8 00401 #define OCI_OFT_SHORT 16 00402 #define OCI_OFT_INT 32 00403 #define OCI_OFT_BIGINT 64 00404 #define OCI_OFT_DOUBLE 128 00405 #define OCI_OFT_TEXT 256 00406 #define OCI_OFT_STRUCT 512 00407 00408 #define OCI_OFFSET_PAIR(a, b) (a + (b << 16)) 00409 00410 /* --------------------------------------------------------------------------------------------- * 00411 * string functions mapping 00412 * --------------------------------------------------------------------------------------------- */ 00413 00414 #ifdef OCI_METADATA_WIDE 00415 00416 #define mttoupper towupper 00417 #define mtisdigit iswdigit 00418 #define mtsscanf swscanf 00419 00420 #else 00421 00422 #define mttoupper toupper 00423 #define mtisdigit isdigit 00424 #define mtsscanf sscanf 00425 00426 #endif 00427 00428 /* --------------------------------------------------------------------------------------------- * 00429 * Internal integer types 00430 * --------------------------------------------------------------------------------------------- */ 00431 00432 #define OCI_NUM_NUMBER 32 00433 00434 /* --------------------------------------------------------------------------------------------- * 00435 * Unicode constants 00436 * --------------------------------------------------------------------------------------------- */ 00437 00438 /* OCI unicode flag */ 00439 00440 #ifndef OCI_UTF16ID 00441 00442 #define OCI_UTF16ID OCI_UCS2ID 00443 00444 #endif 00445 00446 /* unicode constants */ 00447 00448 #define UNI_SHIFT ((int) 10 ) 00449 #define UNI_BASE ((unsigned int) 0x0010000UL) 00450 #define UNI_MASK ((unsigned int) 0x3FFUL) 00451 #define UNI_REPLACEMENT_CHAR ((unsigned int) 0x0000FFFD) 00452 #define UNI_MAX_BMP ((unsigned int) 0x0000FFFF) 00453 #define UNI_MAX_UTF16 ((unsigned int) 0x0010FFFF) 00454 #define UNI_MAX_UTF32 ((unsigned int) 0x7FFFFFFF) 00455 #define UNI_MAX_LEGAL_UTF32 ((unsigned int) 0x0010FFFF) 00456 #define UNI_SUR_HIGH_START ((unsigned int) 0xD800) 00457 #define UNI_SUR_HIGH_END ((unsigned int) 0xDBFF) 00458 #define UNI_SUR_LOW_START ((unsigned int) 0xDC00) 00459 #define UNI_SUR_LOW_END ((unsigned int) 0xDFFF) 00460 00461 #define CVT_SRC_ILLEGAL 0 00462 #define CVT_SRC_EXHAUSTED -1 00463 #define CVT_DST_EXHAUSTED -2 00464 00465 #define CVT_STRICT 0 00466 #define CVT_LENIENT 1 00467 00468 #define UTF8_BYTES_PER_CHAR 4 00469 00470 /* --------------------------------------------------------------------------------------------- * 00471 * Local helper macros 00472 * --------------------------------------------------------------------------------------------- */ 00473 00474 /* check OCI status */ 00475 00476 #define OCI_NO_ERROR(res) ((res) == OCI_SUCCESS) 00477 00478 /* memory management helpers */ 00479 00480 #define OCI_FREE(ptr) OCI_MemFree(ptr), ptr = NULL; 00481 00482 /* indicator and nullity handlers */ 00483 00484 #define OCI_IND(exp) (sb2) ((exp) ? 0 : -1) 00485 00486 #define OCI_NOT_USED(p) (p) = (p); 00487 00488 /* miscellaneaous */ 00489 00490 #define OCI_NB_ARG_VERSION 3 00491 00492 #define OCI_LIB_THREADED (OCILib.env_mode & OCI_ENV_THREADED) 00493 00494 #define OCI_LIB_CONTEXT (OCILib.env_mode & OCI_ENV_CONTEXT) 00495 00496 #define OCI_RESULT(res) \ 00497 \ 00498 if (OCI_LIB_CONTEXT) \ 00499 OCI_SetStatus(res); \ 00500 00501 #ifdef _WINDOWS 00502 00503 #define OCI_CVT_CHAR 1 00504 00505 #else 00506 00507 #define OCI_CVT_CHAR 0 00508 00509 #endif 00510 00511 #define OCI_SQLCMD_COUNT 126 00512 00513 #define OCI_ERR_MSG_SIZE 512 00514 00515 #define OCI_DEF_ALIGN sizeof(void *) 00516 00517 #define ROUNDUP(amount, align) \ 00518 \ 00519 (((unsigned long)(amount)+((align)-1))&~((align)-1)) 00520 00521 #define OCI_SIZEOF_NUMBER 22 00522 #define OCI_SIZEOF_DATE 7 00523 00524 #define msizeof(s) (sizeof(s) / sizeof(mtext)) 00525 #define dsizeof(s) (sizeof(s) / sizeof(dtext)) 00526 00527 #define OCI_ERR_AQ_LISTEN_TIMEOUT 25254 00528 #define OCI_ERR_AQ_DEQUEUE_TIMEOUT 25228 00529 00530 #define OCI_DEFAUT_STMT_CACHE_SIZE 20 00531 00532 #endif /* OCILIB_OCILIB_DEFS_H_INCLUDED */ 00533