• Main Page
  • Modules
  • Data Structures
  • Files
  • File List

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-2010 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.8.1 2010-12-13 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("Unable to perform this operation on a %ls statement"),
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("Unable to perform this operation on a %s statement"),
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 10g R1 LOBs size extensions"),
00177     MT("Oracle 10g R2 Database change notification"),
00178     MT("Oracle 10g R2 remote database startup/shutdown")
00179 };
00180 
00181 static mtext * OCILib_StmtStates[] =
00182 {
00183     MT("closed"),
00184     MT("prepared"),
00185     MT("executed")
00186 };
00187 
00188 static mtext * OCILib_DirPathStates[] =
00189 {
00190     MT("non prepared"),
00191     MT("prepared"),
00192     MT("converted"),
00193     MT("terminated")
00194 };
00195 
00196 static mtext * OCILib_HandleNames[] =
00197 {
00198     MT("OCI handle"),
00199     MT("OCI descriptors"),
00200     MT("OCI Object handles")
00201 };
00202 
00203 /* ********************************************************************************************* *
00204  *                             PRIVATE FUNCTIONS
00205  * ********************************************************************************************* */
00206 
00207 /* --------------------------------------------------------------------------------------------- *
00208  * OCI_ExceptionGetError
00209  * --------------------------------------------------------------------------------------------- */
00210 
00211 OCI_Error * OCI_ExceptionGetError
00212 (
00213     boolean warning
00214 )
00215 {
00216     OCI_Error *err = OCI_ErrorGet(TRUE, warning);
00217 
00218     if (err != NULL)
00219     {
00220         OCI_ErrorReset(err);
00221 
00222         err->active  = TRUE;
00223         err->warning = warning;
00224     }
00225 
00226     return err;
00227 }
00228 
00229 /* --------------------------------------------------------------------------------------------- *
00230  * OCI_ExceptionRaise
00231  * --------------------------------------------------------------------------------------------- */
00232 
00233 void OCI_ExceptionRaise
00234 (
00235     OCI_Error *err
00236 )
00237 {
00238     if (err != NULL)
00239     {
00240         if (OCILib.error_handler != NULL)
00241             OCILib.error_handler(err);
00242 
00243         err->active = FALSE;
00244     }
00245 }
00246 
00247 /* --------------------------------------------------------------------------------------------- *
00248  * OCI_ExceptionOCI
00249  * --------------------------------------------------------------------------------------------- */
00250 
00251 void OCI_ExceptionOCI
00252 (
00253     OCIError       *p_err,
00254     OCI_Connection *con,
00255     OCI_Statement  *stmt,
00256     boolean         warning
00257 )
00258 {
00259     OCI_Error *err = OCI_ExceptionGetError(warning);
00260 
00261     if (err != NULL)
00262     {
00263         int osize  = -1;
00264         void *ostr = NULL;
00265 
00266         err->type = (warning ? OCI_ERR_WARNING : OCI_ERR_ORACLE);
00267         err->con  = con;
00268         err->stmt = stmt;
00269 
00270         /* get oracle description */
00271 
00272         osize = (int) (msizeof(err->str) - (size_t) 1);
00273         ostr  = OCI_GetInputMetaString(err->str, &osize);
00274 
00275         OCIErrorGet((dvoid *) p_err, (ub4) 1, (OraText *) NULL, &err->ocode,
00276                     (OraText *) ostr, (ub4) osize, (ub4) OCI_HTYPE_ERROR);
00277 
00278         OCI_GetOutputMetaString(ostr, err->str, &osize);
00279         OCI_ReleaseMetaString(ostr);
00280     }
00281 
00282     OCI_ExceptionRaise(err);
00283 }
00284 
00285 /* --------------------------------------------------------------------------------------------- *
00286  * OCI_ExceptionNotInitialized
00287  * --------------------------------------------------------------------------------------------- */
00288 
00289 void OCI_ExceptionNotInitialized
00290 (
00291     void
00292 )
00293 {
00294     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00295 
00296     if (err != NULL)
00297     {
00298         err->type  = OCI_ERR_OCILIB;
00299         err->icode = OCI_ERR_NOT_INITIALIZED;
00300 
00301         mtsncat(err->str,  OCILib_ErrorMsg[OCI_ERR_NOT_INITIALIZED],
00302                 msizeof(err->str) - (size_t) 1);
00303     }
00304 
00305     OCI_ExceptionRaise(err);
00306 }
00307 
00308 /* --------------------------------------------------------------------------------------------- *
00309  * OCI_ExceptionLoadingShareLib
00310  * --------------------------------------------------------------------------------------------- */
00311 
00312 void OCI_ExceptionLoadingSharedLib
00313 (
00314     void
00315 )
00316 {
00317     #ifdef OCI_IMPORT_RUNTIME
00318 
00319     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00320 
00321     if (err != NULL)
00322     {
00323         err->type  = OCI_ERR_OCILIB;
00324         err->icode = OCI_ERR_LOADING_SHARED_LIB;
00325 
00326         mtsprintf(err->str, msizeof(err->str) - (size_t) 1,
00327                   OCILib_ErrorMsg[OCI_ERR_LOADING_SHARED_LIB],
00328                   OCI_DL_META_NAME);
00329     }
00330 
00331     OCI_ExceptionRaise(err);
00332 
00333     #endif
00334 }
00335 
00336 /* --------------------------------------------------------------------------------------------- *
00337  * OCI_ExceptionLoadingSymbols
00338  * --------------------------------------------------------------------------------------------- */
00339 
00340 void OCI_ExceptionLoadingSymbols
00341 (
00342     void
00343 )
00344 {
00345     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00346 
00347     if (err != NULL)
00348     {
00349         err->type  = OCI_ERR_OCILIB;
00350         err->icode = OCI_ERR_LOADING_SYMBOLS;
00351 
00352         mtsncat(err->str,  OCILib_ErrorMsg[OCI_ERR_LOADING_SYMBOLS],
00353                 msizeof(err->str) - (size_t) 1);
00354     }
00355 
00356     OCI_ExceptionRaise(err);
00357 }
00358 
00359 /* --------------------------------------------------------------------------------------------- *
00360  * OCI_ExceptionNotMultithreaded
00361  * --------------------------------------------------------------------------------------------- */
00362 
00363 void OCI_ExceptionNotMultithreaded
00364 (
00365     void
00366 )
00367 {
00368     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00369 
00370     if (err != NULL)
00371     {
00372         err->type  = OCI_ERR_OCILIB;
00373         err->icode = OCI_ERR_MULTITHREADED;
00374 
00375         mtsncat(err->str,  OCILib_ErrorMsg[OCI_ERR_MULTITHREADED],
00376                 msizeof(err->str) - (size_t) 1);
00377     }
00378 
00379     OCI_ExceptionRaise(err);
00380 }
00381 
00382 /* --------------------------------------------------------------------------------------------- *
00383  * OCI_ExceptionNullPointer
00384  * --------------------------------------------------------------------------------------------- */
00385 
00386 void OCI_ExceptionNullPointer
00387 (
00388     int type
00389 )
00390 {
00391     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00392 
00393     if (err != NULL)
00394     {
00395         err->type  = OCI_ERR_OCILIB;
00396         err->icode = OCI_ERR_NULL_POINTER;
00397 
00398         mtsprintf(err->str, msizeof(err->str) - (size_t) 1,
00399                   OCILib_ErrorMsg[OCI_ERR_NULL_POINTER],
00400                   OCILib_TypeNames[type-1]);
00401     }
00402 
00403     OCI_ExceptionRaise(err);
00404 }
00405 
00406 /* --------------------------------------------------------------------------------------------- *
00407  * OCI_ExceptionMemory
00408  * --------------------------------------------------------------------------------------------- */
00409 
00410 void OCI_ExceptionMemory
00411 (
00412     int             type,
00413     size_t          nb_bytes,
00414     OCI_Connection *con,
00415     OCI_Statement  *stmt
00416 )
00417 {
00418     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00419 
00420     if (err != NULL)
00421     {
00422         err->type  = OCI_ERR_OCILIB;
00423         err->icode = OCI_ERR_MEMORY;
00424         err->con   = con;
00425         err->stmt  = stmt;
00426 
00427         mtsprintf(err->str,
00428                   msizeof(err->str) - (size_t) 1,
00429                   OCILib_ErrorMsg[OCI_ERR_MEMORY],
00430                   OCILib_TypeNames[type-1],
00431                   nb_bytes);
00432     }
00433 
00434     OCI_ExceptionRaise(err);
00435 }
00436 
00437 /* --------------------------------------------------------------------------------------------- *
00438  * OCI_ExceptionNotAvailable
00439  * --------------------------------------------------------------------------------------------- */
00440 
00441 void OCI_ExceptionNotAvailable
00442 (
00443     OCI_Connection *con,
00444     int             feature
00445 )
00446 {
00447     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00448 
00449     if (err != NULL)
00450     {
00451         err->type  = OCI_ERR_OCILIB;
00452         err->icode = OCI_ERR_NOT_AVAILABLE;
00453         err->con   = con;
00454 
00455         mtsprintf(err->str,
00456                   msizeof(err->str) - (size_t) 1,
00457                   OCILib_ErrorMsg[OCI_ERR_NOT_AVAILABLE],
00458                   OCILib_OraFeatures[feature-1]);
00459     }
00460 
00461     OCI_ExceptionRaise(err);
00462 }
00463 
00464 /* --------------------------------------------------------------------------------------------- *
00465  * OCI_ExceptionDatatypeNotSupported
00466  * --------------------------------------------------------------------------------------------- */
00467 
00468 void OCI_ExceptionDatatypeNotSupported
00469 (
00470     OCI_Connection *con,
00471     OCI_Statement  *stmt,
00472     int             code
00473 )
00474 {
00475     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00476 
00477     if (err != NULL)
00478     {
00479         err->type  = OCI_ERR_OCILIB;
00480         err->icode = OCI_ERR_DATATYPE_NOT_SUPPORTED;
00481         err->con   = con;
00482         err->stmt  = stmt;
00483 
00484         mtsprintf(err->str,
00485                   msizeof(err->str) - (size_t) 1,
00486                   OCILib_ErrorMsg[OCI_ERR_DATATYPE_NOT_SUPPORTED],
00487                   code);
00488     }
00489 
00490     OCI_ExceptionRaise(err);
00491 }
00492 
00493 /* --------------------------------------------------------------------------------------------- *
00494  * OCI_ExceptionParsingError
00495  * --------------------------------------------------------------------------------------------- */
00496 
00497 void OCI_ExceptionParsingToken
00498 (
00499     OCI_Connection *con,
00500     OCI_Statement  *stmt,
00501     mtext           token
00502 )
00503 {
00504     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00505 
00506     if (err != NULL)
00507     {
00508         err->type  = OCI_ERR_OCILIB;
00509         err->icode = OCI_ERR_PARSE_TOKEN;
00510         err->con   = con;
00511         err->stmt  = stmt;
00512 
00513         mtsprintf(err->str,
00514                   msizeof(err->str) - (size_t) 1,
00515                   OCILib_ErrorMsg[OCI_ERR_PARSE_TOKEN],
00516                   token);
00517     }
00518 
00519     OCI_ExceptionRaise(err);
00520 }
00521 
00522 /* --------------------------------------------------------------------------------------------- *
00523  * OCI_ExceptionMappingArgument
00524  * --------------------------------------------------------------------------------------------- */
00525 
00526 void OCI_ExceptionMappingArgument
00527 (
00528     OCI_Connection *con,
00529     OCI_Statement  *stmt,
00530     int             arg
00531 )
00532 {
00533     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00534 
00535     if (err != NULL)
00536     {
00537         err->type  = OCI_ERR_OCILIB;
00538         err->icode = OCI_ERR_MAP_ARGUMENT;
00539         err->con   = con;
00540         err->stmt  = stmt;
00541 
00542         mtsprintf(err->str,
00543                   msizeof(err->str) - (size_t) 1,
00544                   OCILib_ErrorMsg[OCI_ERR_MAP_ARGUMENT],
00545                   arg);
00546     }
00547 
00548     OCI_ExceptionRaise(err);
00549 }
00550 
00551 /* --------------------------------------------------------------------------------------------- *
00552  * OCI_ExceptionOutOfBounds
00553  * --------------------------------------------------------------------------------------------- */
00554 
00555 void OCI_ExceptionOutOfBounds
00556 (
00557     OCI_Connection *con,
00558     int             value
00559 )
00560 {
00561     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00562 
00563     if (err != NULL)
00564     {
00565         err->type  = OCI_ERR_OCILIB;
00566         err->icode = OCI_ERR_OUT_OF_BOUNDS;
00567         err->con   = con;
00568 
00569         mtsprintf(err->str,
00570                   msizeof(err->str) - (size_t) 1,
00571                   OCILib_ErrorMsg[OCI_ERR_OUT_OF_BOUNDS],
00572                   value);
00573     }
00574 
00575     OCI_ExceptionRaise(err);
00576 }
00577 
00578 /* --------------------------------------------------------------------------------------------- *
00579 * OCI_ExceptionUnfreedData
00580 * --------------------------------------------------------------------------------------------- */
00581 
00582 void OCI_ExceptionUnfreedData
00583 (
00584     int type_elem,
00585     int nb_elem
00586 )
00587 {
00588     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00589 
00590     if (err != NULL)
00591     {
00592         err->type  = OCI_ERR_OCILIB;
00593         err->icode = OCI_ERR_UNFREED_DATA;
00594 
00595         mtsprintf(err->str,
00596                   msizeof(err->str) - (size_t) 1,
00597                   OCILib_ErrorMsg[OCI_ERR_UNFREED_DATA],
00598                   nb_elem, OCILib_HandleNames[type_elem-1]);
00599     }
00600 
00601     OCI_ExceptionRaise(err);
00602 }
00603 
00604 /* --------------------------------------------------------------------------------------------- *
00605  * OCI_ExceptionRuntimeLoading
00606  * --------------------------------------------------------------------------------------------- */
00607 
00608 void OCI_ExceptionMaxBind
00609 (
00610     OCI_Statement *stmt
00611 )
00612 {
00613     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00614 
00615     if (err != NULL)
00616     {
00617         err->type  = OCI_ERR_OCILIB;
00618         err->icode = OCI_ERR_MAX_BIND;
00619         err->stmt  = stmt;
00620 
00621         if (stmt != NULL)
00622             err->con =  stmt->con;
00623 
00624         mtsprintf(err->str,
00625                   msizeof(err->str) - (size_t) 1,
00626                   OCILib_ErrorMsg[OCI_ERR_MAX_BIND],
00627                   OCI_BIND_MAX);
00628     }
00629 
00630     OCI_ExceptionRaise(err);
00631 }
00632 
00633 /* --------------------------------------------------------------------------------------------- *
00634  * OCI_ExceptionAttributeNotFound
00635  * --------------------------------------------------------------------------------------------- */
00636 
00637 void OCI_ExceptionAttributeNotFound
00638 (
00639     OCI_Connection *con,
00640     const mtext    *attr
00641 )
00642 {
00643     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00644 
00645     if (err != NULL)
00646     {
00647         err->type  = OCI_ERR_OCILIB;
00648         err->icode = OCI_ERR_ATTR_NOT_FOUND;
00649         err->con   = con;
00650 
00651         mtsprintf(err->str,
00652                   msizeof(err->str) - (size_t) 1,
00653                   OCILib_ErrorMsg[OCI_ERR_ATTR_NOT_FOUND],
00654                   attr);
00655     }
00656 
00657     OCI_ExceptionRaise(err);
00658 }
00659 
00660 /* --------------------------------------------------------------------------------------------- *
00661  * OCI_ExceptionMinimumValue
00662  * --------------------------------------------------------------------------------------------- */
00663 
00664 void OCI_ExceptionMinimumValue
00665 (
00666     OCI_Connection *con,
00667     OCI_Statement  *stmt,
00668     int             min
00669 )
00670 {
00671     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00672 
00673     if (err != NULL)
00674     {
00675         err->type  = OCI_ERR_OCILIB;
00676         err->icode = OCI_ERR_MIN_VALUE;
00677         err->con   = con;
00678         err->stmt  = stmt;
00679         mtsprintf(err->str, msizeof(err->str) - (size_t) 1,
00680                   OCILib_ErrorMsg[OCI_ERR_MIN_VALUE], min);
00681     }
00682 
00683     OCI_ExceptionRaise(err);
00684 }
00685 
00686 /* --------------------------------------------------------------------------------------------- *
00687  * OCI_ExceptionTypeNotCompatible
00688  * --------------------------------------------------------------------------------------------- */
00689 
00690 void OCI_ExceptionTypeNotCompatible
00691 (
00692     OCI_Connection *con
00693 )
00694 {
00695     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00696 
00697     if (err != NULL)
00698     {
00699         err->type  = OCI_ERR_OCILIB;
00700         err->icode = OCI_ERR_NOT_COMPATIBLE;
00701         err->con   = con;
00702 
00703         mtsncat(err->str, OCILib_ErrorMsg[OCI_ERR_NOT_COMPATIBLE],
00704                 msizeof(err->str) - (size_t) 1);
00705     }
00706 
00707     OCI_ExceptionRaise(err);
00708 }
00709 
00710 /* --------------------------------------------------------------------------------------------- *
00711  * OCI_ExceptionStatementState
00712  * --------------------------------------------------------------------------------------------- */
00713 
00714 void OCI_ExceptionStatementState
00715 (
00716     OCI_Statement *stmt,
00717     int            state
00718 )
00719 {
00720     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00721 
00722     if (err != NULL)
00723     {
00724         err->type  = OCI_ERR_OCILIB;
00725         err->icode = OCI_ERR_STMT_STATE;
00726         err->stmt  = stmt;
00727 
00728         if (stmt != NULL)
00729             err->con =  stmt->con;
00730 
00731         mtsprintf(err->str,
00732                   msizeof(err->str) - (size_t) 1,
00733                   OCILib_ErrorMsg[OCI_ERR_STMT_STATE],
00734                   OCILib_StmtStates[state-1]);
00735     }
00736 
00737     OCI_ExceptionRaise(err);
00738 }
00739 
00740 /* --------------------------------------------------------------------------------------------- *
00741  * OCI_ExceptionStatementNotScrollable
00742  * --------------------------------------------------------------------------------------------- */
00743 
00744 void OCI_ExceptionStatementNotScrollable
00745 (
00746     OCI_Statement *stmt
00747 )
00748 {
00749     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00750 
00751     if (err != NULL)
00752     {
00753         err->type  = OCI_ERR_OCILIB;
00754         err->icode = OCI_ERR_STMT_NOT_SCROLLABLE;
00755         err->stmt  = stmt;
00756 
00757         if (stmt != NULL)
00758             err->con =  stmt->con;
00759 
00760         mtsncat(err->str, OCILib_ErrorMsg[OCI_ERR_STMT_NOT_SCROLLABLE],
00761                 msizeof(err->str) - (size_t) 1);
00762 
00763     }
00764 
00765     OCI_ExceptionRaise(err);
00766 }
00767 
00768 /* --------------------------------------------------------------------------------------------- *
00769  * OCI_ExceptionBindAlreadyUsed
00770  * --------------------------------------------------------------------------------------------- */
00771 
00772 void OCI_ExceptionBindAlreadyUsed
00773 (
00774     OCI_Statement *stmt,
00775     const mtext  * bind
00776 )
00777 {
00778     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00779 
00780     if (err != NULL)
00781     {
00782         err->type  = OCI_ERR_OCILIB;
00783         err->icode = OCI_ERR_BIND_ALREADY_USED;
00784         err->stmt  = stmt;
00785 
00786         if (stmt != NULL)
00787             err->con =  stmt->con;
00788 
00789         mtsprintf(err->str,
00790                   msizeof(err->str) - (size_t) 1,
00791                   OCILib_ErrorMsg[OCI_ERR_BIND_ALREADY_USED],
00792                   bind);
00793     }
00794 
00795     OCI_ExceptionRaise(err);
00796 }
00797 
00798 /* --------------------------------------------------------------------------------------------- *
00799  * OCI_ExceptionBindArraySize
00800  * --------------------------------------------------------------------------------------------- */
00801 
00802 void OCI_ExceptionBindArraySize
00803 (
00804     OCI_Statement *stmt,
00805     unsigned int   maxsize,
00806     unsigned int   cursize,
00807     unsigned int   newsize
00808 )
00809 {
00810     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00811 
00812     if (err != NULL)
00813     {
00814         err->type  = OCI_ERR_OCILIB;
00815         err->icode = OCI_ERR_BIND_ARRAY_SIZE;
00816         err->stmt  = stmt;
00817 
00818         if (stmt != NULL)
00819             err->con =  stmt->con;
00820 
00821         mtsprintf(err->str,
00822                   msizeof(err->str) - (size_t) 1,
00823                   OCILib_ErrorMsg[OCI_ERR_BIND_ARRAY_SIZE],
00824                   maxsize, cursize, newsize);
00825     }
00826 
00827     OCI_ExceptionRaise(err);
00828 }
00829 
00830 /* --------------------------------------------------------------------------------------------- *
00831  * OCI_ExceptionDirPathColNotFound
00832  * --------------------------------------------------------------------------------------------- */
00833 
00834 void OCI_ExceptionDirPathColNotFound
00835 (
00836     OCI_DirPath  *dp,
00837     const mtext * column,
00838     const mtext  *table
00839 )
00840 {
00841     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00842 
00843     if (err != NULL)
00844     {
00845         err->type  = OCI_ERR_OCILIB;
00846         err->icode = OCI_ERR_DIRPATH_STATE;
00847         err->stmt  = NULL;
00848 
00849         if (dp != NULL)
00850             dp->con =  dp->con;
00851 
00852         mtsprintf(err->str,
00853                   msizeof(err->str) - (size_t) 1,
00854                   OCILib_ErrorMsg[OCI_ERR_COLUMN_NOT_FOUND],
00855                   column,
00856                   table);
00857     }
00858 
00859     OCI_ExceptionRaise(err);
00860 }
00861 
00862 /* --------------------------------------------------------------------------------------------- *
00863  * OCI_ExceptionDirPathState
00864  * --------------------------------------------------------------------------------------------- */
00865 
00866 void OCI_ExceptionDirPathState
00867 (
00868     OCI_DirPath *dp,
00869     int          state
00870 )
00871 {
00872     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00873 
00874     if (err != NULL)
00875     {
00876         err->type  = OCI_ERR_OCILIB;
00877         err->icode = OCI_ERR_DIRPATH_STATE;
00878         err->stmt  = NULL;
00879 
00880         if (dp != NULL)
00881             dp->con =  dp->con;
00882 
00883         mtsprintf(err->str,
00884                   msizeof(err->str) - (size_t) 1,
00885                   OCILib_ErrorMsg[OCI_ERR_DIRPATH_STATE],
00886                   OCILib_DirPathStates[state-1]);
00887     }
00888 
00889     OCI_ExceptionRaise(err);
00890 }
00891 
00892 /* --------------------------------------------------------------------------------------------- *
00893  * OCI_ExceptionOCIEnvironment
00894  * --------------------------------------------------------------------------------------------- */
00895 
00896 void OCI_ExceptionOCIEnvironment
00897 (
00898     void
00899 )
00900 {
00901     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00902 
00903     if (err != NULL)
00904     {
00905         err->type  = OCI_ERR_OCILIB;
00906         err->icode = OCI_ERR_CREATE_OCI_ENVIRONMENT;
00907 
00908         mtsncat(err->str,  OCILib_ErrorMsg[OCI_ERR_CREATE_OCI_ENVIRONMENT],
00909                 msizeof(err->str) - (size_t) 1);
00910     }
00911 
00912     OCI_ExceptionRaise(err);
00913 }
00914 
00915 /* --------------------------------------------------------------------------------------------- *
00916  * OCI_ExceptionRebindBadDatatype
00917  * --------------------------------------------------------------------------------------------- */
00918 
00919 void OCI_ExceptionRebindBadDatatype
00920 (
00921     OCI_Statement *stmt,
00922     const mtext  * bind
00923 )
00924 {
00925     OCI_Error *err = OCI_ExceptionGetError(FALSE);
00926 
00927     if (err != NULL)
00928     {
00929         err->type  = OCI_ERR_OCILIB;
00930         err->icode = OCI_ERR_REBIND_BAD_DATATYPE;
00931         err->stmt  = stmt;
00932 
00933         if (stmt != NULL)
00934             err->con =  stmt->con;
00935 
00936         mtsprintf(err->str,
00937                   msizeof(err->str) - (size_t) 1,
00938                   OCILib_ErrorMsg[OCI_ERR_REBIND_BAD_DATATYPE],
00939                   bind);
00940     }
00941 
00942     OCI_ExceptionRaise(err);
00943 }
00944 

Generated on Mon Dec 13 2010 22:32:01 for OCILIB (C Driver for Oracle) by  doxygen 1.7.2