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 OCI_ExceptionOCI((err), NULL, NULL); \
00062 (res) = FALSE; \
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 OCI_ExceptionOCI((con)->err, (con), (stmt)); \
00093 (res) = FALSE; \
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 OCI_ExceptionOCI((con)->err, (con), NULL); \
00124 (res) = FALSE; \
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 OCI_ExceptionOCI((err), NULL, NULL); \
00153 (res) = FALSE; \
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 OCI_ExceptionOCI((err), (con), NULL); \
00184 (res) = FALSE; \
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 OCI_ExceptionOCI((con)->err, (con), (stmt)); \
00214 (res) = FALSE; \
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 OCI_CHECK_PTR(type, data, FALSE); \
00280
00281
00293 #define OCI_CHECK_REGISTER_CALL(stmt, name) \
00294 \
00295 OCI_CHECK_PTR(OCI_IPC_STATEMENT, stmt, FALSE); \
00296 OCI_CHECK_PTR(OCI_IPC_STRING, name, FALSE); \
00297
00298
00299
00300
00301
00302
00318 #define OCI_CHECK_BOUND(con, v, b1, b2, ret) \
00319 \
00320 if ((v < (b1)) || (v > (b2))) \
00321 { \
00322 OCI_ExceptionOutOfBounds((con), (v)); \
00323 \
00324 return (ret); \
00325 }
00326
00342 #define OCI_CHECK_MIN(con, stmt, v, m, ret) \
00343 \
00344 if ((v) < (m)) \
00345 { \
00346 OCI_ExceptionMinimumValue((con), (stmt), m); \
00347 \
00348 return (ret); \
00349 }
00350
00364 #define OCI_CHECK_COMPAT(con, exp, ret) \
00365 \
00366 if ((exp) == FALSE) \
00367 { \
00368 OCI_ExceptionTypeNotCompatible((con)); \
00369 \
00370 return (ret); \
00371 }
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
00428 #define OCI_CHECK_SCROLLABLE_CURSOR_ACTIVATED(st, ret) \
00429 \
00430 if (((st)->nb_rbinds > 0) || \
00431 ((st)->exec_mode != OCI_STMT_SCROLLABLE_READONLY)) \
00432 { \
00433 OCI_ExceptionStatementNotScrollable(st); \
00434 return ret; \
00435 }
00436
00451 #define OCI_CHECK_DIRPATH_STATUS(dp, v, ret) \
00452 \
00453 if ((dp)->status != (v)) \
00454 { \
00455 OCI_ExceptionDirPathState((dp), (dp)->status); \
00456 return ret; \
00457 }
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
00574
00587 #define OCI_CHECK_DIRPATH_DATE_CACHE_ENABLED(dp, ret) \
00588 \
00589 if (OCILib.version_runtime < OCI_9_2) \
00590 { \
00591 OCI_ExceptionNotAvailable((dp)->con, OCI_FEATURE_DIRPATH_DATE_CACHE); \
00592 return ret; \
00593 }
00594
00606 #define OCI_CHECK_REMOTE_DBS_CONTROL_ENABLED(ret) \
00607 \
00608 if (OCILib.version_runtime < OCI_10_2) \
00609 { \
00610 OCI_ExceptionNotAvailable(NULL, OCI_FEATURE_DIRPATH_DATE_CACHE); \
00611 return ret; \
00612 }
00613
00614 #endif
00615