TeOCIConnection Class Reference

#include <TeOCIConnect.h>


Detailed Description

This class is reponsible for the connection to ORACLE DBMS using OCI (Oracle Call Interface) library.

Definition at line 42 of file TeOCIConnect.h.


OCI connection handles

OCIEnvenvhp_
 environment OCI handle
OCIErrorerrhp_
 error OCI handle
OCIServersrvhp_
 service context OCI handle - represents a connection
OCIStmtstmthp_
 environment OCI handle - stores SQL statement
OCISvcCtxsvchp_
 service context OCI handle - defines a service
OCITranstxnhp_
 service context OCI handle - controls the transactions
OCISessionusrhp_
 service context OCI handle - defines the permissions and privileges associated to an user

Public Member Functions

bool allocateObjectOrdinates ()
 Locates memory to the ordinates.
bool appendOrdinates (const double &val)
 Appends ordinates to be inserted or updated.
bool bindByName (char *name, void *value, int size, void *indicator, int type)
 Binds objects by name.
bool bindByPos (int pos, void *value, int size, void *indicator, int type)
 Binds objects by position.
bool bindOrdinates ()
 Binds ordinate object.
bool checkError (OCIError *errhp, int status)
 Checks OCI error handle.
bool connect (const char *dblink, const char *username, const char *password, const bool &useSDO=false)
 Connects to ORACLE DBMS.
void disconnect ()
 Disconnects to ORACLE DBMS.
bool execute (const string &stm)
 Executes only SQL statements that do not return rows (INSERT, UPDATE, DELETE, etc).
bool executeBLOBSTM (const string &stm, unsigned char *blobValue, const int &blobLength, const string &name)
 Executes only SQL statements that insert or update rows with BLOB.
bool executeSDOSTM (const string &stm)
 Executes only SQL statements that insert or update rows with SDO Objects.
string getErrorMessage ()
 Gets the error message.
bool isConnected ()
 Checks if there is an opened conection.
bool prepare (const string &stmt)
 Prepares the SQL statement to be executed.
int queryType (void)
 Returns the query (statement SQL) type.
 TeOCIConnection ()
 Constructor.
bool transCommit ()
 Commits a transaction.
bool transRollback ()
 Rollbacks a transaction.
bool transStart ()
 Starts a transaction.
bool useSDOType ()
 Returns if the connected Oracle DBMS uses the SDO_GEOMETRY type.
 ~TeOCIConnection ()
 Destructor.

Data Fields

unsigned char * blobValue_
 stores the blob value that will be inserted into database
OCIArrayordinates_
 stores the ordinates to insert into database
OCITypetdo_geometry_
 describes the SDO_GEOMETRY type
OCITypetdo_ordinates_
 describes the SDO_ORDINATES type

Protected Attributes

bool connected_
 indicates if there is a connection opened or not
string errorMess_
 error message returned by the ORACLE DBMS
bool useSDO_
 indicates if the connected Oracle DBMS uses the SDO_GEOMETRY type

Constructor & Destructor Documentation

TeOCIConnection::TeOCIConnection (  ) 

Definition at line 30 of file TeOCIConnect.cpp.

References blobValue_, connected_, envhp_, errhp_, ordinates_, srvhp_, stmthp_, svchp_, tdo_geometry_, tdo_ordinates_, txnhp_, useSDO_, and usrhp_.

00031 {
00032         connected_ = false;
00033         useSDO_ = false;
00034 
00035         envhp_ = 0;
00036         errhp_ = 0;
00037         srvhp_ = 0;
00038         svchp_ = 0;
00039         usrhp_ = 0;
00040         txnhp_ = 0;
00041         stmthp_ = 0;
00042         tdo_geometry_ = 0;
00043         tdo_ordinates_ = 0;
00044         ordinates_ = 0;
00045         blobValue_ = 0;
00046 }

TeOCIConnection::~TeOCIConnection (  )  [inline]

Definition at line 76 of file TeOCIConnect.h.

00076 { disconnect(); }


Member Function Documentation

bool TeOCIConnection::allocateObjectOrdinates (  ) 

Definition at line 266 of file TeOCIConnect.cpp.

References checkError(), dvoid, envhp_, errhp_, NULL, OCI_DURATION_SESSION, OCI_TYPECODE_VARRAY, ordinates_, SDO_OCIObjectNew(), svchp_, tdo_ordinates_, and TRUE.

Referenced by TeOracleSpatial::allocateOrdinatesObject().

00267 {
00268         sword status = SDO_OCIObjectNew(envhp_, errhp_, svchp_, OCI_TYPECODE_VARRAY, tdo_ordinates_, (dvoid*)NULL, 
00269                                         OCI_DURATION_SESSION, TRUE, (dvoid**)&ordinates_);
00270 
00271         if(!checkError(errhp_, status))
00272                 return false;
00273 
00274         return true;
00275 }

bool TeOCIConnection::appendOrdinates ( const double &  val  ) 

Definition at line 278 of file TeOCIConnect.cpp.

References checkError(), dvoid, envhp_, errhp_, OCICollAppend(), OCINumberFromReal(), and ordinates_.

Referenced by TeOracleSpatial::allocateOrdinatesObject().

00279 {
00280         
00281         OCINumber       oci_number;
00282         sword       status;
00283         
00284         status = OCINumberFromReal(errhp_, (dvoid *)&(val), 
00285                 (uword)sizeof(double),&oci_number);
00286 
00287         status = OCICollAppend(envhp_, errhp_, 
00288                 (dvoid *) &oci_number,
00289                 (dvoid *)0, (OCIColl *)ordinates_);
00290 
00291         if(!checkError(errhp_, status))
00292                 return false;
00293 
00294         return true;
00295 }

bool TeOCIConnection::bindByName ( char *  name,
void *  value,
int  size,
void *  indicator,
int  type 
)

bool TeOCIConnection::bindByPos ( int  pos,
void *  value,
int  size,
void *  indicator,
int  type 
)

Definition at line 220 of file TeOCIConnect.cpp.

References checkError(), connected_, dvoid, errhp_, NULL, OCI_DEFAULT, SDO_OCIBindByPos(), and stmthp_.

00221 {
00222         if (!connected_)
00223                 return false;
00224 
00225         OCIBind *bindp = NULL;
00226 
00227         sword status = SDO_OCIBindByPos(stmthp_, &bindp, errhp_, pos, (dvoid *)value, 
00228                                                                 (sb4)size, type, (dvoid *)indicator, (ub2 *)0, 
00229                                                                 (ub2 *)0, (ub4)0, (ub4 *)0, (ub4)OCI_DEFAULT);
00230         if(!checkError(errhp_, status))
00231                 return false;
00232         return true;
00233 }

bool TeOCIConnection::bindOrdinates (  ) 

Definition at line 235 of file TeOCIConnect.cpp.

References checkError(), dvoid, errhp_, NULL, OCI_DEFAULT, OCIBindByName(), OCIBindObject(), ordinates_, SQLT_NTY, stmthp_, and tdo_ordinates_.

Referenced by executeSDOSTM().

00236 {
00237         OCIBind         *bnd1p = NULL;
00238         
00239         /* bind coordinate varray object */
00240         sword status = OCIBindByName(stmthp_, &bnd1p, errhp_, 
00241             (text *)":ordinates_", (sb4)-1, (dvoid *)0, (sb4)0, SQLT_NTY, (dvoid *)0, 
00242                 (ub2 *)0, (ub2 *)0, (ub4)0, (ub4 *)0, (ub4)OCI_DEFAULT);
00243         if(!checkError(errhp_, status))
00244                 return false;
00245 
00246         status = OCIBindObject(bnd1p, errhp_, tdo_ordinates_, (dvoid **)&ordinates_, (ub4 *)0, 
00247             (dvoid **)0, (ub4 *)0);
00248         if(!checkError(errhp_, status))
00249                 return false;
00250 
00251         return true;
00252 }

bool TeOCIConnection::checkError ( OCIError errhp,
int  status 
)

Definition at line 404 of file TeOCIConnect.cpp.

References dvoid, errorMess_, NULL, OCI_CONTINUE, OCI_ERROR, OCI_HTYPE_ERROR, OCI_INVALID_HANDLE, OCI_NEED_DATA, OCI_NO_DATA, OCI_STILL_EXECUTING, OCI_SUCCESS, OCI_SUCCESS_WITH_INFO, and SDO_OCIErrorGet().

Referenced by allocateObjectOrdinates(), appendOrdinates(), bindByPos(), bindOrdinates(), connect(), execute(), executeSDOSTM(), prepare(), queryType(), transCommit(), transRollback(), and transStart().

00405 {
00406         char errbuf[512];
00407         sb4 errcode = 0;
00408         bool returnedVal = false;
00409                 
00410         if (status == OCI_ERROR)
00411         {
00412                 SDO_OCIErrorGet((dvoid*)errhp_, (ub4)1, (text*)NULL, &errcode, 
00413                                                 (text*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
00414                 errorMess_ = errbuf;
00415                 return false;
00416         }
00417 
00418         switch (status)
00419         { 
00420                 case OCI_SUCCESS:
00421                         //errorMess_ = "Success!";
00422                         returnedVal = true;
00423                         break;
00424 
00425                 case OCI_SUCCESS_WITH_INFO:
00426                         //errorMess_ = "Success with information!";
00427                         returnedVal = true;
00428                         break;
00429 
00430                 case OCI_NEED_DATA:
00431                         errorMess_ = "Need data!";
00432                         break;
00433                 
00434                 case OCI_NO_DATA:
00435                         errorMess_ = "No data!";
00436                         break;
00437 
00438                 //An invalid handle was passed as a parameter or a user callback is passed an
00439                 //invalid handle or invalid context. No further diagnostics are available.
00440                 case OCI_INVALID_HANDLE:
00441                         errorMess_ = "Invalid handle!";
00442                         break;
00443 
00444                 case OCI_STILL_EXECUTING:
00445                         errorMess_ = "Still executing!";
00446                         break;
00447 
00448                 case OCI_CONTINUE:
00449                         errorMess_ = "Continue!";
00450                         break;
00451                 default:
00452                         break;
00453         }
00454 
00455         return returnedVal;
00456 }

bool TeOCIConnection::connect ( const char *  dblink,
const char *  username,
const char *  password,
const bool useSDO = false 
)

Allocate a user session handle

Definition at line 49 of file TeOCIConnect.cpp.

References checkError(), connected_, dvoid, envhp_, errhp_, OCI_ATTR_PASSWORD, OCI_ATTR_SERVER, OCI_ATTR_SESSION, OCI_ATTR_TRANS, OCI_ATTR_USERNAME, OCI_CRED_RDBMS, OCI_DEFAULT, OCI_DURATION_SESSION, OCI_HTYPE_ERROR, OCI_HTYPE_SERVER, OCI_HTYPE_SESSION, OCI_HTYPE_STMT, OCI_HTYPE_SVCCTX, OCI_HTYPE_TRANS, OCI_OBJECT, OCI_THREADED, OCI_TYPEGET_HEADER, OCIAttrSet(), OCIHandleAlloc(), OCITypeByName(), SDO_OCIAttrSet(), SDO_OCIEnvCreate(), SDO_OCIHandleAlloc(), SDO_OCIServerAttach(), SDO_OCISessionBegin(), srvhp_, stmthp_, svchp_, tdo_geometry_, tdo_ordinates_, txnhp_, useSDO_, and usrhp_.

Referenced by TeOracleSpatial::connect(), and TeOCIOracle::connect().

00050 {
00051         sword status;
00052 
00053         int mode = OCI_THREADED|OCI_OBJECT;
00054         
00055         //create and initialize the environment
00056         status = SDO_OCIEnvCreate(&envhp_, (ub4)mode, (dvoid *)0, 
00057                                       (dvoid*(*)(dvoid *ctxp, size_t size))0, 
00058                                       (dvoid*(*)(dvoid *ctxp, dvoid *memptr, size_t newsize))0, 
00059                                       (void (*)(dvoid *ctxp, dvoid *memptr))0, 
00060                                           (size_t)0, (dvoid**)0);
00061         if(!checkError(errhp_, status))
00062                 return false;
00063 
00064         // Allocate handles - errhp_(OCIError) and srvhp_ (OCIServer)
00065         status = SDO_OCIHandleAlloc((dvoid*)envhp_, (dvoid**)&errhp_, (ub4)OCI_HTYPE_ERROR,
00066                                            (size_t)0, (dvoid**)0);
00067         if(!checkError(errhp_, status))
00068                 return false;
00069 
00070         status = SDO_OCIHandleAlloc((dvoid*)envhp_, (dvoid**)&srvhp_, (ub4)OCI_HTYPE_SERVER,
00071                                            (size_t)0, (dvoid**)0);
00072         if(!checkError(errhp_, status))
00073                 return false;
00074 
00075         // Multiple Sessions or Connections
00076         status = SDO_OCIServerAttach(srvhp_, errhp_, (text*)dblink, 
00077                                                  (sb4)strlen(dblink), (ub4)OCI_DEFAULT);
00078         if(!checkError(errhp_, status))
00079                 return false;
00080 
00081         // Allocate handles: svchp_(OCISvcCtx)
00082         status = SDO_OCIHandleAlloc((dvoid*)envhp_, (dvoid**)&svchp_, (ub4)OCI_HTYPE_SVCCTX, 
00083                                            (size_t)0, (dvoid**)0);
00084         if(!checkError(errhp_, status))
00085                 return false;
00086 
00087         // Set the server attribute in the service context handle
00088         status = SDO_OCIAttrSet((dvoid*)svchp_, (ub4)OCI_HTYPE_SVCCTX, (dvoid*)srvhp_, (ub4)0, 
00089                                    (ub4)OCI_ATTR_SERVER, errhp_);
00090         if(!checkError(errhp_, status))
00091                 return false;
00092 
00093         /// Allocate a user session handle
00094         status = SDO_OCIHandleAlloc((dvoid*)envhp_, (dvoid**)&usrhp_, (ub4)OCI_HTYPE_SESSION, 
00095                                            (size_t)0, (dvoid**)0);
00096         if(!checkError(errhp_, status))
00097                 return false;
00098 
00099         // set user name attribute in user session handle 
00100         status = SDO_OCIAttrSet((dvoid*)usrhp_, (ub4)OCI_HTYPE_SESSION, (dvoid*)username, 
00101                                    (ub4)strlen(username), (ub4)OCI_ATTR_USERNAME, errhp_);
00102         if(!checkError(errhp_, status))
00103                 return false;
00104         
00105         // set password attribute in user session handle
00106         status = SDO_OCIAttrSet((dvoid*)usrhp_, (ub4)OCI_HTYPE_SESSION, (dvoid*)password, 
00107                                    (ub4)strlen(password), (ub4)OCI_ATTR_PASSWORD, errhp_);
00108         if(!checkError(errhp_, status))
00109                 return false;
00110 
00111         // Session begins - establishes a session for a user against a particular
00112         // server. This call is required for the user to execute operations on the server.
00113         status = SDO_OCISessionBegin(svchp_, errhp_, usrhp_, OCI_CRED_RDBMS, 
00114                                                                  OCI_DEFAULT);
00115         if(!checkError(errhp_, status))
00116                 return false;
00117 
00118         // set the user session attribute in the service context handle
00119         status = SDO_OCIAttrSet((dvoid*)svchp_, (ub4)OCI_HTYPE_SVCCTX, (dvoid*)usrhp_, (ub4)0, 
00120                                    (ub4)OCI_ATTR_SESSION, errhp_);
00121         if(!checkError(errhp_, status))
00122                 return false;
00123 
00124         // allocate transaction handle 1 and set it in the service handle (OCITrans)
00125         status = OCIHandleAlloc((dvoid *)envhp_, (dvoid **)&txnhp_, OCI_HTYPE_TRANS, 0, 0);
00126         if(!checkError(errhp_, status))
00127                 return false;
00128 
00129         status = OCIAttrSet((dvoid *)svchp_, OCI_HTYPE_SVCCTX, (dvoid *)txnhp_, 0,OCI_ATTR_TRANS, errhp_);
00130         if(!checkError(errhp_, status))
00131                 return false;
00132 
00133         // locate stmthp_
00134         status = SDO_OCIHandleAlloc((dvoid*)envhp_, (dvoid**)&stmthp_, 
00135                                                                   (ub4)OCI_HTYPE_STMT, (size_t)0, (dvoid**)0);
00136         if(!checkError(errhp_, status))
00137                 return false;
00138 
00139         if(useSDO)
00140         {
00141                 //load the tdo type to sdo_geometry (OCIType)
00142                 status = OCITypeByName(envhp_, errhp_, svchp_, (const text *)
00143                         "MDSYS", (ub4) strlen((char *)"MDSYS"),
00144                         (const text *) "SDO_GEOMETRY",  (ub4) strlen((char *)"SDO_GEOMETRY"),
00145                         (text *)0, 0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, &tdo_geometry_);
00146                 if(!checkError(errhp_, status))
00147                         return false;
00148 
00149                 //load the tdo type to sdo_ordinates (OCIType)
00150                 status = OCITypeByName(envhp_, errhp_, svchp_, (const text *)
00151                         "MDSYS", (ub4) strlen((char *)"MDSYS"),
00152                         (const text *) "SDO_ORDINATE_ARRAY", (ub4) strlen((char *)"SDO_ORDINATE_ARRAY"),
00153                         (text *)0, 0, OCI_DURATION_SESSION, OCI_TYPEGET_HEADER, &tdo_ordinates_);
00154                 if(!checkError(errhp_, status))
00155                         return false;
00156         }
00157         connected_ = true;
00158         useSDO_ = useSDO;
00159         return true;
00160 }

void TeOCIConnection::disconnect (  ) 

Definition at line 163 of file TeOCIConnect.cpp.

References blobValue_, connected_, dvoid, envhp_, errhp_, OCI_DEFAULT, OCI_HTYPE_DESCRIBE, OCI_HTYPE_ENV, OCI_HTYPE_ERROR, OCI_HTYPE_SERVER, OCI_HTYPE_SESSION, OCI_HTYPE_STMT, OCI_HTYPE_SVCCTX, OCI_HTYPE_TRANS, OCI_OBJECTFREE_FORCE, OCIObjectFree(), ordinates_, SDO_OCIHandleFree(), SDO_OCIServerDetach(), SDO_OCISessionEnd(), srvhp_, stmthp_, svchp_, tdo_geometry_, tdo_ordinates_, txnhp_, and usrhp_.

Referenced by TeOCIOracle::close().

00164 {
00165         
00166         OCIObjectFree(envhp_, errhp_, (dvoid*)ordinates_, (ub4)OCI_OBJECTFREE_FORCE);
00167         
00168         // Session ends
00169         SDO_OCISessionEnd(svchp_, errhp_, usrhp_, (ub4)OCI_DEFAULT);
00170         SDO_OCIServerDetach(srvhp_, errhp_, (ub4)OCI_DEFAULT);
00171 
00172 
00173         SDO_OCIHandleFree((dvoid*)tdo_geometry_, (ub4)OCI_HTYPE_DESCRIBE);
00174         SDO_OCIHandleFree((dvoid*)tdo_ordinates_, (ub4)OCI_HTYPE_DESCRIBE);
00175 
00176         // Finalize svchp_, srvhp_, errhp_ and stmthp_
00177         SDO_OCIHandleFree((dvoid*)txnhp_, (ub4)OCI_HTYPE_TRANS);
00178         SDO_OCIHandleFree((dvoid*)srvhp_, (ub4)OCI_HTYPE_SERVER);
00179         SDO_OCIHandleFree((dvoid*)svchp_, (ub4)OCI_HTYPE_SVCCTX);
00180         SDO_OCIHandleFree((dvoid*)errhp_, (ub4)OCI_HTYPE_ERROR);
00181         SDO_OCIHandleFree((dvoid*)usrhp_, (ub4)OCI_HTYPE_SESSION);
00182         SDO_OCIHandleFree((dvoid*)stmthp_, (ub4)OCI_HTYPE_STMT);
00183         
00184         SDO_OCIHandleFree((dvoid*)envhp_, (ub4)OCI_HTYPE_ENV);
00185 
00186         
00187 
00188         connected_ = false;             
00189         envhp_ = 0;
00190         errhp_ = 0;
00191         srvhp_ = 0;
00192         svchp_ = 0;
00193         usrhp_ = 0;
00194         txnhp_ = 0;
00195         tdo_geometry_ = 0;
00196         tdo_ordinates_ = 0;
00197         ordinates_ = 0;
00198         stmthp_ = 0;
00199         if(blobValue_)
00200                 delete [] blobValue_;
00201         blobValue_ = 0;
00202 }

bool TeOCIConnection::execute ( const string stm  ) 

Definition at line 324 of file TeOCIConnect.cpp.

References checkError(), errhp_, NULL, OCI_DEFAULT, OCIStmtExecute(), prepare(), queryType(), stmthp_, svchp_, transCommit(), transRollback(), and transStart().

Referenced by TeOCIOracle::addColumn(), and TeOCIOracle::execute().

00325 {
00326         if(!prepare(stm))
00327                 return false;
00328         
00329         if ((queryType()<0) || (queryType()==1))
00330                 return false;  //return records (query)
00331         
00332         transStart();
00333         sword status = OCIStmtExecute(svchp_, stmthp_, errhp_, (ub4)1, (ub4)0, (OCISnapshot *)NULL, 
00334                                                                   (OCISnapshot *)NULL, (ub4)OCI_DEFAULT);
00335         
00336         if(!checkError(errhp_, status))
00337         {
00338                 transRollback();
00339                 return false;
00340         }
00341 
00342         transCommit();
00343         return true; 
00344 }

bool TeOCIConnection::executeBLOBSTM ( const string stm,
unsigned char *  blobValue,
const int &  blobLength,
const string name 
)

Definition at line 375 of file TeOCIConnect.cpp.

References dvoid, errhp_, NULL, OCI_DEFAULT, OCI_SUCCESS, OCI_SUCCESS_WITH_INFO, OCIBindByName(), OCIStmtExecute(), prepare(), queryType(), SQLT_LBI, stmthp_, and svchp_.

Referenced by TeOCIOracle::insertBlob(), TeOCIOracle::insertLine(), TeOCIOracle::insertPolygon(), TeOracleSpatial::insertRasterBlock(), TeOCIOracle::insertRasterBlock(), TeOCIOracle::insertTable(), TeOCIOracle::updateLine(), TeOCIOracle::updatePolygon(), and TeOCIOracle::updateTable().

00376 {
00377         //prepare the statement
00378         if(!prepare(stm))
00379                 return false;
00380         
00381         if((queryType()<0) || (queryType()==1))
00382                 return false;  //return records (query)
00383 
00384         //Bind blob
00385         OCIBind         *bnd1p = NULL;
00386         sword status = OCIBindByName(stmthp_, &bnd1p, errhp_,
00387                 (text *) name.c_str(), (sb4) name.size(),
00388                 (dvoid *) blobValue, (sb4) blobLength, SQLT_LBI,
00389                 (dvoid *) 0, (ub2 *)0, (ub2 *) 0,
00390                 (ub4) 0, (ub4 *) 0, (ub4) OCI_DEFAULT);
00391         if ((status != OCI_SUCCESS) && (status!=OCI_SUCCESS_WITH_INFO))
00392                 return false;
00393 
00394         status = OCIStmtExecute(svchp_, stmthp_, errhp_, (ub4)1, (ub4)0, (OCISnapshot *)NULL, 
00395                                                   (OCISnapshot *)NULL, (ub4)OCI_DEFAULT);
00396         if ((status != OCI_SUCCESS) && (status!=OCI_SUCCESS_WITH_INFO))
00397                 return false;
00398 
00399         return true;
00400 }

bool TeOCIConnection::executeSDOSTM ( const string stm  ) 

Definition at line 347 of file TeOCIConnect.cpp.

References bindOrdinates(), checkError(), dvoid, envhp_, errhp_, NULL, OCI_DEFAULT, OCI_OBJECTFREE_FORCE, OCIObjectFree(), OCIStmtExecute(), ordinates_, prepare(), queryType(), stmthp_, svchp_, transCommit(), transRollback(), and transStart().

Referenced by TeOracleSpatial::insertLine(), TeOracleSpatial::insertPolygon(), TeOracleSpatial::updateLine(), and TeOracleSpatial::updatePolygon().

00348 {
00349         if(!prepare(stm))
00350                 return false;
00351 
00352         if(!bindOrdinates())
00353                 return false;
00354 
00355         if((queryType()<0) || (queryType()==1))
00356                 return false;  //return records (query)
00357                 
00358         transStart();
00359         sword status = OCIStmtExecute(svchp_, stmthp_, errhp_, (ub4)1, (ub4)0, (OCISnapshot *)NULL, 
00360                                                                   (OCISnapshot *)NULL, (ub4)OCI_DEFAULT);
00361         
00362         if(!checkError(errhp_, status))
00363         {               
00364                 OCIObjectFree(envhp_, errhp_, (dvoid *)ordinates_, (ub2)OCI_OBJECTFREE_FORCE);
00365                 transRollback();
00366                 return false;
00367         }
00368 
00369         transCommit();
00370         OCIObjectFree(envhp_, errhp_, (dvoid *)ordinates_, (ub2)OCI_OBJECTFREE_FORCE);
00371         return true; 
00372 }

string TeOCIConnection::getErrorMessage (  )  [inline]

Definition at line 133 of file TeOCIConnect.h.

Referenced by TeOracleSpatial::connect(), and TeOCIOracle::execute().

00133 { return errorMess_; }

bool TeOCIConnection::isConnected (  )  [inline]

Definition at line 124 of file TeOCIConnect.h.

Referenced by TeOracleSpatial::connect(), TeOCIOracle::connect(), and TeOCIOraclePortal::isConnected().

00124 { return connected_; }

bool TeOCIConnection::prepare ( const string stmt  ) 

Definition at line 205 of file TeOCIConnect.cpp.

References checkError(), connected_, errhp_, OCI_DEFAULT, OCI_NTV_SYNTAX, SDO_OCIStmtPrepare(), stmthp_, and svchp_.

Referenced by execute(), executeBLOBSTM(), and executeSDOSTM().

00206 {       
00207         if (!connected_)
00208                 return false;
00209         
00210         ub4 size = stmt.size();
00211         sword status = SDO_OCIStmtPrepare(svchp_, (OCIStmt *)stmthp_, errhp_, (text*)stmt.c_str(), (ub4)size,  
00212                 (text*)0, (ub4)0, (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
00213         if(!checkError(errhp_, status))
00214                 return false;
00215 
00216         return true;
00217 }

int TeOCIConnection::queryType ( void   ) 

Definition at line 254 of file TeOCIConnect.cpp.

References checkError(), dvoid, errhp_, NULL, OCI_ATTR_STMT_TYPE, OCI_HTYPE_STMT, OCIAttrGet(), and stmthp_.

Referenced by execute(), executeBLOBSTM(), and executeSDOSTM().

00255 {       
00256         ub2 querytype_;
00257                 
00258         sword status = OCIAttrGet((dvoid *)stmthp_, (ub4)OCI_HTYPE_STMT, (ub2 *)&querytype_,
00259         (ub4*)NULL, (ub4)OCI_ATTR_STMT_TYPE, (OCIError *)errhp_);
00260         if(!checkError(errhp_, status))
00261                 return -1;
00262         return (querytype_);
00263 }

bool TeOCIConnection::transCommit (  ) 

Definition at line 315 of file TeOCIConnect.cpp.

References checkError(), errhp_, OCITransCommit(), and svchp_.

Referenced by TeOCIOracle::commitTransaction(), execute(), and executeSDOSTM().

00316 {
00317         sword status = OCITransCommit(svchp_, errhp_, (ub4) 0);
00318         if(!checkError(errhp_, status))
00319                 return false;
00320 
00321         return true;
00322 }

bool TeOCIConnection::transRollback (  ) 

Definition at line 306 of file TeOCIConnect.cpp.

References checkError(), errhp_, OCITransRollback(), and svchp_.

Referenced by execute(), executeSDOSTM(), and TeOCIOracle::rollbackTransaction().

00307 {
00308         sword status = OCITransRollback(svchp_, errhp_, (ub4) 0);
00309         if(!checkError(errhp_, status))
00310                 return false;
00311 
00312         return true;
00313 }

bool TeOCIConnection::transStart (  ) 

Definition at line 297 of file TeOCIConnect.cpp.

References checkError(), errhp_, OCI_TRANS_NEW, OCITransStart(), and svchp_.

Referenced by TeOCIOracle::beginTransaction(), execute(), and executeSDOSTM().

00298 {
00299         sword status = OCITransStart (svchp_, errhp_, 60, OCI_TRANS_NEW); 
00300         if(!checkError(errhp_, status))
00301                 return false;
00302 
00303         return true;
00304 }

bool TeOCIConnection::useSDOType (  )  [inline]

Definition at line 127 of file TeOCIConnect.h.

Referenced by TeOCICursor::freeResult(), TeOCICursor::open(), and TeOCICursor::TeOCICursor().

00127 { return useSDO_; } 


Field Documentation

unsigned char* TeOCIConnection::blobValue_

Definition at line 68 of file TeOCIConnect.h.

Referenced by disconnect(), and TeOCIConnection().

bool TeOCIConnection::connected_ [protected]

Definition at line 45 of file TeOCIConnect.h.

Referenced by bindByPos(), connect(), disconnect(), prepare(), and TeOCIConnection().

OCIEnv* TeOCIConnection::envhp_

Definition at line 53 of file TeOCIConnect.h.

Referenced by TeOCICursor::allocateCursor(), allocateObjectOrdinates(), TeOCICursor::appendOrdinates(), appendOrdinates(), TeOCICursor::bindOrdinates(), connect(), disconnect(), executeSDOSTM(), TeOCICursor::freeResult(), TeOCICursor::getCoordinates(), TeOCICursor::getDimArraySize(), TeOCICursor::getDimElement(), TeOCICursor::getNumberOrdinates(), TeOCICursor::open(), and TeOCIConnection().

OCIError* TeOCIConnection::errhp_

Definition at line 54 of file TeOCIConnect.h.

Referenced by TeOCICursor::allocateCursor(), allocateObjectOrdinates(), TeOCICursor::appendOrdinates(), appendOrdinates(), bindByPos(), TeOCICursor::bindOrdinates(), bindOrdinates(), TeOCICursor::checkError(), connect(), TeOCICursor::defineByPos(), disconnect(), execute(), executeBLOBSTM(), executeSDOSTM(), TeOCICursor::fetch(), TeOCICursor::freeResult(), TeOCICursor::getCoordinates(), TeOCICursor::getDimArraySize(), TeOCICursor::getDimElement(), TeOCICursor::getFieldValue(), TeOCICursor::getGeometryType(), TeOCICursor::getNumberOrdinates(), TeOCICursor::getSpatialReferenceId(), TeOCICursor::getXYZcoord(), TeOCICursor::loadCollDescription(), TeOCICursor::moveFirst(), TeOCICursor::moveLast(), TeOCICursor::moveNext(), TeOCICursor::moveTo(), TeOCICursor::numCol(), TeOCICursor::numRows(), TeOCICursor::open(), TeOCICursor::prepare(), prepare(), TeOCICursor::query(), TeOCICursor::querySDO(), TeOCICursor::queryType(), queryType(), TeOCIConnection(), transCommit(), transRollback(), and transStart().

string TeOCIConnection::errorMess_ [protected]

Definition at line 47 of file TeOCIConnect.h.

Referenced by checkError().

OCIArray* TeOCIConnection::ordinates_

Definition at line 66 of file TeOCIConnect.h.

Referenced by allocateObjectOrdinates(), appendOrdinates(), bindOrdinates(), disconnect(), executeSDOSTM(), and TeOCIConnection().

OCIServer* TeOCIConnection::srvhp_

Definition at line 56 of file TeOCIConnect.h.

Referenced by connect(), disconnect(), and TeOCIConnection().

OCIStmt* TeOCIConnection::stmthp_

Definition at line 61 of file TeOCIConnect.h.

Referenced by bindByPos(), bindOrdinates(), connect(), disconnect(), execute(), executeBLOBSTM(), executeSDOSTM(), prepare(), queryType(), and TeOCIConnection().

OCISvcCtx* TeOCIConnection::svchp_

Definition at line 57 of file TeOCIConnect.h.

Referenced by TeOCICursor::allocateCursor(), allocateObjectOrdinates(), TeOCICursor::appendOrdinates(), TeOCICursor::bindOrdinates(), connect(), disconnect(), execute(), executeBLOBSTM(), executeSDOSTM(), TeOCICursor::open(), TeOCICursor::prepare(), prepare(), TeOCICursor::query(), TeOCICursor::querySDO(), TeOCIConnection(), transCommit(), transRollback(), and transStart().

OCIType* TeOCIConnection::tdo_geometry_

Definition at line 64 of file TeOCIConnect.h.

Referenced by TeOCICursor::allocateCursor(), connect(), disconnect(), and TeOCIConnection().

OCIType* TeOCIConnection::tdo_ordinates_

Definition at line 65 of file TeOCIConnect.h.

Referenced by allocateObjectOrdinates(), TeOCICursor::appendOrdinates(), TeOCICursor::bindOrdinates(), bindOrdinates(), connect(), disconnect(), TeOCICursor::open(), and TeOCIConnection().

OCITrans* TeOCIConnection::txnhp_

Definition at line 59 of file TeOCIConnect.h.

Referenced by connect(), disconnect(), and TeOCIConnection().

bool TeOCIConnection::useSDO_ [protected]

Definition at line 46 of file TeOCIConnect.h.

Referenced by connect(), and TeOCIConnection().

OCISession* TeOCIConnection::usrhp_

Definition at line 58 of file TeOCIConnect.h.

Referenced by connect(), disconnect(), and TeOCIConnection().


The documentation for this class was generated from the following files:
Generated on Sun Jul 29 04:07:03 2012 for TerraLib - Development Source by  doxygen 1.5.3