C:/Users/vincent/Data/Perso/dev/ocilib/ocilib/src/ocilib_checks.h

00001 /*
00002    +----------------------------------------------------------------------+   
00003    |                                                                      |
00004    |                     OCILIB - C Driver for Oracle                     |
00005    |                                                                      |
00006    |                      (C Wrapper for Oracle OCI)                      |
00007    |                                                                      |
00008    +----------------------------------------------------------------------+
00009    |                      Website : http://www.ocilib.net                 |
00010    +----------------------------------------------------------------------+
00011    |               Copyright (c) 2007-2009 Vincent ROGIER                 |
00012    +----------------------------------------------------------------------+
00013    | This library is free software; you can redistribute it and/or        |
00014    | modify it under the terms of the GNU Lesser General Public           |
00015    | License as published by the Free Software Foundation; either         |
00016    | version 2 of the License, or (at your option) any later version.     |
00017    |                                                                      |
00018    | This library is distributed in the hope that it will be useful,      |
00019    | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
00020    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
00021    | Lesser General Public License for more details.                      |
00022    |                                                                      |
00023    | You should have received a copy of the GNU Lesser General Public     |
00024    | License along with this library; if not, write to the Free           |
00025    | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   |
00026    +----------------------------------------------------------------------+
00027    |          Author: Vincent ROGIER <vince.rogier@gmail.com>             |
00028    +----------------------------------------------------------------------+ 
00029 */
00030 
00031 /* ------------------------------------------------------------------------ *
00032  * $Id: ocilib_checks.h, v 3.4.0 2009-07-30 17:40 Vince $
00033  * ------------------------------------------------------------------------ */
00034 
00035 #ifndef OCILIB_OCILIB_CHECKS_H_INCLUDED
00036 #define OCILIB_OCILIB_CHECKS_H_INCLUDED
00037 
00038 /* ************************************************************************ *
00039                         MACROS FOR CHECKING OCI CALLS
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                         PARAMETER CHECKING MACROS
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                         MISCELLANEOUS CHECKING MACROS
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                   INTERNAL STATES/ATTRIBUTES CHECKING MACROS
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                     INTERNAL FEATURES AVAILABILITY CHECKING MACROS
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    /* OCILIB_OCILIB_CHECKS_H_INCLUDED */
00615 

Generated on Thu Jul 30 17:41:53 2009 for OCILIB (C Driver for Oracle) by  doxygen 1.5.4