1 // ANNA - Anna is Not 'N' Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // https://bitbucket.org/testillano/anna
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_dbms_oracle_Database_hpp
38 #define anna_dbms_oracle_Database_hpp
40 #include <anna/dbms/Database.hpp>
41 #include <anna/dbms/DatabaseException.hpp>
53 Clase que modela la interaccion entre la RDMS Oracle (tm) y nuestra aplicacion.
55 \warning La definicion conexiones y clusters debe hacerse antes de invocar al metodo Application::start,
56 o bien, en el metodo Application::initialize.
58 class Database : public dbms::Database {
62 \param dbmsName Nombre de la base de datos.
64 Database(const char* dbmsName);
68 \param componentName Nombre logico de la base de datos por que el podemos buscar este compoenente.
69 \param dbmsName Nombre de la base de datos.
71 Database(const char* componentName, const char* dbmsName);
79 Devuelve el manejador de error asociado a esta base de datos.
80 \return El manejador de error asociado a esta base de datos.
82 OCIError* getErrorHandler() throw() { return a_error; }
85 Operador de conversion.
86 \return El puntero al entorno asociado a esta base de datos.
88 operator OCIEnv*() throw() { return a_env; }
91 Devuelve la cadena por la que podemos buscar el componente.
92 \return La cadena por la que podemos buscar el componente.
93 \see Application::find
95 static const char* getClassName() { return "anna::dbms::oracle::Database"; }
98 * Devuelve el caracter usado como punto decimal, obtenido a partir de la configuraciĆ³n establecida
99 * por la variables de entorno, LANG, LC_NUMERIC, etc, etc.
101 * \return El caracter usado como punto decimal.
103 * \warning Metodo exclusivamente de uso interno.
105 static char getDecimalPoint() throw() { return st_decimalPoint; }
111 static char st_decimalPoint;
113 void do_initialize() throw(RuntimeException);
115 dbms::Connection* allocateConnection(const std::string& name, const char* user, const char* password)
116 throw(RuntimeException);
118 dbms::Statement* allocateStatement(const char* name, const std::string& expression, const bool isCritical)
119 throw(RuntimeException);
121 dbms::InputBind* allocateInputBind(const char* name, Data&)
122 throw(RuntimeException);
123 void deallocate(dbms::InputBind* inputBind) throw();
125 dbms::OutputBind* allocateOutputBind(const char* name, Data&)
126 throw(RuntimeException);
127 void deallocate(dbms::OutputBind* outputBind) throw();
129 static void initializeDecimalPoint() throw(RuntimeException);
132 #ifdef ANNA_RDBMS_TRACE
133 #define anna_dbms_oracle_check(a,error) \
135 Logger::write (Logger::Debug, (#a), __FILE__, __LINE__); \
136 const sword status = (a); \
137 if (status != OCI_SUCCESS) { \
138 anna::dbms::oracle::ResultCode resultCode (status, (error)); \
139 throw DatabaseException (resultCode, __FILE__, __LINE__); \
143 #define anna_dbms_oracle_check(a,error) \
145 const sword status = (a); \
146 if (status != OCI_SUCCESS) { \
147 anna::dbms::oracle::ResultCode resultCode (status, (error)); \
148 throw DatabaseException (resultCode, __FILE__, __LINE__); \