00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OCILIB_OCILIB_CHECKS_H_INCLUDED
00036 #define OCILIB_OCILIB_CHECKS_H_INCLUDED
00037
00038
00039
00040
00041
00055 #define OCI_CALL0(res, err, fct) \
00056 \
00057 { \
00058 (res) = (boolean) fct; \
00059 if (OCI_NO_ERROR((res)) == FALSE) \
00060 { \
00061 (res) = ((res) == OCI_SUCCESS_WITH_INFO); \
00062 OCI_ExceptionOCI((err), NULL, NULL, res); \
00063 } \
00064 else \
00065 (res) = TRUE; \
00066 }
00067
00084 #define OCI_CALL1(res, con, stmt, fct) \
00085 \
00086 { \
00087 if ((res) == TRUE) \
00088 { \
00089 (res) = (boolean) fct; \
00090 if (OCI_NO_ERROR((res)) == FALSE) \
00091 { \
00092 (res) = ((res) == OCI_SUCCESS_WITH_INFO); \
00093 OCI_ExceptionOCI((con)->err, (con), (stmt), res); \
00094 } \
00095 else \
00096 (res) = TRUE; \
00097 } \
00098 }
00099
00115 #define OCI_CALL2(res, con, fct) \
00116 \
00117 { \
00118 if ((res) == TRUE) \
00119 { \
00120 (res) = (boolean) fct; \
00121 if (OCI_NO_ERROR((res)) == FALSE) \
00122 { \
00123 (res) = ((res) == OCI_SUCCESS_WITH_INFO); \
00124 OCI_ExceptionOCI((con)->err, (con), NULL, res); \
00125 } \
00126 else \
00127 (res) = TRUE; \
00128 } \
00129 }
00130
00144 #define OCI_CALL3(res, err, fct) \
00145 \
00146 { \
00147 if ((res) == TRUE) \
00148 { \
00149 (res) = (boolean) fct; \
00150 if (OCI_NO_ERROR((res)) == FALSE) \
00151 { \
00152 (res) = ((res) == OCI_SUCCESS_WITH_INFO); \
00153 OCI_ExceptionOCI((err), NULL, NULL, res); \
00154 } \
00155 else \
00156 (res) = TRUE; \
00157 } \
00158 }
00159
00175 #define OCI_CALL4(res, err, con, fct) \
00176 \
00177 { \
00178 if ((res) == TRUE) \
00179 { \
00180 (res) = (boolean) fct; \
00181 if (OCI_NO_ERROR((res)) == FALSE) \
00182 { \
00183 (res) = ((res) == OCI_SUCCESS_WITH_INFO); \
00184 OCI_ExceptionOCI((err), (con), NULL, res); \
00185 } \
00186 else \
00187 (res) = TRUE; \
00188 } \
00189 }
00190
00207 #define OCI_CALL5(res, con, stmt, fct) \
00208 \
00209 { \
00210 (res) = (boolean) fct; \
00211 if (OCI_NO_ERROR((res)) == FALSE) \
00212 { \
00213 (res) = ((res) == OCI_SUCCESS_WITH_INFO); \
00214 OCI_WarningOCI((con)->err, (con), (stmt), res); \
00215 } \
00216 else \
00217 (res) = TRUE; \
00218 }
00219
00220
00221
00222
00223
00236 #define OCI_CHECK(exp, ret) if ((exp) == TRUE) return (ret);
00237
00251 #define OCI_CHECK_PTR(type, ptr, ret) \
00252 \
00253 if ((ptr) == NULL) \
00254 { \
00255 OCI_ExceptionNullPointer(type); \
00256 \
00257 return (ret); \
00258 }
00259
00275 #define OCI_CHECK_BIND_CALL(stmt, name, data, type) \
00276 \
00277 OCI_CHECK_PTR(OCI_IPC_STATEMENT, stmt, FALSE); \
00278 OCI_CHECK_PTR(OCI_IPC_STRING, name, FALSE); \
00279 if (stmt->bind_alloc_mode == OCI_BAM_EXTERNAL) \
00280 OCI_CHECK_PTR(type, data, FALSE); \
00281
00282
00294 #define OCI_CHECK_REGISTER_CALL(stmt, name) \
00295 \
00296 OCI_CHECK_PTR(OCI_IPC_STATEMENT, stmt, FALSE); \
00297 OCI_CHECK_PTR(OCI_IPC_STRING, name, FALSE); \
00298
00299
00300
00301
00302
00303
00319 #define OCI_CHECK_BOUND(con, v, b1, b2, ret) \
00320 \
00321 if ((v < (b1)) || (v > (b2))) \
00322 { \
00323 OCI_ExceptionOutOfBounds((con), (v)); \
00324 \
00325 return (ret); \
00326 }
00327
00343 #define OCI_CHECK_MIN(con, stmt, v, m, ret) \
00344 \
00345 if ((v) < (m)) \
00346 { \
00347 OCI_ExceptionMinimumValue((con), (stmt), m); \
00348 \
00349 return (ret); \
00350 }
00351
00365 #define OCI_CHECK_COMPAT(con, exp, ret) \
00366 \
00367 if ((exp) == FALSE) \
00368 { \
00369 OCI_ExceptionTypeNotCompatible((con)); \
00370 \
00371 return (ret); \
00372 }
00373
00374
00375
00376
00377
00390 #define OCI_CHECK_OBJECT_FETCHED(obj, ret) \
00391 \
00392 if ((obj)->hstate == OCI_OBJECT_FETCHED_CLEAN) \
00393 return (ret);
00394
00408 #define OCI_CHECK_STMT_STATUS(st, v, ret) \
00409 \
00410 if ((st)->status == (v)) \
00411 { \
00412 OCI_ExceptionStatementState((st), v); \
00413 return ret; \
00414 } \
00415
00416
00429 #define OCI_CHECK_SCROLLABLE_CURSOR_ACTIVATED(st, ret) \
00430 \
00431 if (((st)->nb_rbinds > 0) || \
00432 ((st)->exec_mode != OCI_STMT_SCROLLABLE_READONLY)) \
00433 { \
00434 OCI_ExceptionStatementNotScrollable(st); \
00435 return ret; \
00436 }
00437
00452 #define OCI_CHECK_DIRPATH_STATUS(dp, v, ret) \
00453 \
00454 if ((dp)->status != (v)) \
00455 { \
00456 OCI_ExceptionDirPathState((dp), (dp)->status); \
00457 return ret; \
00458 }
00459
00460
00461
00462
00463
00475 #define OCI_CHECK_INITIALIZED(ret) \
00476 \
00477 if (OCILib.loaded == FALSE) \
00478 { \
00479 OCI_ExceptionNotInitialized(); \
00480 return ret; \
00481 }
00482
00497 #define OCI_CHECK_FEATURE(con, feat, ver, ret) \
00498 \
00499 if (OCILib.version_runtime < ver || (((con) != NULL) && (con)->ver_num < ver)) \
00500 { \
00501 OCI_ExceptionNotAvailable(con, feat); \
00502 return ret; \
00503 }
00504
00517 #define OCI_CHECK_THREAD_ENABLED(ret) \
00518 \
00519 if ((OCI_LIB_THREADED) == FALSE) \
00520 { \
00521 OCI_ExceptionNotMultithreaded(); \
00522 return ret; \
00523 }
00524
00538 #define OCI_CHECK_TIMESTAMP_ENABLED(con, ret) \
00539 \
00540 OCI_CHECK_FEATURE(con, OCI_FEATURE_TIMESTAMP, OCI_9_0, ret)
00541
00555 #define OCI_CHECK_INTERVAL_ENABLED OCI_CHECK_TIMESTAMP_ENABLED
00556
00570 #define OCI_CHECK_SCROLLABLE_CURSOR_ENABLED(con, ret) \
00571 \
00572 OCI_CHECK_FEATURE(con, OCI_FEATURE_SCROLLABLE_CURSOR, OCI_9_0, ret)
00573
00586 #define OCI_CHECK_DIRPATH_DATE_CACHE_ENABLED(dp, ret) \
00587 \
00588 if (OCILib.version_runtime < OCI_9_2) \
00589 { \
00590 OCI_ExceptionNotAvailable((dp)->con, OCI_FEATURE_DIRPATH_DATE_CACHE); \
00591 return ret; \
00592 }
00593
00605 #define OCI_CHECK_REMOTE_DBS_CONTROL_ENABLED(ret) \
00606 \
00607 if (OCILib.version_runtime < OCI_10_2) \
00608 { \
00609 OCI_ExceptionNotAvailable(NULL, OCI_FEATURE_DIRPATH_DATE_CACHE); \
00610 return ret; \
00611 }
00612
00624 #define OCI_CHECK_DATABASE_NOTIFY_ENABLED(ret) \
00625 \
00626 if (OCILib.version_runtime < OCI_10_2) \
00627 { \
00628 OCI_ExceptionNotAvailable(NULL, OCI_FEATURE_DATABASE_NOTIFY); \
00629 return ret; \
00630 }
00631
00632 #endif
00633