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