OCILIB (C Driver for Oracle) 3.9.1
D:/Perso/dev/ocilib/ocilib/src/exception.c
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: exception.c, v 3.9.1 2011-07-08 00:00 Vincent Rogier $
00033  * --------------------------------------------------------------------------------------------- */
00034 
00035 #include "ocilib_internal.h"
00036 
00037 /* ********************************************************************************************* *
00038  *                            STRINGS MESSAGES
00039  * ********************************************************************************************* */
00040 
00041 static mtext * OCILib_TypeNames[] =
00042 {
00043     MT("generic pointer"),
00044     MT("short pointer"),
00045     MT("int pointer"),
00046     MT("big_int pointer"),
00047     MT("double pointer"),
00048     MT("string pointer"),
00049     MT("function callback"),
00050 
00051     MT("Error handle"),
00052     MT("Schema handle"),
00053     MT("Connection handle"),
00054     MT("Pool handle"),
00055     MT("Transaction handle"),
00056     MT("Statement handle"),
00057     MT("Resultset handle"),
00058     MT("Column handle"),
00059     MT("Date handle"),
00060     MT("Timestamp handle"),
00061     MT("Interval handle"),
00062     MT("Lob handle"),
00063     MT("File handle"),
00064     MT("Long handle"),
00065     MT("Object handle"),
00066     MT("Collection handle"),
00067     MT("Collection iterator handle"),
00068     MT("Collection element handle"),
00069     MT("Hash Table handle"),
00070     MT("Thread handle"),
00071     MT("Mutex handle"),
00072     MT("Bind handle"),
00073     MT("Ref handle"),
00074     MT("Direct Path handle"),
00075     MT("Subscription handle"),
00076     MT("Event handle"),
00077     MT("Array handle"),
00078     MT("Message handle"),
00079     MT("Enqueue handle"),
00080     MT("Dequeue handle"),
00081     MT("Agent handle"),
00082 
00083     MT("Internal list handle"),
00084     MT("Internal list item handle"),
00085     MT("Internal array of bind handles"),
00086     MT("Internal define handle"),
00087     MT("Internal array of define handles"),
00088     MT("Internal hash entry handle"),
00089     MT("Internal array of hash entry handles"),
00090     MT("Internal hash value handle"),
00091     MT("Internal thread key handle"),
00092     MT("Internal Oracle date handle"),
00093     MT("Internal C tm structure"),
00094     MT("Internal array of resultset handles"),
00095     MT("Internal array of PL/SQL sizes integers"),
00096     MT("Internal array of PL/SQL return codes integers"),
00097     MT("Internal server output handle"),
00098     MT("Internal array of indicator integers"),
00099     MT("Internal array of buffer length integers"),
00100     MT("Internal array of data buffers"),
00101     MT("Internal Long handle data buffer"),
00102     MT("Internal trace info structure"),
00103     MT("Internal array of direct path columns"),
00104     MT("Internal array of batch error objects")
00105 };
00106 
00107 #if defined(OCI_CHARSET_WIDE) && !defined(_MSC_VER)
00108 
00109 static mtext * OCILib_ErrorMsg[] =
00110 {
00111     MT("No error"),
00112     MT("OCILIB has not been initialized"),
00113     MT("Cannot load OCI shared library (%ls)"),
00114     MT("Cannot load OCI symbols from shared library"),
00115     MT("OCILIB has not been initialized in multithreaded mode"),
00116     MT("Memory allocation failure (type %ls, size : %d)"),
00117     MT("Feature not available (%ls) "),
00118     MT("A null %ls has been provided"),
00119     MT("Oracle datatype (sqlcode %d) not supported for this operation "),
00120     MT("Unknown identifier %c while parsing SQL"),
00121     MT("Unknown argument %d while retrieving data"),
00122     MT("Index %d out of bounds"),
00123     MT("Found %d unfreed %ls"),
00124     MT("Maximum number of binds (%d) already reached"),
00125     MT("Object attribute '%ls' not found"),
00126     MT("The integer parameter value must be at least %d"),
00127     MT("Elements are not compatible"),
00128     MT("The statement must be %ls to perform this operation"),
00129     MT("The statement is not scrollable"),
00130     MT("Name or position '%ls' already binded to the statement"),
00131     MT("Invalid new size for bind arrays (initial %d, current %d, new %d)"),
00132     MT("Column '%ls' not find in table '%ls'"),
00133     MT("Unable to perform this operation on a %ls direct path process"),
00134     MT("Cannot create OCI environment"),
00135     MT("Name or position '%ls' previously binded with different datatype")
00136 };
00137 
00138 #else
00139 
00140 static mtext * OCILib_ErrorMsg[] =
00141 {
00142     MT("No error"),
00143     MT("OCILIB has not been initialized"),
00144     MT("Cannot load OCI shared library (%s)"),
00145     MT("Cannot load OCI symbols from shared library"),
00146     MT("OCILIB has not been initialized in multithreaded mode"),
00147     MT("Memory allocation failure (type %s, size : %d)"),
00148     MT("Feature not available (%s) "),
00149     MT("A null %s has been provided"),
00150     MT("Oracle datatype (sqlcode %d) not supported for this operation "),
00151     MT("Unknown identifier %c while parsing SQL : "),
00152     MT("Unknown argument %d while retrieving data"),
00153     MT("Index %d out of bounds"),
00154     MT("Found %d unfreed %s"),
00155     MT("Maximum number of binds (%d) already reached"),
00156     MT("Object attribute '%s' not found"),
00157     MT("The integer parameter value must be at least %d"),
00158     MT("Elements are not compatible"),
00159     MT("The statement must be %s to perform this operation"),
00160     MT("The statement is not scrollable"),
00161     MT("Name or position '%s' already binded to the statement"),
00162     MT("Invalid new size for bind arrays (initial %d, current %d, new %d)"),
00163     MT("Column '%s' not find in table '%s'"),
00164     MT("Unable to perform this operation on a %s direct path process"),
00165     MT("Cannot create OCI environment"),
00166     MT("Name or position '%ls' previously binded with different datatype")
00167 };
00168 
00169 #endif
00170 
00171 static mtext * OCILib_OraFeatures[] =
00172 {
00173     MT("Oracle 9.0 support for Unicode data"),
00174     MT("Oracle 9.0 Timestamps and Intervals"),
00175     MT("Oracle 9.2 Direct path date caching"),
00176     MT("Oracle 9.2 Statement caching"),
00177     MT("Oracle 10g R1 LOBs size extensions"),
00178     MT("Oracle 10g R2 Database change notification"),
00179     MT("Oracle 10g R2 remote database startup/shutdown"),
00180     MT("Oracle 10g R2 High Availability")
00181 };
00182 
00183 typedef struct OCI_StmtStateTable
00184 {
00185     int    state;
00186     mtext *name;
00187 } OCI_StmtStateTable;
00188 
00189 static OCI_StmtStateTable OCILib_StmtStates[] =
00190 {
00191     { OCI_STMT_CLOSED,    MT("closed")        },
00192     { OCI_STMT_PARSED,    MT("parsed")        },
00193     { OCI_STMT_PREPARED,  MT("prepared")      },
00194     { OCI_STMT_DESCRIBED, MT("described")     },
00195     { OCI_STMT_EXECUTED,  MT("executed")      }
00196 };
00197 
00198 static mtext * OCILib_DirPathStates[] =
00199 {
00200     MT("non prepared"),
00201     MT("prepared"),
00202     MT("converted"),
00203     MT("terminated")
00204 };
00205 
00206 static mtext * OCILib_HandleNames[] =
00207 {
00208     MT("OCI handle"),
00209     MT("OCI descriptors"),
00210     MT("OCI Object handles")
00211 };
00212 
00213 /* ********************************************************************************************* *
00214  *                             PRIVATE FUNCTIONS
00215  * ********************************************************************************************* */
00216 
00217 /* --------------------------------------------------------------------------------------------- *
00218  * OCI_ExceptionGetError
00219  * --------------------------------------------------------------------------------------------- */
00220 
00221 OCI_Error * OCI_ExceptionGetError
00222 (
00223     boolean warning
00224 )
00225 {
00226     OCI_Error *err = OCI_ErrorGet(TRUE, warning);
00227 
00228     if (err != NULL)
00229     {
00230         OCI_ErrorReset(err);
00231 
00232         err->active  = TRUE;
00233         err->warning = warning;
00234     }
00235 
00236     return err;
00237 }
00238 
00239 /* --------------------------------------------------------------------------------------------- *
00240  * OCI_ExceptionRaise
00241  * --------------------------------------------------------------------------------------------- */
00242 
00243 void OCI_ExceptionRaise
00244 (
00245     OCI_Error *err
00246 )
00247 {
00248     if (err != NULL)
00249     {
00250         if (OCILib.error_handler != NULL)
00251         {
00252             OCILib.error_handler(err);
00253         }
00254 
00255         err->active = FALSE;
00256     }
00257 }
00258 
00259 /* --------------------------------------------------------------------------------------------- *
00260  * OCI_ExceptionOCI
00261  * --------------------------------------------------------------------------------------------- */
00262 
00263 void OCI_ExceptionOCI
00264 (
00265     OCIError       *p_err,
00266     OCI_Connection *con,
00267     OCI_Statement  *stmt,
00268     boolean         warning
00269 )
00270 {
00271     OCI_Error *err = OCI_ExceptionGetError(warning);
00272 
00273     if (err != NULL)
00274     {
00275         int osize  = -1;
00276         void *ostr = NULL;
00277 
00278         err->type = (warning ? OCI_ERR_WARNING : OCI_ERR_ORACLE);
00279         err->con  = con;
00280         err->stmt = stmt;
00281 
00282         /* get oracle description */
00283 
00284         osize = (int) (msizeof(err->str) - (size_t) 1);
00285         ostr  = OCI_GetInputMetaString(err->str, &osize);
00286 
00287         OCIErrorGet((dvoid *) p_err, (ub4) 1, (OraText *) NULL, &err->ocode,
00288                     (OraText *) ostr, (ub4) osize, (ub4) OCI_HTYPE_ERROR);
00289 
00290         OCI_GetOutputMetaString(ostr, err->str, &osize);
00291         OCI_ReleaseMetaString(ostr);
00292     }
00293 
00294     OCI_ExceptionRaise(err);
00295 }
00296 
00297 /* --------------------------------------------------------------------------------------------- *
00298  * OCI_ExceptionNotInitialized
00299  * --------------------------------------------------------------------------------------------- */
00300 
00301 void OCI_ExceptionNotInitialized
00302 (
00303     void
00304 )
00305 {
00306     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00307 
00308     if (err != NULL)
00309     {
00310         err->type  = OCI_ERR_OCILIB;
00311         err->icode = OCI_ERR_NOT_INITIALIZED;
00312 
00313         mtsncat(err->str,  OCILib_ErrorMsg[OCI_ERR_NOT_INITIALIZED], msizeof(err->str) - (size_t) 1);
00314     }
00315 
00316     OCI_ExceptionRaise(err);
00317 }
00318 
00319 /* --------------------------------------------------------------------------------------------- *
00320  * OCI_ExceptionLoadingShareLib
00321  * --------------------------------------------------------------------------------------------- */
00322 
00323 void OCI_ExceptionLoadingSharedLib
00324 (
00325     void
00326 )
00327 {
00328 #ifdef OCI_IMPORT_RUNTIME
00329 
00330     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00331 
00332     if (err != NULL)
00333     {
00334         err->type  = OCI_ERR_OCILIB;
00335         err->icode = OCI_ERR_LOADING_SHARED_LIB;
00336 
00337         mtsprintf(err->str, msizeof(err->str) - (size_t) 1,
00338                   OCILib_ErrorMsg[OCI_ERR_LOADING_SHARED_LIB],
00339                   OCI_DL_META_NAME);
00340     }
00341 
00342     OCI_ExceptionRaise(err);
00343 
00344 #endif
00345 }
00346 
00347 /* --------------------------------------------------------------------------------------------- *
00348  * OCI_ExceptionLoadingSymbols
00349  * --------------------------------------------------------------------------------------------- */
00350 
00351 void OCI_ExceptionLoadingSymbols
00352 (
00353     void
00354 )
00355 {
00356     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00357 
00358     if (err != NULL)
00359     {
00360         err->type  = OCI_ERR_OCILIB;
00361         err->icode = OCI_ERR_LOADING_SYMBOLS;
00362 
00363         mtsncat(err->str, OCILib_ErrorMsg[OCI_ERR_LOADING_SYMBOLS], msizeof(err->str) - (size_t) 1);
00364     }
00365 
00366     OCI_ExceptionRaise(err);
00367 }
00368 
00369 /* --------------------------------------------------------------------------------------------- *
00370  * OCI_ExceptionNotMultithreaded
00371  * --------------------------------------------------------------------------------------------- */
00372 
00373 void OCI_ExceptionNotMultithreaded
00374 (
00375     void
00376 )
00377 {
00378     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00379 
00380     if (err != NULL)
00381     {
00382         err->type  = OCI_ERR_OCILIB;
00383         err->icode = OCI_ERR_MULTITHREADED;
00384 
00385         mtsncat(err->str, OCILib_ErrorMsg[OCI_ERR_MULTITHREADED], msizeof(err->str) - (size_t) 1);
00386     }
00387 
00388     OCI_ExceptionRaise(err);
00389 }
00390 
00391 /* --------------------------------------------------------------------------------------------- *
00392  * OCI_ExceptionNullPointer
00393  * --------------------------------------------------------------------------------------------- */
00394 
00395 void OCI_ExceptionNullPointer
00396 (
00397     int type
00398 )
00399 {
00400     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00401 
00402     if (err != NULL)
00403     {
00404         err->type  = OCI_ERR_OCILIB;
00405         err->icode = OCI_ERR_NULL_POINTER;
00406 
00407         mtsprintf(err->str, msizeof(err->str) - (size_t) 1,
00408                   OCILib_ErrorMsg[OCI_ERR_NULL_POINTER],
00409                   OCILib_TypeNames[type-1]);
00410     }
00411 
00412     OCI_ExceptionRaise(err);
00413 }
00414 
00415 /* --------------------------------------------------------------------------------------------- *
00416  * OCI_ExceptionMemory
00417  * --------------------------------------------------------------------------------------------- */
00418 
00419 void OCI_ExceptionMemory
00420 (
00421     int             type,
00422     size_t          nb_bytes,
00423     OCI_Connection *con,
00424     OCI_Statement  *stmt
00425 )
00426 {
00427     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00428 
00429     if (err != NULL)
00430     {
00431         err->type  = OCI_ERR_OCILIB;
00432         err->icode = OCI_ERR_MEMORY;
00433         err->con   = con;
00434         err->stmt  = stmt;
00435 
00436         mtsprintf(err->str,
00437                   msizeof(err->str) - (size_t) 1,
00438                   OCILib_ErrorMsg[OCI_ERR_MEMORY],
00439                   OCILib_TypeNames[type-1],
00440                   nb_bytes);
00441     }
00442 
00443     OCI_ExceptionRaise(err);
00444 }
00445 
00446 /* --------------------------------------------------------------------------------------------- *
00447  * OCI_ExceptionNotAvailable
00448  * --------------------------------------------------------------------------------------------- */
00449 
00450 void OCI_ExceptionNotAvailable
00451 (
00452     OCI_Connection *con,
00453     int             feature
00454 )
00455 {
00456     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00457 
00458     if (err != NULL)
00459     {
00460         err->type  = OCI_ERR_OCILIB;
00461         err->icode = OCI_ERR_NOT_AVAILABLE;
00462         err->con   = con;
00463 
00464         mtsprintf(err->str,
00465                   msizeof(err->str) - (size_t) 1,
00466                   OCILib_ErrorMsg[OCI_ERR_NOT_AVAILABLE],
00467                   OCILib_OraFeatures[feature-1]);
00468     }
00469 
00470     OCI_ExceptionRaise(err);
00471 }
00472 
00473 /* --------------------------------------------------------------------------------------------- *
00474  * OCI_ExceptionDatatypeNotSupported
00475  * --------------------------------------------------------------------------------------------- */
00476 
00477 void OCI_ExceptionDatatypeNotSupported
00478 (
00479     OCI_Connection *con,
00480     OCI_Statement  *stmt,
00481     int             code
00482 )
00483 {
00484     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00485 
00486     if (err != NULL)
00487     {
00488         err->type  = OCI_ERR_OCILIB;
00489         err->icode = OCI_ERR_DATATYPE_NOT_SUPPORTED;
00490         err->con   = con;
00491         err->stmt  = stmt;
00492 
00493         mtsprintf(err->str,
00494                   msizeof(err->str) - (size_t) 1,
00495                   OCILib_ErrorMsg[OCI_ERR_DATATYPE_NOT_SUPPORTED],
00496                   code);
00497     }
00498 
00499     OCI_ExceptionRaise(err);
00500 }
00501 
00502 /* --------------------------------------------------------------------------------------------- *
00503  * OCI_ExceptionParsingError
00504  * --------------------------------------------------------------------------------------------- */
00505 
00506 void OCI_ExceptionParsingToken
00507 (
00508     OCI_Connection *con,
00509     OCI_Statement  *stmt,
00510     mtext           token
00511 )
00512 {
00513     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00514 
00515     if (err != NULL)
00516     {
00517         err->type  = OCI_ERR_OCILIB;
00518         err->icode = OCI_ERR_PARSE_TOKEN;
00519         err->con   = con;
00520         err->stmt  = stmt;
00521 
00522         mtsprintf(err->str,
00523                   msizeof(err->str) - (size_t) 1,
00524                   OCILib_ErrorMsg[OCI_ERR_PARSE_TOKEN],
00525                   token);
00526     }
00527 
00528     OCI_ExceptionRaise(err);
00529 }
00530 
00531 /* --------------------------------------------------------------------------------------------- *
00532  * OCI_ExceptionMappingArgument
00533  * --------------------------------------------------------------------------------------------- */
00534 
00535 void OCI_ExceptionMappingArgument
00536 (
00537     OCI_Connection *con,
00538     OCI_Statement  *stmt,
00539     int             arg
00540 )
00541 {
00542     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00543 
00544     if (err != NULL)
00545     {
00546         err->type  = OCI_ERR_OCILIB;
00547         err->icode = OCI_ERR_MAP_ARGUMENT;
00548         err->con   = con;
00549         err->stmt  = stmt;
00550 
00551         mtsprintf(err->str,
00552                   msizeof(err->str) - (size_t) 1,
00553                   OCILib_ErrorMsg[OCI_ERR_MAP_ARGUMENT],
00554                   arg);
00555     }
00556 
00557     OCI_ExceptionRaise(err);
00558 }
00559 
00560 /* --------------------------------------------------------------------------------------------- *
00561  * OCI_ExceptionOutOfBounds
00562  * --------------------------------------------------------------------------------------------- */
00563 
00564 void OCI_ExceptionOutOfBounds
00565 (
00566     OCI_Connection *con,
00567     int             value
00568 )
00569 {
00570     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00571 
00572     if (err != NULL)
00573     {
00574         err->type  = OCI_ERR_OCILIB;
00575         err->icode = OCI_ERR_OUT_OF_BOUNDS;
00576         err->con   = con;
00577 
00578         mtsprintf(err->str,
00579                   msizeof(err->str) - (size_t) 1,
00580                   OCILib_ErrorMsg[OCI_ERR_OUT_OF_BOUNDS],
00581                   value);
00582     }
00583 
00584     OCI_ExceptionRaise(err);
00585 }
00586 
00587 /* --------------------------------------------------------------------------------------------- *
00588 * OCI_ExceptionUnfreedData
00589 * --------------------------------------------------------------------------------------------- */
00590 
00591 void OCI_ExceptionUnfreedData
00592 (
00593     int type_elem,
00594     int nb_elem
00595 )
00596 {
00597     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00598 
00599     if (err != NULL)
00600     {
00601         err->type  = OCI_ERR_OCILIB;
00602         err->icode = OCI_ERR_UNFREED_DATA;
00603 
00604         mtsprintf(err->str,
00605                   msizeof(err->str) - (size_t) 1,
00606                   OCILib_ErrorMsg[OCI_ERR_UNFREED_DATA],
00607                   nb_elem, OCILib_HandleNames[type_elem-1]);
00608     }
00609 
00610     OCI_ExceptionRaise(err);
00611 }
00612 
00613 /* --------------------------------------------------------------------------------------------- *
00614  * OCI_ExceptionRuntimeLoading
00615  * --------------------------------------------------------------------------------------------- */
00616 
00617 void OCI_ExceptionMaxBind
00618 (
00619     OCI_Statement *stmt
00620 )
00621 {
00622     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00623 
00624     if (err != NULL)
00625     {
00626         err->type  = OCI_ERR_OCILIB;
00627         err->icode = OCI_ERR_MAX_BIND;
00628         err->stmt  = stmt;
00629 
00630         if (stmt != NULL)
00631             err->con =  stmt->con;
00632 
00633         mtsprintf(err->str,
00634                   msizeof(err->str) - (size_t) 1,
00635                   OCILib_ErrorMsg[OCI_ERR_MAX_BIND],
00636                   OCI_BIND_MAX);
00637     }
00638 
00639     OCI_ExceptionRaise(err);
00640 }
00641 
00642 /* --------------------------------------------------------------------------------------------- *
00643  * OCI_ExceptionAttributeNotFound
00644  * --------------------------------------------------------------------------------------------- */
00645 
00646 void OCI_ExceptionAttributeNotFound
00647 (
00648     OCI_Connection *con,
00649     const mtext    *attr
00650 )
00651 {
00652     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00653 
00654     if (err != NULL)
00655     {
00656         err->type  = OCI_ERR_OCILIB;
00657         err->icode = OCI_ERR_ATTR_NOT_FOUND;
00658         err->con   = con;
00659 
00660         mtsprintf(err->str,
00661                   msizeof(err->str) - (size_t) 1,
00662                   OCILib_ErrorMsg[OCI_ERR_ATTR_NOT_FOUND],
00663                   attr);
00664     }
00665 
00666     OCI_ExceptionRaise(err);
00667 }
00668 
00669 /* --------------------------------------------------------------------------------------------- *
00670  * OCI_ExceptionMinimumValue
00671  * --------------------------------------------------------------------------------------------- */
00672 
00673 void OCI_ExceptionMinimumValue
00674 (
00675     OCI_Connection *con,
00676     OCI_Statement  *stmt,
00677     int             min
00678 )
00679 {
00680     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00681 
00682     if (err != NULL)
00683     {
00684         err->type  = OCI_ERR_OCILIB;
00685         err->icode = OCI_ERR_MIN_VALUE;
00686         err->con   = con;
00687         err->stmt  = stmt;
00688 
00689         mtsprintf(err->str, msizeof(err->str) - (size_t) 1, OCILib_ErrorMsg[OCI_ERR_MIN_VALUE], min);
00690     }
00691 
00692     OCI_ExceptionRaise(err);
00693 }
00694 
00695 /* --------------------------------------------------------------------------------------------- *
00696  * OCI_ExceptionTypeNotCompatible
00697  * --------------------------------------------------------------------------------------------- */
00698 
00699 void OCI_ExceptionTypeNotCompatible
00700 (
00701     OCI_Connection *con
00702 )
00703 {
00704     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00705 
00706     if (err != NULL)
00707     {
00708         err->type  = OCI_ERR_OCILIB;
00709         err->icode = OCI_ERR_NOT_COMPATIBLE;
00710         err->con   = con;
00711 
00712         mtsncat(err->str, OCILib_ErrorMsg[OCI_ERR_NOT_COMPATIBLE], msizeof(err->str) - (size_t) 1);
00713     }
00714 
00715     OCI_ExceptionRaise(err);
00716 }
00717 
00718 /* --------------------------------------------------------------------------------------------- *
00719  * OCI_ExceptionStatementState
00720  * --------------------------------------------------------------------------------------------- */
00721 
00722 void OCI_ExceptionStatementState
00723 (
00724     OCI_Statement *stmt,
00725     int            state
00726 )
00727 {
00728     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00729 
00730     if (err != NULL)
00731     {
00732         int i, index;
00733 
00734         index      = 0;
00735 
00736         err->type  = OCI_ERR_OCILIB;
00737         err->icode = OCI_ERR_STMT_STATE;
00738         err->stmt  = stmt;
00739         err->con   =  stmt->con;
00740 
00741         for(i = 0; i < OCI_STMT_STATES_COUNT; i++)
00742         {
00743             if (state == OCILib_StmtStates[i].state)
00744             {
00745                 index = i;
00746                 break;
00747             }
00748         }
00749 
00750         mtsprintf(err->str,
00751                   msizeof(err->str) - (size_t) 1,
00752                   OCILib_ErrorMsg[OCI_ERR_STMT_STATE],
00753                   OCILib_StmtStates[index].name);
00754     }
00755 
00756     OCI_ExceptionRaise(err);
00757 }
00758 
00759 /* --------------------------------------------------------------------------------------------- *
00760  * OCI_ExceptionStatementNotScrollable
00761  * --------------------------------------------------------------------------------------------- */
00762 
00763 void OCI_ExceptionStatementNotScrollable
00764 (
00765     OCI_Statement *stmt
00766 )
00767 {
00768     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00769 
00770     if (err != NULL)
00771     {
00772         err->type  = OCI_ERR_OCILIB;
00773         err->icode = OCI_ERR_STMT_NOT_SCROLLABLE;
00774         err->stmt  = stmt;
00775 
00776         if (stmt != NULL)
00777         {
00778             err->con =  stmt->con;
00779         }
00780 
00781         mtsncat(err->str, OCILib_ErrorMsg[OCI_ERR_STMT_NOT_SCROLLABLE], msizeof(err->str) - (size_t) 1);
00782 
00783     }
00784 
00785     OCI_ExceptionRaise(err);
00786 }
00787 
00788 /* --------------------------------------------------------------------------------------------- *
00789  * OCI_ExceptionBindAlreadyUsed
00790  * --------------------------------------------------------------------------------------------- */
00791 
00792 void OCI_ExceptionBindAlreadyUsed
00793 (
00794     OCI_Statement *stmt,
00795     const mtext  * bind
00796 )
00797 {
00798     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00799 
00800     if (err != NULL)
00801     {
00802         err->type  = OCI_ERR_OCILIB;
00803         err->icode = OCI_ERR_BIND_ALREADY_USED;
00804         err->stmt  = stmt;
00805 
00806         if (stmt != NULL)
00807         {
00808             err->con =  stmt->con;
00809         }
00810 
00811         mtsprintf(err->str,
00812                   msizeof(err->str) - (size_t) 1,
00813                   OCILib_ErrorMsg[OCI_ERR_BIND_ALREADY_USED],
00814                   bind);
00815     }
00816 
00817     OCI_ExceptionRaise(err);
00818 }
00819 
00820 /* --------------------------------------------------------------------------------------------- *
00821  * OCI_ExceptionBindArraySize
00822  * --------------------------------------------------------------------------------------------- */
00823 
00824 void OCI_ExceptionBindArraySize
00825 (
00826     OCI_Statement *stmt,
00827     unsigned int   maxsize,
00828     unsigned int   cursize,
00829     unsigned int   newsize
00830 )
00831 {
00832     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00833 
00834     if (err != NULL)
00835     {
00836         err->type  = OCI_ERR_OCILIB;
00837         err->icode = OCI_ERR_BIND_ARRAY_SIZE;
00838         err->stmt  = stmt;
00839 
00840         if (stmt != NULL)
00841         {
00842             err->con =  stmt->con;
00843         }
00844 
00845         mtsprintf(err->str,
00846                   msizeof(err->str) - (size_t) 1,
00847                   OCILib_ErrorMsg[OCI_ERR_BIND_ARRAY_SIZE],
00848                   maxsize, cursize, newsize);
00849     }
00850 
00851     OCI_ExceptionRaise(err);
00852 }
00853 
00854 /* --------------------------------------------------------------------------------------------- *
00855  * OCI_ExceptionDirPathColNotFound
00856  * --------------------------------------------------------------------------------------------- */
00857 
00858 void OCI_ExceptionDirPathColNotFound
00859 (
00860     OCI_DirPath  *dp,
00861     const mtext * column,
00862     const mtext  *table
00863 )
00864 {
00865     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00866 
00867     if (err != NULL)
00868     {
00869         err->type  = OCI_ERR_OCILIB;
00870         err->icode = OCI_ERR_DIRPATH_STATE;
00871         err->stmt  = NULL;
00872 
00873         if (dp != NULL)
00874         {
00875             err->con =  dp->con;
00876         }
00877 
00878         mtsprintf(err->str,
00879                   msizeof(err->str) - (size_t) 1,
00880                   OCILib_ErrorMsg[OCI_ERR_COLUMN_NOT_FOUND],
00881                   column,
00882                   table);
00883     }
00884 
00885     OCI_ExceptionRaise(err);
00886 }
00887 
00888 /* --------------------------------------------------------------------------------------------- *
00889  * OCI_ExceptionDirPathState
00890  * --------------------------------------------------------------------------------------------- */
00891 
00892 void OCI_ExceptionDirPathState
00893 (
00894     OCI_DirPath *dp,
00895     int          state
00896 )
00897 {
00898     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00899 
00900     if (err != NULL)
00901     {
00902         err->type  = OCI_ERR_OCILIB;
00903         err->icode = OCI_ERR_DIRPATH_STATE;
00904         err->stmt  = NULL;
00905 
00906         if (dp != NULL)
00907         {
00908             dp->con =  dp->con;
00909         }
00910 
00911         mtsprintf(err->str,
00912                   msizeof(err->str) - (size_t) 1,
00913                   OCILib_ErrorMsg[OCI_ERR_DIRPATH_STATE],
00914                   OCILib_DirPathStates[state-1]);
00915     }
00916 
00917     OCI_ExceptionRaise(err);
00918 }
00919 
00920 /* --------------------------------------------------------------------------------------------- *
00921  * OCI_ExceptionOCIEnvironment
00922  * --------------------------------------------------------------------------------------------- */
00923 
00924 void OCI_ExceptionOCIEnvironment
00925 (
00926     void
00927 )
00928 {
00929     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00930 
00931     if (err != NULL)
00932     {
00933         err->type  = OCI_ERR_OCILIB;
00934         err->icode = OCI_ERR_CREATE_OCI_ENVIRONMENT;
00935 
00936         mtsncat(err->str,  OCILib_ErrorMsg[OCI_ERR_CREATE_OCI_ENVIRONMENT], msizeof(err->str) - (size_t) 1);
00937     }
00938 
00939     OCI_ExceptionRaise(err);
00940 }
00941 
00942 /* --------------------------------------------------------------------------------------------- *
00943  * OCI_ExceptionRebindBadDatatype
00944  * --------------------------------------------------------------------------------------------- */
00945 
00946 void OCI_ExceptionRebindBadDatatype
00947 (
00948     OCI_Statement *stmt,
00949     const mtext  * bind
00950 )
00951 {
00952     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00953 
00954     if (err != NULL)
00955     {
00956         err->type  = OCI_ERR_OCILIB;
00957         err->icode = OCI_ERR_REBIND_BAD_DATATYPE;
00958         err->stmt  = stmt;
00959 
00960         if (stmt != NULL)
00961         {
00962             err->con =  stmt->con;
00963         }
00964 
00965         mtsprintf(err->str,
00966                   msizeof(err->str) - (size_t) 1,
00967                   OCILib_ErrorMsg[OCI_ERR_REBIND_BAD_DATATYPE],
00968                   bind);
00969     }
00970 
00971     OCI_ExceptionRaise(err);
00972 }
00973